/* =============================================================================
   CRM Connector Platform — Design System
   Light + dark. Tokens first, components second.
   ============================================================================= */

/* Colours, radii and shadows follow crm-connector.com (src/app/globals.css):
   primary #0227b6, slate ink, #e2e8f0 lines, gradient headings, and the
   hairline-plus-lift card hover. Same brand, built for an app instead of a
   marketing page. */
:root {
  color-scheme: light;

  /* Brand */
  --brand:        #0227b6;
  --brand-2:      #1d4ed8;
  --brand-3:      #3b82f6;
  --brand-hover:  #041f96;
  --brand-soft:   #eaeeff;
  --brand-line:   #c7d2fe;
  --on-brand:     #ffffff;
  --brand-grad:   linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 55%, var(--brand-3) 100%);

  /* Accent */
  --accent:       #0d9488;
  --accent-soft:  #e6faf7;
  --accent-line:  #99e6dc;

  /* Ink */
  --ink:    #0f172a;
  --ink-2:  #334155;
  --ink-3:  #64748b;
  --ink-4:  #94a3b8;

  /* Surfaces. The page sits a clear step below the cards so white reads as
     raised rather than as more background. */
  --bg:      #e9eef7;
  --panel:   #ffffff;
  --panel-2: #f4f7fc;
  --panel-3: #e3e9f4;
  --input:   #ffffff;

  /* App chrome: topbar and rail carry a faint gradient of their own. */
  --chrome:      linear-gradient(180deg, #ffffff 0%, #f7f9fd 100%);
  --chrome-line: #dde4f0;
  --page-wash:   radial-gradient(1100px 520px at 72% -12%, rgba(2,39,182,.07) 0%, transparent 68%),
                 radial-gradient(760px 420px at 8% 0%, rgba(59,130,246,.06) 0%, transparent 70%);

  /* Lines */
  --line:      #dde4f0;
  --line-soft: #eaeff8;
  --focus:     #0227b6;

  /* Semantic */
  --ok:    #15803d;  --ok-soft:   #ecfdf5;  --ok-line:   #a7f3d0;
  --warn:  #b45309;  --warn-soft: #fffbeb;  --warn-line: #fde68a;
  --bad:   #dc2626;  --bad-soft:  #fef2f2;  --bad-line:  #fecaca;
  --info:  #0227b6;  --info-soft: #eaeeff;  --info-line: #c7d2fe;

  /* Chart series */
  --c1: #0227b6;
  --c2: #3b82f6;
  --c3: #14b8a6;
  --c4: #f59e0b;
  --c5: #7c3aed;
  --grid: #e6ebf3;

  /* Elevation. In light mode the shadow does the work the border used to do,
     which is what stops everything looking like flat paper. */
  --sh-s: 0 1px 2px rgba(15,23,42,.06), 0 2px 5px -2px rgba(15,23,42,.05);
  --sh-m: 0 4px 12px -2px rgba(15,23,42,.09), 0 14px 30px -14px rgba(2,39,182,.20);
  --sh-l: 0 18px 40px -18px rgba(2,39,182,.30), 0 32px 70px -34px rgba(15,23,42,.30);
  --sh-card: 0 1px 2px rgba(15,23,42,.04), 0 8px 20px -12px rgba(15,23,42,.16);
  --sh-brand: 0 8px 18px -10px rgba(2,39,182,.60);
  --sh-brand-h: 0 12px 26px -10px rgba(2,39,182,.68);

  /* Radius */
  --r-xs: 6px;
  --r-s:  9px;
  --r-m:  14px;
  --r-l:  18px;
  --r-xl: 26px;
  --r-full: 999px;

  /* Type */
  --sans: "Geist", "Geist Sans", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  /* Layout */
  --rail: 232px;
  --topbar: 62px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand:       #3b82f6;
    --brand-2:     #2563eb;
    --brand-3:     #60a5fa;
    --brand-hover: #60a5fa;
    --brand-soft:  #10203c;
    --brand-line:  #1e3a6b;
    --on-brand:    #ffffff;

    --accent:      #2dd4bf;
    --accent-soft: #072b28;
    --accent-line: #115e57;

    --ink:   #f8fafc;
    --ink-2: #cbd5e1;
    --ink-3: #94a3b8;
    --ink-4: #64748b;

    --bg:      #020617;
    --panel:   #0f172a;
    --panel-2: #1e293b;
    --panel-3: #334155;
    --input:   #0b1220;
    --chrome:      linear-gradient(180deg, #111c33 0%, #0d1728 100%);
    --chrome-line: #2b3a55;
    --page-wash:   radial-gradient(1100px 520px at 72% -12%, rgba(59,130,246,.10) 0%, transparent 68%);

    --line:      #334155;
    --line-soft: #1e293b;
    --focus:     #3b82f6;

    --ok:   #34d399;  --ok-soft:   #052e26;  --ok-line:   #115e4a;
    --warn: #fbbf24;  --warn-soft: #2a1f06;  --warn-line: #653f12;
    --bad:  #f87171;  --bad-soft:  #2d0f12;  --bad-line:  #7f1d1d;
    --info: #60a5fa;  --info-soft: #10203c;  --info-line: #1e3a6b;

    --c1: #60a5fa;
    --c2: #3b82f6;
    --c3: #2dd4bf;
    --c4: #fbbf24;
    --c5: #a78bfa;
    --grid: #1e293b;

    --sh-s: 0 1px 2px rgba(0,0,0,.45);
    --sh-m: 0 2px 10px rgba(0,0,0,.5), 0 10px 26px -18px rgba(59,130,246,.35);
    --sh-l: 0 14px 40px rgba(0,0,0,.62), 0 26px 60px -32px rgba(59,130,246,.30);
    --sh-card: 0 1px 2px rgba(0,0,0,.45);
    --sh-brand: 0 8px 18px -10px rgba(59,130,246,.55);
    --sh-brand-h: 0 12px 26px -10px rgba(59,130,246,.70);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --brand:       #3b82f6;
  --brand-2:     #2563eb;
  --brand-3:     #60a5fa;
  --brand-hover: #60a5fa;
  --brand-soft:  #10203c;
  --brand-line:  #1e3a6b;
  --on-brand:    #ffffff;
  --accent:      #2dd4bf;
  --accent-soft: #072b28;
  --accent-line: #115e57;
  --ink:   #f8fafc;
  --ink-2: #cbd5e1;
  --ink-3: #94a3b8;
  --ink-4: #64748b;
  --bg:      #020617;
  --panel:   #0f172a;
  --panel-2: #1e293b;
  --panel-3: #334155;
  --input:   #0b1220;
  --chrome:      linear-gradient(180deg, #111c33 0%, #0d1728 100%);
  --chrome-line: #2b3a55;
  --page-wash:   radial-gradient(1100px 520px at 72% -12%, rgba(59,130,246,.10) 0%, transparent 68%);
  --line:      #334155;
  --line-soft: #1e293b;
  --focus:     #3b82f6;
  --ok:   #34d399;  --ok-soft:   #052e26;  --ok-line:   #115e4a;
  --warn: #fbbf24;  --warn-soft: #2a1f06;  --warn-line: #653f12;
  --bad:  #f87171;  --bad-soft:  #2d0f12;  --bad-line:  #7f1d1d;
  --info: #60a5fa;  --info-soft: #10203c;  --info-line: #1e3a6b;
  --c1: #60a5fa;
  --c2: #3b82f6;
  --c3: #2dd4bf;
  --c4: #fbbf24;
  --c5: #a78bfa;
  --grid: #1e293b;
  --sh-s: 0 1px 2px rgba(0,0,0,.45);
  --sh-m: 0 2px 10px rgba(0,0,0,.5), 0 10px 26px -18px rgba(59,130,246,.35);
  --sh-l: 0 14px 40px rgba(0,0,0,.62), 0 26px 60px -32px rgba(59,130,246,.30);
  --sh-card: 0 1px 2px rgba(0,0,0,.45);
  --sh-brand: 0 8px 18px -10px rgba(59,130,246,.55);
  --sh-brand-h: 0 12px 26px -10px rgba(59,130,246,.70);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image: var(--page-wash);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-xs); }

h1,h2,h3,h4,h5 { margin: 0; letter-spacing: -.02em; font-weight: 700; text-wrap: balance; }
h1 { font-size: 26px; letter-spacing: -.03em; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; }
p { margin: 0 0 12px; }
.mono { font-family: var(--mono); }

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-columns: var(--rail) minmax(0,1fr); min-height: 100vh; }

