:root {
  --bg: #f4f6fa; --card: #ffffff; --text: #0a1a2f; --muted: #5b6b80; --line: #e2e7ef;
  --blue: #2563eb; --blue-dark: #1d4fd0; --red: #dc2626; --green: #15803d; --amber: #b45309;
  --radius: 12px; --shadow: 0 1px 2px rgba(10,26,47,.06), 0 4px 16px rgba(10,26,47,.05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1220; --card: #111a2c; --text: #e6ebf3; --muted: #93a3b8; --line: #22304a;
          --shadow: 0 1px 2px rgba(0,0,0,.3); --green: #4ade80; --red: #f87171; --amber: #fbbf24; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0 0 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 17px; margin: 0 0 12px; }
code, .key { font-family: ui-monospace, Consolas, monospace; background: rgba(37,99,235,.08); padding: 2px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.ok { color: var(--green); }
.err { color: var(--red); }
.inline { display: inline; }
.hidden { display: none !important; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 20px; padding: 10px 24px; background: var(--card);
          border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--blue); color: #fff;
              display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; }
.nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 14px; }

.container { max-width: 1120px; margin: 0 auto; padding: 24px 16px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 20px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } .topbar-right { margin-left: 0; } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 9px;
       padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; line-height: 1.2; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--line); }
.btn-danger:hover { background: rgba(220,38,38,.08); }
.btn[disabled] { opacity: .6; cursor: wait; }
.btn-row, .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions { justify-content: flex-end; }

/* forms */
.form label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
.form label small { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 9px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.35); border-color: var(--blue); }
input[disabled] { opacity: .7; }
textarea { resize: vertical; min-height: 160px; font-weight: 400; }
label small.muted { display: block; font-weight: 400; margin-top: 4px; }
.radio { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; margin-bottom: 10px !important; cursor: pointer; }
.when-box { margin: -4px 0 14px 26px; }
.admin-action select { display: inline-block; width: auto; margin: 0 4px 0 0; padding: 6px 8px; font-size: 13px; }

/* alerts */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid; }
.alert-error { background: rgba(220,38,38,.07); border-color: rgba(220,38,38,.3); color: var(--red); }
.alert-success { background: rgba(21,128,61,.07); border-color: rgba(21,128,61,.3); color: var(--green); }
.alert-info { background: rgba(37,99,235,.07); border-color: rgba(37,99,235,.3); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 16px 0 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: var(--text); box-shadow: var(--shadow); }
.stat:hover { text-decoration: none; border-color: var(--blue); }
.stat b { display: block; font-size: 28px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat-warn b { color: var(--amber); }
@media (max-width: 820px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.row-link { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.row-link:last-child { border-bottom: 0; }
.row-link:hover { text-decoration: none; color: var(--blue); }
.row-link .when { font-weight: 600; min-width: 150px; font-size: 14px; }
.row-link .snippet { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* tables */
.table-wrap { overflow-x: auto; padding: 0; }
.table-wrap > h2 { padding: 20px 20px 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.thumb-cell { width: 56px; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; display: block; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: var(--card); font-size: 14px; }
.tab.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.tab:hover { text-decoration: none; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-draft { background: rgba(91,107,128,.15); color: var(--muted); }
.badge-scheduled { background: rgba(37,99,235,.12); color: var(--blue); }
.badge-publishing { background: rgba(180,83,9,.12); color: var(--amber); }
.badge-published { background: rgba(21,128,61,.12); color: var(--green); }
.badge-partial { background: rgba(180,83,9,.12); color: var(--amber); }
.badge-failed { background: rgba(220,38,38,.12); color: var(--red); }

/* platform icons (letter badges) */
.pf { display: inline-flex; width: 26px; height: 26px; border-radius: 7px; align-items: center; justify-content: center;
      color: #fff; font-size: 13px; font-weight: 800; flex: none; vertical-align: middle; }
.pf-lg { width: 40px; height: 40px; font-size: 18px; border-radius: 10px; }
.pf::before { content: "?"; }
.pf-instagram { background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); } .pf-instagram::before { content: "IG"; font-size: 11px; }
.pf-facebook { background: #1877f2; } .pf-facebook::before { content: "f"; }
.pf-threads { background: #000; } .pf-threads::before { content: "@"; }
.pf-linkedin { background: #0a66c2; } .pf-linkedin::before { content: "in"; font-size: 12px; }
.pf-x { background: #000; } .pf-x::before { content: "𝕏"; }
.pf-pinterest { background: #e60023; } .pf-pinterest::before { content: "P"; }
.pf-telegram { background: #229ed9; } .pf-telegram::before { content: "✈"; }
.pf-discord { background: #5865f2; } .pf-discord::before { content: "D"; }
.pf-gone { background: #94a3b8; }
.pf-lg.pf-instagram::before { font-size: 15px; } .pf-lg.pf-linkedin::before { font-size: 16px; }

.platform-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.platform-card { display: flex; flex-direction: column; gap: 6px; background: var(--card); border: 1px solid var(--line);
                 border-radius: var(--radius); padding: 16px; color: var(--text); box-shadow: var(--shadow); }
.platform-card:hover { border-color: var(--blue); text-decoration: none; }

/* post form */
.targets { display: grid; gap: 8px; }
.target { display: flex !important; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line);
          border-radius: 10px; margin: 0 !important; cursor: pointer; font-weight: 400 !important; }
.target:has(input:checked) { border-color: var(--blue); background: rgba(37,99,235,.06); }
.target span b, .target span small { display: block; }
.counter { font-size: 13px; margin: -6px 0 14px; color: var(--muted); }
.counter .over { color: var(--red); font-weight: 700; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-bottom: 14px; }
.media-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.media-item { margin: 0 !important; font-weight: 400 !important; font-size: 13px; }
.media-item span { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.post-text { white-space: normal; word-wrap: break-word; }

.deliveries { list-style: none; padding: 0; margin: 0; }
.deliveries li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.deliveries li:last-child { border-bottom: 0; }
.deliveries small { margin-left: 6px; }
.steps { padding-left: 20px; } .steps li { margin-bottom: 8px; }
.checks { list-style: none; padding: 0; } .checks li { padding: 6px 0; border-bottom: 1px solid var(--line); }

/* guest pages */
body.guest { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.guest-box { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.guest-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 20px; }
.guest-box .card { box-shadow: none; border: 0; padding: 0; margin: 0; }
