/* ==========================================================================
   Pulse · prototype styles
   Single stylesheet, CSS custom properties, light + dark.
   ========================================================================== */

/* ------------------------------------------------------------------ tokens */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef1f8;
  --ink: #0e1526;
  --ink-soft: #33405c;
  --muted: #66748f;
  --line: #e6eaf3;
  --line-strong: #d7ddeb;
  --brand: #5b5bf5;
  --brand-ink: #4a48e0;
  --brand-soft: #eeeffe;
  --good: #0f9f6e;
  --good-soft: #e6f7f0;
  --warn: #b7791f;
  --warn-soft: #fdf4e3;
  --bad: #d64545;
  --bad-soft: #fdecec;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 30px -18px rgba(15, 23, 42, 0.35);
  --radius: 16px;
  --radius-sm: 10px;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b0f1a;
  --surface: #121826;
  --surface-2: #161d2c;
  --surface-3: #1c2536;
  --ink: #e9edf8;
  --ink-soft: #c3cce0;
  --muted: #8d9ab3;
  --line: #22304a;
  --line-strong: #2d3d5a;
  --brand: #7a7aff;
  --brand-ink: #9a9aff;
  --brand-soft: #1c2246;
  --good: #3ad39a;
  --good-soft: #102a22;
  --warn: #e6b35d;
  --warn-soft: #2a2113;
  --bad: #ff8080;
  --bad-soft: #2d1618;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 18px 40px -22px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

/* ------------------------------------------------------------------- reset */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(900px 420px at 85% -120px, color-mix(in srgb, var(--brand) 9%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.drawer-open { overflow: hidden; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }
code { font-family: var(--mono); font-size: 11.5px; }

.ico { width: 18px; height: 18px; flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.pos { color: var(--good); font-weight: 600; }
.warn-text { color: var(--warn); }
.spacer { flex: 1; }

/* ------------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 4px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #6a6aff, #a855f7);
  color: #fff; font-weight: 700; font-size: 17px;
  box-shadow: 0 6px 16px -8px rgba(91, 91, 245, 0.9);
}
.brand div { display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font-size: 15px; letter-spacing: -0.02em; }
.brand span { font-size: 10.5px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); padding: 12px 10px 6px;
}
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border: 0; background: transparent; border-radius: 9px;
  color: var(--ink-soft); font-size: 13.5px; font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-btn:hover { background: var(--surface-3); color: var(--ink); }
.nav-btn.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.nav-btn.active .ico { color: var(--brand); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.sync-box {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 11px; display: flex; flex-direction: column; gap: 8px;
}
.sync-top { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ink-soft); }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 18%, transparent);
}
.syncing .live-dot { background: var(--warn); animation: pulse 1s infinite; }

.user { display: flex; align-items: center; gap: 9px; padding: 6px 4px; }
.user div { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user strong { font-size: 12.5px; }
.user span { font-size: 11px; color: var(--muted); }

.avatar {
  width: var(--av-size, 34px); height: var(--av-size, 34px);
  border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 600; font-size: calc(var(--av-size, 34px) * 0.36);
  flex: none; letter-spacing: 0.01em;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* -------------------------------------------------------------------- main */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 26px 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.page-id { min-width: 0; }
.page-id h1 { font-size: 21px; letter-spacing: -0.025em; }
.page-id p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 2px; box-shadow: var(--shadow-sm); }
.seg button {
  border: 0; background: transparent; padding: 5px 11px; border-radius: 7px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--brand); color: #fff; box-shadow: 0 2px 8px -3px rgba(91, 91, 245, 0.8); }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface); border-radius: 9px;
  color: var(--ink-soft); box-shadow: var(--shadow-sm);
}
.icon-btn:hover { background: var(--surface-3); }
.nav-toggle { display: none; }

.audience-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 11px; border-radius: 9px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12px; color: var(--muted); box-shadow: var(--shadow-sm);
}
.audience-chip strong { color: var(--ink); font-size: 12.5px; }
.audience-chip .ico { width: 15px; height: 15px; }

/* ----------------------------------------------------------------- filters */
.filters { padding: 0 26px 14px; }
.filter-row {
  display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow-sm);
}
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field > span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 10px; top: 50%; width: 6px; height: 6px;
  border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.field select {
  appearance: none; font: inherit; font-size: 13px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 28px 7px 10px; min-width: 146px; max-width: 224px;
}
.field select:focus-visible { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 1px; }
.reset-btn { margin-bottom: 1px; }
.reset-btn .ico { width: 14px; height: 14px; }
.filter-meta { margin-left: auto; font-size: 12px; color: var(--muted); padding-bottom: 8px; }
.filter-meta strong { color: var(--ink); }

.view { padding: 4px 26px 30px; display: flex; flex-direction: column; gap: 16px; }
.page-foot { padding: 6px 26px 26px; font-size: 11px; color: var(--muted); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 9px; padding: 8px 13px; font-size: 12.5px; font-weight: 600;
  box-shadow: var(--shadow-sm); transition: background 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 15px; height: 15px; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 8px 18px -12px rgba(91, 91, 245, 0.9); }
.btn.primary:hover { background: var(--brand-ink); }

