/* ============================================================
   ABDI AI Sales Companion — dashboard stylesheet
   Light theme · warm neutrals · emerald/teal accent
   Spacing scale: 4 / 8 / 12 / 16 / 24 · radius 12 cards
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --bg: #f4f2ee;
  --bg-soft: #faf9f6;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --border: #e8e4dd;
  --border-strong: #d8d3c9;

  --text: #292524;          /* stone-800 */
  --text-soft: #44403c;     /* stone-700 */
  --muted: #6b645e;
  --faint: #8d867f;

  --accent: #0d9488;        /* teal-600 — accents, charts, active */
  --accent-strong: #0f766e; /* teal-700 — button bg, link text (AA on white) */
  --accent-soft: #e6f4f2;
  --accent-ring: rgba(13, 148, 136, .28);

  --green: #15803d;   --green-soft: #e5f4ea;
  --amber: #9a5b0b;   --amber-soft: #fbf0dd;
  --red: #b91c1c;     --red-soft: #fdebeb;
  --gray: #57534e;    --gray-soft: #f0ede8;
  --teal: #0f766e;    --teal-soft: #e0f2ef;

  --side-bg: #1c1917;
  --side-bg-2: #262220;
  --side-text: #b8b1aa;
  --side-text-strong: #f5f4f2;
  --side-border: rgba(255, 255, 255, .08);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --shadow-sm: 0 1px 2px rgba(28, 25, 23, .06);
  --shadow-md: 0 1px 2px rgba(28, 25, 23, .05), 0 4px 14px rgba(28, 25, 23, .07);
  --shadow-lg: 0 8px 20px rgba(28, 25, 23, .12), 0 20px 50px rgba(28, 25, 23, .16);

  --sidebar-w: 240px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 60px;
  --statusbar-h: 30px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --speed: .18s;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; color: var(--text); }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13.5px; }
p { margin: 0 0 8px; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
button { font-family: inherit; }
::placeholder { color: var(--faint); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 300;
  background: var(--surface); padding: 10px 16px; border-radius: 0 0 8px 0;
  box-shadow: var(--shadow-md);
}
.skip-link:focus { left: 0; }

/* Scrollbars (webkit) — subtle */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #d3cec6; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #beb7ac; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Progress bar ---------- */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  z-index: 400; pointer-events: none; opacity: 0; transition: opacity var(--speed);
}
.progress.active { opacity: 1; }
.progress-bar {
  height: 100%; width: 40%; border-radius: 0 3px 3px 0;
  background: linear-gradient(90deg, var(--accent), #34d399);
  transition: width .35s ease;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "side top" "side main" "status status";
  min-height: 100vh;
}
.app.side-collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

/* ---------- Sidebar ---------- */
.sidebar {
  grid-area: side;
  background: var(--side-bg);
  color: var(--side-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0;
  height: 100vh;
  z-index: 60;
  transition: width var(--speed) ease;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; min-height: var(--topbar-h);
  border-bottom: 1px solid var(--side-border);
  color: var(--side-text-strong);
  flex: none;
}
.brand-logo {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent) 0%, #059669 100%);
  display: grid; place-items: center; color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
}
.brand-name { font-weight: 700; font-size: 13.5px; letter-spacing: .2px; white-space: nowrap; }
.brand-sub { font-size: 10.5px; color: var(--side-text); letter-spacing: .8px; text-transform: uppercase; white-space: nowrap; }

.side-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 10px 16px; }
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 4px; }
.nav-group-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.1px;
  color: #7d756d; padding: 0 10px 6px; white-space: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; min-height: 40px;
  padding: 8px 10px; margin: 1px 0;
  border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--side-text);
  font-size: 13.5px; font-weight: 500; text-align: left; cursor: pointer;
  white-space: nowrap; overflow: hidden;
  transition: background var(--speed), color var(--speed);
}
.nav-item:hover { background: var(--side-bg-2); color: var(--side-text-strong); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(13,148,136,.24), rgba(13,148,136,.10));
  color: #fff;
  box-shadow: inset 2.5px 0 0 var(--accent);
}
.nav-item .icon { flex: none; opacity: .9; }
.nav-item .nav-badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 10.5px; font-weight: 700; border-radius: 99px;
  padding: 1px 7px; min-width: 19px; text-align: center;
}

