/* ============================================================
   Reptra — Editorial Design System
   Warm paper · ink sidebar · single lime accent · flat hairlines
   Display: Secular One · Body: Assistant · light-default, theme-aware
   ============================================================ */
:root {
  /* ---- Light (default) · clean neutral ---- */
  --bg: #f2f3f1;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #edefec;
  --surface-hover: rgba(24, 24, 27, 0.05);
  --border: rgba(24, 24, 27, 0.12);
  --border-strong: rgba(24, 24, 27, 0.22);
  --text: #18181b;
  --text-dim: #64646e;
  --text-faint: #9d9da7;
  --sunken: rgba(24, 24, 27, 0.045);
  --track: rgba(24, 24, 27, 0.11);
  --input-bg: #ffffff;
  --input-bg-focus: #ffffff;
  --chart-grid: rgba(24, 24, 27, 0.08);
  --scrollbar: rgba(24, 24, 27, 0.2);

  /* ink sidebar (same in light; deeper in dark) */
  --sidebar-bg: #18181b;
  --sidebar-fg: #f4f4f5;
  --sidebar-dim: rgba(244, 244, 245, 0.60);
  --sidebar-faint: rgba(244, 244, 245, 0.38);
  --sidebar-line: rgba(244, 244, 245, 0.12);
  --topbar-bg: #f2f3f1;

  --accent: #c7f000;          /* lime */
  --accent-ink: #18181b;      /* text on lime */

  /* re-purposed legacy names (kept so markup stays untouched) */
  --violet: #18181b;   --violet-2: #18181b;              /* ink */
  --emerald: #6f9200;  --emerald-2: #4a6600;             /* lime fill / lime text */
  --amber: #9a6410;    --rose: #c02c22;    --sky: #2f5e42;/* ochre / red / forest */

  --c-violet-bg: rgba(24,24,27,.07);   --c-violet-fg:#18181b;  --c-violet-bd: rgba(24,24,27,.18);
  --c-emerald-bg: rgba(111,146,0,.15); --c-emerald-fg:#4a6600; --c-emerald-bd: rgba(111,146,0,.38);
  --c-amber-bg: rgba(154,100,16,.13);  --c-amber-fg:#8a5a0e;   --c-amber-bd: rgba(154,100,16,.3);
  --c-sky-bg: rgba(47,94,66,.12);      --c-sky-fg:#2f5e42;     --c-sky-bd: rgba(47,94,66,.28);
  --c-rose-bg: rgba(192,44,34,.10);    --c-rose-fg:#b52c22;    --c-rose-bd: rgba(192,44,34,.28);

  /* "gradients" flattened to solids (editorial: no gradients) */
  --grad-brand: var(--accent);
  --grad-violet: #18181b;
  --grad-emerald: var(--accent);
  --grad-warm: #cf9022;
  --grad-rose: #c02c22;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 18px 44px -24px rgba(26, 22, 14, 0.34);
  --card-shadow: none;
  --font: 'Assistant', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Secular One', 'Assistant', sans-serif;
  --sidebar-w: 258px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #101012;
  --bg-2: #17171a;
  --surface: #1a1a1d;
  --surface-2: #212124;
  --surface-hover: rgba(244, 244, 245, 0.06);
  --border: rgba(244, 244, 245, 0.12);
  --border-strong: rgba(244, 244, 245, 0.22);
  --text: #f4f4f5;
  --text-dim: #a1a1aa;
  --text-faint: #6b6b74;
  --sunken: rgba(0, 0, 0, 0.28);
  --track: rgba(244, 244, 245, 0.1);
  --input-bg: rgba(0, 0, 0, 0.25);
  --input-bg-focus: rgba(0, 0, 0, 0.32);
  --chart-grid: rgba(244, 244, 245, 0.08);
  --scrollbar: rgba(244, 244, 245, 0.12);

  --sidebar-bg: #09090b;
  --sidebar-fg: #f4f4f5;
  --sidebar-dim: rgba(244, 244, 245, 0.58);
  --sidebar-faint: rgba(244, 244, 245, 0.36);
  --sidebar-line: rgba(244, 244, 245, 0.1);
  --topbar-bg: #101012;

  --accent: #c7f000; --accent-ink: #18181b;

  --violet: #f4f4f5;  --violet-2: #f4f4f5;
  --emerald: #c7f000; --emerald-2: #c7f000;
  --amber: #e0a020;   --rose: #ef6b5e;   --sky: #5fae7e;

  --c-violet-bg: rgba(243,239,228,.10); --c-violet-fg:#f3efe4;  --c-violet-bd: rgba(243,239,228,.22);
  --c-emerald-bg: rgba(199,240,0,.14);  --c-emerald-fg:#c7f000; --c-emerald-bd: rgba(199,240,0,.3);
  --c-amber-bg: rgba(224,160,32,.14);   --c-amber-fg:#e0a020;   --c-amber-bd: rgba(224,160,32,.28);
  --c-sky-bg: rgba(95,174,126,.14);     --c-sky-fg:#7cc79a;     --c-sky-bd: rgba(95,174,126,.3);
  --c-rose-bg: rgba(239,107,94,.13);    --c-rose-fg:#ef6b5e;    --c-rose-bd: rgba(239,107,94,.3);

  --grad-brand: var(--accent);
  --grad-violet: var(--accent);
  --grad-emerald: var(--accent);
  --grad-warm: #e0a020;
  --grad-rose: #ef6b5e;

  --shadow: 0 24px 60px -22px rgba(0, 0, 0, 0.7);
  --card-shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  line-height: 1.55;
  transition: background .25s ease, color .25s ease;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, textarea, select { outline: none; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 0; border: 3px solid transparent; background-clip: padding-box; }

h1,h2,h3,.display { font-family: var(--font-display); font-weight: 400; letter-spacing: 0; }

/* ============================================================ Utilities */
.hidden { display: none !important; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.center { text-align: center; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mono { font-variant-numeric: tabular-nums; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 5px; font-size: 11.5px; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
  letter-spacing: .2px;
}
.pill svg { width: 13px; height: 13px; }
.pill.ok { background: var(--c-emerald-bg); color: var(--c-emerald-fg); border-color: var(--c-emerald-bd); }
.pill.warn { background: var(--c-amber-bg); color: var(--c-amber-fg); border-color: var(--c-amber-bd); }
.pill.bad { background: var(--c-rose-bg); color: var(--c-rose-fg); border-color: var(--c-rose-bd); }
.pill.info { background: var(--c-sky-bg); color: var(--c-sky-fg); border-color: var(--c-sky-bd); }
.pill.violet { background: var(--c-violet-bg); color: var(--c-violet-fg); border-color: var(--c-violet-bd); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.ok { background: var(--emerald); }
.dot.warn { background: var(--amber); }
.dot.bad { background: var(--rose); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 17px; border-radius: var(--radius-sm); font-weight: 700; font-size: 14px;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  transition: transform .12s ease, background .18s ease, border-color .18s ease, color .18s ease;
  white-space: nowrap; min-height: 42px;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { background: var(--surface-hover); border-color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--grad-violet); border-color: var(--grad-violet); color: var(--bg-2); }
:root[data-theme="dark"] .btn.primary { color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.12); background: var(--grad-violet); border-color: var(--grad-violet); }
.btn.success { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.success:hover { filter: brightness(1.05); background: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-hover); border-color: var(--border); }
.btn.danger { background: var(--c-rose-bg); border-color: var(--c-rose-bd); color: var(--rose); }
.btn.danger:hover { background: var(--c-rose-bg); filter: brightness(1.05); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; border-radius: 6px; min-height: 32px; }
.btn.icon { padding: 9px; width: 42px; height: 42px; border-radius: var(--radius-sm); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .4; pointer-events: none; }

.icon-btn {
  width: 42px; height: 42px; border-radius: var(--radius-sm); display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  transition: all .14s ease; flex-shrink: 0;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--text); }

/* Cards — flat, hairline, no glass */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--card-shadow); }
.card.pad { padding: 22px; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--text-dim); }
.input, .select, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--input-bg); border: 1px solid var(--border-strong); color: var(--text);
  font-size: 16px; transition: border-color .18s ease, box-shadow .18s ease;
}
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--text); box-shadow: 0 0 0 3px rgba(199,240,0,.4);
}
.input::placeholder { color: var(--text-faint); }
textarea.input { resize: vertical; min-height: 84px; line-height: 1.6; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23888' stroke-width='2'><path d='M4 6l4 4 4-4'/></svg>");
  background-repeat: no-repeat; background-position: left 14px center; padding-left: 38px;
}