.topbar {
  grid-column: 1 / -1;
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: var(--chrome);
  border-bottom: 1px solid var(--chrome-line);
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 2px 8px rgba(15,23,42,.05);
  backdrop-filter: saturate(140%) blur(8px);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); flex: none; }
.brand:hover { text-decoration: none; }

/* The real wordmark from the website repo. Two files, one per theme: the light
   one is black text with the #0227b6 mark, the dark one is white with #3b82f6. */
.brandlogo { height: 26px; width: auto; display: block; }
:root[data-theme="dark"] .brandlogo { content: url("brand/crm-connector-logo-dark.svg"); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brandlogo { content: url("brand/crm-connector-logo-dark.svg"); }
}
.lp-nav .brandlogo { height: 30px; }
.sf-brand .brandlogo { height: 28px; }
.brand .glyph {
  width: 28px; height: 28px; border-radius: 9px; background: var(--brand-grad);
  color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 12px; letter-spacing: -.04em; flex: none;
  box-shadow: var(--sh-brand);
}
.brand b { font-size: 14px; letter-spacing: -.02em; font-weight: 700; }

.ws-switch {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 8px; border: 1px solid var(--line);
  border-radius: var(--r-s); background: var(--panel-2);
  font-size: 12.5px; cursor: pointer; color: var(--ink);
}
.ws-switch:hover { border-color: var(--brand-line); }
.ws-switch .avatar-sq {
  width: 18px; height: 18px; border-radius: var(--r-xs);
  background: var(--accent); color: var(--on-brand);
  display: grid; place-items: center; font-size: 9px; font-weight: 800;
}
.ws-switch .chev { color: var(--ink-4); font-size: 10px; }

