/* ───────────────────────────────────────────────────────────────────────────
   On Triton — dashboard design system
   Navy icon sidebar + light app canvas, KPI stat cards, data tables, badges,
   right detail drawer, tabs, dark mode. Charts are placeholders for now.
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  /* surfaces */
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --sidebar: #0e1a2b;
  --sidebar-2: #0a1422;
  --sidebar-ink: #aebbcb;
  --sidebar-ink-dim: #6b7c92;

  /* text */
  --ink: #1b2533;
  --ink-2: #46546a;
  --muted: #7a8699;
  --line: #e7ebf0;
  --line-2: #eef1f5;

  /* brand + accents */
  --primary: #2f6bff;
  --primary-600: #2358e6;
  --primary-ink: #ffffff;
  --primary-soft: #eaf1ff;
  --accent: #ff7a18;        /* trident / tablet highlight */

  /* status */
  --ok: #16a34a;   --ok-soft: #e6f6ec;
  --warn: #d97706; --warn-soft: #fdf0db;
  --danger: #dc2626; --danger-soft: #fdeaea;
  --info: #2f6bff; --info-soft: #eaf1ff;
  --purple: #7c3aed; --purple-soft: #f0eafe;
  --teal: #0d9488; --teal-soft: #e2f6f3;

  /* shape */
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-pill: 999px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 8px 28px rgba(16,24,40,.12);
  --sidebar-w: 248px;
}

[data-theme="dark"] {
  --bg: #0b1119;
  --panel: #121a26;
  --panel-2: #0f1722;
  --sidebar: #080e17;
  --sidebar-2: #060a11;
  --sidebar-ink: #9fb0c4;
  --sidebar-ink-dim: #5b6b80;
  --ink: #e8edf4;
  --ink-2: #b6c1d1;
  --muted: #8492a6;
  --line: #1e2937;
  --line-2: #19222e;
  --primary-soft: #15233f;
  --ok-soft: #102a1c; --warn-soft: #2e2310; --danger-soft: #2e1414;
  --info-soft: #15233f; --purple-soft: #1e1733; --teal-soft: #0d2422;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }
h3 { margin: 0; font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.muted-sm { color: var(--muted); font-size: 12px; }
.right { margin-left: auto; }
code { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--line-2);
       padding: 1px 5px; border-radius: 5px; color: var(--ink-2); }

/* ── App shell ─────────────────────────────────────────────────────────────*/
.shell { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 22px 26px 40px; }

/* ── Sidebar ───────────────────────────────────────────────────────────────*/
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-ink);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 16px; }
.brand .mark { width: 30px; height: 30px; flex: 0 0 30px; color: var(--accent); }
.brand .mark svg { width: 100%; height: 100%; display: block; }
.brand .wordmark { line-height: 1.1; }
.brand .wordmark b { display: block; color: #fff; font-size: 15px; font-weight: 700; letter-spacing: .02em; }
.brand .wordmark span { display: block; font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--sidebar-ink-dim); }

.nav { flex: 1; overflow-y: auto; padding: 6px 12px 12px; display: flex; flex-direction: column; gap: 1px; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 6px; }
.nav-group { margin: 14px 10px 6px; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--sidebar-ink-dim); }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  color: var(--sidebar-ink); text-decoration: none;
  padding: 9px 11px; border-radius: var(--r-sm); font-weight: 500; position: relative;
}
.nav-item .ic { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.nav-item .ic svg { width: 100%; height: 100%; display: block; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(47,107,255,.35); }
.nav-item.active .ic { opacity: 1; }
.nav-item .tag { margin-left: auto; font-size: 10px; font-weight: 700; background: var(--accent);
                 color: #1a1206; padding: 1px 6px; border-radius: var(--r-pill); }
.nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 1px 0 1px 30px;
           border-left: 1px solid rgba(255,255,255,.08); padding-left: 8px; }
.nav-sub a { color: var(--sidebar-ink); text-decoration: none; padding: 7px 10px; border-radius: var(--r-sm); font-size: 13px; }
.nav-sub a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-sub a.active { color: #fff; background: rgba(47,107,255,.18); }

.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.07); }
.plan-card { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07);
             border-radius: var(--r); padding: 11px 12px; }