/* collapsed (tablet) */
.side-collapsed .brand { justify-content: center; padding: 14px 8px; }
.side-collapsed .brand-text, .side-collapsed .nav-group-label, .side-collapsed .nav-badge { display: none; }
.side-collapsed .nav-item { justify-content: center; padding: 10px 8px; gap: 0; }
.side-collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.side-foot {
  flex: none; border-top: 1px solid var(--side-border);
  padding: 10px; display: flex; flex-direction: column; gap: 6px;
}
.side-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; overflow: hidden; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700;
}
.side-user-meta { min-width: 0; }
.side-user-name { color: var(--side-text-strong); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-role { font-size: 11px; color: var(--side-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-collapse-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 34px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--side-text); cursor: pointer; font-size: 12px;
}
.side-collapse-btn:hover { background: var(--side-bg-2); color: var(--side-text-strong); }
.side-collapsed .side-user-meta, .side-collapsed .side-collapse-btn span { display: none; }
.side-collapsed .side-user { justify-content: center; padding: 6px 0; }

/* ---------- Topbar ---------- */
.main-col { display: contents; }
.topbar {
  grid-area: top;
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
}
.topbar-title { font-size: 15.5px; font-weight: 700; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-crumb { color: var(--faint); font-weight: 500; font-size: 12px; margin-top: 1px; }
.topbar-spacer { flex: 1; }

.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none;
  border: 1px solid transparent; border-radius: 10px;
  background: none; color: var(--text-soft); cursor: pointer;
  transition: background var(--speed), border-color var(--speed);
}
.icon-btn:hover { background: var(--gray-soft); }
.icon-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-strong); }
.pill-count {
  position: absolute; top: 4px; right: 3px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: #dc2626; color: #fff; border: 2px solid #fff;
  font-size: 9.5px; font-weight: 800; line-height: 12px; border-radius: 99px;
  text-align: center;
}
.hamburger { display: none; }