/* Avatar — squared editorial */
.avatar {
  border-radius: 26%; display: grid; place-items: center; font-weight: 800; color: #fff;
  flex-shrink: 0; letter-spacing: .3px; user-select: none; font-family: var(--font);
}

/* ============================================================ Auth / Login */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-inner { width: 100%; max-width: 940px; }
.auth-top { position: absolute; top: 18px; inset-inline-end: 18px; }
.brand-lockup { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 6px; }
.brand-mark { width: 52px; height: 52px; border-radius: 13px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); }
.brand-mark svg { width: 30px; height: 30px; }
.brand-name { font-family: var(--font-display); font-size: 42px; font-weight: 400; letter-spacing: -.5px; }
.brand-name b { color: var(--text); font-weight: 400; }
.auth h2 { text-align: center; font-family: var(--font-display); font-size: 22px; font-weight: 400; margin-top: 16px; }
.auth .sub { text-align: center; color: var(--text-dim); margin-top: 8px; margin-bottom: 32px; font-size: 15px; }

.role-tabs { display: flex; gap: 6px; background: var(--surface); border: 1px solid var(--border); padding: 5px; border-radius: 11px; max-width: 340px; margin: 0 auto 26px; }
.role-tabs button { flex: 1; padding: 11px; border-radius: 7px; font-weight: 700; color: var(--text-dim); transition: all .16s ease; }
.role-tabs button.active { background: var(--grad-violet); color: var(--bg-2); }
:root[data-theme="dark"] .role-tabs button.active { color: var(--accent-ink); }