.plan-card .loc { color: #fff; font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.plan-card .loc .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: 0 0 7px; }
.plan-card .loc-sub { color: var(--sidebar-ink-dim); font-size: 12px; margin-top: 2px; }
.plan-card .plan-row { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; font-size: 12px; }
.plan-card .plan-pill { background: var(--accent); color: #1a1206; font-weight: 700; padding: 2px 8px; border-radius: var(--r-pill); }
.plan-card .upgrade { color: var(--sidebar-ink); }
.help { display: flex; align-items: center; gap: 9px; margin-top: 10px; padding: 4px 4px 0; color: var(--sidebar-ink-dim); font-size: 12px; }
.help b { color: #fff; display: block; font-size: 12px; }

/* ── Top toolbar ───────────────────────────────────────────────────────────*/
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 22px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.loc-switcher { display: flex; align-items: center; gap: 10px; padding: 5px 10px 5px 6px;
                border: 1px solid var(--line); border-radius: var(--r-pill); cursor: pointer; background: var(--panel); }
.loc-switcher:hover { background: var(--panel-2); }
.loc-logo { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff;
            display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: 0 0 26px; }
.loc-switcher .loc-name { font-weight: 600; font-size: 13px; }
.loc-switcher .loc-name small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }
.chevron { color: var(--muted); }

.toolbar-search { flex: 1; max-width: 460px; position: relative; }
.toolbar-search input {
  width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--bg); color: var(--ink); font: inherit;
}
.toolbar-search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
                      width: 15px; height: 15px; color: var(--muted); }
.toolbar-search input:focus { outline: none; border-color: var(--primary); background: var(--panel); }

.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.daterange { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line);
             border-radius: var(--r-sm); background: var(--panel); color: var(--ink-2); font-size: 13px; cursor: pointer; }
.daterange .ic { width: 15px; height: 15px; color: var(--muted); }
.icon-btn { position: relative; width: 38px; height: 38px; border: 1px solid var(--line); background: var(--panel);
            border-radius: var(--r-sm); color: var(--ink-2); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--panel-2); }
.icon-btn .ic { width: 17px; height: 17px; }
.icon-btn .ping { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%;
                  background: var(--danger); border: 2px solid var(--panel); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
          display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: 0 0 34px; cursor: pointer; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; flex: 0 0 26px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; flex: 0 0 56px; }
button.avatar { border: 0; padding: 0; }

/* Account menu (topbar avatar dropdown) */
.user-menu { position: relative; }
.user-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; background: var(--panel);
            border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 10px 30px rgba(0,0,0,.12);
            padding: 6px; z-index: 50; }
.user-pop-id { padding: 9px 11px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.user-pop-id b { display: block; font-size: 13px; }
.user-pop-id small { color: var(--muted); font-size: 12px; word-break: break-all; }
.user-pop-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: none;
                 border: 0; padding: 9px 11px; border-radius: var(--r-sm); font: inherit; color: var(--ink);
                 cursor: pointer; }
.user-pop-item:hover { background: var(--panel-2); }
.user-pop-item .ic { width: 16px; height: 16px; }

/* ── Page header ───────────────────────────────────────────────────────────*/
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-head .titles { flex: 1; min-width: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 9px; align-items: center; }

/* ── Buttons ───────────────────────────────────────────────────────────────*/
.btn, button.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  background: var(--primary); color: var(--primary-ink); border: 1px solid var(--primary);
  border-radius: var(--r-sm); padding: 9px 15px; font: 600 13px/1 inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--primary-600); border-color: var(--primary-600); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn .ic { width: 15px; height: 15px; }