.topsearch { flex: 1; max-width: 420px; position: relative; }
.topsearch input {
  width: 100%; padding: 7px 12px 7px 32px;
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--input); font-size: 13px;
}
.topsearch input::placeholder { color: var(--ink-4); }
.topsearch .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-4); font-size: 12px; }
.topsearch kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 10px; color: var(--ink-4);
  border: 1px solid var(--line); border-radius: var(--r-xs); padding: 1px 5px;
  background: var(--panel-2);
}

.topright { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-s);
  border: 1px solid transparent; background: transparent;
  display: grid; place-items: center; cursor: pointer;
  color: var(--ink-2); font-size: 14px; position: relative;
}
.icon-btn:hover { background: var(--panel-2); border-color: var(--line); }
.icon-btn .dot-badge {
  position: absolute; top: 5px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--bad); border: 1.5px solid var(--panel);
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: var(--on-brand);
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  cursor: pointer; flex: none;
}

/* ---------- Rail ---------- */
.rail {
  position: sticky; top: var(--topbar); align-self: start;
  height: calc(100vh - var(--topbar));
  overflow-y: auto;
  background: var(--chrome);
  border-right: 1px solid var(--chrome-line);
  padding: 14px 10px 24px;
  display: flex; flex-direction: column; gap: 3px;
}
.rail .group {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-4); font-weight: 700; margin: 14px 10px 5px;
}
.rail .group:first-child { margin-top: 2px; }
.rail a.nav {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r-s);
  color: var(--ink-2); font-size: 13.5px; text-decoration: none;
  line-height: 1.3;
}
.rail a.nav {
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.rail a.nav:hover { background: var(--panel-2); color: var(--ink); text-decoration: none; }
.rail a.nav.active {
  background: var(--brand-grad); color: #fff; font-weight: 600;
  box-shadow: var(--sh-brand);
}
.rail a.nav .ic { width: 16px; text-align: center; font-size: 13px; flex: none; opacity: .9; }
.rail a.nav .count {
  margin-left: auto; font-size: 10.5px; font-variant-numeric: tabular-nums;
  background: var(--panel-3); color: var(--ink-3);
  padding: 1px 6px; border-radius: var(--r-full); font-weight: 600;
}
.rail a.nav.active .count { background: rgba(255,255,255,.22); color: var(--on-brand); }
.rail a.nav .count.alert { background: var(--bad-soft); color: var(--bad); }
.rail .spacer { flex: 1; }
.rail .rail-foot {
  border-top: 1px solid var(--line); margin: 10px 6px 0; padding-top: 12px;
  font-size: 11px; color: var(--ink-4); line-height: 1.5;
}

/* ---------- Main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.page { padding: 22px 26px 40px; flex: 1; }
.page-narrow { max-width: 1120px; }
.page-wide { max-width: 1560px; }

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .ph-text { min-width: 0; }
.page-head h1 { margin-bottom: 3px; }

/* Headings carry the same ink-to-brand gradient as the website. */
.page-head h1, .grad {
  background-image: linear-gradient(135deg, var(--ink) 0%, #1e3a8a 52%, var(--brand) 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
}
:root[data-theme="dark"] .page-head h1, :root[data-theme="dark"] .grad {
  background-image: linear-gradient(135deg, var(--ink) 0%, #c7d2fe 55%, var(--brand-3) 100%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .page-head h1,
  :root:not([data-theme="light"]) .grad {
    background-image: linear-gradient(135deg, var(--ink) 0%, #c7d2fe 55%, var(--brand-3) 100%);
  }
}

/* Soft brand glow behind a page, as on the marketing site. */
.glow { position: relative; isolation: isolate; }
.glow::before {
  content: ""; position: absolute; inset: -10% -5% auto; height: 620px; z-index: -1;
  pointer-events: none; border-radius: 50%; filter: blur(96px); opacity: .40;
  background: radial-gradient(ellipse at 22% 45%, var(--brand-soft) 0%, transparent 68%),
              radial-gradient(ellipse at 78% 30%, color-mix(in srgb, var(--brand-3) 22%, transparent) 0%, transparent 68%);
}
@media (max-width: 767px) { .glow::before { display: none; } }
.page-head .ph-sub { color: var(--ink-3); font-size: 13.5px; margin: 0; }
.page-head .ph-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.crumbs { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--ink-3); }
.crumbs .sep { color: var(--ink-4); }

/* ---------- Buttons ----------
   Every button lifts a little and settles back on press. The primary carries
   the brand gradient plus a light sweep on hover, the same move the website
   uses on its cards. */
.btn {
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--r-s);
  border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); font-size: 13px; font-weight: 600; letter-spacing: -.011em;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: var(--sh-s);
  transition: transform .18s cubic-bezier(.2,.7,.3,1), box-shadow .18s ease,
              background .18s ease, border-color .18s ease, color .18s ease;
}
.btn:hover { text-decoration: none; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--sh-m);
    border-color: color-mix(in srgb, var(--brand) 32%, var(--line));
    background: var(--panel);
  }
}
.btn:active:not(:disabled) { transform: translateY(0); box-shadow: var(--sh-s); }

