:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #16191d;
  --muted: #5b6470;
  --line: #e6e8eb;
  --accent: #d6336c;
  --accent-text: #ffffff;
  --ok: #2b8a3e;
  --bad: #c92a2a;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1215;
    --card: #171b20;
    --text: #e8eaed;
    --muted: #9aa3ad;
    --line: #2a3038;
    --accent: #f06595;
    --accent-text: #16191d;
    --ok: #51cf66;
    --bad: #ff8787;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1rem; margin: 0 0 12px; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; color: var(--text); }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a, .topbar nav .soon {
  padding: 6px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap;
}
.topbar nav a[aria-current="page"] { background: var(--bg); color: var(--text); font-weight: 600; }
.topbar nav .soon { opacity: .5; cursor: default; }
.logout { display: flex; align-items: center; gap: 10px; margin: 0; }
.who { color: var(--muted); font-size: .9rem; }

/* ---------- layout ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 24px 20px 48px; display: grid; gap: 20px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 20px; }
.chart-box { position: relative; height: 260px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.kpi-group.placeholder { opacity: .6; }
.kpi-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.kpi { display: flex; flex-direction: column; }
.kpi .label { font-size: .8rem; color: var(--muted); }
.kpi .value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.delta { font-size: .8rem; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.platform {
  display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 99px; margin-right: 6px; color: #fff; vertical-align: middle;
}
.platform.ig { background: #d6336c; }
.platform.yt { background: #e03131; }
.platform.wa { background: #2f9e44; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); }
.tabs a[aria-current="page"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.caption { min-width: 220px; max-width: 420px; }
.tag { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); }

/* ---------- forms / auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.auth-card.wide { max-width: 520px; }
.auth-card h2 { margin-top: 8px; }
form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: .9rem; font-weight: 600; }
input {
  font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .button {
  font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 8px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-text); text-align: center; display: inline-block;
}
button.link { background: none; color: var(--muted); padding: 4px 8px; font-weight: 500; }
button.link:hover { color: var(--text); }
.alert { margin: 0; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.ok { margin: 0; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.qr { display: flex; justify-content: center; padding: 12px; background: #fff; border-radius: 8px; }
.qr svg { width: min(240px, 100%); height: auto; aspect-ratio: 1; }
.secret { word-break: break-all; font-size: .85rem; }
details summary { cursor: pointer; color: var(--muted); }

@media (max-width: 560px) {
  .page { padding: 16px 12px 40px; gap: 14px; }
  .card { padding: 14px; }
  .kpi .value { font-size: 1.25rem; }
  .chart-box { height: 220px; }
  .who { display: none; }
}

/* ---------- publishing calendar ---------- */
.small { font-size: .85rem; }
.narrow { max-width: 640px; width: 100%; }
select, textarea {
  font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); width: 100%;
}
textarea { resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
legend { font-size: .9rem; font-weight: 600; margin-bottom: 6px; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { display: flex; align-items: center; gap: 6px; font-weight: 500; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input, .choice input { width: auto; }
.button.secondary, button.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.day { display: grid; gap: 10px; }
.day.past { opacity: .75; }
.day-title { font-size: .95rem; color: var(--muted); margin: 8px 0 0; }
.post { display: grid; gap: 12px; }
.post-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.post-head .time, .upcoming .time { font-weight: 700; font-variant-numeric: tabular-nums; }
.post-body { display: flex; gap: 14px; }
.post-text { min-width: 0; display: grid; gap: 6px; }
.post-text p { margin: 0; }
.caption { white-space: pre-line; overflow-wrap: anywhere; }
.thumbs { display: flex; gap: 6px; flex-shrink: 0; }
.thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: var(--bg);
  border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); font-size: 1.2rem; }
.post-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.post-actions form { display: block; }
.post-actions button, .post-actions summary.button { padding: 7px 12px; font-size: .9rem; }
details.inline > summary { list-style: none; }
details.inline > summary::-webkit-details-marker { display: none; }
details.inline[open] > summary { margin-bottom: 8px; }
form.row { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.badge.scheduled, .badge.approved { color: #4c6ef5; }
.badge.awaiting_approval { color: #f59f00; }
.badge.processing { color: #7950f2; }
.badge.published { color: var(--ok); }
.badge.failed, .badge.missed { color: var(--bad); }
.badge.cancelled { color: var(--muted); }
.upcoming { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.upcoming li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }
@media (max-width: 560px) {
  .post-body { flex-direction: column; }
  .thumb { width: 56px; height: 56px; }
}

/* ---------- post detail ---------- */
h3 { font-size: .9rem; margin: 0 0 8px; color: var(--muted); }
.kpi-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.kpi-grid.compact { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.chart-box.short { height: 140px; }
.notice { margin: 0 0 14px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); }
a.ext { margin-left: 6px; color: var(--muted); }

/* ---------- comments ---------- */
.comment { display: grid; gap: 8px; }
.comment.attention { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.comment p { margin: 0; }
.comment-text { font-size: 1rem; white-space: pre-line; overflow-wrap: anywhere; }
.comment form { gap: 8px; }
.reply { padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--bg); border-radius: 6px; white-space: pre-line; }
.badge.cat { color: var(--text); border-color: var(--line); }
.nav-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 99px;
  background: var(--accent); color: var(--accent-text); font-size: .7rem; font-weight: 700; text-align: center; }

/* ---------- legal pages ---------- */
.legal { max-width: 760px; margin: 0 auto; display: grid; gap: 10px; }
.legal h1 { font-size: 1.4rem; }
.legal h2 { margin-top: 10px; }
.legal p, .legal li { line-height: 1.6; }
.legal hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* Edit form in the calendar: takes the full card width when open. */
details.inline.edit[open] { flex-basis: 100%; order: 10; }
.stack { display: grid; gap: 10px; max-width: 720px; }
.stack label { display: grid; gap: 4px; }