.btn.ghost { background: var(--panel); color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 6px 11px; font-size: 12px; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { filter: brightness(.96); }

/* ── Cards / panels ────────────────────────────────────────────────────────*/
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.panel-pad { padding: 18px; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { flex: 1; }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }

/* layout helpers */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
.grid-cols { display: grid; gap: 18px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ── KPI stat cards ────────────────────────────────────────────────────────*/
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
       box-shadow: var(--shadow); padding: 16px 17px; display: flex; flex-direction: column; gap: 10px; }
.kpi-top { display: flex; align-items: center; gap: 11px; }
.kpi-ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: 0 0 40px; }
.kpi-ic .ic { width: 20px; height: 20px; }
.kpi-ic.blue { background: var(--info-soft); color: var(--info); }
.kpi-ic.green { background: var(--ok-soft); color: var(--ok); }
.kpi-ic.amber { background: var(--warn-soft); color: var(--warn); }
.kpi-ic.red { background: var(--danger-soft); color: var(--danger); }
.kpi-ic.purple { background: var(--purple-soft); color: var(--purple); }
.kpi-ic.teal { background: var(--teal-soft); color: var(--teal); }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }

/* ── Badges ────────────────────────────────────────────────────────────────*/
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--r-pill);
         font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; }
.badge.dot::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active, .badge.online, .badge.success, .badge.ok, .badge.published, .badge.sent { background: var(--ok-soft); color: var(--ok); }
.badge.at_risk, .badge.warning, .badge.pending, .badge.scheduled, .badge.draft, .badge.degraded, .badge.unpaired { background: var(--warn-soft); color: var(--warn); }
.badge.paired, .badge.syncing { background: var(--info-soft); color: var(--info); }
.badge.inactive, .badge.offline, .badge.failed, .badge.error, .badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info, .badge.new { background: var(--info-soft); color: var(--info); }
.badge.purple, .badge.vip { background: var(--purple-soft); color: var(--purple); }

/* ── Tables ────────────────────────────────────────────────────────────────*/
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
                  background: var(--panel-2); position: sticky; top: 0; }
.table tbody tr:hover { background: var(--panel-2); cursor: default; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.active { background: var(--primary-soft); }
.table tbody tr.active:hover { background: var(--primary-soft); }
.table td.right, .table th.right { text-align: right; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user .who { line-height: 1.25; }
.cell-user .who b { font-weight: 600; }
.cell-user .who small { display: block; color: var(--muted); font-size: 12px; }
.pagination { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.pagination button { border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
                     border-radius: 7px; min-width: 32px; height: 32px; padding: 0 8px; cursor: pointer; font: inherit; }
.pagination button:hover:not(:disabled) { background: var(--panel-2); }
.pagination button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination button:disabled { opacity: .5; cursor: default; }

/* ── Filter bar ────────────────────────────────────────────────────────────*/
.filterbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search input { width: 100%; padding: 8px 12px 8px 32px; border: 1px solid var(--line); border-radius: var(--r-sm);
                background: var(--bg); color: var(--ink); font: inherit; }
.search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line);
        border-radius: var(--r-sm); background: var(--panel); color: var(--ink-2); font-size: 13px; cursor: pointer; }
.chip:hover { background: var(--panel-2); }
.chip.active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* ── Tabs (underline) ──────────────────────────────────────────────────────*/
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 11px 15px; border: 0; background: none; cursor: pointer; font: 600 13px/1 inherit;
       color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabpane { display: none; }
.tabpane.active { display: block; }

/* ── Forms ─────────────────────────────────────────────────────────────────*/
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea, .input {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg); color: var(--ink); font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--primary); background: var(--panel); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }

/* ── Right detail drawer ───────────────────────────────────────────────────*/
.detail { width: 340px; flex: 0 0 340px; }
.detail .panel { position: sticky; top: 78px; }
.detail-head { padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px;
               text-align: center; border-bottom: 1px solid var(--line); }