.btn.primary {
  border-color: transparent; color: var(--on-brand);
  background: var(--brand-grad);
  background-size: 170% 170%; background-position: 0% 50%;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.20), var(--sh-brand);
  transition: transform .18s cubic-bezier(.2,.7,.3,1), box-shadow .18s ease, background-position .45s ease;
}
/* the sweep */
.btn.primary::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(100deg, transparent 22%, rgba(255,255,255,.30) 50%, transparent 78%);
  transform: translateX(-130%);
  transition: transform .65s cubic-bezier(.3,.7,.3,1);
}
@media (hover: hover) and (pointer: fine) {
  .btn.primary:hover:not(:disabled) {
    background-position: 100% 50%; border-color: transparent;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.24), var(--sh-brand-h);
  }
  .btn.primary:hover:not(:disabled)::after { transform: translateX(130%); }
}

.btn.accent {
  border-color: transparent; color: #ffffff;
  background: linear-gradient(135deg, var(--accent) 0%, #14b8a6 55%, #2dd4bf 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.20), 0 8px 18px -10px rgba(13,148,136,.6);
}
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); box-shadow: none; }
@media (hover: hover) and (pointer: fine) {
  .btn.ghost:hover:not(:disabled) { background: var(--panel-2); border-color: transparent; box-shadow: none; color: var(--ink); }
}
.btn.danger { color: var(--bad); border-color: var(--bad-line); background: var(--bad-soft); box-shadow: none; }
@media (hover: hover) and (pointer: fine) {
  .btn.danger:hover:not(:disabled) { background: var(--bad-soft); border-color: var(--bad); box-shadow: var(--sh-s); }
}
.btn.sm { padding: 5px 11px; font-size: 12px; border-radius: var(--r-xs); gap: 6px; }
.btn.lg { padding: 11px 20px; font-size: 14.5px; border-radius: var(--r-m); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* ---------- App footer ----------
   One quiet line. The full sitemap footer belongs on the public pages. */
.appfoot {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 11px 26px; margin-top: auto;
  border-top: 1px solid var(--chrome-line); background: var(--chrome);
  font-size: 12px; color: var(--ink-4);
}
.appfoot .links { display: flex; gap: 15px; margin-left: auto; }
.appfoot a { color: var(--ink-3); }
.appfoot a:hover { color: var(--ink); }
.appfoot .btn.sm { padding: 3px 9px; font-size: 11.5px; }

/* ---------- Cards / panels ----------
   The website's signature: a brand hairline wipes in across the top edge on
   hover. Tiles that are small enough to lift get .lift as well. */
.card {
  position: relative;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-l); box-shadow: var(--sh-card);
  transition: box-shadow .22s ease, border-color .22s ease, transform .22s ease;
}
.card::before {
  content: ""; position: absolute; top: -1px; left: 18px; right: 18px; height: 2px;
  border-radius: var(--r-full); background: var(--brand-grad);
  transform: scaleX(0); transform-origin: left; opacity: .9;
  transition: transform .22s ease; pointer-events: none; z-index: 2;
}
@media (hover: hover) and (pointer: fine) {
  .card:hover { border-color: color-mix(in srgb, var(--brand) 22%, var(--line)); box-shadow: var(--sh-m); }
  .card:hover::before { transform: scaleX(1); }
  .card.lift:hover, .stat:hover { transform: translateY(-2px); box-shadow: var(--sh-l); }
}
.card.flat::before { display: none; }
.card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-head h3 { font-size: 14px; }
.card-head .sub { font-size: 12px; color: var(--ink-3); margin: 1px 0 0; }
.card-head .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 16px; }
.card-body.tight { padding: 10px; }
.card-foot { padding: 11px 16px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 var(--r-l) var(--r-l); font-size: 12.5px; color: var(--ink-3); }

