/* =========================================================
   OAK Admin — design tokens
   ========================================================= */
:root {
  color-scheme: light;

  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-hover: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;

  --text: #09090b;
  --text-2: #52525b;
  --text-3: #71717a;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eef3fe;
  --accent-text: #1d4ed8;
  --on-accent: #ffffff;
  --ring: rgba(37, 99, 235, 0.35);

  --success-text: #15803d;
  --success-soft: #ecfdf3;
  --warning-text: #a15c07;
  --warning-soft: #fef6e7;
  --info-text: #1d4ed8;
  --info-soft: #eef3fe;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  /* Chart roles (dataviz reference palette) */
  --series-1: #2a78d6;
  --status-new: #fab219;
  --status-review: #2a78d6;
  --status-done: #0ca30c;
  --grid: #ececef;
  --axis: #d4d4d8;

  --shadow-sm: 0 1px 2px rgba(9, 9, 11, 0.05);
  --shadow-md: 0 4px 12px rgba(9, 9, 11, 0.06), 0 1px 3px rgba(9, 9, 11, 0.05);
  --shadow-lg: 0 24px 48px rgba(9, 9, 11, 0.14), 0 4px 12px rgba(9, 9, 11, 0.06);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --sidebar-w: 256px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #09090b;
    --surface: #111113;
    --surface-2: #18181b;
    --surface-hover: #1c1c1f;
    --border: #27272a;
    --border-strong: #3f3f46;
    --text: #fafafa;
    --text-2: #a1a1aa;
    --text-3: #8b8b94;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-soft: rgba(59, 130, 246, 0.14);
    --accent-text: #93b4ff;
    --ring: rgba(96, 165, 250, 0.45);
    --success-text: #4ade80;
    --success-soft: rgba(34, 197, 94, 0.12);
    --warning-text: #fbbf24;
    --warning-soft: rgba(250, 178, 25, 0.12);
    --info-text: #93b4ff;
    --info-soft: rgba(59, 130, 246, 0.14);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --series-1: #3987e5;
    --status-review: #3987e5;
    --grid: #232326;
    --axis: #3f3f46;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --surface: #111113;
  --surface-2: #18181b;
  --surface-hover: #1c1c1f;
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #fafafa;
  --text-2: #a1a1aa;
  --text-3: #8b8b94;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --accent-text: #93b4ff;
  --ring: rgba(96, 165, 250, 0.45);
  --success-text: #4ade80;
  --success-soft: rgba(34, 197, 94, 0.12);
  --warning-text: #fbbf24;
  --warning-soft: rgba(250, 178, 25, 0.12);
  --info-text: #93b4ff;
  --info-soft: rgba(59, 130, 246, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --series-1: #3987e5;
  --status-review: #3987e5;
  --grid: #232326;
  --axis: #3f3f46;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.55);
}

/* =========================================================
   Base
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
svg.lucide { width: 16px; height: 16px; stroke-width: 2; flex-shrink: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; left: 12px; top: -48px; z-index: 2000;
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent); font-weight: 500;
  transition: top 0.15s var(--ease);
}
.skip-link:focus { top: 12px; }

kbd {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  font: 500 11px/1 var(--font); color: var(--text-3);
  background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* =========================================================
   Controls
   ========================================================= */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  font-weight: 500; white-space: nowrap;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.btn-lg { height: 42px; font-size: 15px; }
.btn-block { width: 100%; }

.btn[aria-busy="true"] { color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"] > * { visibility: hidden; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--on-accent); border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
.btn-secondary[aria-busy="true"]::after { border-color: var(--text-2); border-right-color: transparent; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  color: var(--text-2); transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn-bordered { border: 1px solid var(--border); background: var(--surface); }

input[type="text"], input[type="password"], input[type="search"], select, textarea {
  width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"], input[type="password"], input[type="search"], select { height: 36px; padding: 0 12px; }
textarea { padding: 10px 12px; line-height: 1.55; resize: vertical; min-height: 96px; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 15 5 5 5-5M7 9l5-5 5 5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

.select-wrap { position: relative; min-width: 0; }
.select-wrap > svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.select-wrap > select { padding-left: 34px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 500; font-size: 13px; }

.input-affix { position: relative; }
.input-affix input { padding-right: 42px; }
.affix-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 30px; display: grid; place-items: center; color: var(--text-3); border-radius: 5px; }
.affix-btn:hover { color: var(--text); background: var(--surface-hover); }

.alert { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.alert-danger { background: var(--danger-soft); color: var(--danger); }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.segmented button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: 7px;
  font-weight: 500; color: var(--text-2); white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.segmented-block { display: flex; }
.segmented-block button { flex: 1; }

/* =========================================================
   Auth
   ========================================================= */
.auth {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  padding: 32px 16px;
  background:
    radial-gradient(60rem 30rem at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; padding: 32px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.auth-title { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-top: 20px; }
.auth-sub { color: var(--text-2); margin-top: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.auth-form .btn { margin-top: 4px; }
.auth-foot { color: var(--text-3); font-size: 12px; }

.brand-mark {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}
.brand-mark-lg { width: 48px; height: 48px; border-radius: 12px; font-size: 14px; }

/* =========================================================
   Shell
   ========================================================= */
.shell { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar-head { display: flex; align-items: center; gap: 10px; height: 64px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1; }
.brand-text strong { font-weight: 600; }
.brand-text span { font-size: 12px; color: var(--text-3); }
.sidebar-close { display: none; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 16px 12px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); padding: 0 10px 8px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
  transition: background-color 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--surface-hover); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.nav-link > span:first-of-type { flex: 1; }
.nav-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--accent); color: var(--on-accent);
}

.sidebar-foot { display: flex; flex-direction: column; gap: 12px; padding: 12px; border-top: 1px solid var(--border); }
.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.theme-switch button { height: 28px; display: grid; place-items: center; border-radius: 7px; color: var(--text-3); }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }

.user-card { display: flex; align-items: center; gap: 10px; padding: 4px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.user-meta strong { font-weight: 500; }
.user-meta > span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.online-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--status-done); }

.avatar {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600;
}
.avatar svg { width: 14px; height: 14px; }

.backdrop { position: fixed; inset: 0; background: rgba(9, 9, 11, 0.45); animation: fade 0.15s ease; }
.sidebar-backdrop { z-index: 35; }

.main { margin-left: var(--sidebar-w); min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  min-height: 64px; padding: 10px 28px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; }
.topbar-title p { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.search { position: relative; width: 320px; }
.search > svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search input { padding-left: 34px; padding-right: 36px; }
.search input::-webkit-search-cancel-button { display: none; }
.search-kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search input:focus + .search-kbd, .search input:not(:placeholder-shown) + .search-kbd { display: none; }

.sync { font-size: 12px; color: var(--text-3); white-space: nowrap; }
#refresh-btn.is-spinning svg { animation: spin 0.8s linear infinite; }

main { flex: 1; padding: 24px 28px 48px; outline: none; }
.view { display: flex; flex-direction: column; gap: 20px; max-width: 1400px; margin: 0 auto; width: 100%; animation: fade 0.2s ease; }

/* =========================================================
   Cards & KPIs
   ========================================================= */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card-sub { font-size: 13px; color: var(--text-3); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 500; font-size: 13px; }
.kpi-icon { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--surface-2); color: var(--text-2); }
.kpi-icon svg { width: 14px; height: 14px; }
.kpi-icon.is-new { background: var(--warning-soft); color: var(--warning-text); }
.kpi-icon.is-review { background: var(--info-soft); color: var(--info-text); }
.kpi-icon.is-done { background: var(--success-soft); color: var(--success-text); }
.kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; margin-top: 10px; }
.kpi-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-meta strong { color: var(--text-2); font-weight: 500; }

.skeleton { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }

/* =========================================================
   Appeals table
   ========================================================= */
.card-toolbar { padding: 0 20px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.card-toolbar::-webkit-scrollbar { display: none; }
.tabs { display: flex; gap: 20px; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  height: 48px; color: var(--text-2); font-weight: 500; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.tab-count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center; font-size: 12px; font-variant-numeric: tabular-nums; background: var(--surface-2); color: var(--text-2); }
.tab[aria-selected="true"] .tab-count { background: var(--accent-soft); color: var(--accent-text); }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.filters .select-wrap { width: 200px; }
.filters-spacer { flex: 1; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
  height: 40px; padding: 0 12px; text-align: left; white-space: nowrap;
  font-size: 12px; font-weight: 500; color: var(--text-3);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.th-sort { display: inline-flex; align-items: center; gap: 4px; height: 28px; margin: 0 -6px; padding: 0 6px; border-radius: 5px; color: inherit; font-weight: inherit; }
.th-sort:hover { color: var(--text); background: var(--surface-hover); }
.th-sort svg { width: 13px; height: 13px; opacity: 0.5; }
th[aria-sort="ascending"] .th-sort, th[aria-sort="descending"] .th-sort { color: var(--text); }
th[aria-sort="ascending"] .th-sort svg, th[aria-sort="descending"] .th-sort svg { opacity: 1; }

.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.row { cursor: pointer; transition: background-color 0.1s; }
.table tbody tr.row:hover td { background: var(--surface-hover); }
.table tbody tr.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.table tbody tr.row.is-active td { background: var(--accent-soft); }

.cell-id { display: flex; flex-direction: column; min-width: 0; }
.cell-id .id { font-weight: 600; font-variant-numeric: tabular-nums; }
.sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; display: block; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person-body { display: flex; flex-direction: column; min-width: 0; }
.person-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.person.is-anon .person-name { color: var(--text-2); font-style: italic; }
.c-otm { color: var(--text-2); max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-text { color: var(--text-2); max-width: 320px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.c-date { white-space: nowrap; color: var(--text-2); }
.c-date time { display: flex; flex-direction: column; line-height: 1.3; }
.c-date small { font-size: 12px; color: var(--text-3); }
.c-go { width: 1%; color: var(--text-3); }
.c-go svg { transition: transform 0.15s var(--ease); }
.row:hover .c-go svg { transform: translateX(2px); color: var(--text); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px 0 7px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.pill svg { width: 13px; height: 13px; }
.pill-new { background: var(--warning-soft); color: var(--warning-text); }
.pill-review { background: var(--info-soft); color: var(--info-text); }
.pill-done { background: var(--success-soft); color: var(--success-text); }

.empty { padding: 56px 20px; text-align: center; }
.empty-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); color: var(--text-3); margin-bottom: 12px; }
.empty-icon svg { width: 20px; height: 20px; }
.empty h3 { font-size: 15px; font-weight: 600; }
.empty p { color: var(--text-3); margin: 4px 0 16px; }

.pagination { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--border); }
.page-info { color: var(--text-3); font-size: 13px; flex: 1; font-variant-numeric: tabular-nums; }
.page-size { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; }
.page-size select { width: 72px; height: 32px; }
.pager { display: flex; align-items: center; gap: 4px; }
.pager-list { display: flex; gap: 4px; }
.pager .icon-btn { width: 32px; height: 32px; }
.page-btn { min-width: 32px; height: 32px; padding: 0 6px; border-radius: var(--radius-sm); font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; }
.page-btn:hover { background: var(--surface-hover); color: var(--text); }
.page-btn[aria-current="page"] { background: var(--text); color: var(--bg); }
.page-gap { min-width: 20px; display: grid; place-items: center; color: var(--text-3); }

/* =========================================================
   Statistics / charts
   ========================================================= */
.stats-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stats-filters .select-wrap { width: 240px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 20px; }
.chart-card > div:last-child { padding: 16px 20px 20px; }
.chart-empty { display: grid; place-items: center; min-height: 160px; color: var(--text-3); }

/* Trend (column chart) */
.trend { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 220px auto; column-gap: 10px; }
.trend-y { position: relative; min-width: 24px; }
.trend-y span { position: absolute; right: 0; transform: translateY(50%); font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.trend-plot { position: relative; border-bottom: 1px solid var(--axis); }
.grid-line { position: absolute; left: 0; right: 0; height: 1px; background: var(--grid); }
.trend-cols { position: absolute; inset: 0; display: flex; align-items: stretch; gap: 2px; }
.trend-col { flex: 1; min-width: 0; display: flex; align-items: flex-end; justify-content: center; border-radius: 4px 4px 0 0; }
.trend-col:hover { background: color-mix(in srgb, var(--series-1) 7%, transparent); }
.trend-bar { width: min(24px, 100%); height: var(--h); background: var(--series-1); border-radius: 4px 4px 0 0; transition: height 0.4s var(--ease); }
.trend-bar.is-zero { height: 0; }
.trend-x { grid-column: 2; display: flex; gap: 2px; padding-top: 6px; }
.trend-x span { flex: 1; min-width: 0; font-size: 11px; color: var(--text-3); text-align: center; white-space: nowrap; overflow: visible; }

/* Status stacked bar */
.stack { display: flex; gap: 2px; height: 14px; margin-top: 4px; }
.stack-seg { min-width: 4px; height: 100%; }
.stack-seg:first-child { border-radius: 4px 0 0 4px; }
.stack-seg:last-child { border-radius: 0 4px 4px 0; }
.stack-seg:only-child { border-radius: 4px; }
.seg-new { background: var(--status-new); }
.seg-review { background: var(--status-review); }
.seg-done { background: var(--status-done); }
.legend { list-style: none; padding: 0; margin-top: 20px; display: flex; flex-direction: column; gap: 4px; }
.legend li { display: grid; grid-template-columns: 10px auto 1fr auto; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.legend li:last-child { border-bottom: 0; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.legend-label { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.legend-label svg { width: 14px; height: 14px; color: var(--text-3); }
.legend-value { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; grid-column: 4; }
.legend-value small { font-weight: 400; color: var(--text-3); margin-left: 6px; }
.rate { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.rate strong { font-size: 32px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.rate span { color: var(--text-3); }

/* Horizontal bars */
.hbars { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.hbar { display: grid; grid-template-columns: minmax(0, 34%) minmax(0, 1fr); align-items: center; gap: 12px; }
.hbar-label { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { display: flex; align-items: center; gap: 8px; min-width: 0; height: 22px; }
.hbar-fill { flex: 0 0 auto; width: calc((100% - 48px) * var(--p)); min-width: 2px; height: 14px; background: var(--series-1); border-radius: 0 4px 4px 0; transition: width 0.4s var(--ease); }
.hbar-value { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.hbar:hover .hbar-label { color: var(--text); }

.tooltip {
  position: fixed; z-index: 1500; pointer-events: none;
  padding: 8px 10px; border-radius: 8px; max-width: 260px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-md);
  font-size: 12px; line-height: 1.4;
}
.tooltip strong { display: block; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* =========================================================
   Sheet (appeal details)
   ========================================================= */
.sheet-backdrop { z-index: 900; }
.sheet {
  position: fixed; inset: 0 0 0 auto; z-index: 910;
  width: min(560px, 100vw);
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: slide-in 0.25s var(--ease);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 14px 24px; border-bottom: 1px solid var(--border); }
.eyebrow { font-size: 12px; color: var(--text-3); }
.sheet-heading h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.sheet-head-actions { display: flex; align-items: center; gap: 2px; }
.divider-v { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }

.sheet-body { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 20px; }
.sheet-section { display: flex; flex-direction: column; gap: 8px; }
.section-label { font-size: 12px; font-weight: 500; color: var(--text-3); }

.meta { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); }
.meta-row { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.meta-row:last-child { border-bottom: 0; }
.meta dt { display: flex; align-items: center; gap: 8px; color: var(--text-3); }
.meta dt svg { width: 14px; height: 14px; }
.meta dd { font-weight: 500; overflow-wrap: anywhere; }

.message { padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.message-answer { background: var(--success-soft); border-color: transparent; white-space: normal; }
.message-answer > p:first-child { white-space: pre-wrap; }
.message-meta { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; color: var(--success-text); white-space: normal; }
.message-meta svg { width: 14px; height: 14px; }

.composer { padding: 16px 24px 20px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 12px; font-weight: 500; transition: border-color 0.15s, color 0.15s, background-color 0.15s; }
.chip:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-hover); }
.composer-foot { display: flex; align-items: center; gap: 12px; }
.hint { font-size: 12px; color: var(--text-3); flex: 1; }
.counter { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* =========================================================
   Admins
   ========================================================= */
.card-head-bar { align-items: center; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.user-meta strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muted { color: var(--text-3); }
.tag { display: inline-grid; place-items: center; height: 18px; padding: 0 6px; margin-left: 6px; border-radius: 999px; font-size: 11px; font-weight: 500; vertical-align: 1px; background: var(--accent-soft); color: var(--accent-text); }
.pill-muted { background: var(--surface-2); color: var(--text-2); }
.tg-id { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.tg-id svg { width: 14px; height: 14px; color: var(--text-3); }
.admin-row td { transition: background-color 0.1s; }
.admin-row:hover td { background: var(--surface-hover); }
.admin-row.is-inactive .person { opacity: 0.55; }
.c-last { white-space: nowrap; color: var(--text-2); }
.c-actions { width: 1%; }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.icon-btn-danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.card-note { display: flex; align-items: flex-start; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.card-note svg { width: 14px; height: 14px; margin-top: 2px; }
.card-note b { font-weight: 600; color: var(--text-2); }
.card-note code { font-size: 11px; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); }

.btn-danger { background: var(--danger); color: #fff; box-shadow: var(--shadow-sm); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, #000); }

/* Dialogs */
.modal {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  margin: auto; padding: 0; overflow: hidden;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.modal[open] { display: flex; flex-direction: column; animation: modal-in 0.2s var(--ease); }
.modal::backdrop { background: rgba(9, 9, 11, 0.45); }
.modal-sm { width: min(400px, calc(100vw - 32px)); }
.modal-form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 16px 14px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2, .modal-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.modal-sub { font-size: 13px; color: var(--text-3); }
.modal-body { display: flex; flex-direction: column; gap: 14px; padding: 18px 20px; overflow-y: auto; }
.modal-text { color: var(--text-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 16px; border-top: 1px solid var(--border); }
.field-hint { font-size: 12px; color: var(--text-3); }
.optional { font-weight: 400; color: var(--text-3); }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; height: 36px; font-weight: 500; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: inherit; }
.check:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
select:disabled { opacity: 0.55; cursor: not-allowed; }

@keyframes modal-in { from { transform: translateY(8px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }

/* =========================================================
   Toasts
   ========================================================= */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: 420px;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s var(--ease);
}
.toast svg { color: var(--success-text); }
.toast.is-error svg { color: var(--danger); }
.toast.is-leaving { animation: fade 0.2s ease reverse forwards; }

/* =========================================================
   Motion
   ========================================================= */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1280px) {
  .search { width: 260px; }
  .sync { display: none; }
  .c-otm { display: none; }
}

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s var(--ease); box-shadow: none; }
  .sidebar.is-open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-close { display: inline-grid; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; margin-left: -6px; }
  .topbar { padding-inline: 16px; }
  main { padding: 16px 16px 40px; }
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  .topbar-title p { display: none; }
  .topbar-actions { width: 100%; order: 3; }
  .search { width: auto; flex: 1; }
  .search-kbd { display: none; }
  .btn-label { display: none; }
  .btn-icon-only-sm { width: 36px; padding: 0; }

  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 24px; }

  .card-toolbar { padding: 0 16px; }
  .filters { padding: 12px 16px; }
  .filters .select-wrap { width: auto; flex: 1 1 calc(50% - 4px); }
  .filters-spacer { display: none; }
  #export-btn { flex: 1 1 100%; }

  .table thead { display: none; }
  .table, .table tbody { display: block; }
  .table tbody tr.row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px;
    grid-template-areas: "id status" "person person" "text text" "date date";
    padding: 14px 16px; border-bottom: 1px solid var(--border);
  }
  .table tbody tr.row td { display: block; padding: 0 !important; border: 0; background: none !important; }
  .table tbody tr.row:hover { background: var(--surface-hover); }
  .table tbody tr.row:last-child { border-bottom: 0; }
  .c-id { grid-area: id; }
  .c-person { grid-area: person; }
  .c-text { grid-area: text; max-width: none; }
  .c-text .clamp { -webkit-line-clamp: 2; }
  .c-date { grid-area: date; }
  .c-date time { flex-direction: row; gap: 6px; }
  .c-status { grid-area: status; }
  .c-otm, .c-go { display: none !important; }
  .table tbody tr:not(.row) { display: block; }
  .table tbody tr:not(.row) td { display: block; }
  .sub, .person-name { max-width: none; }

  .pagination { padding: 12px 16px; }
  .page-info { flex-basis: 100%; }
  .page-size { flex: 1; }

  .stats-filters .segmented { width: 100%; }
  .stats-filters .segmented button { flex: 1; padding: 0 6px; }
  .stats-filters .select-wrap { width: 100%; }
  .hbar { grid-template-columns: 1fr; gap: 4px; }

  .sheet-head { padding-left: 16px; }
  .sheet-body { padding: 16px; }
  .composer { padding: 12px 16px 16px; }
  .hint { display: none; }
  .composer-foot .btn { margin-left: auto; }
  .meta-row { grid-template-columns: 1fr; gap: 2px; }
  .segmented-block button { padding: 0 6px; font-size: 13px; }
  .segmented-block button svg { display: none; }

  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { min-width: 0; max-width: none; }

  .card-head-bar { padding: 14px 16px; }
  .card-note { padding: 12px 16px; }
  .table tbody tr.admin-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .table tbody tr.admin-row::after { content: ""; order: 1; flex-basis: 100%; }
  .table tbody tr.admin-row:last-child { border-bottom: 0; }
  .table tbody tr.admin-row td { display: block; padding: 0 !important; border: 0; background: none !important; }
  .admin-row .c-admin { flex: 1; min-width: 0; }
  .admin-row .c-actions { width: auto; }
  .admin-row .c-role, .admin-row .c-tg, .admin-row .c-state { order: 2; }
  .admin-row .c-last { display: none !important; }
  .field-row { grid-template-columns: 1fr; gap: 10px; }
}