.detail-head .nm { font-size: 16px; font-weight: 700; }
.detail-mini { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; border-bottom: 1px solid var(--line); }
.detail-mini > div { padding: 14px 8px; border-right: 1px solid var(--line); }
.detail-mini > div:last-child { border-right: 0; }
.detail-mini .n { font-size: 18px; font-weight: 700; }
.detail-mini .l { font-size: 11px; color: var(--muted); }
.detail-sec { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.detail-sec h3 { margin-bottom: 10px; color: var(--ink-2); }
.timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline .ev { display: flex; gap: 10px; }
.timeline .ev .tdot { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; background: var(--primary-soft);
                      color: var(--primary); display: grid; place-items: center; font-size: 12px; }
.timeline .ev .meta b { font-weight: 600; display: block; font-size: 13px; }
.timeline .ev .meta small { color: var(--muted); font-size: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Media grid ────────────────────────────────────────────────────────────*/
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.media-tile { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--panel); box-shadow: var(--shadow); }
.media-tile .thumb { aspect-ratio: 16/10; background: var(--line-2) center/cover no-repeat; display: grid;
                     place-items: center; color: var(--muted); font-size: 30px; }
.media-tile .meta { padding: 9px 11px; font-size: 13px; }
.media-tile .meta .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* folder tree (media library) */
.folders { display: flex; flex-direction: column; gap: 1px; }
.folders a { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--r-sm);
             color: var(--ink-2); text-decoration: none; font-size: 13px; }
.folders a:hover { background: var(--panel-2); }
.folders a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.folders a .ct { margin-left: auto; color: var(--muted); font-size: 12px; }

/* ── Chart placeholder (charts come later) ─────────────────────────────────*/
.chart-ph { height: 230px; border-radius: var(--r-sm); position: relative; overflow: hidden;
            background:
              linear-gradient(180deg, var(--primary-soft), transparent 70%),
              repeating-linear-gradient(90deg, var(--line-2) 0 1px, transparent 1px 64px); }
.chart-ph::after { content: "Chart — coming soon"; position: absolute; inset: 0; display: grid; place-items: center;
                   color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .03em; }
.chart-ph svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.donut-ph { width: 150px; height: 150px; border-radius: 50%;
            background: conic-gradient(var(--primary) 0 38%, var(--teal) 38% 60%, var(--accent) 60% 78%, var(--line) 78% 100%);
            position: relative; margin: 0 auto; }
.donut-ph::after { content: ""; position: absolute; inset: 28px; border-radius: 50%; background: var(--panel); }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; cursor: pointer; background: var(--line); border-radius: var(--r-pill); transition: background .15s; }
.switch span::before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: var(--shadow); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(16px); }

/* progress bars */
.progress { height: 7px; border-radius: var(--r-pill); background: var(--line-2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--primary); }

/* misc */
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.list-line { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list-line:last-child { border-bottom: 0; }
.list-line .grow { flex: 1; min-width: 0; }
.list-line .grow b { font-weight: 600; }
.list-line .grow small { display: block; color: var(--muted); font-size: 12px; }

/* ── Auth gate ─────────────────────────────────────────────────────────────
   Nothing in the app paints until auth.js verifies the JWT and adds
   `auth-ready` to <html>. With JS off / verification failing, only the gate
   shows — never the app shell. */
.shell { display: none; }
html.auth-ready .shell { display: flex; }
.auth-gate { position: fixed; inset: 0; z-index: 9999; display: flex; flex-direction: column;
             align-items: center; justify-content: center; gap: 16px; background: var(--bg);
             color: var(--muted); text-align: center; padding: 24px; }
html.auth-ready .auth-gate { display: none; }
.auth-gate .spinner { width: 36px; height: 36px; border-radius: 50%;
                      border: 3px solid var(--line); border-top-color: var(--primary); animation: triton-spin .8s linear infinite; }
.auth-gate .gate-msg { max-width: 340px; }
.auth-gate .gate-msg b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
@keyframes triton-spin { to { transform: rotate(360deg); } }

/* ── Campaign wizard ───────────────────────────────────────────────────────*/
.wizard { display: grid; grid-template-columns: 210px 1fr 330px; gap: 18px; align-items: start; }
@media (max-width: 1200px) { .wizard { grid-template-columns: 180px 1fr; } .wizard .wiz-preview { grid-column: 1 / -1; } }
@media (max-width: 760px) { .wizard { grid-template-columns: 1fr; } .wizard .step-rail { display: flex; overflow-x: auto; } }

.step-rail { display: flex; flex-direction: column; gap: 4px; padding: 14px; position: sticky; top: 78px; }
.step { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--r-sm); color: var(--muted); cursor: pointer; white-space: nowrap; }
.step .num { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; display: grid; place-items: center;
             font-weight: 700; font-size: 13px; background: var(--line-2); color: var(--muted); }
