/* ============================================================================
   NexusHR — design system v2
   A rail + panel shell, violet/ink palette, soft surfaces and a single accent
   per surface. Every legacy class name is preserved so views keep working;
   the language underneath is new.
   ========================================================================== */

:root {
  /* surfaces */
  --bg: #f6f5fb;
  --bg-mesh-1: rgba(124, 58, 237, .10);
  --bg-mesh-2: rgba(14, 165, 233, .08);
  --surface: #ffffff;
  --surface-2: #fbfaff;
  --surface-3: #f3f1fb;
  --rail: #14132b;
  --rail-ink: #9c9ab8;
  --ink: #17162e;
  --ink-2: #3c3b58;
  --muted: #6f6e8c;
  --line: #eae7f4;
  --line-2: #f2f0f9;

  /* accents */
  --brand: #6d28d9;
  --brand-2: #8b5cf6;
  --brand-ink: #4c1d95;
  --brand-soft: #f1ecff;
  --brand-grad: linear-gradient(135deg, #7c3aed 0%, #a855f7 55%, #c084fc 100%);
  --ai: #0d9488;
  --ai-soft: #e7fbf7;
  --ok: #0f9d6e;
  --ok-soft: #e6f8f1;
  --warn: #b45309;
  --warn-soft: #fdf4e3;
  --danger: #d92d20;
  --danger-soft: #fdecea;
  --info: #1d6ff2;
  --info-soft: #eaf1ff;

  /* geometry */
  --r-xl: 20px;
  --r-lg: 16px;
  --r: 12px;
  --r-sm: 9px;
  --shadow-xs: 0 1px 2px rgba(23, 22, 46, .05);
  --shadow: 0 1px 2px rgba(23, 22, 46, .04), 0 10px 28px -16px rgba(23, 22, 46, .22);
  --shadow-lg: 0 28px 70px -24px rgba(23, 22, 46, .38);
  --ring: 0 0 0 3px rgba(124, 58, 237, .16);

  --rail-w: 74px;
  --panel-w: 232px;
  --top-h: 66px;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #0d0c18;
  --bg-mesh-1: rgba(124, 58, 237, .22);
  --bg-mesh-2: rgba(14, 165, 233, .14);
  --surface: #16152a;
  --surface-2: #1b1a31;
  --surface-3: #201f38;
  --rail: #0a0917;
  --rail-ink: #8e8caa;
  --ink: #f4f3fb;
  --ink-2: #c9c7de;
  --muted: #928fae;
  --line: #272541;
  --line-2: #221f39;
  --brand: #a78bfa;
  --brand-2: #c4b5fd;
  --brand-ink: #ddd6fe;
  --brand-soft: #241f45;
  --brand-grad: linear-gradient(135deg, #7c3aed 0%, #a855f7 55%, #d8b4fe 100%);
  --ai: #2dd4bf;
  --ai-soft: #10312f;
  --ok: #34d399;
  --ok-soft: #0f2e26;
  --warn: #fbbf24;
  --warn-soft: #33270f;
  --danger: #f87171;
  --danger-soft: #3a1a1a;
  --info: #60a5fa;
  --info-soft: #14243d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 14px 34px -18px rgba(0, 0, 0, .8);
  --shadow-lg: 0 30px 80px -30px rgba(0, 0, 0, .9);
  --ring: 0 0 0 3px rgba(167, 139, 250, .22);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 8% -8%, var(--bg-mesh-1), transparent 62%),
    radial-gradient(900px 460px at 96% 0%, var(--bg-mesh-2), transparent 58%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5 { margin: 0; font-weight: 640; letter-spacing: -.022em; color: var(--ink); }
h1 { font-size: 25px; }
h2 { font-size: 16px; }
h3 { font-size: 14.5px; }
p { margin: 0 0 10px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 12px; }
code, pre, .mono { font-family: var(--mono); font-size: 12.3px; }
::selection { background: rgba(124, 58, 237, .22); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }

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

/* icon rail */
.rail {
  background: var(--rail);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0 12px; gap: 6px;
  position: sticky; top: 0; height: 100vh; z-index: 30;
}
.rail-brand {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--brand-grad); color: #fff; font-weight: 800; font-size: 13px;
  letter-spacing: -.03em; box-shadow: 0 8px 20px -8px rgba(124, 58, 237, .9);
  margin-bottom: 10px;
}
.rail-sep { width: 26px; height: 1px; background: rgba(255,255,255,.09); margin: 6px 0; }
.rail-btn {
  position: relative; width: 44px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  color: var(--rail-ink); background: transparent; border: none; cursor: pointer; transition: .16s;
}
.rail-btn:hover { color: #fff; background: rgba(255,255,255,.07); }
.rail-btn.active { color: #fff; background: var(--brand-grad); box-shadow: 0 10px 24px -12px rgba(168, 85, 247, .95); }
.rail-btn .ic { width: 19px; height: 19px; }
.rail-btn::after {
  content: attr(data-tip); position: absolute; left: 56px; top: 50%; transform: translateY(-50%) scale(.96);
  background: #1d1c33; color: #fff; font-size: 11.5px; padding: 5px 9px; border-radius: 8px;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: .14s; box-shadow: var(--shadow);
  z-index: 60;
}
.rail-btn:hover::after { opacity: 1; transform: translateY(-50%) scale(1); }
.rail-spacer { flex: 1; }
.rail-avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; color: #fff; cursor: pointer;
  border: 2px solid rgba(255,255,255,.16);
}

/* contextual panel */
.panel {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 25;
}
.panel-head { padding: 16px 16px 10px; display: flex; align-items: center; gap: 9px; }
.panel-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.panel-brand .mark {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: var(--brand-grad); color: #fff; font-weight: 800; font-size: 10.5px;
}
.panel-brand .name { font-weight: 660; font-size: 14px; letter-spacing: -.02em; }
.panel-brand .sub { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.panel-search {
  margin: 4px 12px 10px; display: flex; align-items: center; gap: 8px;
  background: var(--surface-3); border: 1px solid transparent; border-radius: 10px;
  padding: 7px 9px; cursor: pointer; color: var(--muted); font-size: 12.5px;
}
.panel-search:hover { border-color: var(--line); background: var(--surface-2); }
.panel-search kbd {
  margin-left: auto; font-family: var(--sans); font-size: 10.5px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--muted);
}
.nav { padding: 0 10px 16px; overflow-y: auto; flex: 1; }
.nav-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
  font-weight: 650; padding: 14px 10px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  color: var(--ink-2); font-size: 13px; font-weight: 520; margin-bottom: 1px;
  position: relative; transition: .14s; text-decoration: none;
}
.nav a:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.nav a.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav a .ic { width: 16px; height: 16px; opacity: .8; flex: 0 0 16px; }
.nav a.active .ic { opacity: 1; }
.nav .count {
  margin-left: auto; background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 650;
  padding: 1px 6px; border-radius: 20px; min-width: 18px; text-align: center;
}
.panel-foot { padding: 10px 12px 14px; border-top: 1px solid var(--line); }
.panel-foot .ai-chip {
  display: flex; align-items: center; gap: 8px; background: var(--surface-3);
  border-radius: 11px; padding: 8px 10px; font-size: 11.5px; color: var(--muted);
}
.panel-foot .ai-chip b { color: var(--ink-2); font-weight: 600; display: block; font-size: 11.5px; }
.panel-foot .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ai); box-shadow: 0 0 0 3px var(--ai-soft); }
.panel-foot .build { text-align: center; font-size: 10px; color: var(--muted); margin-top: 8px; opacity: .8; }

