:root {
  --bg: #f7f4ef;
  --surface: #fcfcfb;
  --surface-2: #f1ece4;
  --line: #e4ddd2;
  --grid: #ece6dc;
  --ink: #1f1b16;
  --ink-2: #5c544a;
  --ink-3: #8a8175;
  --accent: #9a5a2e;
  --accent-ink: #fff;
  --good: #2f7d4f;
  --bad: #b3362b;
  --warn: #a8700f;
  --ig: #C13584; --fb: #1877F2; --tt: #0E9F9A; --pin: #E0412F;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(40,30,20,.05), 0 4px 16px rgba(40,30,20,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --surface: #1a1a19; --surface-2: #23221f; --line: #33312d; --grid: #2a2926;
    --ink: #f1ede6; --ink-2: #bdb5a9; --ink-3: #8c857a; --accent: #d79a63; --accent-ink: #1a1208;
    --good: #5cc287; --bad: #f07b6f; --warn: #e5b35a;
    --ig: #D4529E; --fb: #3D8BF0; --tt: #119E98; --pin: #E8533F;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211; --surface: #1a1a19; --surface-2: #23221f; --line: #33312d; --grid: #2a2926;
  --ink: #f1ede6; --ink-2: #bdb5a9; --ink-3: #8c857a; --accent: #d79a63; --accent-ink: #1a1208;
  --good: #5cc287; --bad: #f07b6f; --warn: #e5b35a;
  --ig: #D4529E; --fb: #3D8BF0; --tt: #119E98; --pin: #E8533F;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--ink-3); }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 22px 16px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; background: var(--surface); }
.brand { font-family: "Cormorant Garamond", serif; font-size: 26px; font-weight: 600; line-height: 1.05; margin: 0 8px 4px; }
.brand small { display: block; font: 500 11px Inter, sans-serif; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-top: 6px; }
.nav { margin-top: 22px; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--surface-2); color: var(--ink); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side .foot { margin-top: auto; font-size: 12px; color: var(--ink-3); padding: 0 8px; display: grid; gap: 8px; }
.main { padding: 28px 32px 60px; min-width: 0; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head h1 { font-family: "Cormorant Garamond", serif; font-weight: 600; font-size: 34px; margin: 0; line-height: 1; }
.head p { margin: 6px 0 0; color: var(--ink-3); }

/* controls */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--ink-2); font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 6px 12px 6px 10px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-weight: 500; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip.off { opacity: .45; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .5; cursor: default; }
input[type=email], input[type=text], select { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 12px; min-width: 0; }
input:focus, select:focus, .btn:focus-visible, .seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* cards */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.card .sub { color: var(--ink-3); font-size: 12px; margin: 0 0 12px; }
.kpi .label { color: var(--ink-3); font-size: 12px; font-weight: 500; }
.kpi .val { font-size: 28px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; font-weight: 500; color: var(--ink-3); margin-top: 2px; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); }
.two { grid-template-columns: 1.5fr 1fr; }
.chartbox { position: relative; height: 280px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--ink-3); font-weight: 500; }
th.num, td.num { text-align: right; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
tr:last-child td { border-bottom: 0; }
.pf { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.pf .dot { width: 9px; height: 9px; border-radius: 50%; }
.muted { color: var(--ink-3); }
.err { color: var(--bad); font-size: 12px; white-space: normal; max-width: 420px; }

/* posts */
.posts { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.post { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.post .thumb { aspect-ratio: 1; background: var(--surface-2) center/cover no-repeat; position: relative; }
.post .badge { position: absolute; top: 10px; left: 10px; background: rgba(20,16,12,.72); color: #fff; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; display: inline-flex; gap: 6px; align-items: center; }
.post .badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.post .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.post .cap { font-size: 13px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.post .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 12px; }
.post .stats b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.post .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); margin-top: auto; }

/* accounts */
.connect { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 18px; }
.connect .card { display: flex; flex-direction: column; gap: 10px; }
.acc { display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2) center/cover; flex: none; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; word-break: break-all; display: block; }
details { margin-top: 18px; }
details summary { cursor: pointer; font-weight: 600; }
details ol { color: var(--ink-2); padding-left: 20px; }
details li { margin: 6px 0; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(400px, 100%); padding: 32px; }
.login h1 { font-family: "Cormorant Garamond", serif; font-size: 36px; margin: 0; line-height: 1.05; }
.login p { color: var(--ink-3); }
.login form { display: grid; gap: 10px; margin-top: 18px; }

.empty { text-align: center; padding: 48px 16px; color: var(--ink-3); }
.empty h3 { color: var(--ink); font-size: 16px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100% - 32px); z-index: 50; }
#toast.show { opacity: 1; transform: translateX(-50%); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mobilebar { display: none; }

@media (max-width: 900px) {
  .two { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .mobilebar { display: flex; position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 16px; gap: 4px; overflow-x: auto; align-items: center; }
  .mobilebar .brand { font-size: 20px; margin: 0 10px 0 0; white-space: nowrap; }
  .mobilebar .nav { flex-direction: row; margin: 0; }
  .mobilebar .nav a { padding: 7px 9px; white-space: nowrap; }
  .mobilebar .nav a span { display: none; }
  .main { padding: 18px 16px 48px; }
  .head h1 { font-size: 28px; }
  .kpi .val { font-size: 22px; }
  .chartbox { height: 230px; }
}
.connect .card .btn { margin-top: auto; }