.step .lbl { font-weight: 600; font-size: 13px; line-height: 1.15; }
.step .lbl small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.step.active { background: var(--primary-soft); color: var(--ink); }
.step.active .num { background: var(--primary); color: #fff; }
.step.done .num { background: var(--ok); color: #fff; }
.step.done .lbl { color: var(--ink); }

.wiz-step { display: none; }
.wiz-step.active { display: block; }
.wiz-actions { display: flex; gap: 10px; align-items: center; padding: 14px 18px; border-top: 1px solid var(--line); }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.choice { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 13px; cursor: pointer; background: var(--panel); }
.choice:hover { background: var(--panel-2); }
.choice.sel { border-color: var(--primary); background: var(--primary-soft); }
.choice b { display: block; font-size: 13px; }
.choice small { color: var(--muted); font-size: 12px; }

.channel-card { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.channel-card.on { border-color: var(--primary); }
.channel-card .ch-body { flex: 1; min-width: 0; }
.channel-card .ch-body[hidden] { display: none; }
.channel-head { display: flex; align-items: center; gap: 10px; }
.channel-head b { flex: 1; }

/* live preview rail */
.wiz-preview .panel { position: sticky; top: 78px; }
.phone { background: #0e1a2b; border-radius: 22px; padding: 14px 12px 18px; margin: 0 auto; max-width: 250px; }
.phone .scr { background: #f1f5f9; border-radius: 14px; min-height: 230px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.bubble { background: #fff; border-radius: 14px 14px 14px 4px; padding: 9px 12px; font-size: 13px; color: #1b2533; box-shadow: 0 1px 2px rgba(0,0,0,.12); align-self: flex-start; max-width: 90%; white-space: pre-wrap; }
.coupon { border: 2px dashed var(--accent); border-radius: var(--r); padding: 14px; text-align: center; background: #fff7ef; color: #7a3d05; }
.coupon .big { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.coupon .exp { font-size: 11px; color: #9a6a3a; margin-top: 4px; }
[data-theme="dark"] .coupon { background: #2a1d0d; color: #f0c79a; }
.sum-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.sum-row:last-child { border-bottom: 0; }
.sum-row .k { color: var(--muted); }
.sum-row .v { font-weight: 600; text-align: right; }

/* ── Mobile off-canvas nav + responsive layout ─────────────────────────────*/
.hamburger, .search-toggle { display: none; }
.nav-backdrop { position: fixed; inset: 0; background: rgba(8,14,23,.5); z-index: 50;
                opacity: 0; transition: opacity .2s ease; }
.shell.nav-open .nav-backdrop { opacity: 1; }

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr !important; }
  .detail { width: auto; flex: 1 1 auto; }
  .detail .panel { position: static; }
}

@media (max-width: 900px) {
  .content { padding: 16px 14px 36px; }

  /* sidebar becomes an off-canvas drawer */
  .sidebar { position: fixed; top: 0; left: 0; height: 100dvh; max-width: 86vw; z-index: 60;
             transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: translateX(0); }

  .hamburger { display: grid; }
  .search-toggle { display: grid; }

  /* toolbar condenses: hide the inline search, show it on demand below the bar */
  .topbar { gap: 8px; padding: 10px 14px; flex-wrap: wrap; }
  .toolbar-search { order: 99; flex-basis: 100%; max-width: none; display: none; }
  .topbar.search-open .toolbar-search { display: block; }
  .loc-switcher .loc-name { display: none; }
  .loc-switcher { padding: 5px; border: 0; }
  .daterange .daterange-text, .daterange .dr-chevron { display: none; }
  .daterange { padding: 9px; }

  /* page header + actions stack */
  .page-head { flex-wrap: wrap; }
  .page-actions { width: 100%; flex-wrap: wrap; }
  .page-actions .btn { flex: 1 1 auto; }

  .kpis { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 22px; }

  /* media library: folder tree stacks above the grid */
  .grid-2[style*="230px"] { grid-template-columns: 1fr !important; }
}

@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .filterbar { gap: 8px; }
  .search { max-width: none; }
  .filterbar .input { max-width: none !important; width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .table th, .table td { padding: 10px 10px; }
}
