:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e3e6eb;
  --text: #1c2330;
  --muted: #667085;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --green: #127a4a; --green-bg: #e6f6ee;
  --blue: #1d5fd1; --blue-bg: #e8f0fd;
  --amber: #9a5b00; --amber-bg: #fff4dc;
  --red: #b42318; --red-bg: #fdecea;
  --purple: #6d3fd0; --purple-bg: #f1ebfd;
  --gray: #4b5563; --gray-bg: #eef0f3;
  --radius: 12px;
  --sidebar: 244px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
code, .code, pre { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.hidden { display: none !important; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: #111827; color: #cbd5e1; padding: 18px 12px; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; overflow-y: auto; }
.brand { color: #fff; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; display: flex; gap: 8px; align-items: center; }
.brand span { background: var(--accent); border-radius: 6px; padding: 2px 7px; font-size: 13px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6b7280; padding: 14px 10px 4px; }
.sidebar a { display: block; color: #cbd5e1; padding: 7px 10px; border-radius: 6px; }
.sidebar a:hover { background: #1f2937; color: #fff; text-decoration: none; }
.sidebar a.active { background: #262f40; color: #fff; }
.sidebar .user { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid #1f2937; font-size: 12px; }
.main { margin-left: var(--sidebar); flex: 1; padding: 24px 32px 48px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn.menu-toggle { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; z-index: 20; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; padding: 16px; }
  .btn.menu-toggle { display: inline-flex; }
}

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@media (max-width: 1100px) { .grid-2, .grid-3, .grid-sidebar { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .meta { font-size: 12px; color: var(--muted); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: #fafbfc; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* badges */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--gray-bg); color: var(--gray); white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.purple { background: var(--purple-bg); color: var(--purple); }
.chip { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); margin: 1px 2px 1px 0; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 13px; border-radius: 6px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 550; margin-bottom: 4px; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 3px; }
.field .error, .errorlist { color: var(--red); font-size: 12.5px; margin: 4px 0 0; padding: 0; list-style: none; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date],
input[type=datetime-local], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cfd4dc; border-radius: 6px; font: inherit; background: #fff; color: var(--text);
}
textarea.code { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-size: 12.5px; line-height: 1.5; tab-size: 2; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 12px; max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.checks label { font-weight: 400; display: flex; gap: 6px; align-items: center; margin: 0; }
.checks ul, .checks li { list-style: none; margin: 0; padding: 0; }
.check-row { display: flex; gap: 8px; align-items: center; }
.check-row label { margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-width: 150px; }

/* alerts */
.messages { margin-bottom: 16px; }
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 8px; background: var(--blue-bg); color: var(--blue); border: 1px solid transparent; }
.alert.success { background: var(--green-bg); color: var(--green); }
.alert.error { background: var(--red-bg); color: var(--red); }
.alert.warning { background: var(--amber-bg); color: var(--amber); }

/* progress */
.progress { height: 8px; background: var(--gray-bg); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; }

/* funnel bars */
.bar-row { display: grid; grid-template-columns: 120px 1fr 70px; gap: 10px; align-items: center; margin: 6px 0; }
.bar { height: 10px; background: var(--gray-bg); border-radius: 999px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); }

/* editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.editor iframe { width: 100%; height: 720px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.editor .preview-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.editor iframe.mobile { width: 390px; display: block; margin: 0 auto; }
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } }

/* steps */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: #fff; margin-bottom: 8px; position: relative; }
.steps li .num { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; }
.steps li .body { flex: 1; min-width: 0; }
.steps li + li::before { content: ""; position: absolute; left: 27px; top: -9px; height: 9px; border-left: 2px solid var(--border); }

/* rule builder */
.rule { display: grid; grid-template-columns: 1.2fr 1fr 1.2fr auto; gap: 8px; margin-bottom: 8px; }
@media (max-width: 700px) { .rule { grid-template-columns: 1fr; } }

/* auth / public */
.center-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { color: var(--text); justify-content: center; padding-bottom: 8px; }
.auth-card .brand span { color: #fff; }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 12px 14px; }
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.chart-box { position: relative; height: 260px; }
.timeline-item { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: baseline; }
.timeline-item:last-child { border-bottom: 0; }
.key-box { background: #111827; color: #a7f3d0; padding: 12px 14px; border-radius: 6px; overflow-wrap: anywhere; }

/* Shared application design */
body { -webkit-font-smoothing: antialiased; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -.035em; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -.015em; }
.sidebar { background: #111827; padding: 26px 16px 18px; }
.brand { gap: 11px; padding: 0 10px 27px; font-size: 19px; letter-spacing: -.025em; }
.brand span { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border-radius: 10px; background: linear-gradient(145deg, #818cf8, #4f46e5); box-shadow: 0 4px 12px #0002; font-size: 16px; letter-spacing: -.06em; }
.nav-group { padding: 22px 12px 8px; font-size: 10px; font-weight: 650; letter-spacing: .12em; color: #8290a8; }
.sidebar > a { display: flex; align-items: center; gap: 11px; min-height: 39px; padding: 9px 12px; margin: 2px 0; font-size: 13px; font-weight: 500; color: #aab6cb; border: 1px solid transparent; border-radius: 8px; transition: background .15s, color .15s; }
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.sidebar > a.active { color: #e3e5ff; background: #252d4b; border-color: #383f65; }
.sidebar > a.active .nav-icon { color: #a5b4fc; opacity: 1; }
.sidebar .user { margin-top: 28px; padding: 18px 10px 0; border-color: #293244; overflow-wrap: anywhere; color: #94a3b8; }
.sidebar .user .btn { background: #1d2738; border-color: #344055; color: #dbe3ef; }
.main { padding: 0 36px 48px; }
.workspace-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 76px; border-bottom: 1px solid var(--border); margin-bottom: 32px; font-size: 12px; color: var(--muted); }
.workspace-name { display: flex; gap: 10px; align-items: center; font-weight: 600; color: #475569; }
.workspace-mark { display: grid; place-items: center; background: #e9ecf4; border: 1px solid #dce1ec; border-radius: 7px; width: 28px; height: 28px; color: #64748b; }
.workspace-account { display: flex; align-items: center; gap: 10px; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #e9e7fc; color: var(--accent); font-weight: 700; }
.page-head { margin-bottom: 26px; gap: 18px; }
.page-head .sub { margin-top: 7px; font-size: 13px; }
.eyebrow { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: var(--accent); margin-bottom: 8px; }
.card { padding: 24px; box-shadow: 0 2px 4px #192b4b03; }
.grid { gap: 20px; }
.card + .card { margin-top: 20px; }
.grid > .card + .card { margin-top: 0; }
.card-head { margin-bottom: 18px; }
.card-head h2 { margin: 0; }
.section-description { color: var(--muted); font-size: 12px; margin: -5px 0 20px; }
.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { padding: 21px 22px; position: relative; box-shadow: 0 2px 4px #192b4b03; }
.stat .label { font-size: 12px; font-weight: 550; color: #526078; }
.stat .value { font-size: 30px; font-weight: 650; letter-spacing: -.045em; margin: 10px 0 7px; line-height: 1.2; }
.stat .meta { font-size: 11px; }
.stat:first-child { border-top: 3px solid var(--accent); padding-top: 19px; }
th, td { padding: 14px 20px; }
th { font-size: 10px; text-transform: uppercase; letter-spacing: .065em; background: #f8fafc; color: #718096; }
td { font-size: 13px; }
tbody tr:hover td { background: #fafbfe; }
td a { font-weight: 550; }
.empty { padding: 48px 24px; font-size: 13px; }
.badge { padding: 4px 10px; font-size: 10px; letter-spacing: .015em; }
.btn { min-height: 38px; border-radius: 8px; padding: 9px 15px; font-size: 12px; font-weight: 600; box-shadow: 0 1px 2px #15213b06; transition: background .15s, box-shadow .15s; }
.btn.primary { box-shadow: 0 2px 4px #4f46e526; }
.btn.primary:hover { background: #4338ca; filter: none; }
.btn.small { min-height: 30px; padding: 5px 10px; font-size: 11px; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 3px; }
.field { margin-bottom: 20px; }
.field label { font-size: 12px; margin-bottom: 7px; color: #364152; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date], input[type=datetime-local], input[type=search], input[type=file], select, textarea { padding: 10px 12px; border-color: #dbe0e9; border-radius: 8px; font-size: 13px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: 0 0 0 3px #6366f11a; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
.filters { gap: 10px; margin-bottom: 20px; }
.alert { padding: 12px 16px; border-radius: 9px; font-size: 12px; border-color: currentColor; border-color: color-mix(in srgb, currentColor 15%, transparent); }
.chart-box { height: 270px; }
.period-picker { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: #edf0f6; }
.period-picker .btn { border-color: transparent; box-shadow: none; background: transparent; color: var(--muted); }
.period-picker .btn.primary { background: white; color: var(--text); border-color: #e0e4ed; box-shadow: 0 1px 3px #18243a0a; }
.table-heading { padding: 20px 22px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.table-heading h2 { margin: 0; }
.table-heading a { font-size: 11px; font-weight: 600; }
.center-wrap { background: radial-gradient(ellipse at 50% 0%, #e5e7fc 0%, transparent 65%), #f5f7fb; padding: 32px 20px; }
.auth-card { max-width: 420px; padding: 36px; box-shadow: 0 12px 48px #18243a0a; }
.auth-card .brand { padding-bottom: 18px; }
.auth-title { text-align: center; font-size: 23px; margin: 10px 0; }
.auth-card form { margin-top: 28px; }
.auth-card .btn.primary { min-height: 42px; }
.auth-footer { text-align: center; font-size: 11px; color: var(--muted); margin-top: 24px; }
summary { cursor: pointer; }
.editor iframe.mobile { max-width: 100%; }
@media (min-width: 1600px) { .main { padding-left: 48px; padding-right: 48px; } }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .main { padding: 0 20px 32px; }
  .workspace-bar { min-height: 64px; margin-bottom: 24px; }
  .workspace-bar .menu-toggle { margin: 0; }
  .sidebar.open { box-shadow: 12px 0 40px #11182740; }
  .workspace-account > span:not(.avatar) { display: none; }
  .sidebar-close { display: block; }
}
.sidebar-close { display: none; background: transparent; border: 0; color: #cbd5e1; position: absolute; right: 16px; top: 8px; font-size: 24px; cursor: pointer; }
@media (max-width: 900px) { .sidebar-close { display: block; } }
@media (max-width: 560px) {
  h1 { font-size: 24px; }
  .main { padding-left: 16px; padding-right: 16px; }
  .workspace-name { font-size: 11px; }
  .workspace-mark { display: none; }
  .stats { gap: 10px; }
  .stat { padding: 16px; }
  .stat:first-child { padding-top: 14px; }
  .stat .value { font-size: 26px; }
  .card { padding: 18px; }
  .filters input, .filters select { min-width: 0; width: 100%; }
  .auth-card { padding: 28px 24px; }
  dl.kv { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .bar-row { grid-template-columns: 85px 1fr 55px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
