:root {
  --bg: #f6f6f3;
  --panel: #ffffff;
  --ink: #1b1d1f;
  --muted: #6b6f75;
  --line: #e3e2dc;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --ok: #1f7a4a;
  --warn: #9a6200;
  --bad: #b3261e;
  --soft-ok: #e6f3ec;
  --soft-warn: #fbf0db;
  --soft-bad: #fbe6e4;
  --radius: 10px;
  --fb: #1877f2;
  --ig: #c13584;
  --li: #0a66c2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141615; --panel: #1c1f1e; --ink: #e9ebe8; --muted: #9aa09c; --line: #2d312f;
    --accent: #4fb596; --accent-ink: #0d1412;
    --soft-ok: #17301f; --soft-warn: #33290f; --soft-bad: #3a1a17;
    --ok: #6fd29b; --warn: #e3b04b; --bad: #f08a80;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.tabs { display: flex; gap: 4px; }
.tabs button { background: none; border: 0; padding: 8px 14px; border-radius: 8px; color: var(--muted); font: inherit; cursor: pointer; }
.tabs button.active { background: var(--bg); color: var(--ink); font-weight: 600; }
.count { font-size: 12px; background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 0 7px; margin-left: 4px; }
.count:empty { display: none; }
main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
.tab { display: none; }
.tab.active { display: block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.flash { max-width: 1080px; margin: 16px auto 0; padding: 10px 14px; border-radius: var(--radius); }
.flash.ok { background: var(--soft-ok); color: var(--ok); }
.flash.bad { background: var(--soft-bad); color: var(--bad); }

.compose { display: grid; grid-template-columns: 1fr 320px; gap: 24px; }
@media (max-width: 820px) { .compose { grid-template-columns: 1fr; } }
.col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.side { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; align-self: start; position: sticky; top: 80px; }
.field-label { font-weight: 600; margin-top: 10px; }
textarea, input[type=text], input[type=datetime-local], input:not([type]) { width: 100%; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
textarea { resize: vertical; }
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.drop { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; background: var(--panel); cursor: pointer; }
.drop p { margin: 4px 0; }
.drop.over { border-color: var(--accent); background: var(--soft-ok); }
.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--line); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 4px; right: 4px; border: 0; background: rgba(0,0,0,.6); color: #fff; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; line-height: 1; }
.thumb .tag { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; }

.counters { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.counters .over { color: var(--bad); font-weight: 600; }
.per-platform { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.per-platform summary { cursor: pointer; font-weight: 600; }
.per-platform label { display: block; margin-top: 8px; font-size: 13px; font-weight: 600; }

.targets { display: flex; flex-direction: column; gap: 6px; }
.target { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.target:has(input:checked) { border-color: var(--accent); background: var(--soft-ok); }
.target input { accent-color: var(--accent); }
.badge { font-size: 11px; font-weight: 700; color: #fff; padding: 1px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: .03em; }
.b-facebook { background: var(--fb); } .b-instagram { background: var(--ig); } .b-linkedin { background: var(--li); }
.when { display: flex; flex-direction: column; gap: 6px; }
.radio { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.errors { background: var(--soft-bad); color: var(--bad); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.errors ul { margin: 0; padding-left: 18px; }
button, .button { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .button { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary { width: 100%; padding: 12px; margin-top: 12px; }
button:disabled { opacity: .6; cursor: wait; }
button.ghost { background: none; }
button.danger { color: var(--bad); }

.queue-head { margin-bottom: 14px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border-radius: 20px; padding: 5px 12px; font-size: 14px; }
.chip.active { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.queue { display: flex; flex-direction: column; gap: 10px; }
.post { display: grid; grid-template-columns: 88px 1fr auto; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
@media (max-width: 640px) { .post { grid-template-columns: 64px 1fr; } .post .actions { grid-column: 1 / -1; } }
.post .media { width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--line); display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.post .media img, .post .media video { width: 100%; height: 100%; object-fit: cover; }
.post .meta { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.post .text { margin: 4px 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.results { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.result { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.st { font-weight: 600; }
.st-published { color: var(--ok); } .st-failed { color: var(--bad); } .st-publishing, .st-scheduled { color: var(--warn); }
.err { color: var(--bad); overflow-wrap: anywhere; }
.status-pill { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.p-scheduled { background: var(--soft-warn); color: var(--warn); }
.p-publishing { background: var(--soft-warn); color: var(--warn); }
.p-published { background: var(--soft-ok); color: var(--ok); }
.p-partial, .p-failed { background: var(--soft-bad); color: var(--bad); }
.actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.empty { text-align: center; padding: 40px; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }

.connect-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .connect-row { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 4px; }
.inline-form { display: flex; gap: 6px; margin-top: 12px; }
.section-title { margin-top: 28px; }
.accounts { display: flex; flex-direction: column; gap: 8px; }
.account { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.account .grow { flex: 1; min-width: 0; }
.warn-box { background: var(--soft-warn); color: var(--warn); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.warn-box code { overflow-wrap: anywhere; }
.inline-form button { white-space: nowrap; }
.logout { margin: 0; }
.logout button { color: var(--muted); }
.brand-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.brand-chips .chip { font-size: 13px; padding: 3px 10px; }
.brand-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 6px; }
.account { flex-wrap: wrap; }
.brand-input { width: 160px !important; padding: 6px 10px !important; }
@media (max-width: 640px) { .brand-input { width: 100% !important; order: 3; } }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 6px; }
.login .brand { margin-bottom: 8px; font-size: 18px; }
.login input { width: 100%; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }

/* ---------- v3: new platforms, checks, options ---------- */
:root { --th: #101010; --tt: #111111; --yt: #e00000; --gbp: #1e8e3e; --xx: #0f1419; }
.b-threads { background: var(--th); } .b-tiktok { background: var(--tt); } .b-youtube { background: var(--yt); }
.b-gbp { background: var(--gbp); } .b-x { background: var(--xx); }
@media (prefers-color-scheme: dark) { .b-threads, .b-tiktok, .b-x { background: #3a3f3d; } }
.badge { display: inline-block; min-width: 22px; text-align: center; }
.tabs { flex-wrap: wrap; }
.label-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.insert-bar select { font: inherit; font-size: 13px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.checks { display: flex; flex-direction: column; gap: 4px; }
.check { font-size: 13px; border-radius: 6px; padding: 6px 10px; }
.check.bad { background: var(--soft-bad); color: var(--bad); }
.check.fix { background: var(--soft-warn); color: var(--warn); }
.option-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.option-box h4 { margin: 0 0 4px; display: flex; gap: 8px; align-items: center; }
.option-box select, select { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.small-label { font-size: 13px; font-weight: 600; margin-top: 4px; }
.seg { display: flex; gap: 14px; flex-wrap: wrap; }
.seg label, .checks-row label { display: flex; gap: 6px; align-items: center; cursor: pointer; font-size: 14px; }
.checks-row { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 4px; }
.cover-video { width: 160px; max-height: 284px; border-radius: 8px; background: #000; }
.status-pill.p-preparing, .status-pill.p-retrying { background: var(--soft-warn); color: var(--warn); }
.st-retrying, .st-preparing { color: var(--warn); }
.stat-line { color: var(--muted); }
.fixes { font-size: 13px; color: var(--warn); margin-bottom: 6px; }
.fixes ul { margin: 4px 0 0; padding-left: 18px; }
.warn-text { color: var(--warn); }
.ok-text { color: var(--ok); }
.row-inline { display: flex; gap: 6px; }
.row-inline input { flex: 1; min-width: 0; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.post-body { min-width: 0; }

/* Bulk */
.bulk-head { margin-bottom: 14px; }
.bulk-grid { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
@media (max-width: 820px) { .bulk-grid { grid-template-columns: 1fr; } }
.bulk-grid .side { position: sticky; top: 80px; }
.bulk-rows { display: flex; flex-direction: column; gap: 10px; }
.bulk-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.bulk-row.r-ok { border-color: var(--ok); }
.bulk-row.r-bad { border-color: var(--bad); }
.bulk-thumbs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; align-content: start; }
.bulk-thumbs img, .bulk-thumbs video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.bulk-thumbs :only-child { grid-column: 1 / -1; }
.bulk-fields { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
@media (max-width: 560px) { .bulk-row { grid-template-columns: 70px 1fr; } .bulk-row > button { grid-column: 1 / -1; } }

/* Calendar */
.cal-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-head h2 { margin: 0 8px; font-size: 20px; min-width: 170px; }
.cal-head select { margin-left: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 4px; }
.cal-day { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-height: 104px; padding: 4px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day.other { opacity: .55; }
.cal-day.today { border-color: var(--accent); }
.cal-day.drop-target { background: var(--soft-ok); border-style: dashed; }
.cal-date { font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-item { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 5px; border-radius: 5px; background: var(--bg); border-left: 3px solid var(--line); min-width: 0; }
.cal-item[draggable=true] { cursor: grab; }
.cal-item.sel { outline: 2px solid var(--accent); }
.cal-item.dragging { opacity: .4; }
.cal-item.s-scheduled, .cal-item.s-preparing { border-left-color: var(--warn); }
.cal-item.s-published { border-left-color: var(--ok); }
.cal-item.s-failed, .cal-item.s-partial, .cal-item.s-retrying { border-left-color: var(--bad); }
.cal-time { font-weight: 600; white-space: nowrap; }
.cal-plats { display: flex; gap: 2px; }
.cal-plats i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-facebook { background: var(--fb); } .dot-instagram { background: var(--ig); } .dot-linkedin { background: var(--li); } .dot-threads { background: var(--muted); }
.dot-tiktok { background: #25f4ee; } .dot-youtube { background: var(--yt); } .dot-gbp { background: var(--gbp); } .dot-x { background: var(--ink); }
.cal-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#calDetail { margin-top: 14px; }
@media (max-width: 640px) { .cal-day { min-height: 64px; } .cal-text, .cal-plats { display: none; } .cal-item { justify-content: center; } }

/* Stats */
.stats-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.stats-head p { flex-basis: 100%; margin: 0; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat-head { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.stat-big { font-size: 28px; font-weight: 700; margin: 6px 0 2px; letter-spacing: -0.02em; }
.stat-big span { font-size: 14px; font-weight: 400; color: var(--muted); }
.stat-small { font-size: 13px; color: var(--muted); }
.stat-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 720px) { .stat-split { grid-template-columns: 1fr; } }
.card h3 { margin: 0 0 4px; }
.bars { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.bar-row { display: grid; grid-template-columns: 48px 1fr 40px; gap: 8px; align-items: center; font-size: 13px; }
.bar-track { background: var(--bg); border-radius: 4px; height: 12px; overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; }
.bar-val { text-align: right; color: var(--muted); }
.top-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.top-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px; border-bottom: 1px solid var(--line); }
.top-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.top-cap { max-width: 360px; overflow-wrap: anywhere; }
@media (max-width: 640px) { .top-table th:nth-child(4), .top-table td:nth-child(4), .top-table th:nth-child(6), .top-table td:nth-child(6) { display: none; } }

/* Brands */
.brand-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; margin-top: 12px; }
@media (max-width: 520px) { .brand-list { grid-template-columns: 1fr; } }
.brand-card { display: flex; flex-direction: column; gap: 6px; }
.brand-top { display: flex; align-items: center; gap: 10px; }
.brand-name { font: inherit; font-weight: 700; font-size: 17px; border: 1px solid transparent; background: none; color: var(--ink); padding: 4px 6px; border-radius: 6px; flex: 1; }
.brand-name:hover, .brand-name:focus { border-color: var(--line); }
.slot-table { border-collapse: collapse; font-size: 13px; width: 100%; }
.slot-table th { font-size: 11px; color: var(--muted); font-weight: 600; padding: 2px; }
.slot-table td { text-align: center; padding: 2px; }
.slot-table td:first-child { font-weight: 600; text-align: left; }
.slot-table input { accent-color: var(--accent); }
.saved-list { display: flex; flex-direction: column; gap: 6px; }
.saved-item { display: grid; grid-template-columns: 150px 1fr auto; gap: 6px; align-items: start; }
.saved-item textarea { grid-column: 1 / 3; font: inherit; font-size: 14px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.saved-item input { font: inherit; font-size: 14px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.saved-item select { padding: 6px 8px; font-size: 13px; }
.brand-actions { display: flex; justify-content: flex-end; }
.brand-actions .primary { width: auto; margin-top: 6px; }

/* Accounts */
.connect-row { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.connect-card { display: flex; flex-direction: column; gap: 6px; }
.connect-card h3 { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 16px; }
.connect-card .button { align-self: flex-start; }
.connect-card details code { overflow-wrap: anywhere; font-size: 12px; }
.alerts-card { margin-top: 16px; }
.bulk-row > button { align-self: start; }

.status-pill.p-missed { background: var(--soft-bad); color: var(--bad); }
.cal-item.s-missed { border-left-color: var(--bad); }

/* Elements with the hidden attribute must stay hidden even when a class sets display. */
[hidden] { display: none !important; }
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
.row-inline input[type=time] { min-width: 120px; flex: 0 0 auto; }

/* Public legal pages */
.legal-body { background: var(--bg); color: var(--ink); padding: 32px 16px; }
.legal { max-width: 760px; margin: 0 auto; padding: 32px; line-height: 1.6; }
.legal h1 { margin: 12px 0 4px; }
.legal h2 { font-size: 1.05rem; margin: 24px 0 6px; }
.legal ul, .legal ol { padding-left: 20px; }
.legal hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0 12px; }