/* ---------- Grid ---------- */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.split-2-1 { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.split-1-2 { grid-template-columns: minmax(0,1fr) minmax(0,2fr); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Stat tiles ---------- */
.stat {
  position: relative; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-l); padding: 15px 17px; box-shadow: var(--sh-card);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.stat::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--brand) 12%, transparent) 0%, transparent 60%);
  transition: opacity .22s ease;
}
@media (hover: hover) and (pointer: fine) {
  .stat:hover { border-color: color-mix(in srgb, var(--brand) 26%, var(--line)); }
  .stat:hover::after { opacity: 1; }
}
.stat .label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-4); font-weight: 700;
}
.stat .value {
  font-size: 28px; font-weight: 750; letter-spacing: -.03em;
  line-height: 1.1; margin-top: 5px; font-variant-numeric: tabular-nums;
}
.stat .delta { font-size: 12px; margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.stat .delta.up { color: var(--ok); }
.stat .delta.down { color: var(--bad); }
.stat .delta.flat { color: var(--ink-3); }
.stat .spark { margin-top: 8px; height: 28px; }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
  padding: 2.5px 8px; border-radius: var(--r-full);
  border: 1px solid transparent; white-space: nowrap;
}
.pill .led { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok    { background: var(--ok-soft);    color: var(--ok);    border-color: var(--ok-line); }
.pill.warn  { background: var(--warn-soft);  color: var(--warn);  border-color: var(--warn-line); }
.pill.bad   { background: var(--bad-soft);   color: var(--bad);   border-color: var(--bad-line); }
.pill.info  { background: var(--info-soft);  color: var(--info);  border-color: var(--info-line); }
.pill.acc   { background: var(--accent-soft);color: var(--accent);border-color: var(--accent-line); }
.pill.mute  { background: var(--panel-2);    color: var(--ink-3); border-color: var(--line); }

.tag {
  display: inline-block; font-size: 11px; padding: 2px 7px;
  border-radius: var(--r-xs); background: var(--panel-2);
  border: 1px solid var(--line); color: var(--ink-2); font-family: var(--mono);
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-m); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
table.data thead th {
  text-align: left; padding: 9px 14px; background: var(--panel-2);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-3); font-weight: 700; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0;
}
table.data tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; color: var(--ink-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--panel-2); }
table.data td.strong { color: var(--ink); font-weight: 600; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.actions { text-align: right; white-space: nowrap; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--ink); }
.field .hint { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; line-height: 1.45; }
.field .err { font-size: 11.5px; color: var(--bad); margin-top: 5px; }
.input, select.input, textarea.input {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--input); font-size: 13.5px; color: var(--ink);
}
.input::placeholder { color: var(--ink-4); }
.input, select.input, textarea.input { transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
.input:hover:not(:focus) { border-color: color-mix(in srgb, var(--brand) 28%, var(--line)); }
.input:focus {
  border-color: var(--brand); outline: none;
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--brand) 16%, transparent);
}
textarea.input { min-height: 96px; resize: vertical; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; }
.switch .track {
  width: 34px; height: 20px; border-radius: var(--r-full);
  background: var(--panel-3); border: 1px solid var(--line);
  position: relative; transition: background .15s; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--panel); box-shadow: var(--sh-s); transition: transform .15s;
}
.switch.on .track { background: var(--brand); border-color: var(--brand); }
.switch.on .track::after { transform: translateX(14px); background: #fff; }

.check {
  display: inline-flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 13px; line-height: 1.5;
}
.check .box {
  width: 16px; height: 16px; border-radius: var(--r-xs); flex: none; margin-top: 2px;
  border: 1px solid var(--line); background: var(--input);
  display: grid; place-items: center; font-size: 10px; color: transparent;
}
.check.on .box { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-s);
}
.seg button {
  padding: 4px 12px; border: 0; background: transparent; border-radius: var(--r-xs);
  font-size: 12.5px; color: var(--ink-3); cursor: pointer; font-weight: 550;
}
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: var(--sh-s); font-weight: 600; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a {
  padding: 9px 14px; font-size: 13.5px; color: var(--ink-3);
  border-bottom: 2px solid transparent; text-decoration: none; white-space: nowrap; font-weight: 550;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 650; }

