:root {
  --bg: #0b0b0d; --panel: #131316; --panel2: #18181b; --line: #27272a; --text: #f4f4f5; --muted: #a1a1aa; --dim: #71717a;
  --accent: #f4f4f5; --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444; --info: #3b82f6; --purple: #a855f7;
  --ig: #e1306c; --tt: #25f4ee; --yt: #ff0033;
  --r: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: #52525b; }
textarea { width: 100%; resize: vertical; }
.muted { color: var(--muted); } .sm { font-size: 12px; } .grow { flex: 1; }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text); }
.btn:hover:not(:disabled) { border-color: #52525b; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: #0b0b0d; border-color: var(--accent); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.big { width: 100%; padding: 12px; font-size: 15px; margin-top: 8px; }
.btn.danger { color: var(--bad); }

/* Header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: rgba(11,11,13,.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.logo { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: var(--text); color: var(--bg); font-weight: 800; }
nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
nav button { background: none; border: 0; padding: 7px 12px; border-radius: 8px; color: var(--muted); cursor: pointer; }
nav button.on { background: var(--panel2); color: var(--text); }
main { padding: 20px; max-width: 1280px; margin: 0 auto; }
.tab { display: none; } .tab.on { display: block; }
h2 { font-size: 13px; text-transform: none; color: var(--muted); font-weight: 600; margin: 18px 0 8px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; cursor: pointer; }
.stat:hover { border-color: #3f3f46; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; }

.connect-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.connect-row .btn { display: inline-flex; align-items: center; gap: 8px; }
.connect-row input { width: 160px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar input { width: 220px; }

/* Tables */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-weight: 500; color: var(--dim); font-size: 12px; padding: 9px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.grid td { padding: 8px 12px; border-bottom: 1px solid #1f1f23; vertical-align: middle; }
.grid tr:last-child td { border-bottom: 0; }
.grid tr:hover td { background: #16161a; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid .cb { width: 34px; }
.acc { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.av { width: 30px; height: 30px; border-radius: 50%; background: var(--panel2); object-fit: cover; flex: none; position: relative; }
.acc .pf { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pf.instagram { background: var(--ig); } .pf.tiktok { background: var(--tt); } .pf.youtube { background: var(--yt); }
.acc small { display: block; color: var(--dim); font-size: 11px; }
.detail { color: var(--dim); font-size: 12px; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-active, .b-published { color: var(--ok); background: #22c55e1a; }
.b-restricted, .b-processing { color: var(--warn); background: #f59e0b1a; }
.b-banned, .b-failed { color: var(--bad); background: #ef44441a; }
.b-reconnect, .b-publishing { color: var(--info); background: #3b82f61a; }
.b-queued { color: var(--purple); background: #a855f71a; }
.b-error, .b-canceled { color: var(--muted); background: #a1a1aa1a; }

.tag { padding: 2px 8px; border-radius: 6px; background: var(--panel2); border: 1px solid var(--line); font-size: 12px; cursor: pointer; }
.tag.none { color: var(--dim); border-style: dashed; }
.actions { display: flex; gap: 4px; justify-content: flex-end; }
.icon { background: none; border: 0; color: var(--dim); cursor: pointer; padding: 4px 6px; border-radius: 6px; font-size: 12px; }
.icon:hover { color: var(--text); background: var(--panel2); }
a { color: var(--text); }

/* Publish */
.publish { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.publish .col { min-width: 0; }
.drop { display: grid; place-items: center; gap: 8px; height: 120px; border: 1.5px dashed #3f3f46; border-radius: var(--r); cursor: pointer; color: var(--muted); text-align: center; padding: 10px; }
.drop.over { border-color: var(--text); color: var(--text); }
.bar { width: 80%; height: 4px; background: var(--panel2); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--text); transition: width .15s; }
.row { display: flex; gap: 8px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.row input:not([type=radio]):not([type=number]):not([type=datetime-local]) { flex: 1; }
#preview { width: 100%; max-height: 360px; margin-top: 10px; border-radius: var(--r); background: #000; }
#media-pick, #yt-title { width: 100%; margin-top: 8px; }
.pick-actions { display: flex; gap: 6px; align-items: center; margin: 8px 0; }
.pick-list { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.pick-list label { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-bottom: 1px solid #1f1f23; cursor: pointer; }
.pick-list label:last-child { border-bottom: 0; }
.pick-list label.off { opacity: .45; }
.radio { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.field { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.field input { width: 70px; }
.msg { min-height: 20px; color: var(--muted); }
.msg.ok { color: var(--ok); } .msg.err { color: var(--bad); }

/* Events */
.events { list-style: none; padding: 0; margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.events li { padding: 9px 14px; border-bottom: 1px solid #1f1f23; display: flex; gap: 12px; font-size: 13px; }
.events li:last-child { border-bottom: 0; }
.events time { color: var(--dim); font-variant-numeric: tabular-nums; flex: none; width: 110px; }
.events .k { flex: none; width: 80px; color: var(--muted); }

/* Settings */
.settings { max-width: 760px; }
pre { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; overflow: auto; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.linkrow { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.linkrow code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--panel); border: 1px solid var(--line); padding: 7px 10px; border-radius: 8px; font-size: 12px; }

/* Modal + toast */
.modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 20; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(440px, calc(100vw - 32px)); }
.modal-card h3 { margin: 0 0 12px; font-size: 16px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500; z-index: 30; }

/* Login */
body.login { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: min(340px, calc(100vw - 32px)); display: grid; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.login-card p { margin: 0 0 6px; }
.err { color: var(--bad); }

@media (max-width: 820px) {
  .publish { grid-template-columns: 1fr; }
  main { padding: 14px 16px; }
  .top { padding: 10px 16px; gap: 10px; }
  .toolbar input { width: 100%; }
  .hide-m { display: none; }
}