/* main column */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 16px; letter-spacing: -.02em; }
.topbar .crumb { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.topbar-spacer { flex: 1; }
.topbar .icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent;
  color: var(--ink-2); display: grid; place-items: center; cursor: pointer; transition: .14s; position: relative;
}
.topbar .icon-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.topbar .dot-unread {
  position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 2px var(--surface);
}
.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px; border-radius: 30px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; transition: .14s;
}
.user-chip:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.user-chip .who { line-height: 1.15; }
.user-chip .who b { display: block; font-size: 12.5px; font-weight: 600; }
.user-chip .who span { font-size: 10.5px; color: var(--muted); }

.content { padding: 22px 24px 72px; width: 100%; max-width: 1440px; }

/* mobile bottom nav */
.tabbar { display: none; }
.mobile-only { display: none; }

/* ------------------------------------------------------------------ type + layout helpers */
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.g-auto { grid-template-columns: repeat(auto-fit, minmax(186px, 1fr)); }
.mt { margin-top: 14px; }
.divider { height: 1px; background: var(--line); margin: 6px 0; }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.section-title h2 { font-size: 15px; }
.section-title .sub { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------ surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  transition: box-shadow .2s, border-color .2s, transform .2s;
}
.card-pad { padding: 18px; }
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 15px 18px;
  border-bottom: 1px solid var(--line-2);
}
.card-head h2, .card-head h3 { font-size: 14px; }
.card-head .sub { color: var(--muted); font-size: 12px; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card.flush { border: none; box-shadow: none; background: transparent; }

/* hero */
.hero {
  position: relative; overflow: hidden; border-radius: var(--r-xl);
  background: linear-gradient(120deg, #2a1a5e 0%, #4c1d95 45%, #7c3aed 100%);
  color: #fff; padding: 24px 26px; box-shadow: 0 24px 60px -30px rgba(76, 29, 149, .9);
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(420px 200px at 88% 10%, rgba(216, 180, 254, .38), transparent 70%),
    radial-gradient(360px 220px at 70% 120%, rgba(56, 189, 248, .3), transparent 70%);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { color: #fff; font-size: 24px; letter-spacing: -.03em; }
.hero .sub { color: rgba(255,255,255,.74); font-size: 12.5px; }
.hero .hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hero .btn-ghost-light {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); color: #fff;
}
.hero .btn-ghost-light:hover { background: rgba(255,255,255,.22); }
.hero .btn-white { background: #fff; border-color: #fff; color: #4c1d95; font-weight: 640; }
.hero .btn-white:hover { background: #f5f0ff; }

/* punch clock */
.punch { display: flex; align-items: center; gap: 20px; }
.punch-ring { position: relative; width: 108px; height: 108px; flex: 0 0 108px; }
.punch-ring svg { transform: rotate(-90deg); }
.punch-ring .core {
  position: absolute; inset: 12px; border-radius: 50%; background: rgba(255,255,255,.1);
  backdrop-filter: blur(4px); display: grid; place-items: center; text-align: center;
}
.punch-ring .core b { font-size: 17px; letter-spacing: -.02em; display: block; }
.punch-ring .core span { font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; opacity: .72; }
.punch-meta { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.punch-meta .line { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: rgba(255,255,255,.85); }
.punch-meta .line .ic { opacity: .7; }

/* kpi */
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi .label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 650;
  display: flex; align-items: center; gap: 6px;
}
.kpi .value { font-size: 26px; font-weight: 680; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .foot { font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.kpi .delta { font-weight: 620; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--danger); }
.kpi .icon-tile {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
}
.kpi.row-kpi { flex-direction: row; align-items: center; gap: 14px; }
.kpi.row-kpi .body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* AI surfaces */
.ai-card {
  border: 1px solid color-mix(in srgb, var(--ai) 24%, var(--line));
  background: linear-gradient(180deg, var(--ai-soft), var(--surface) 72%);
  border-radius: var(--r-lg); padding: 15px 16px;
}
.ai-card .ai-tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 750;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ai);
}
.ai-card h4 { font-size: 13.5px; margin: 7px 0 4px; }
.ai-card p { font-size: 12.5px; color: var(--ink-2); margin: 0 0 10px; }
.ai-spark {
  width: 20px; height: 20px; border-radius: 7px; display: grid; place-items: center;
  background: var(--brand-grad); color: #fff;
}
.ai-spark .ic { width: 12px; height: 12px; }
.sev-high { border-left: 3px solid var(--danger); }
.sev-medium { border-left: 3px solid var(--warn); }
.sev-low { border-left: 3px solid color-mix(in srgb, var(--ai) 60%, var(--line)); }

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 10px; font-size: 12.8px; font-weight: 570;
  font-family: inherit; cursor: pointer; transition: .15s; white-space: nowrap;
  box-shadow: var(--shadow-xs);
}
.btn:hover { border-color: color-mix(in srgb, var(--brand) 34%, var(--line)); background: var(--surface-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand-grad); border-color: transparent; color: #fff; box-shadow: 0 10px 24px -14px rgba(124, 58, 237, .95); }
.btn-primary:hover { filter: brightness(1.06); color: #fff; }
.btn-dark { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(1.06); }
.btn-danger { background: var(--surface); border-color: color-mix(in srgb, var(--danger) 32%, var(--line)); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-icon { width: 34px; height: 34px; padding: 0; }
.btn .ic { width: 15px; height: 15px; }

.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 13px; font-family: inherit; color: var(--ink); background: var(--surface);
  outline: none; transition: .15s; box-shadow: var(--shadow-xs);
}
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-2); box-shadow: var(--ring); }
.textarea { min-height: 88px; resize: vertical; line-height: 1.55; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 11.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.hint { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.search { position: relative; }
.search .input { padding-left: 34px; }
.search .ic { position: absolute; left: 11px; top: 10px; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 620; background: var(--surface-3); color: var(--ink-2);
  border: 1px solid transparent; white-space: nowrap; line-height: 1.6;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.brand { background: var(--brand-soft); color: var(--brand-ink); }
.badge.ai { background: var(--ai-soft); color: var(--ai); }
.badge.outline { background: var(--surface); border-color: var(--line); color: var(--muted); }
.badge.info { background: var(--info-soft); color: var(--info); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; color: #fff; flex: 0 0 auto; letter-spacing: -.02em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.avatar.lg { width: 48px; height: 48px; font-size: 15px; }
.avatar.sm { width: 26px; height: 26px; font-size: 10px; }
.avatar-group { display: flex; }
.avatar-group .avatar { margin-left: -8px; border: 2px solid var(--surface); }
.avatar-group .avatar:first-child { margin-left: 0; }

.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .who { min-width: 0; }
.person .who b { display: block; font-weight: 580; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .who span { display: block; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow: auto; border-radius: 0 0 var(--r-lg) var(--r-lg); min-width: 0; }
.table-wrap::-webkit-scrollbar { height: 9px; width: 9px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.8px; }
.table th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 700; padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
.table td { padding: 11px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; color: var(--ink-2); }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr:last-child td { border-bottom: none; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td b { color: var(--ink); }

/* ------------------------------------------------------------------ charts */
.chart { width: 100%; }
.chart .bar-row { display: grid; grid-template-columns: 118px 1fr 48px; gap: 12px; align-items: center; margin-bottom: 11px; font-size: 12.3px; color: var(--ink-2); }
.chart .bar-track { height: 8px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.chart .bar-fill { height: 100%; border-radius: 6px; background: var(--brand-grad); transition: width .5s ease; }
.chart .bar-row .n { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; }
.sparkline { display: block; width: 100%; }
.progress { height: 7px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand-grad); border-radius: 6px; transition: width .45s ease; }
.progress.ok > span { background: linear-gradient(90deg, #10b981, #34d399); }
.progress.warn > span { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress.danger > span { background: linear-gradient(90deg, #dc2626, #f87171); }

/* ------------------------------------------------------------------ tabs + chips */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 6px; margin-bottom: 2px; }
.tabs button {
  border: none; background: none; padding: 10px 12px; font-size: 12.8px; font-weight: 560;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; font-family: inherit;
  transition: .14s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 620; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px;
  font-size: 12px; cursor: pointer; color: var(--ink-2); font-family: inherit; transition: .14s;
}
.chip:hover { border-color: color-mix(in srgb, var(--brand) 34%, var(--line)); color: var(--ink); }
.chip.active { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 34%, var(--line)); color: var(--brand-ink); font-weight: 600; }

/* ------------------------------------------------------------------ chat */
.chat-wrap { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; height: calc(100vh - var(--top-h) - 46px); }
.chat-side { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 0; }
.chat-main { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-log { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 18px; background: var(--surface-2); }
.msg { display: flex; gap: 10px; max-width: 860px; }
.msg.user { margin-left: auto; flex-direction: row-reverse; }
.msg .body {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 15px; font-size: 13.3px; line-height: 1.6; max-width: 720px; box-shadow: var(--shadow-xs);
}
.msg.user .body { background: var(--brand-grad); border-color: transparent; color: #fff; box-shadow: 0 12px 30px -18px rgba(124,58,237,.9); }
.msg .body p:last-child { margin-bottom: 0; }
.msg .meta { margin-top: 9px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cite {
  font-size: 10.8px; background: var(--ai-soft); color: var(--ai); border: 1px solid color-mix(in srgb, var(--ai) 26%, transparent);
  border-radius: 6px; padding: 1px 7px; cursor: pointer; font-weight: 640;
}
.composer {
  border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 10px; align-items: flex-end;
  background: var(--surface); border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.composer .textarea { min-height: 44px; max-height: 150px; }
.trace {
  border: 1px dashed color-mix(in srgb, var(--ai) 30%, var(--line)); border-radius: 12px;
  background: var(--surface); padding: 11px 13px; font-size: 12px; color: var(--ink-2);
}
.trace ol { margin: 8px 0 0; padding-left: 18px; }
.trace li { margin-bottom: 7px; }
.trace code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; font-size: 11.5px; }

/* ------------------------------------------------------------------ kanban */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(178px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.kcol { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 14px; padding: 9px; min-height: 140px; }
.kcol h4 {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  padding: 4px 5px 9px; display: flex; align-items: center; font-weight: 700;
}
.kcol h4 span { margin-left: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; font-size: 10.5px; }
.kcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 10px 11px;
  margin-bottom: 8px; cursor: pointer; transition: .15s; box-shadow: var(--shadow-xs);
}
.kcard:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); transform: translateY(-1px); box-shadow: var(--shadow); }
.kcard b { font-size: 12.5px; display: block; color: var(--ink); }
.kcard .sub { font-size: 11px; color: var(--muted); }
.score-pill { font-size: 10.5px; font-weight: 750; padding: 1px 7px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink); }
.score-pill.hi { background: var(--ok-soft); color: var(--ok); }
.score-pill.lo { background: var(--danger-soft); color: var(--danger); }

/* ------------------------------------------------------------------ overlays */
.overlay {
  position: fixed; inset: 0; background: rgba(16, 15, 32, .48); backdrop-filter: blur(3px);
  z-index: 80; display: flex; justify-content: flex-end; animation: fade .16s ease;
}
.overlay.center { align-items: center; justify-content: center; padding: 20px; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  width: min(640px, 96vw); background: var(--bg); height: 100%; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: slide .22s cubic-bezier(.2,.8,.3,1);
}
@keyframes slide { from { transform: translateX(28px); opacity: .5; } }
.drawer-head {
  position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 16px 20px; display: flex; gap: 12px; align-items: center; z-index: 2;
}
.drawer-head h2 { font-size: 16px; }
.drawer-body { padding: 18px 20px 44px; display: flex; flex-direction: column; gap: 14px; }
.modal {
  width: min(620px, 94vw); background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); max-height: 88vh; display: flex; flex-direction: column;
  animation: pop .18s cubic-bezier(.2,.8,.3,1); overflow: hidden;
}
@keyframes pop { from { transform: scale(.97) translateY(6px); opacity: .4; } }
.modal-head { padding: 17px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 13px; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--line); display: flex; gap: 9px; justify-content: flex-end;
  background: var(--surface-2);
}

/* command palette */
.palette-wrap {
  position: fixed; inset: 0; background: rgba(16, 15, 32, .42); backdrop-filter: blur(4px);
  z-index: 90; display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh;
  animation: fade .14s ease;
}
.palette {
  width: min(620px, 92vw); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg);
  overflow: hidden; animation: pop .16s cubic-bezier(.2,.8,.3,1); border: 1px solid var(--line);
}
.palette input {
  width: 100%; border: none; outline: none; background: transparent; padding: 17px 20px;
  font-size: 15px; font-family: inherit; color: var(--ink); border-bottom: 1px solid var(--line);
}
.palette-list { max-height: 46vh; overflow-y: auto; padding: 8px; }
.palette-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  cursor: pointer; font-size: 13px; color: var(--ink-2);
}
.palette-item .ic { color: var(--muted); }
.palette-item.active, .palette-item:hover { background: var(--brand-soft); color: var(--brand-ink); }
.palette-item.active .ic, .palette-item:hover .ic { color: var(--brand); }
.palette-item .kbd { margin-left: auto; font-size: 10.5px; color: var(--muted); }
.palette-foot {
  border-top: 1px solid var(--line); padding: 9px 16px; font-size: 11px; color: var(--muted);
  display: flex; gap: 14px; background: var(--surface-2);
}
.palette-foot kbd {
  font-family: var(--sans); font-size: 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px; margin-right: 4px;
}

/* ------------------------------------------------------------------ misc */
.empty { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.empty b { display: block; color: var(--ink-2); margin-bottom: 5px; font-size: 14px; }
.empty .ic { opacity: .35; margin-bottom: 8px; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--ink); color: var(--bg); padding: 11px 15px; border-radius: 11px; font-size: 12.8px;
  box-shadow: var(--shadow-lg); animation: pop .18s ease; max-width: 380px; font-weight: 520;
}
.toast.ok { background: #0f9d6e; color: #fff; }
.toast.err { background: #b42318; color: #fff; }
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%; animation: sh 1.3s infinite; border-radius: 10px;
}
@keyframes sh { to { background-position: -200% 0; } }
.kv { display: grid; grid-template-columns: 132px 1fr; gap: 7px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); }
.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 24px 1fr; gap: 10px; padding-bottom: 13px; position: relative; }
.tl-item::before { content: ""; position: absolute; left: 11px; top: 20px; bottom: 0; width: 1px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); margin-top: 6px; margin-left: 7px; box-shadow: 0 0 0 3px var(--brand-soft); }
.tl-item.done .tl-dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.tl-item h5 { margin: 0; font-size: 12.8px; font-weight: 560; color: var(--ink); }
.tl-item .sub { font-size: 11.5px; color: var(--muted); }

/* ------------------------------------------------------------------ login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.08fr 1fr; }
.login-art {
  position: relative; overflow: hidden; padding: 52px;
  background:
    radial-gradient(120% 85% at 102% -6%, rgba(168, 85, 247, .95) 0%, transparent 52%),
    radial-gradient(85% 70% at -10% 104%, rgba(76, 29, 149, .95) 0%, transparent 58%),
    radial-gradient(60% 50% at 78% 78%, rgba(56, 189, 248, .35) 0%, transparent 62%),
    linear-gradient(160deg, #0d0820 0%, #25104f 46%, #5b21b6 100%);
  color: #fff; display: flex; flex-direction: column; justify-content: space-between;
}
.login-art::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.5) 1px, transparent 1px);
  background-size: 26px 26px; opacity: .18;
  -webkit-mask-image: radial-gradient(70% 60% at 25% 22%, #000 10%, transparent 72%);
  mask-image: radial-gradient(70% 60% at 25% 22%, #000 10%, transparent 72%);
}
.login-art::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(520px 300px at 84% 4%, rgba(56, 189, 248, .42), transparent 66%),
    radial-gradient(460px 320px at 4% 96%, rgba(244, 114, 182, .3), transparent 68%);
  mix-blend-mode: screen;
}
.login-art > * { position: relative; z-index: 1; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .26);
  color: #fff; font-weight: 800; font-size: 13px; letter-spacing: -.03em;
  backdrop-filter: blur(6px); box-shadow: 0 10px 26px -14px rgba(0, 0, 0, .8);
}
.login-art h1 { color: #fff; font-size: 38px; line-height: 1.1; letter-spacing: -.035em; max-width: 470px; }
.login-art p { color: rgba(255,255,255,.76); max-width: 430px; margin-top: 16px; font-size: 13.5px; }
.login-feats { display: grid; gap: 14px; margin-top: 30px; }
.login-feat { display: flex; gap: 12px; align-items: flex-start; font-size: 13px; color: rgba(255,255,255,.88); }
.login-feat .tile {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 30px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.18);
}
.login-feat b { display: block; color: #fff; font-weight: 620; margin-bottom: 1px; }
.login-form { display: grid; place-items: center; padding: 40px; background: var(--surface); }
.login-box { width: min(390px, 100%); }
.demo-list { display: grid; gap: 7px; margin-top: 12px; }
.demo-row {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 11px;
  padding: 9px 11px; cursor: pointer; font-size: 12.5px; background: var(--surface); transition: .15s;
}
.demo-row:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); background: var(--surface-2); transform: translateY(-1px); }
.demo-row .role { margin-left: auto; }
.login-theme {
  position: absolute; top: 20px; right: 20px; z-index: 5; width: 38px; height: 38px;
  border-radius: 11px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; color: var(--ink-2); cursor: pointer; transition: .15s;
}
.login-theme:hover { border-color: var(--brand-2); color: var(--brand); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1280px) {
  .g-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-side { grid-template-columns: 1fr; }
}
@media (max-width: 1080px) {
  .shell { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .panel { display: none; }
  .mobile-only { display: inline-flex; }
}
@media (max-width: 860px) {
  :root { --top-h: 60px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .topbar { padding: 0 14px; }
  .topbar h1 { font-size: 15px; }
  .topbar .crumb { display: none; }
  .user-chip .who { display: none; }
  .user-chip { padding: 3px; border-radius: 50%; }
  .content { padding: 16px 14px 92px; }
  .g-2, .g-3, .g-4, .g-5 { grid-template-columns: 1fr; }
  .hero { padding: 20px; border-radius: 18px; }
  .hero h1 { font-size: 20px; }
  .punch { gap: 14px; }
  .punch-ring { width: 88px; height: 88px; flex: 0 0 88px; }
  .chat-wrap { grid-template-columns: 1fr; height: calc(100vh - 200px); }
  .chat-side { display: none; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .kanban { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .drawer { width: 100vw; }
  .modal { width: 94vw; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line); padding: 6px 8px 8px; justify-content: space-around;
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 12px;
    font-size: 9.5px; color: var(--muted); border-radius: 10px; text-decoration: none; font-weight: 600;
  }
  .tabbar a.active { color: var(--brand); background: var(--brand-soft); }
  .tabbar .ic { width: 19px; height: 19px; }
  .toasts { left: 12px; right: 12px; bottom: 76px; }
}

@media print {
  body { background: #fff; }
  .rail, .panel, .topbar, .tabbar, .toasts, .overlay > .drawer > .drawer-head,
  .drawer > .row:last-child { display: none !important; }
  .overlay { position: static !important; background: #fff !important; backdrop-filter: none !important; }
  .drawer { width: 100% !important; height: auto !important; box-shadow: none !important; }
  .drawer-body { padding: 0 !important; }
  .print-area { border: none !important; box-shadow: none !important; padding: 0 !important; }
  .print-area .rail-brand { background: #4c1d95 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .shell { grid-template-columns: 1fr; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ------------------------------------------------------------------ copilot artifacts */
.artifact {
  border: 1px solid var(--line, #e6e8ef);
  border-radius: 14px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(124, 58, 237, .04), rgba(124, 58, 237, 0));
}
.art-icon {
  width: 26px; height: 26px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(124, 58, 237, .12); color: var(--brand, #7c3aed);
}
.meter { height: 6px; border-radius: 999px; background: #ecebf5; overflow: hidden; margin-top: 6px; }
.meter span { display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #7c3aed, #a855f7); }

/* ------------------------------------------------------------------ agent trace */
.trace-chip {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; list-style: none;
  padding: 7px 10px; border-radius: 10px;
  background: rgba(124, 58, 237, .06);
  border: 1px solid rgba(124, 58, 237, .14);
  font-size: 12px;
}
.trace-chip::-webkit-details-marker { display: none; }
.trace-chip:hover { background: rgba(124, 58, 237, .1); }
.trace-dot { width: 7px; height: 7px; border-radius: 999px; background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.trace-toggle { margin-left: auto; font-weight: 600; color: var(--brand, #7c3aed); }
.trace[open] .trace-toggle::after { content: " ▾"; }
.trace:not([open]) .trace-toggle::after { content: " ▸"; }
.trace-steps { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.trace-steps li { display: flex; gap: 10px; align-items: flex-start; }
.trace-num {
  width: 20px; height: 20px; border-radius: 999px; flex: none;
  background: #ede9fe; color: #6d28d9; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.tool-chip {
  font-size: 11px; padding: 2px 7px; border-radius: 6px;
  background: #f4f2fb; color: #5b21b6; border: 1px solid #e6e1f8;
}
.trace-args { font-size: 11px; color: var(--muted, #6b7280); margin-top: 4px;
  font-family: var(--mono, ui-monospace, monospace); word-break: break-word; }

/* ------------------------------------------------------------------ a11y */
:focus-visible { outline: 2px solid var(--brand, #7c3aed); outline-offset: 2px; border-radius: 8px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ------------------------------------------------------------------ pre-check panel */
.precheck { margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  background: #faf9ff; border: 1px solid #ece9f8; }
.precheck.ok { background: #f4fbf6; border-color: #d9f0e1; }
.precheck.warn { background: #fffbf2; border-color: #f7e6c4; }
.precheck.danger { background: #fff6f6; border-color: #f8d7d7; }
.verdict-dot { width: 8px; height: 8px; border-radius: 999px; background: #7c3aed; }
.precheck.ok .verdict-dot { background: #16a34a; }
.precheck.warn .verdict-dot { background: #d97706; }
.precheck.danger .verdict-dot { background: #dc2626; }
.meter.ok span { background: linear-gradient(90deg, #16a34a, #4ade80); }
.meter.warn span { background: linear-gradient(90deg, #d97706, #fbbf24); }
.meter.danger span { background: linear-gradient(90deg, #dc2626, #f87171); }
.verdict-note { font-size: 11.5px; color: #b91c1c; margin-top: 6px; }
.checks { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 7px; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: 12px; }
.check b { font-weight: 600; }
.check .muted { font-size: 11.5px; }
.check-dot { width: 16px; height: 16px; border-radius: 999px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; background: #eef0f4; color: #6b7280; }
.check.pass .check-dot { background: #e7f6ec; color: #15803d; }
.check.warn .check-dot { background: #fdf3e2; color: #b45309; }
.check.fail .check-dot { background: #fdeaea; color: #b91c1c; }
.artifact.danger { border-color: #f3d4d4; }
.artifact.warn { border-color: #f6e5c8; }

/* ------------------------------------------------------------------ agent signals */
.signal-card { border-color: rgba(124, 58, 237, .18); }
.signal { border: 1px solid var(--line, #e9eaf2); border-radius: 12px; padding: 11px 13px;
  background: #fcfbff; }
.signal:hover { background: #faf8ff; }
.vote { display: inline-flex; gap: 4px; margin-left: 8px; }
.vote-btn { border: 1px solid var(--line, #e6e8ef); background: #fff; border-radius: 7px;
  padding: 1px 6px; font-size: 11px; cursor: pointer; line-height: 1.6; }
.vote-btn:hover { background: #f4f2fb; border-color: #d9d2f5; }

/* ------------------------------------------------------------------ citation source view */
.cite-doc { white-space: pre-wrap; font-family: var(--sans, inherit); font-size: 12.5px;
  line-height: 1.7; margin: 0; max-height: 62vh; overflow: auto; }
.cite-doc mark { background: #fde68a; color: inherit; padding: 1px 2px; border-radius: 3px;
  box-shadow: 0 0 0 2px #fde68a; }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; }
ul.plain li { padding-left: 14px; position: relative; }
ul.plain li::before { content: "•"; position: absolute; left: 2px; color: var(--brand, #7c3aed); }