/* ---------- Callouts ---------- */
.note {
  border-left: 3px solid var(--brand); background: var(--brand-soft);
  padding: 12px 15px; border-radius: 0 var(--r-s) var(--r-s) 0;
  font-size: 13px; color: var(--ink); line-height: 1.55;
}
.note.acc  { border-left-color: var(--accent); background: var(--accent-soft); }
.note.ok   { border-left-color: var(--ok);     background: var(--ok-soft); }
.note.warn { border-left-color: var(--warn);   background: var(--warn-soft); }
.note.bad  { border-left-color: var(--bad);    background: var(--bad-soft); }
.note p:last-child { margin-bottom: 0; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--ink-3); }
.empty .em-ic { font-size: 30px; margin-bottom: 10px; opacity: .5; }
.empty h3 { color: var(--ink); margin-bottom: 5px; }

/* ---------- List rows ---------- */
.lrow {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--r-s); background: var(--panel); margin-bottom: 8px;
}
.lrow:hover { border-color: var(--brand-line); }
.lrow .lr-main { min-width: 0; flex: 1; }
.lrow .lr-title { font-weight: 600; font-size: 13.5px; }
.lrow .lr-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.lrow .lr-side { display: flex; align-items: center; gap: 8px; flex: none; }

/* System glyph */
.sysg {
  width: 32px; height: 32px; border-radius: var(--r-s); flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 750;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2);
  letter-spacing: -.02em;
}
.sysg.lg { width: 40px; height: 40px; font-size: 13px; border-radius: var(--r-m); }
.sysg.b1 { background: #eaeeff; border-color: #c7d2fe; color: #0227b6; }
.sysg.b2 { background: #e6faf7; border-color: #99e6dc; color: #0d9488; }
.sysg.b3 { background: #f3e8ff; border-color: #ddc7fb; color: #7c3aed; }
.sysg.b4 { background: #fffbeb; border-color: #fde68a; color: #b45309; }
.sysg.b5 { background: #e0f2fe; border-color: #a5dcf7; color: #0369a1; }
:root[data-theme="dark"] .sysg.b1, :root:not([data-theme="light"]) .sysg.b1 { background:#10203c; border-color:#1e3a6b; color:#60a5fa; }
:root[data-theme="dark"] .sysg.b2, :root:not([data-theme="light"]) .sysg.b2 { background:#072b28; border-color:#115e57; color:#2dd4bf; }
:root[data-theme="dark"] .sysg.b3, :root:not([data-theme="light"]) .sysg.b3 { background:#241a3d; border-color:#3d2d63; color:#a78bfa; }
:root[data-theme="dark"] .sysg.b4, :root:not([data-theme="light"]) .sysg.b4 { background:#2c2210; border-color:#5c4715; color:#fbbf24; }
:root[data-theme="dark"] .sysg.b5, :root:not([data-theme="light"]) .sysg.b5 { background:#0c2c40; border-color:#12496b; color:#38bdf8; }

/* ---------- Progress ---------- */
.prog { height: 6px; border-radius: var(--r-full); background: var(--panel-3); overflow: hidden; }
.prog > i { display: block; height: 100%; background: var(--brand); border-radius: var(--r-full); }
.prog > i.ok { background: var(--ok); }
.prog > i.warn { background: var(--warn); }
.prog > i.acc { background: var(--accent); }

/* ---------- Meter rows ---------- */
.meter { display: grid; grid-template-columns: 130px 1fr 68px; gap: 10px; align-items: center; font-size: 12.5px; margin-bottom: 9px; }
.meter .mv { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }

/* ---------- Diff ---------- */
.diff { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; }
.diff > div { padding: 10px 13px; }
.diff > div + div { border-left: 1px solid var(--line); }
.diff .dh { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-4); font-weight: 700; margin-bottom: 5px; }
.diff .dv { font-family: var(--mono); font-size: 13px; color: var(--ink); word-break: break-word; }
.diff .a { background: var(--bad-soft); }
.diff .b { background: var(--ok-soft); }

/* ---------- Timeline ---------- */
.tl { position: relative; padding-left: 22px; }
.tl::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 1px; background: var(--line); }
.tl .ti { position: relative; padding-bottom: 16px; font-size: 13px; }
.tl .ti::before {
  content: ""; position: absolute; left: -21px; top: 6px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--panel); border: 2px solid var(--brand);
}
.tl .ti.ok::before { border-color: var(--ok); }
.tl .ti.bad::before { border-color: var(--bad); }
.tl .ti.mute::before { border-color: var(--ink-4); }
.tl .ti .tt { font-weight: 600; }
.tl .ti .tm { font-size: 11.5px; color: var(--ink-4); font-variant-numeric: tabular-nums; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; gap: 14px; }
.bubble { max-width: 78%; padding: 11px 14px; border-radius: var(--r-m); font-size: 13.5px; line-height: 1.6; }
.bubble.me { align-self: flex-end; background: var(--brand); color: var(--on-brand); border-bottom-right-radius: 4px; }
.bubble.ai { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.ai p:last-child { margin-bottom: 0; }
.cite {
  display: flex; align-items: center; gap: 6px; margin-top: 9px; padding-top: 8px;
  border-top: 1px solid var(--line); font-size: 11px; color: var(--ink-3); font-family: var(--mono);
  flex-wrap: wrap;
}

/* ---------- Composer ---------- */
.composer {
  border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--panel); padding: 10px 12px;
}
.composer textarea {
  width: 100%; border: 0; background: transparent; resize: none;
  font-size: 13.5px; min-height: 44px; outline: none;
}
.composer .cbar { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.composer .cbar .right { margin-left: auto; }

/* ---------- Footer ---------- */
.foot {
  border-top: 1px solid var(--line); background: var(--panel);
  padding: 26px 26px 22px; margin-top: auto;
}
.foot-in { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 26px; max-width: 1320px; }
.foot .fbrand { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.foot p { font-size: 12.5px; color: var(--ink-3); max-width: 34ch; line-height: 1.55; }
.foot h5 { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-4); font-weight: 700; margin-bottom: 9px; }
.foot ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.foot ul a { font-size: 12.5px; color: var(--ink-2); }
.foot-bottom {
  max-width: 1320px; margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line);
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  font-size: 12px; color: var(--ink-4);
}
.foot-bottom .right { margin-left: auto; display: flex; gap: 14px; align-items: center; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-aside {
  background: var(--brand); color: var(--on-brand);
  padding: 46px 46px; display: flex; flex-direction: column; gap: 26px;
  position: relative; overflow: hidden;
}
.auth-aside .brand b, .auth-aside .brand { color: var(--on-brand); }
.auth-aside .glyph { background: rgba(255,255,255,.18); color: var(--on-brand); }
.auth-aside h2 { font-size: 30px; line-height: 1.15; letter-spacing: -.03em; max-width: 15ch; }
.auth-aside .lede { font-size: 15px; opacity: .82; max-width: 40ch; line-height: 1.6; }
.auth-aside .pts { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }
.auth-aside .pt { display: flex; gap: 11px; align-items: flex-start; font-size: 13.5px; opacity: .92; }
.auth-aside .pt .k { opacity: .7; flex: none; }
.auth-main { display: grid; place-items: center; padding: 40px 26px; background: var(--bg); }
.auth-card { width: 100%; max-width: 384px; }
.auth-card h1 { font-size: 22px; margin-bottom: 5px; }
.auth-card .sub { color: var(--ink-3); font-size: 13.5px; margin-bottom: 22px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--ink-4); font-size: 11.5px; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }

.otp { display: flex; gap: 8px; justify-content: space-between; }
.otp input {
  width: 46px; height: 54px; text-align: center;
  font-size: 21px; font-weight: 700; font-family: var(--mono);
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--input); color: var(--ink);
}
.otp input:focus { border-color: var(--brand); outline: 2px solid color-mix(in srgb, var(--brand) 22%, transparent); }

/* ---------- Code block ---------- */
pre.code {
  background: var(--input); border: 1px solid var(--line);
  border-radius: var(--r-s); padding: 13px 15px; overflow-x: auto;
  font-family: var(--mono); font-size: 12px; line-height: 1.65; margin: 0;
  color: var(--ink-2);
}
pre.code .k { color: var(--brand); }
pre.code .s { color: var(--accent); }
pre.code .c { color: var(--ink-4); }

/* ---------- Utility ---------- */
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.xs { font-size: 11px; }
.tnum { font-variant-numeric: tabular-nums; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; } .mb24 { margin-bottom: 24px; }
.hr { height: 1px; background: var(--line); border: 0; margin: 22px 0; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .g5, .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .split-2-1, .split-1-2 { grid-template-columns: 1fr; }
  .foot-in { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .topsearch { display: none; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .page { padding: 18px 16px 32px; }
  .foot { padding: 22px 16px; }
  .foot-in { grid-template-columns: 1fr; gap: 20px; }
  .diff { grid-template-columns: 1fr; }
  .diff > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .meter { grid-template-columns: 92px 1fr 56px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