/* dropdown menus */
.menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 230px; max-width: 340px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 6px; z-index: 90;
  animation: pop .14s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.menu-head { padding: 10px 12px 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-head .t { font-weight: 700; font-size: 13px; }
.menu-head .s { color: var(--muted); font-size: 12px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); font-size: 13.5px; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--gray-soft); }
.menu-item.danger { color: var(--red); }
.menu-item.danger:hover { background: var(--red-soft); }
.menu-item .icon { color: var(--muted); }
.menu-item.danger .icon { color: var(--red); }
.menu-empty { padding: 22px 14px; text-align: center; color: var(--muted); font-size: 13px; }
.notif-item { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; align-items: flex-start; }
.notif-item:hover { background: var(--gray-soft); }
.notif-item.unread { background: var(--accent-soft); }
.notif-item.unread:hover { background: #d9efec; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex: none; }
.notif-dot.read { background: var(--border-strong); }
.notif-title { font-weight: 600; font-size: 13px; }
.notif-body { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.notif-time { color: var(--faint); font-size: 11px; margin-top: 2px; }
.menu-list { max-height: 380px; overflow-y: auto; }

/* ---------- Content ---------- */
.content {
  grid-area: main;
  padding: 24px;
  overflow-x: hidden;
}
.content-inner { max-width: 1240px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 220px; }
.page-desc { color: var(--muted); font-size: 13px; margin-top: 3px; max-width: 640px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Status bar (footer) ---------- */
.statusbar {
  grid-area: status;
  position: sticky; bottom: 0; z-index: 55;
  height: var(--statusbar-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px; font-size: 11.5px; color: var(--muted);
}
.statusbar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.statusbar .dot.off { background: #dc2626; }
.statusbar .dot.wait { background: #d97706; }
.statusbar .sep { width: 1px; height: 14px; background: var(--border); }
.statusbar-right { margin-left: auto; display: flex; gap: 14px; align-items: center; }

/* ============================================================
   PRIMITIVES
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-head h2, .card-head h3 { flex: 1; min-width: 120px; }
.card-head .count-pill {
  background: var(--gray-soft); color: var(--text-soft);
  border-radius: 99px; font-size: 11.5px; font-weight: 700; padding: 2px 9px;
}
.card-body { padding: 16px; }
.card-body.tight { padding: 8px 0 4px; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 7px 15px;
  border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: background var(--speed), border-color var(--speed), box-shadow var(--speed), transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-soft); border-color: #c9c3b8; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.primary:hover { background: #0c5f59; border-color: #0c5f59; }
.btn.danger { background: var(--surface); border-color: #efc4c4; color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: #e6a5a5; }
.btn.danger-solid { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn.danger-solid:hover { background: #991b1b; }
.btn.ghost { border-color: transparent; background: none; color: var(--accent-strong); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.subtle { border-color: transparent; background: var(--gray-soft); }
.btn.subtle:hover { background: #e7e3db; }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.lg { min-height: 44px; padding: 10px 20px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn .icon { flex: none; }
.btn.loading { pointer-events: none; opacity: .75; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: currentColor;
  animation: spin .7s linear infinite; flex: none;
}
.btn:not(.primary):not(.danger-solid) .spinner { border-color: rgba(0,0,0,.15); border-top-color: var(--accent-strong); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Fields / forms ---------- */
.field { margin-bottom: 14px; min-width: 0; }
.field > label { display: block; font-size: 12.5px; font-weight: 650; color: var(--text-soft); margin-bottom: 5px; }
.field .hint { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.input, .select, .textarea {
  width: 100%; min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 13.5px;
  transition: border-color var(--speed), box-shadow var(--speed);
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b645e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 30px; cursor: pointer;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.check-row { display: flex; align-items: center; gap: 9px; padding: 8px 2px; cursor: pointer; font-size: 13.5px; }
.check-row input[type="checkbox"], .check-row input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent-strong); cursor: pointer; }

/* toggle switch */
.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track {
  width: 38px; height: 22px; border-radius: 99px; flex: none;
  background: #d5cfc5; transition: background var(--speed); position: relative;
}
.toggle .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform var(--speed);
}
.toggle input:checked + .track { background: var(--accent-strong); }
.toggle input:checked + .track::after { transform: translateX(16px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle .tl { font-size: 13.5px; font-weight: 600; color: var(--text-soft); }

/* range slider */
.range { width: 100%; accent-color: var(--accent-strong); height: 28px; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-val {
  min-width: 52px; text-align: center; font-variant-numeric: tabular-nums;
  background: var(--accent-soft); color: var(--accent-strong);
  font-weight: 700; font-size: 12.5px; border-radius: 7px; padding: 3px 8px;
}

/* tags input */
.tags-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.tags-input .tag-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; font-size: 12.5px; border-radius: 99px; padding: 3px 6px 3px 10px; }
.tags-input .tag-chip button { border: 0; background: none; color: inherit; cursor: pointer; display: grid; place-items: center; padding: 1px; border-radius: 50%; }
.tags-input .tag-chip button:hover { background: rgba(15,118,110,.15); }
.tags-input input { flex: 1; min-width: 110px; border: 0; outline: none; font: inherit; font-size: 13.5px; padding: 4px; background: none; }

/* key-value rows editor */
.kv-row { display: grid; grid-template-columns: 1fr 1.4fr 34px; gap: 8px; margin-bottom: 8px; align-items: center; }
.kv-row .btn { min-height: 34px; }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .1px;
  background: var(--gray-soft); color: var(--gray);
  white-space: nowrap; max-width: 100%;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.teal { background: var(--teal-soft); color: var(--teal); }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-soft);
  font-size: 12px; font-weight: 600;
}
.chip.ok { border-color: #bfe3cd; background: var(--green-soft); color: var(--green); }
.chip.bad { border-color: #f0c4c4; background: var(--red-soft); color: var(--red); }
.chip.warn { border-color: #ecd9b0; background: var(--amber-soft); color: var(--amber); }

/* ---------- Filter / toolbar row ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; }
.toolbar .search { flex: 1; min-width: 180px; max-width: 340px; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 12px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--speed), transform var(--speed);
}
a.stat-card, button.stat-card { display: block; text-align: left; cursor: pointer; color: inherit; font: inherit; width: 100%; }
a.stat-card:hover, button.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); text-decoration: none; }
.stat-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.stat-label { font-size: 12px; font-weight: 650; color: var(--muted); flex: 1; }
.stat-ico { color: var(--accent-strong); opacity: .85; }
.stat-value { font-size: 26px; font-weight: 750; letter-spacing: -.4px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-sub { font-size: 11.5px; color: var(--faint); margin-top: 3px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--faint); padding: 11px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
.data-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background var(--speed); }
.data-table tbody tr:hover { background: #fbfaf7; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .cell-strong { font-weight: 650; }
.data-table .cell-sub { display: block; font-size: 11.5px; color: var(--faint); margin-top: 1px; }
.data-table.dense th, .data-table.dense td { padding: 8px 12px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* responsive: tables become stacked cards */
@media (max-width: 720px) {
  .data-table, .data-table thead, .data-table tbody, .data-table tr, .data-table th, .data-table td { display: block; }
  .data-table thead { display: none; }
  .data-table tr { border-bottom: 1px solid var(--border); padding: 10px 14px; }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .data-table td { border: 0; padding: 3px 0; display: flex; align-items: baseline; gap: 10px; }
  .data-table td::before {
    content: attr(data-label);
    flex: 0 0 38%; max-width: 38%;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
    color: var(--faint);
  }
  .data-table td.no-label::before { content: none; }
  .data-table td.num { text-align: left; }
  .data-table td.row-actions { justify-content: flex-start; }
}

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; }
.pagination .page-info { color: var(--muted); font-size: 12.5px; margin-right: auto; }
.page-btn {
  min-width: 32px; height: 32px; padding: 0 9px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text-soft);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-strong); }
.page-btn.current { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 44px 20px; gap: 4px;
}
.empty .empty-ico {
  width: 52px; height: 52px; border-radius: 16px;
  background: var(--gray-soft); color: var(--faint);
  display: grid; place-items: center; margin-bottom: 10px;
}
.empty h3 { font-size: 15px; }
.empty p { color: var(--muted); font-size: 13px; max-width: 380px; margin: 0 0 12px; }

/* ---------- Skeletons ---------- */
.skel {
  border-radius: 8px;
  background: linear-gradient(90deg, #ecebe7 25%, #f5f4f1 45%, #ecebe7 65%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skel-line { height: 12px; margin: 10px 0; }
.skel-line.w60 { width: 60%; } .skel-line.w80 { width: 80%; } .skel-line.w40 { width: 40%; }
.skel-card { height: 92px; border-radius: var(--radius); }
.skel-row { height: 44px; border-radius: 8px; margin-bottom: 8px; }
.skel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 12px; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; right: 16px; bottom: calc(var(--statusbar-h) + 14px); z-index: 500;
  display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--side-bg); color: #f5f4f2;
  border-radius: 10px; padding: 11px 12px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px; line-height: 1.45;
  animation: toast-in .2s ease;
  border-left: 3px solid var(--gray);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast.success { border-left-color: #34d399; }
.toast.error { border-left-color: #f87171; }
.toast.warn { border-left-color: #fbbf24; }
.toast .icon { flex: none; margin-top: 1px; }
.toast.success .icon { color: #34d399; }
.toast.error .icon { color: #f87171; }
.toast.warn .icon { color: #fbbf24; }
.toast .toast-close {
  margin-left: auto; border: 0; background: none; color: inherit; opacity: .6;
  cursor: pointer; padding: 2px; flex: none;
}
.toast .toast-close:hover { opacity: 1; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all .25s ease; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(28, 25, 23, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 16px;
  overflow-y: auto;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px;
  animation: modal-in .18s ease;
  display: flex; flex-direction: column;
  max-height: 88vh;
}
.modal.wide { max-width: 780px; }
.modal.xl { max-width: 960px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex: none;
}
.modal-head h2 { flex: 1; font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; gap: 8px; justify-content: flex-end;
  padding: 14px 20px; border-top: 1px solid var(--border); flex: none; flex-wrap: wrap;
}
.modal-foot .left { margin-right: auto; }

/* ============================================================
   VIEW-SPECIFIC
   ============================================================ */

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(13,148,136,.10), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(5,150,105,.08), transparent 60%),
    var(--bg);
  padding: 24px 16px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-md);
  padding: 28px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .brand-logo { width: 42px; height: 42px; border-radius: 12px; }
.login-title { font-size: 19px; font-weight: 750; }
.login-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.login-error {
  background: var(--red-soft); color: var(--red);
  border: 1px solid #f0c4c4; border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13px; margin-bottom: 14px;
}
.login-foot { margin-top: 18px; text-align: center; color: var(--faint); font-size: 12px; }

/* ---------- Conversations two-pane ---------- */
.conv-layout { display: grid; grid-template-columns: 350px minmax(0, 1fr); gap: 16px; align-items: start; }
.conv-list { display: flex; flex-direction: column; min-height: 200px; }
.conv-scroll { overflow-y: auto; max-height: calc(100vh - 250px); }
.conv-item {
  display: flex; gap: 10px; width: 100%; text-align: left;
  padding: 12px 14px; border: 0; border-bottom: 1px solid var(--border);
  background: none; cursor: pointer; align-items: flex-start;
}
.conv-item:hover { background: #fbfaf7; }
.conv-item.active { background: var(--accent-soft); box-shadow: inset 2.5px 0 0 var(--accent); }
.conv-item .c-main { flex: 1; min-width: 0; }
.conv-item .c-name { font-weight: 650; font-size: 13.5px; display: flex; gap: 6px; align-items: center; }
.conv-item .c-preview { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-item .c-time { font-size: 11px; color: var(--faint); white-space: nowrap; }
.conv-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: var(--teal-soft); color: var(--teal);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}

.conv-detail { display: flex; flex-direction: column; min-width: 0; }
.conv-detail-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.conv-detail-head .cd-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.conv-detail-head .cd-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.takeover-banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--amber-soft); color: var(--amber);
  border-bottom: 1px solid #ecd9b0;
  padding: 9px 16px; font-size: 13px; font-weight: 600;
}
.takeover-banner .btn { margin-left: auto; }

.msg-scroll { overflow-y: auto; padding: 18px 16px; max-height: calc(100vh - 480px); min-height: 220px; }
.msg-day { text-align: center; color: var(--faint); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; margin: 12px 0; }
.msg-row { display: flex; margin-bottom: 10px; }
.msg-row.out { justify-content: flex-end; }
.bubble {
  max-width: min(78%, 560px);
  border-radius: 14px; padding: 9px 13px;
  font-size: 13.5px; line-height: 1.5;
  box-shadow: var(--shadow-sm);
  overflow-wrap: anywhere; white-space: pre-wrap;
}
.msg-row.in .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-row.out .bubble { background: #d9f2ee; border: 1px solid #bfe3dd; border-bottom-right-radius: 4px; }
.bubble-meta { display: flex; align-items: center; gap: 6px; margin-top: 5px; font-size: 10.5px; color: var(--faint); flex-wrap: wrap; }
.bubble .sender-chip { font-weight: 700; text-transform: uppercase; letter-spacing: .4px; font-size: 9.5px; padding: 1px 6px; border-radius: 5px; background: rgba(0,0,0,.06); color: var(--muted); }
.sender-ai { background: var(--teal-soft) !important; color: var(--teal) !important; }
.sender-human { background: var(--amber-soft) !important; color: var(--amber) !important; }
.bubble .media-note { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-style: italic; }

.conv-composer { border-top: 1px solid var(--border); padding: 12px 16px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-row .textarea { min-height: 44px; max-height: 140px; }
.conv-grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 0; }
.conv-detail-main { min-width: 0; display: flex; flex-direction: column; }
.ai-panel { border-left: 1px solid var(--border); max-height: 640px; overflow-y: auto; background: var(--surface-2); }
.ai-decision-item { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.ai-decision-item:last-child { border-bottom: 0; }
.confidence-bar { height: 5px; border-radius: 99px; background: var(--gray-soft); overflow: hidden; margin-top: 6px; }
.confidence-bar > div { height: 100%; border-radius: 99px; background: var(--accent); }
.decision-response {
  margin-top: 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 130px; overflow-y: auto;
}

@media (max-width: 980px) {
  .conv-layout { grid-template-columns: 1fr; }
  .conv-layout .pane-detail { display: none; }
  .conv-layout.has-detail .pane-list { display: none; }
  .conv-layout.has-detail .pane-detail { display: flex; }
  .conv-grid-2 { grid-template-columns: 1fr; }
  .ai-panel { border-left: 0; border-top: 1px solid var(--border); max-height: none; }
  .msg-scroll { max-height: 46vh; }
}
.back-to-list { display: none; }
@media (max-width: 980px) { .back-to-list { display: inline-flex; } }

/* ---------- Content grid ---------- */
.content-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.content-card { display: flex; flex-direction: column; }
.content-card .cc-body { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.content-card .cc-title { font-weight: 700; font-size: 14px; }
.content-card .cc-desc { color: var(--muted); font-size: 12.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.content-card .cc-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.content-card .cc-foot { display: flex; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--border); align-items: center; }
.cc-thumb {
  height: 96px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--teal-soft), var(--accent-soft));
  color: var(--accent-strong); border-radius: var(--radius) var(--radius) 0 0;
}

/* ---------- Business traits grid ---------- */
.traits-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 10px; }
.trait-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; background: var(--surface-2); }
.trait-name { font-weight: 650; font-size: 13px; margin-bottom: 8px; text-transform: capitalize; }
.weight-row { display: flex; gap: 5px; }
.weight-btn {
  flex: 1; height: 30px; border-radius: 7px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.weight-btn:hover { border-color: var(--accent); color: var(--accent-strong); }
.weight-btn.on { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; margin-bottom: 18px; }
.tab-btn {
  padding: 10px 14px; border: 0; background: none; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  border-bottom: 2.5px solid transparent; margin-bottom: -1px;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent-strong); border-bottom-color: var(--accent); }
.tab-count { background: var(--gray-soft); border-radius: 99px; font-size: 10.5px; padding: 1px 7px; margin-left: 6px; color: var(--text-soft); }
.tab-btn.active .tab-count { background: var(--accent-soft); color: var(--accent-strong); }

/* ---------- Escalations kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; padding-bottom: 8px; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); min-width: 210px; }
.kanban-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 12px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border); color: var(--text-soft);
}
.kanban-head .count { margin-left: auto; background: var(--gray-soft); border-radius: 99px; padding: 1px 8px; font-size: 11px; }
.kanban-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kanban-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 12px; box-shadow: var(--shadow-sm); cursor: pointer;
  transition: box-shadow var(--speed), transform var(--speed);
  text-align: left; width: 100%;
}
.kanban-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kanban-card .kc-top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.kanban-card .kc-reason { font-weight: 650; font-size: 13px; }
.kanban-card .kc-sub { color: var(--muted); font-size: 12px; margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
@media (max-width: 1100px) { .kanban { grid-template-columns: repeat(5, 240px); } }

/* ---------- Extension pairing ---------- */
.pairing-code {
  font-family: var(--mono); font-size: clamp(22px, 4.5vw, 34px);
  font-weight: 800; letter-spacing: 3px; text-align: center;
  background: var(--side-bg); color: #5eead4;
  border-radius: 12px; padding: 18px 12px; margin: 12px 0;
  user-select: all; overflow-wrap: anywhere;
}
.pair-steps { counter-reset: step; display: flex; flex-direction: column; gap: 10px; }
.pair-step { display: flex; gap: 12px; align-items: flex-start; }
.pair-step .n {
  counter-increment: step; flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-strong); color: #fff;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700;
}
.pair-step .n::before { content: counter(step); }
.cap-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.count-chip { font-variant-numeric: tabular-nums; }

/* ---------- Charts ---------- */
.chart-wrap { overflow-x: auto; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 10px 16px 0; }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); font-weight: 600; }
.chart-legend .sw { width: 11px; height: 11px; border-radius: 3px; }
.hbar-row { display: grid; grid-template-columns: 130px 1fr 48px; gap: 10px; align-items: center; margin-bottom: 9px; }
.hbar-label { font-size: 12.5px; color: var(--text-soft); font-weight: 600; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { background: var(--gray-soft); border-radius: 99px; height: 18px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 99px; min-width: 2px; transition: width .4s ease; }
.hbar-val { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.sparkline { display: inline-block; vertical-align: middle; }

/* ---------- Notes / lists ---------- */
.note-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: var(--surface-2); }
.note-item .n-meta { color: var(--faint); font-size: 11.5px; margin-top: 4px; }
.list-tight > * + * { margin-top: 8px; }
.divided > * + * { border-top: 1px solid var(--border); }

/* detail rows */
.detail-rows { display: flex; flex-direction: column; }
.detail-row { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; align-items: baseline; }
.detail-row:last-child { border-bottom: 0; }
.detail-row .k { flex: 0 0 38%; max-width: 38%; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.detail-row .v { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Utility ---------- */
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 8px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.gap-4 { gap: 4px; } .gap-12 { gap: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.strong { font-weight: 650; }
.mono { font-family: var(--mono); font-size: .93em; }
.wrap-anywhere { overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.w-100 { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1024px) { .grid-side { grid-template-columns: 1fr; } }
.banner {
  border-radius: var(--radius-sm); padding: 11px 14px; font-size: 13px;
  display: flex; gap: 10px; align-items: flex-start;
}
.banner .icon { flex: none; margin-top: 1px; }
.banner.warn { background: var(--amber-soft); color: var(--amber); border: 1px solid #ecd9b0; }
.banner.danger { background: var(--red-soft); color: var(--red); border: 1px solid #f0c4c4; }
.banner.info { background: var(--teal-soft); color: var(--teal); border: 1px solid #bfe3dd; }
.banner .banner-body { flex: 1; }
.kbd {
  font-family: var(--mono); font-size: 11.5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px; background: var(--surface);
}

/* ============================================================
   RESPONSIVE SHELL
   ============================================================ */
@media (max-width: 1024px) {
  .app { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
  .brand-text, .nav-group-label, .nav-badge { display: none; }
  .nav-item { justify-content: center; padding: 10px 8px; gap: 0; }
  .side-user-meta { display: none; }
  .side-user { justify-content: center; padding: 6px 0; }
  .side-collapse-btn span { display: none; }
  .sidebar { width: var(--sidebar-w-collapsed); }
  .content { padding: 18px; }
}
@media (max-width: 860px) {
  .hamburger { display: inline-flex; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main" "status"; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 82vw);
    transform: translateX(-102%); transition: transform .22s ease;
    box-shadow: none; height: 100dvh;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar .brand-text, .sidebar .nav-group-label, .sidebar .nav-item, .sidebar .side-user-meta, .sidebar .side-collapse-btn { all: unset; }
  .sidebar .nav-item { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 44px; padding: 8px 10px; margin: 1px 0; border-radius: var(--radius-sm); color: var(--side-text); font-size: 13.5px; font-weight: 500; cursor: pointer; }
  .sidebar .nav-item.active { background: linear-gradient(90deg, rgba(13,148,136,.24), rgba(13,148,136,.10)); color: #fff; box-shadow: inset 2.5px 0 0 var(--accent); }
  .sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--side-border); color: var(--side-text-strong); }
  .sidebar .nav-group-label { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.1px; color: #7d756d; padding: 0 10px 6px; margin-top: 14px; }
  .sidebar .side-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
  .sidebar .side-user-meta { display: block; }
  .sidebar .side-collapse-btn { display: none; }
  .side-overlay {
    position: fixed; inset: 0; background: rgba(28,25,23,.45); z-index: 58;
    animation: fade .15s ease;
  }
  .content { padding: 14px 12px calc(var(--statusbar-h) + 18px); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .topbar { padding: 0 12px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 21px; }
  .content-grid { grid-template-columns: 1fr; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
}
@media (max-width: 360px) {
  .stat-grid { grid-template-columns: 1fr; }
  .toolbar .input, .toolbar .select { min-width: 0; flex: 1 1 100%; }
}

/* Touch targets ≥44px */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.sm { min-height: 40px; }
  .input, .select, .textarea { min-height: 44px; }
  .nav-item { min-height: 44px; }
  .page-btn { min-width: 40px; height: 40px; }
  .icon-btn { width: 44px; height: 44px; }
}

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