.link-btn { border: 0; background: transparent; color: var(--brand-ink); font-size: 12px; font-weight: 600; padding: 2px 4px; border-radius: 6px; }
.link-btn:hover { background: var(--brand-soft); }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-3); color: var(--ink-soft); font-size: 11.5px; font-weight: 600;
}
.chip.subtle { background: transparent; border: 1px solid var(--line); color: var(--muted); font-weight: 500; }

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px 18px; box-shadow: var(--shadow-sm); min-width: 0;
}
.card-head { display: flex; align-items: flex-start; gap: 12px; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 14.5px; }
.card-head p { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.card-note { font-size: 11.5px; color: var(--muted); margin-top: 10px; line-height: 1.45; }

.grid { display: grid; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.platform-inline { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.grid-main { grid-template-columns: minmax(0, 1.9fr) minmax(280px, 0.85fr); }
.grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.empty { padding: 34px 10px; text-align: center; color: var(--muted); font-size: 13px; }
.empty.small { padding: 18px 8px; font-size: 12px; }

.section-title { font-size: 16px; letter-spacing: -0.02em; }
.content-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.content-head p { font-size: 12px; margin-top: 3px; }


/* -------------------------------------------------------------------- KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 14px 15px 30px; position: relative; overflow: hidden; }
.kpi-label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.kpi-value { font-size: 25px; font-weight: 650; letter-spacing: -0.03em; margin-top: 4px; line-height: 1.1; }
.kpi-foot { display: flex; align-items: center; gap: 5px; margin-top: 7px; flex-wrap: wrap; }
.delta {
  display: inline-flex; align-items: center; gap: 2px; font-size: 11px; font-weight: 650;
  padding: 1px 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted);
}
.delta.up { background: var(--good-soft); color: var(--good); }
.delta.down { background: var(--bad-soft); color: var(--bad); }
.kpi-sub { font-size: 10px; color: var(--muted); }
.kpi-spark {
  position: absolute; left: 0; right: 0; bottom: 0; height: 30px;
  opacity: 0.5; pointer-events: none;
  -webkit-mask-image: linear-gradient(to top, #000 30%, transparent 100%);
  mask-image: linear-gradient(to top, #000 30%, transparent 100%);
}
.kpi-spark .spark { width: 100%; height: 30px; }
.spark { display: block; overflow: visible; }

/* ------------------------------------------------------------------ charts */
.card-chart { display: flex; flex-direction: column; }
.chart-host { width: 100%; }
.chart-host.sm { margin-top: 4px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; color: var(--muted); }
.grid-line { stroke: var(--line); stroke-width: 1; }
.axis-text { fill: var(--muted); font-size: 10px; font-family: var(--sans); }
.prev-line { opacity: 0.55; }
.hotdot { fill: var(--brand); opacity: 0; transition: opacity 0.12s ease; }
.hot:hover .hotdot { opacity: 1; }
.chart-foot { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 11px; color: var(--ink-soft); margin-top: 8px; }
.chart-foot strong { color: var(--ink); }
.key { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.key.solid { background: var(--kc, var(--brand)); }
.key.dashed { background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 7px); height: 2px; }
.tabs { display: flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; flex-wrap: wrap; }
.tab { border: 0; background: transparent; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 5px 9px; border-radius: 7px; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------------ donut */
.donut-wrap { position: relative; width: 168px; margin: 2px auto 12px; }
.donut { width: 100%; height: auto; display: block; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; pointer-events: none; }
.donut-center strong { font-size: 19px; letter-spacing: -0.03em; }
.donut-center span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.legend { display: flex; flex-direction: column; gap: 7px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-soft); }
.legend .pdot { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.leg-name { flex: 1; }
.leg-val { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.leg-pct { width: 38px; text-align: right; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.legend.tight { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 8px; }
.legend.tight li { font-size: 11.5px; }
.legend.tight em { font-style: normal; color: var(--ink); font-weight: 600; margin-left: auto; }
.legend.tight span:last-child { color: var(--muted); width: 34px; text-align: right; }

/* --------------------------------------------------------------- top posts */
.top-list { display: flex; flex-direction: column; gap: 2px; }
.top-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 0; background: transparent; padding: 7px 6px; border-radius: 9px; text-align: left;
}
.top-row:hover { background: var(--surface-2); }
.rank { width: 14px; font-size: 11px; font-weight: 700; color: var(--muted); flex: none; }
.thumb {
  position: relative; width: 42px; height: 42px; border-radius: 9px; flex: none;
  display: grid; place-items: center; color: rgba(255, 255, 255, 0.95);
}
.thumb .ico { width: 17px; height: 17px; }
.thumb em {
  position: absolute; bottom: 2px; right: 3px; font-style: normal; font-size: 8px; font-weight: 700;
  background: rgba(0, 0, 0, 0.45); color: #fff; padding: 0 3px; border-radius: 3px;
}
.thumb.sm { width: 36px; height: 36px; border-radius: 8px; }
.thumb.sm .ico { width: 15px; height: 15px; }
.top-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.top-cap {
  font-size: 12.5px; font-weight: 550; color: var(--ink); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.top-meta { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--muted); }
.top-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex: none; }
.top-stats strong { font-size: 13px; }
.top-stats span { font-size: 10px; color: var(--muted); }


/* ------------------------------------------------------------------ bars */
.bar-list { display: flex; flex-direction: column; gap: 11px; margin-top: 2px; }
.bar-row { display: grid; grid-template-columns: 20px 1fr 84px 46px; align-items: center; gap: 8px; }
.bar-ico { color: var(--muted); display: grid; place-items: center; }
.bar-ico .ico { width: 15px; height: 15px; }
.bar-label { display: flex; flex-direction: column; font-size: 12px; font-weight: 550; line-height: 1.25; }
.bar-label em { font-style: normal; font-size: 10px; color: var(--muted); font-weight: 400; }
.bar-track { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #7c7cff, #22d3ee); }
.bar-val { text-align: right; font-size: 11.5px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- heatmap */
.heatmap { display: flex; flex-direction: column; gap: 4px; }
.hm-row { display: grid; grid-template-columns: 30px repeat(6, minmax(0, 1fr)); gap: 4px; align-items: center; }
.hm-head span { font-size: 9.5px; color: var(--muted); text-align: center; }
.hm-day { font-size: 10px; color: var(--muted); }
.hm-cell {
  height: 25px; border-radius: 6px; display: grid; place-items: center;
  font-size: 9.5px; color: #fff; font-weight: 600; letter-spacing: -0.01em;
}
.hm-cell.empty { padding: 0; background: var(--surface-2); border: 1px dashed var(--line); }

/* ------------------------------------------------------------------ table */
.table-wrap { width: 100%; overflow-x: auto; }
.table-panel { padding-bottom: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; font-size: 10.5px; font-weight: 650; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted); padding: 7px 10px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table th button { border: 0; background: transparent; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; }
.table th.sorted { color: var(--ink); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--brand-soft) 40%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table.mini { font-size: 11.5px; }
.table.mini td, .table.mini th { padding: 7px 8px; }
.table.mini code { color: var(--ink-soft); background: var(--surface-2); padding: 1px 4px; border-radius: 4px; white-space: normal; word-break: break-word; }
.post-table { min-width: 920px; }
.post-row { cursor: pointer; }
.handler-cell { display: flex; align-items: center; gap: 9px; min-width: 0; }
.handler-cell div { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.handler-cell strong { font-size: 12.5px; white-space: nowrap; }
.handler-cell span { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.verified {
  display: inline-grid; place-items: center; width: 13px; height: 13px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 9px; flex: none;
}
.post-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.post-cell > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; max-width: 330px; }
.post-cap { font-size: 12.5px; font-weight: 550; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-meta { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-cell { display: flex; flex-direction: column; line-height: 1.25; white-space: nowrap; }
.date-cell em { font-style: normal; font-size: 10px; color: var(--muted); }


.type-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 7px;
  font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--ink-soft); white-space: nowrap;
}
.type-chip .ico { width: 13px; height: 13px; }
.type-chip.t-video { background: #eef2ff; color: #4338ca; }
.type-chip.t-short { background: #fdf2f8; color: #be185d; }
.type-chip.t-carousel { background: #ecfeff; color: #0e7490; }
.type-chip.t-image { background: #f0fdf4; color: #15803d; }
.type-chip.t-text { background: #f8fafc; color: #475569; }
.type-chip.t-story { background: #fff7ed; color: #c2410c; }
[data-theme="dark"] .type-chip.t-video { background: #1e2350; color: #a5b4fc; }
[data-theme="dark"] .type-chip.t-short { background: #3b1229; color: #f9a8d4; }
[data-theme="dark"] .type-chip.t-carousel { background: #0b2e35; color: #67e8f9; }
[data-theme="dark"] .type-chip.t-image { background: #10281b; color: #86efac; }
[data-theme="dark"] .type-chip.t-text { background: #1b2231; color: #cbd5e1; }
[data-theme="dark"] .type-chip.t-story { background: #331a0b; color: #fdba74; }
.type-chip.light { background: rgba(255, 255, 255, 0.2); color: #fff; backdrop-filter: blur(4px); }

.pbadge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.pdot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 650; white-space: nowrap;
  background: var(--good-soft); color: var(--good);
}
.pill .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--brand-soft); color: var(--brand-ink); }
.pill.muted { background: var(--surface-3); color: var(--muted); }

/* ------------------------------------------------------------------ pager */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px 0; flex-wrap: wrap; }
.pager .muted { font-size: 11.5px; }
.pager-btns { display: flex; align-items: center; gap: 4px; }
.page-btn {
  min-width: 28px; height: 28px; padding: 0 7px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  font-size: 11.5px; font-weight: 600; display: grid; place-items: center;
}
.page-btn:hover:not(:disabled) { background: var(--surface-2); }
.page-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: default; }
.page-btn .ico { width: 14px; height: 14px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.searchbox {
  display: flex; align-items: center; gap: 8px; padding: 8px 11px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  color: var(--muted); flex: 1; min-width: 240px; max-width: 430px; box-shadow: var(--shadow-sm);
}
.searchbox .ico { width: 16px; height: 16px; }
.searchbox input { border: 0; outline: 0; background: transparent; font: inherit; font-size: 13px; color: var(--ink); width: 100%; }
.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-note { font-size: 11.5px; color: var(--muted); padding: 0 2px; }


/* ----------------------------------------------------------------- drawer */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(9, 13, 25, 0.45); backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; z-index: 61;
  width: min(560px, 100%); height: 100vh; overflow-y: auto;
  background: var(--surface); box-shadow: -30px 0 70px -40px rgba(0, 0, 0, 0.6);
  transform: translateX(102%); transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-banner { position: relative; display: flex; flex-direction: column; min-height: 158px; padding: 14px 18px 16px; color: #fff; }
.drawer-banner::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(130% 120% at 100% 0%, rgba(255, 255, 255, 0.28), transparent 62%);
}
.drawer-banner-top { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; }
.drawer-banner-mid { position: relative; z-index: 1; flex: 1; display: grid; place-items: center; opacity: 0.9; }
.drawer-banner-mid .ico { width: 44px; height: 44px; }
.drawer-banner-bot { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; font-size: 11px; opacity: 0.95; }
.drawer-banner-bot .pbadge { color: #fff; }
.icon-btn.light { background: rgba(255, 255, 255, 0.2); border-color: transparent; color: #fff; box-shadow: none; }
.icon-btn.light:hover { background: rgba(255, 255, 255, 0.3); }
.drawer-body { padding: 16px 18px 26px; display: flex; flex-direction: column; gap: 16px; }
.drawer-title h2 { font-size: 17px; line-height: 1.35; }
.drawer-title p { margin-top: 6px; font-size: 11.5px; color: var(--brand-ink); }
.drawer-owner {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px;
}
.drawer-owner div { display: flex; flex-direction: column; min-width: 0; }
.drawer-owner strong { font-size: 12.5px; }
.drawer-owner span { font-size: 10.5px; color: var(--muted); }
.drawer-owner .btn { margin-left: auto; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-box {
  display: flex; flex-direction: column; padding: 9px 11px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.stat-box.accent { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.stat-label { font-size: 9.5px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; }
.stat-sub { font-size: 10px; color: var(--muted); }
.drawer-section { border-top: 1px solid var(--line); padding-top: 14px; }
.drawer-section h3 { font-size: 13px; }
.drawer-section .small { margin-top: 3px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.split-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; margin-top: 12px; background: var(--surface-3); }
.split-bar span { display: block; height: 100%; }
.drawer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.meter { display: inline-block; width: 48px; height: 5px; border-radius: 999px; background: var(--surface-3); margin-right: 8px; vertical-align: middle; overflow: hidden; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, #7c7cff, #22d3ee); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }


/* -------------------------------------------------------------- accounts */
.summary-strip {
  display: flex; align-items: center; gap: 26px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow-sm);
}
.sum-item { display: flex; flex-direction: column; gap: 1px; }
.sum-item span { font-size: 9.5px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sum-item strong { font-size: 20px; letter-spacing: -0.025em; }
.sum-spacer { flex: 1; }

.account-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 16px; box-shadow: var(--shadow-sm);
}
.account-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.acc-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.acc-logo {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: grid; place-items: center; color: #fff;
}
.acc-logo .ico { width: 17px; height: 17px; }
.acc-logo.sm { width: 28px; height: 28px; border-radius: 8px; }
.acc-id h3 { font-size: 14px; }
.acc-id p { font-size: 11px; color: var(--muted); }
.acc-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.handler-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 12px; }
.handler-card {
  display: flex; flex-direction: column; gap: 10px; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.handler-top { display: flex; align-items: center; gap: 9px; }
.handler-id { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.handler-id strong { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.handler-id span { font-size: 10.5px; color: var(--muted); }
.handler-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; background: var(--surface-2); border-radius: 9px; padding: 8px; }
.handler-stats div { display: flex; flex-direction: column; min-width: 0; }
.handler-stats strong { font-size: 13px; letter-spacing: -0.02em; }
.handler-stats span { font-size: 9px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); white-space: nowrap; }
.handler-spark { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.handler-spark .spark { width: 88px; height: 24px; }
.handler-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.inline-alert {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 10.5px; line-height: 1.35; padding: 6px 8px; border-radius: 8px;
  background: var(--bad-soft); color: var(--bad);
}
.inline-alert.warn { background: var(--warn-soft); color: var(--warn); }
.inline-alert .ico { width: 13px; height: 13px; }
.inline-alert .link-btn { font-size: 10.5px; padding: 0; color: inherit; text-decoration: underline; }
.connect-card { border-style: dashed; background: transparent; box-shadow: none; }
.connect-inner { display: flex; align-items: flex-start; gap: 12px; }
.connect-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.connect-inner h3 { font-size: 14px; }
.connect-inner p { font-size: 11.5px; color: var(--muted); margin-top: 3px; max-width: 640px; }
.platform-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pchip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 11.5px; font-weight: 600;
}
.pchip:hover { border-color: var(--brand); color: var(--brand-ink); }


/* --------------------------------------------------------------- content */
.insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(232px, 1fr)); gap: 12px; }
.insight {
  display: flex; gap: 10px; padding: 13px 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-sm);
}
.insight-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.insight-ico .ico { width: 15px; height: 15px; }
.kicker { font-size: 9.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.insight h3 { font-size: 13px; margin-top: 3px; line-height: 1.35; }
.insight p { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.45; }

.format-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.format-card {
  position: relative; padding: 13px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm);
}
.format-card.best { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); box-shadow: 0 0 0 3px var(--brand-soft); }
.best-flag {
  position: absolute; top: 10px; right: 10px; font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: #fff;
  background: var(--brand); border-radius: 5px; padding: 2px 6px;
}
.format-top { display: flex; align-items: center; gap: 8px; }
.format-ico { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-3); color: var(--ink-soft); display: grid; place-items: center; flex: none; }
.format-ico .ico { width: 15px; height: 15px; }
.format-top strong { display: block; font-size: 12.5px; }
.format-top span { font-size: 10px; color: var(--muted); }
.format-er { font-size: 24px; font-weight: 650; letter-spacing: -0.03em; margin-top: 12px; }
.format-er span { display: block; font-size: 9.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.format-list { margin: 10px 0 0; display: flex; flex-direction: column; gap: 5px; }
.format-list div { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; }
.format-list dt { color: var(--muted); }
.format-list dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }


/* --------------------------------------------------------------- sources */
.notice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 12px; font-size: 12px;
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.notice .ico { color: var(--warn); margin-top: 1px; }
.notice strong { color: var(--warn); }
.notice div { color: var(--ink-soft); line-height: 1.45; }

.pipeline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.pipe-step {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px; box-shadow: var(--shadow-sm);
}
.pipe-ico {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); margin-bottom: 8px;
}
.pipe-ico .ico { width: 15px; height: 15px; }
.pipe-step h3 { font-size: 12.5px; }
.pipe-step p { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.scope-list { display: flex; flex-wrap: wrap; gap: 4px; max-width: 240px; }
.scope-list code {
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 5px; font-size: 9.5px; color: var(--ink-soft);
}

/* ---------------------------------------------------------------- toasts */
.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  min-width: 250px; max-width: 350px; padding: 11px 13px;
  background: #101728; color: #fff; border-radius: 11px;
  box-shadow: 0 20px 45px -18px rgba(0, 0, 0, 0.6);
  animation: toastIn 0.22s ease;
}
[data-theme="dark"] .toast { background: var(--surface-3); color: var(--ink); border: 1px solid var(--line-strong); }
.toast div { display: flex; flex-direction: column; gap: 1px; }
.toast strong { font-size: 12px; }
.toast span { font-size: 11px; opacity: 0.78; line-height: 1.4; }
.toast-dot { width: 7px; height: 7px; border-radius: 50%; background: #3ad39a; margin-top: 6px; flex: none; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.3s ease, transform 0.3s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }


@keyframes sweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* ==========================================================================
   v2 — sync panel, tab bar, modals, admin, mobile-first layout
   ========================================================================== */
.brand-mark .ico { width: 20px; height: 20px; color: #fff; }
.mobile-brand { display: none; width: 30px; height: 30px; }

/* ------------------------------------------------------------ sync panel */
.sync-box { gap: 9px; }
.sync-line { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.sync-line .live-dot { justify-self: center; }
.sync-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sync-txt strong { font-size: 12px; display: flex; align-items: center; gap: 5px; }
.sync-txt span { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync-line .btn { padding: 5px 9px; }
.sync-line.syncing .btn .ico { animation: spin 0.9s linear infinite; }
.sync-line.syncing .live-dot { background: var(--warn); }
.x-mark {
  width: 22px; height: 22px; border-radius: 7px; display: inline-grid; place-items: center; flex: none;
  background: #0f1419; color: #fff;
}
[data-theme="dark"] .x-mark { background: #e7e9ea; color: #0f1419; }
.x-mark .ico { width: 11px; height: 11px; }
.paid {
  font-style: normal; font-size: 9px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 1px 5px; border-radius: 5px; background: var(--warn-soft); color: var(--warn);
}
.btn.x-btn { background: #0f1419; border-color: #0f1419; color: #fff; }
.btn.x-btn:hover { background: #272c30; }
[data-theme="dark"] .btn.x-btn { background: #e7e9ea; border-color: #e7e9ea; color: #0f1419; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.budget-meter { height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.budget-meter.lg { height: 9px; margin: 6px 0 4px; }
.budget-meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #22c55e, #0ea5e9); }
.budget-meter span.hot { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.budget-cap { font-size: 10px; color: var(--muted); }
.modal .sync-box { background: transparent; border: 0; padding: 0; gap: 14px; }
.modal .sync-line .btn { padding: 9px 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------- top bar */
.icon-btn.sm { width: 32px; height: 32px; border-radius: 8px; box-shadow: none; }
.icon-btn.sm .ico { width: 15px; height: 15px; }
.bell { position: relative; }
.bell .badge {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg);
}
.bell .badge:empty { display: none; }
.sync-btn { display: none; }

/* ------------------------------------------------------------- filters */
.filter-bar { display: none; }
.filter-toggle .count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--brand); color: #fff;
  font-size: 10.5px; display: inline-grid; place-items: center;
}
.active-chips { display: flex; align-items: center; gap: 5px; overflow-x: auto; scrollbar-width: none; min-width: 0; flex: 1; }
.active-chips::-webkit-scrollbar { display: none; }
.active-chips .chip { white-space: nowrap; }
.filter-count { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.filter-count strong { color: var(--ink); }

/* ---------------------------------------------------------------- hero */
.hero {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 20px 22px; border-radius: 20px; color: #fff;
  background:
    radial-gradient(420px 220px at 100% 0%, rgba(34, 211, 238, 0.45), transparent 65%),
    radial-gradient(380px 260px at 0% 120%, rgba(236, 72, 153, 0.35), transparent 70%),
    linear-gradient(135deg, #4f46e5, #6d28d9);
  box-shadow: 0 22px 44px -28px rgba(79, 70, 229, 0.9);
}
.hero-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 260px; }
.hero-kicker { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.8; }
.hero-num { font-size: 40px; font-weight: 700; letter-spacing: -0.04em; line-height: 1.05; }
.hero-sub { font-size: 12.5px; opacity: 0.92; }
.hero-delta { display: inline-block; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.2); font-weight: 700; font-size: 11.5px; margin: 0 3px; }
.hero-delta.up { background: rgba(52, 211, 153, 0.3); }
.hero-delta.down { background: rgba(251, 113, 133, 0.32); }
.hero-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; flex: 1 1 380px; }
.hero-stats > * {
  display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; border-radius: 13px; text-align: left;
  background: rgba(255, 255, 255, 0.13); border: 1px solid rgba(255, 255, 255, 0.18); color: #fff;
}
.hero-stats button { font: inherit; cursor: pointer; }
.hero-stats button:hover { background: rgba(255, 255, 255, 0.22); }
.hero-stats strong { font-size: 19px; letter-spacing: -0.02em; }
.hero-stats span { font-size: 10.5px; opacity: 0.85; }
.kpi { transition: box-shadow 0.2s ease, border-color 0.2s ease; }
.kpi:hover { box-shadow: var(--shadow-md); }

/* ---------------------------------------------------------- post cards */
.post-cards { display: none; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.post-card {
  display: flex; gap: 11px; padding: 12px 2px; border-bottom: 1px solid var(--line); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.post-card:last-child { border-bottom: 0; }
.post-card:active { background: var(--surface-2); }
.post-card .thumb { width: 54px; height: 54px; border-radius: 12px; flex: none; }
.pc-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.pc-cap { font-size: 13px; font-weight: 600; line-height: 1.32; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pc-meta { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); min-width: 0; white-space: nowrap; overflow: hidden; }
.pc-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 2px; }
.pc-stats > span { display: flex; flex-direction: column; font-size: 10px; color: var(--muted); line-height: 1.2; }
.pc-stats strong { font-size: 13px; color: var(--ink); letter-spacing: -0.01em; }
.pc-stats strong.pos { color: var(--good); }
.m-sort-wrap { display: none; }

/* -------------------------------------------------------------- tab bar */
.tabbar { display: none; }

/* --------------------------------------------------------------- modals */
.modal-overlay { position: fixed; inset: 0; z-index: 80; background: rgba(9, 13, 25, 0.5); backdrop-filter: blur(3px); animation: fadeIn 0.2s ease; }
.modal {
  position: fixed; z-index: 81; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(480px, calc(100% - 32px)); max-height: calc(100vh - 48px); overflow-y: auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.55); margin: 0; padding: 0;
  animation: popIn 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}
.grabber { display: none; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 4px; }
.modal-head h2 { font-size: 17px; margin: 0; }
.modal-head p { font-size: 12.5px; color: var(--muted); margin: 3px 0 0; line-height: 1.45; }
.modal-head .icon-btn { box-shadow: none; flex: none; }
.modal-body { padding: 12px 20px 4px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; }
.form-error { margin: 4px 20px 0; padding: 8px 11px; border-radius: 9px; background: var(--bad-soft); color: var(--bad); font-size: 12px; font-weight: 600; }
.modal-body .form-error { margin: 0; }
.form-error[hidden] { display: none; }
@keyframes popIn { from { opacity: 0; transform: translate(-50%, -46%) scale(0.98); } to { opacity: 1; transform: translate(-50%, -50%); } }
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
body.modal-open { overflow: hidden; }

.form-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; border: 0; margin: 0; padding: 0; }
.form-field > span, .form-field > legend { font-size: 11px; font-weight: 650; letter-spacing: 0.03em; color: var(--ink-soft); padding: 0; margin-bottom: 5px; }
.form-field input, .inline-form input, .rule-num input, .form-field select, .inline-form select, .m-sort-wrap select, .rule-sel select {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); width: 100%;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px;
}
.form-field select, .inline-form select, .m-sort-wrap select, .rule-sel select { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer; }
.form-field input:focus, .form-field select:focus, .inline-form input:focus, .rule-num input:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: 1px; border-color: var(--brand);
}
.form-field.inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.form-field.inline .select-wrap, .form-field.inline > select, .form-field.inline > input { max-width: 220px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.modal .form-row { margin-top: 0; }
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.hint { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--ink-soft); background: var(--brand-soft); border-radius: 10px; padding: 9px 11px; line-height: 1.45; margin: 10px 0 0; }
.modal-body .hint { margin: 0; }
.hint .ico { color: var(--brand); width: 16px; height: 16px; margin-top: 1px; flex: none; }
.check-grid { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); margin: 0; flex: none; }
.check-list { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; }
.check.row { display: flex; padding: 9px 2px; border-bottom: 1px solid var(--line); gap: 10px; }
.check.row span { display: flex; flex-direction: column; line-height: 1.25; }
.check.row strong { font-size: 13px; }
.check.row em { font-style: normal; font-size: 11px; color: var(--muted); }
.cost-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cost-row div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; display: flex; flex-direction: column; gap: 2px; }
.cost-row span { font-size: 10.5px; color: var(--muted); }
.cost-row strong { font-size: 16px; letter-spacing: -0.02em; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-ghost { color: var(--bad); }
.btn.danger-ghost:hover { background: var(--bad-soft); }
.alert-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.alert-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 11px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); }
.alert-list .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--muted); }
.alert-list .lvl-bad .dot { background: var(--bad); }
.alert-list .lvl-warn .dot { background: var(--warn); }
.alert-list .lvl-info .dot { background: var(--brand); }
.alert-list .lvl-good .dot { background: var(--good); }
.alert-list div { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.alert-list strong { font-size: 12.5px; }
.alert-list span { font-size: 11.5px; color: var(--muted); }

/* ---------------------------------------------------------------- admin */
.adm-tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm);
}
.adm-tabs::-webkit-scrollbar { display: none; }
.adm-tab {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; flex: none; cursor: pointer;
  border: 0; background: transparent; padding: 8px 12px; border-radius: 10px;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.adm-tab .ico { width: 15px; height: 15px; }
.adm-tab:hover { color: var(--ink); background: var(--surface-2); }
.adm-tab.active { background: var(--brand-soft); color: var(--brand-ink); }
.strip-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.acc-actions { display: flex; align-items: center; gap: 6px; flex: none; margin-left: auto; }
.adm-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.adm-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) 84px 160px auto; align-items: center; gap: 12px;
  padding: 11px 2px; border-bottom: 1px solid var(--line);
}
.adm-row:last-child { border-bottom: 0; }
.adm-row.is-paused .avatar, .adm-row.is-archived .avatar, .adm-row.is-archived .acc-logo { filter: grayscale(0.85); opacity: 0.6; }
.adm-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.adm-id strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adm-id > span { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adm-meta { display: flex; flex-direction: column; text-align: right; line-height: 1.2; }
.adm-meta strong { font-size: 13px; }
.adm-meta span { font-size: 10px; color: var(--muted); }
.adm-status { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.adm-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.gchips { display: flex; gap: 4px; flex-wrap: wrap; }
.gchip {
  display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 650;
  color: var(--gc); background: color-mix(in srgb, var(--gc) 14%, transparent);
}
.gdot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.empty.slim { padding: 18px 10px; }
.adm-account { scroll-margin-top: 16px; }
.x-card { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); background: linear-gradient(180deg, color-mix(in srgb, var(--warn) 5%, var(--surface)), var(--surface) 120px); }
.sync-card .card-head h2 { display: flex; align-items: center; gap: 7px; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.kv span { color: var(--muted); }
.kv strong { text-align: right; }
.plat-list { display: flex; flex-direction: column; margin: 10px 0 0; padding: 0; list-style: none; }
.plat-list li { display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: 8px; padding: 8px 0; font-size: 12px; border-top: 1px solid var(--line); }
.budget { margin-top: 10px; }
.budget-top { display: flex; justify-content: space-between; font-size: 12px; }
.budget-top span { color: var(--muted); }
.inline-form { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.inline-form input { flex: 1; min-width: 0; width: auto; }
.inline-form.compact { margin: 0; }
.inline-form.compact .select-wrap, .inline-form.compact select { min-width: 200px; }
.goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.goal-card { border: 1px solid var(--line); border-radius: 14px; padding: 13px; display: flex; flex-direction: column; gap: 11px; background: var(--surface-2); }
.goal-head { display: flex; align-items: center; gap: 9px; }
.goal-head div { flex: 1; display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.goal-head strong { font-size: 13px; }
.goal-head span { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.goal-bar { display: flex; flex-direction: column; gap: 5px; }
.goal-top { display: flex; justify-content: space-between; font-size: 12px; }
.goal-top span { color: var(--muted); }
.goal-top em { font-style: normal; color: var(--muted); font-weight: 500; }
.goal-track { position: relative; height: 8px; border-radius: 999px; background: var(--surface-3); }
.goal-track span { display: block; height: 100%; border-radius: inherit; }
.goal-track span.ok { background: linear-gradient(90deg, #10b981, #22d3ee); }
.goal-track span.behind { background: linear-gradient(90deg, #f59e0b, #f97316); }
.goal-track i { position: absolute; top: -3px; width: 2px; height: 14px; border-radius: 2px; background: var(--ink); opacity: 0.55; }
.goal-note { font-size: 10.5px; font-weight: 650; }
.goal-note.ok { color: var(--good); }
.goal-note.behind { color: var(--warn); }
.rules { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.rule { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.rule:last-child { border-bottom: 0; }
.rule-txt { flex: 1; min-width: 160px; display: flex; flex-direction: column; line-height: 1.35; }
.rule-txt strong { font-size: 13px; }
.rule-txt span { font-size: 11.5px; color: var(--muted); }
.rule-num { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.rule-num input { width: 70px; padding: 6px 8px; font-size: 13px; }
.rule-sel { width: 96px; }
.rule-sel select, .rule-sel { padding-top: 6px; padding-bottom: 6px; }
.switch { position: relative; width: 40px; height: 24px; flex: none; display: inline-block; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; width: 100%; height: 100%; }
.slider { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background 0.2s ease; }
.slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s ease; }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::after { transform: translateX(16px); }
.switch input:focus-visible + .slider { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
.timeline { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.timeline li { display: flex; gap: 12px; padding: 0 0 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 14px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.t-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); margin-top: 4px; flex: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.timeline div { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.timeline strong { font-size: 12.5px; font-weight: 600; }
.timeline span { font-size: 11px; color: var(--muted); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1360px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-spark { opacity: 0.5; }
}
@media (max-width: 1180px) {
  .grid-main { grid-template-columns: 1fr; }
  .grid-three { grid-template-columns: 1fr 1fr; }
  .pipeline { grid-template-columns: 1fr 1fr; }
  .format-grid { grid-template-columns: 1fr 1fr; }
}

/* Tablet & phone: sidebar slides in, bottom tab bar appears. */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: 276px; height: 100%; overflow-y: auto; z-index: 70;
    transform: translateX(-103%); transition: transform 0.25s ease; box-shadow: var(--shadow-md);
    padding-top: max(18px, env(safe-area-inset-top));
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; z-index: 65; background: rgba(9, 13, 25, 0.42); }
  .nav-toggle, .sync-btn { display: grid; }
  .topbar, .filters, .view, .page-foot { padding-left: 16px; padding-right: 16px; }
  .topbar { padding-top: max(12px, env(safe-area-inset-top)); }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .tab-btn {
    display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: transparent; cursor: pointer;
    padding: 5px 2px; border-radius: 12px; color: var(--muted); font: inherit; font-size: 10.5px; font-weight: 600;
    -webkit-tap-highlight-color: transparent;
  }
  .tab-btn .ico { width: 44px; height: 28px; padding: 4px 11px; border-radius: 999px; box-sizing: border-box; transition: background 0.2s ease; }
  .tab-btn.active { color: var(--brand-ink); }
  .tab-btn.active .ico { background: var(--brand-soft); }
  .toast-root { bottom: calc(82px + env(safe-area-inset-bottom)); }
}

/* Phone */
@media (max-width: 760px) {
  .topbar { gap: 8px; padding-bottom: 10px; flex-wrap: wrap; }
  .mobile-brand { display: grid; }
  .page-id { flex: 1; min-width: 0; }
  .page-id h1 { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .page-id p { display: none; }
  .audience-chip { display: none; }
  .top-actions { display: contents; }
  .icon-btn { width: 36px; height: 36px; border-radius: 10px; }
  /* Range selector drops under the title as a full-width segmented control. */
  .top-actions .seg { order: 9; flex: 1 0 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
  .top-actions .seg button { padding: 7px 0; }
  body[data-screen="admin"] .top-actions .seg, body[data-screen="sources"] .top-actions .seg { display: none; }

  .filters { padding-bottom: 12px; }
  .filter-bar { display: flex; align-items: center; gap: 8px; }
  .filter-row { display: none; margin-top: 10px; }
  body.filters-open .filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .filter-row .field { min-width: 0; }
  .filter-row .field select { width: 100%; max-width: none; min-width: 0; }
  .reset-btn { justify-content: center; }
  .filter-meta { display: none; }

  .view { gap: 12px; padding-bottom: 20px; }
  .hero { padding: 18px; border-radius: 18px; gap: 14px; }
  .hero-num { font-size: 36px; }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); flex-basis: 100%; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-sub { display: none; }
  .grid-three, .grid-two, .pipeline { grid-template-columns: 1fr; }
  .grid { gap: 12px; }
  .card { border-radius: 16px; }
  .drawer { width: 100%; }
  .format-grid { grid-template-columns: 1fr 1fr; }

  /* posts: cards instead of the wide table */
  .toolbar { gap: 8px; flex-wrap: wrap; }
  .searchbox { min-width: 0; max-width: none; flex: 1 0 100%; }
  .m-sort-wrap { display: block; flex: 1; min-width: 0; }
  .toolbar-right { margin-left: 0; }
  .toolbar-right .chip { display: none; }
  .post-cards { display: flex; }
  #post-table > .table-wrap { display: none; }

  /* modals become bottom sheets */
  .modal {
    left: 0; right: 0; top: auto; bottom: 0; transform: none; width: 100%; max-height: 90vh;
    border-radius: 22px 22px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom);
    animation: sheetIn 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .grabber { display: block; width: 40px; height: 5px; border-radius: 999px; background: var(--line-strong); margin: 8px auto 0; }
  .modal-foot { position: sticky; bottom: 0; background: var(--surface); }
  .modal-foot .btn { flex: 1; justify-content: center; padding: 12px; }
  .form-field input, .inline-form input, .form-field select { font-size: 16px; } /* stops iOS zoom on focus */
  .form-row { grid-template-columns: 1fr; }

  /* admin */
  .strip-actions { width: 100%; margin-left: 0; }
  .strip-actions .btn { flex: 1; justify-content: center; }
  .account-head { flex-wrap: wrap; }
  .adm-row { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "av id meta" "st st act"; row-gap: 8px; }
  .adm-row > :first-child { grid-area: av; }
  .adm-row > .adm-id { grid-area: id; }
  .adm-row > .adm-meta { grid-area: meta; }
  .adm-row > .adm-status { grid-area: st; }
  .adm-row > .adm-actions { grid-area: act; }
  .adm-row .icon-btn.sm { width: 38px; height: 38px; }
  .form-field.inline { flex-direction: column; align-items: stretch; }
  .form-field.inline .select-wrap, .form-field.inline > select, .form-field.inline > input { max-width: none; }
  .plat-list li { grid-template-columns: 1fr auto; }
  .plat-list li > :nth-child(2) { display: none; }
  .inline-form.compact { width: 100%; }
  .inline-form.compact .select-wrap, .inline-form.compact select { min-width: 0; flex: 1; }
  .cost-row strong { font-size: 14px; }
  .btn-row .btn { flex: 1 1 100%; justify-content: center; }
}

@media (max-width: 400px) {
  .format-grid, .legend.tight, .stat-grid { grid-template-columns: 1fr; }
  .drawer-banner { min-height: 132px; }
  .pc-stats strong { font-size: 12px; }
  .hero-num { font-size: 32px; }
}

/* Bigger touch targets on touch screens. */
@media (pointer: coarse) {
  .btn { min-height: 40px; }
  .page-btn { min-width: 38px; min-height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