.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.account-card { padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); text-align: center; transition: all .16s ease; cursor: pointer; }
.account-card:hover { transform: translateY(-3px); border-color: var(--text); }
.account-card .avatar { margin: 0 auto 12px; width: 58px; height: 58px; font-size: 21px; }
.account-card .nm { font-weight: 700; font-size: 15px; }
.account-card .rl { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }

/* ============================================================ App shell */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; padding: 22px 14px; position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
  background: var(--sidebar-bg); color: var(--sidebar-fg);
}
.sidebar .logo { display: flex; align-items: center; gap: 11px; padding: 6px 10px 22px; }
.sidebar .logo .brand-mark { width: 38px; height: 38px; border-radius: 10px; }
.sidebar .logo .brand-mark svg { width: 22px; height: 22px; }
.sidebar .logo .t { font-family: var(--font-display); font-size: 23px; font-weight: 400; letter-spacing: -.5px; color: var(--sidebar-fg); }
.sidebar .logo .t b { font-weight: 400; color: var(--sidebar-fg); }
.nav-label { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.4px; color: var(--sidebar-faint); padding: 16px 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-dim); font-weight: 600; font-size: 14.5px; transition: all .14s ease; position: relative;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.07); color: var(--sidebar-fg); }
.nav-item.active { background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.nav-item .badge { margin-inline-start: auto; background: var(--rose); color:#fff; font-size: 11px; font-weight: 800; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; display: grid; place-items: center; }
.sidebar .spacer { flex: 1; }
.side-user { display: flex; align-items: center; gap: 11px; padding: 10px; border-radius: var(--radius-sm); background: rgba(255,255,255,.06); border: 1px solid var(--sidebar-line); margin-top: 6px; }
.side-user .avatar { width: 38px; height: 38px; font-size: 14px; }
.side-user .nm { font-size: 13.5px; font-weight: 700; color: var(--sidebar-fg); }
.side-user .rl { font-size: 11.5px; color: var(--sidebar-dim); }
.side-user .icon-btn { background: transparent; border-color: var(--sidebar-line); color: var(--sidebar-dim); }
.side-user .icon-btn:hover { background: rgba(255,255,255,.08); color: var(--sidebar-fg); border-color: var(--sidebar-line); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 15px 30px; border-bottom: 1px solid var(--border); background: var(--topbar-bg);
}
.topbar .page-title { font-family: var(--font-display); font-size: 24px; font-weight: 400; letter-spacing: -.3px; line-height: 1.15; }
.topbar .page-sub { font-size: 13px; color: var(--text-dim); margin-top: 1px; }
.mobile-menu-btn { display: none; }
.content { padding: 30px; max-width: 1240px; width: 100%; margin: 0 auto; animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.bottom-nav { display: none; }

/* ============================================================ Grids / Layout */
.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.split { display: grid; gap: 18px; grid-template-columns: 1.6fr 1fr; align-items: start; }
.split-even { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; align-items: start; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 18px; gap: 12px; flex-wrap: wrap; }
.section-head h3 { font-family: var(--font-display); font-size: 19px; font-weight: 400; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* Stat card — big editorial number */
.stat { padding: 20px; border-radius: var(--radius); position: relative; background: var(--surface); border: 1px solid var(--border); }
.stat .ic { width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; margin-bottom: 16px; }
.stat .ic svg { width: 21px; height: 21px; }
.stat .val { font-family: var(--font-display); font-size: 36px; font-weight: 400; letter-spacing: -1px; line-height: .95; }
.stat .lbl { font-size: 13px; color: var(--text-dim); margin-top: 9px; font-weight: 600; }
.stat .trend { position: absolute; top: 20px; inset-inline-end: 20px; font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; gap: 2px; }
.stat .trend svg { width: 13px; height: 13px; }
.trend.up { color: var(--emerald-2); }
.trend.down { color: var(--rose); }
.ic.v { background: var(--c-violet-bg); color: var(--c-violet-fg); }
.ic.e { background: var(--c-emerald-bg); color: var(--c-emerald-fg); }
.ic.a { background: var(--c-amber-bg); color: var(--c-amber-fg); }
.ic.s { background: var(--c-sky-bg); color: var(--c-sky-fg); }
.ic.r { background: var(--c-rose-bg); color: var(--c-rose-fg); }

/* Progress bar */
.bar { height: 8px; border-radius: 2px; background: var(--track); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }

/* List rows */
.list { display: flex; flex-direction: column; }
.lrow { display: flex; align-items: center; gap: 14px; padding: 14px 2px; border-bottom: 1px solid var(--border); }
.lrow:last-child { border-bottom: none; }
.lrow .avatar { width: 44px; height: 44px; font-size: 16px; }
.lrow .nm { font-weight: 700; font-size: 15px; }
.lrow .meta { font-size: 12.5px; color: var(--text-dim); }

/* Trainee card */
.trainee-card { padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); cursor: pointer; transition: all .16s ease; }
.trainee-card:hover { transform: translateY(-3px); border-color: var(--text); }
.trainee-card .head { display: flex; align-items: center; gap: 13px; margin-bottom: 16px; }
.trainee-card .avatar { width: 50px; height: 50px; font-size: 18px; }
.tc-stat { text-align: center; padding: 11px 4px; border-radius: 8px; background: var(--sunken); }
.tc-stat .v { font-family: var(--font-display); font-weight: 400; font-size: 20px; }
.tc-stat .l { font-size: 10.5px; color: var(--text-dim); margin-top: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* Tabs — underline editorial */
.tabs { display: flex; gap: 2px; padding: 0; background: transparent; border: none; border-bottom: 1px solid var(--border); border-radius: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { padding: 11px 15px; border-radius: 0; font-weight: 700; font-size: 13.5px; color: var(--text-dim); white-space: nowrap; transition: all .16s ease; display: inline-flex; align-items: center; gap: 7px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button svg { width: 15px; height: 15px; }
.tabs button:hover { color: var(--text); }
.tabs button.active { background: transparent; color: var(--text); box-shadow: none; border-bottom-color: var(--accent); }

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 11px; font-weight: 800; color: var(--text-faint); text-transform: uppercase; letter-spacing: .8px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 13px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .14s ease; }
.table tbody tr:hover { background: var(--surface-hover); }

/* Exercise row */
.ex-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); margin-bottom: 8px; transition: all .14s ease; }
.ex-row.done { border-color: var(--c-emerald-bd); background: var(--c-emerald-bg); }
.ex-check { width: 30px; height: 30px; border-radius: 6px; border: 2px solid var(--border-strong); display: grid; place-items: center; flex-shrink: 0; transition: all .14s ease; cursor: pointer; }
.ex-check.on { background: var(--accent); border-color: var(--accent); }
.ex-check svg { width: 16px; height: 16px; opacity: 0; color: var(--accent-ink); }
.ex-check.on svg { opacity: 1; }
.ex-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.ex-tag { font-size: 12px; padding: 2px 8px; border-radius: 5px; background: var(--sunken); color: var(--text-dim); font-weight: 600; }

/* Chart */
.chart svg { width: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis-label { fill: var(--text-faint); font-size: 11px; }
.chart-dot { fill: var(--text); stroke: var(--surface); stroke-width: 3; }
.chart-empty { padding: 40px; text-align: center; color: var(--text-faint); }

/* Messages — single flat panel */
.chat-panel { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.chat-header .who { display: flex; align-items: center; gap: 11px; }
.chat-header .avatar { width: 42px; height: 42px; font-size: 15px; }
.chat-header .nm { font-weight: 700; font-size: 15px; }
.chat-header .cmeta { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; margin-top: 1px; }
.chat-wrap { display: flex; flex-direction: column; height: calc(100dvh - 300px); min-height: 420px; }
.chat-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 3px; background: var(--surface-2); }
.msg { max-width: 74%; padding: 10px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; margin-top: 9px; }
.msg .ts { font-size: 10px; opacity: .55; margin-top: 4px; }
.msg.them { align-self: flex-start; background: var(--bg-2); border: 1px solid var(--border); color: var(--text); border-bottom-inline-start-radius: 5px; }
.msg.me { align-self: flex-end; background: var(--grad-violet); color: var(--bg-2); border-bottom-inline-end-radius: 5px; }
:root[data-theme="dark"] .msg.me { color: var(--accent-ink); }
.msg.me .ts { text-align: end; }
.chat-input { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-input .input { border-radius: 100px; background: var(--surface-2); border-color: var(--border); }
.chat-input .input:focus { background: var(--surface); }

/* Empty state */
.empty { text-align: center; padding: 54px 20px; color: var(--text-dim); }
.empty .em-ic { width: 66px; height: 66px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; margin: 0 auto 18px; }
.empty svg { width: 32px; height: 32px; color: var(--text-faint); }
.empty h4 { font-family: var(--font-display); font-size: 18px; font-weight: 400; color: var(--text); margin-bottom: 6px; }

/* Timeline */
.tl { position: relative; padding-inline-start: 24px; }
.tl::before { content:""; position:absolute; inset-inline-start:6px; top:6px; bottom:6px; width:2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item::before { content:""; position:absolute; inset-inline-start:-24px; top:3px; width:12px; height:12px; border-radius:3px; background: var(--surface); border:2px solid var(--text-faint); }
.tl-item.done::before { background: var(--accent); border-color: var(--accent); }
.tl-item .tl-date { font-size: 12px; color: var(--text-faint); font-weight: 700; }

/* Modal — flat, ease-out (no bounce) */
#modal-root { position: fixed; inset: 0; z-index: 100; display: none; }
#modal-root.open { display: block; }
.modal-overlay { position: absolute; inset: 0; background: rgba(20,16,8,.55); animation: fade .18s ease; }
.modal {
  position: absolute; inset-inline: 0; margin: 0 auto; top: 50%; transform: translateY(-50%);
  width: min(560px, calc(100% - 32px)); max-height: 90vh; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); animation: pop .22s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-50%) scale(.98); } to { opacity: 1; transform: translateY(-50%) scale(1); } }
@keyframes sheet { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-2); z-index: 2; }
.modal-head h3 { font-family: var(--font-display); font-size: 19px; font-weight: 400; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--bg-2); flex-wrap: wrap; }

/* Toast */
#toast-root { position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; width: max-content; max-width: calc(100% - 32px); }
.toast { padding: 13px 20px; border-radius: var(--radius-sm); background: var(--bg-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 10px; animation: toastIn .25s ease-out; }
.toast svg { width: 17px; height: 17px; }
.toast.ok { border-color: var(--c-emerald-bd); color: var(--emerald-2); }
.toast.err { border-color: var(--c-rose-bd); color: var(--rose); }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* Ring progress */
.ring { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: butt; }
.ring .track { stroke: var(--track); }
.ring .val { stroke: url(#ringGrad); transition: stroke-dashoffset .6s ease; }

/* Chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 8px 14px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border-strong); font-size: 13px; font-weight: 700; color: var(--text-dim); cursor: pointer; transition: all .14s ease; }
.chip:hover { border-color: var(--text); color: var(--text); }
.chip.on { background: var(--grad-violet); border-color: var(--grad-violet); color: var(--bg-2); }
:root[data-theme="dark"] .chip.on { color: var(--accent-ink); }

/* Calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 800; color: var(--text-faint); padding-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.cal-cell { aspect-ratio: 1; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); padding: 8px; position: relative; font-size: 13px; transition: all .14s ease; }
.cal-cell.empty { background: transparent; border: none; }
.cal-cell.today { border-color: var(--text); border-width: 2px; }
.cal-cell .cn { font-weight: 700; }
.cal-cell .ev-dot { position: absolute; bottom: 7px; inset-inline-start: 8px; display: flex; gap: 3px; }
.cal-cell .ev-dot i { width: 6px; height: 6px; border-radius: 2px; background: var(--accent); }

.hr { height: 1px; background: var(--border); margin: 4px 0; border: none; }
.kpi-mini { display: flex; align-items: baseline; gap: 6px; }
.kpi-mini .n { font-family: var(--font-display); font-size: 24px; font-weight: 400; }
.kpi-mini .u { font-size: 13px; color: var(--text-dim); }

/* ============================================================ Responsive */
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .g-3 { grid-template-columns: repeat(2, 1fr); }
  .split-even { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; z-index: 90; transform: translateX(110%); transition: transform .28s ease; box-shadow: var(--shadow); width: min(280px, 82vw); }
  .sidebar.open { transform: translateX(0) !important; }
  .mobile-menu-btn { display: grid; }
  .content { padding: 18px 15px calc(90px + env(safe-area-inset-bottom)); }
  .topbar { padding: 12px 15px; gap: 10px; }
  .topbar .page-title { font-size: 20px; }
  .topbar .page-sub { display: none; }
  .scrim { position: fixed; inset: 0; background: rgba(20,16,8,.5); z-index: 80; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; inset-inline: 0; z-index: 70;
    background: var(--sidebar-bg); border-top: 1px solid var(--sidebar-line);
    padding: 7px 4px calc(7px + env(safe-area-inset-bottom)); justify-content: space-around;
  }
  .bn-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 6px; border-radius: 7px; color: var(--sidebar-dim); font-size: 10.5px; font-weight: 700; flex: 1; max-width: 80px; }
  .bn-item svg { width: 23px; height: 23px; }
  .bn-item.active { color: var(--accent); }
}
@media (max-width: 620px) {
  .g-2, .g-3, .g-4 { grid-template-columns: 1fr; }
  .g-4.keep-2, .g-3.keep-2 { grid-template-columns: repeat(2, 1fr); }
  .brand-name { font-size: 34px; }
  .content { animation: none; padding-top: 16px; }
  .section-head h3 { font-size: 17px; }
  .stat { padding: 17px; }
  .stat .val { font-size: 31px; }
  .card.pad { padding: 17px; }
  .hide-sm { display: none !important; }
  .modal { top: auto; bottom: 0; transform: none; width: 100%; max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom: none; animation: sheet .26s ease-out; }
  .modal-body { padding: 18px; }
  .modal-head, .modal-foot { padding: 16px 18px; }
  .msg { max-width: 88%; }
  .role-tabs { max-width: 100%; }
  .account-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .account-card { padding: 16px; }
  .chat-wrap { height: calc(100dvh - 250px); }
}
@media (max-width: 380px) { .account-grid { grid-template-columns: 1fr; } }
