:root {
  color-scheme: dark;
  --bg: #0f0f0e;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --surface-3: #2d2d2a;
  --border: #34342f;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #8c8b83;
  --accent: #3987e5;
  --accent-ink: #ffffff;
  /* platform identity = categorical slots (dark steps) */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  /* status (reserved) */
  --good: #0ca30c;
  --warning: #c98500;
  --critical: #e66767;
  --radius: 14px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text-primary); }
body { font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface-1); border-right: 1px solid var(--border); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #3987e5, #9085e9); display: grid; place-items: center; font-weight: 800; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.2px; }
.nav-btn { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 10px; color: var(--text-secondary); cursor: pointer; }
.nav-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-btn.active { background: var(--surface-3); color: var(--text-primary); font-weight: 600; }
.nav-btn svg { width: 18px; height: 18px; flex: none; }
.sidebar .spacer { flex: 1; }
.sidebar .foot { font-size: 12px; color: var(--text-muted); padding: 10px 12px; }

main { padding: 28px 32px 80px; max-width: 1280px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
h1 { font-size: 26px; margin: 0; letter-spacing: -.3px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.sub { color: var(--text-secondary); margin: 4px 0 0; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.btn { background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px; padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 14px; display: inline-flex; gap: 8px; align-items: center; text-decoration: none; color: var(--text-primary); }
.btn:hover { border-color: #4a4a44; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: none; }
.btn.danger { color: var(--critical); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-secondary); font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], input[type=url], select, textarea {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: var(--text-primary); width: 100%;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-primary); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi .label { font-size: 13px; color: var(--text-secondary); }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .note { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* chart */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip { position: absolute; pointer-events: none; background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 12px; min-width: 140px; box-shadow: 0 8px 24px rgba(0,0,0,.4); display: none; z-index: 5; }
.tooltip .t-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.tooltip .t-row b { font-variant-numeric: tabular-nums; }
.bars .bar-row { display: grid; grid-template-columns: 120px 1fr 70px; gap: 10px; align-items: center; margin: 10px 0; font-size: 13px; }
.bars .track { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bars .fill { height: 100%; border-radius: 0 4px 4px 0; }
.bars .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; padding: 8px; border-bottom: 1px solid var(--border); }
td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.thumb-sm { width: 36px; height: 64px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }

.platform { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text-secondary); white-space: nowrap; }
.pill.good { color: #7fd67f; } .pill.warning { color: #f0c060; } .pill.critical { color: var(--critical); } .pill.info { color: #8fbaf0; }

/* media grid */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px; text-align: center; background: var(--surface-1); cursor: pointer; transition: border-color .15s; }
.dropzone.drag, .dropzone:hover { border-color: var(--accent); }
.dropzone .big { font-size: 17px; font-weight: 600; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.tile { position: relative; border-radius: 12px; overflow: hidden; background: var(--surface-2); aspect-ratio: 9/16; border: 2px solid transparent; cursor: pointer; }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.selected { border-color: var(--accent); }
.tile .badges { position: absolute; left: 6px; top: 6px; display: flex; gap: 4px; }
.tile .badge { background: rgba(0,0,0,.65); font-size: 11px; padding: 2px 6px; border-radius: 6px; }
.tile .del { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.65); border: 0; color: #fff; border-radius: 8px; width: 26px; height: 26px; cursor: pointer; display: none; }
.tile:hover .del { display: block; }
.tile .used { position: absolute; left: 6px; bottom: 6px; font-size: 11px; background: rgba(0,0,0,.65); padding: 2px 6px; border-radius: 6px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* templates */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tpl { background: var(--surface-2); border: 2px solid var(--border); border-radius: 12px; padding: 14px; cursor: pointer; }
.tpl.active { border-color: var(--accent); }
.tpl .name { font-weight: 700; }
.tpl .desc { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.tpl .meta { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* renders */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.vcard { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.vcard video, .vcard .placeholder { width: 100%; aspect-ratio: 9/16; background: #000; display: block; object-fit: contain; max-height: 460px; }
.vcard .placeholder { display: grid; place-items: center; color: var(--text-muted); }
.vcard .body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.progress { height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; width: 70%; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; }

.acct-card { display: flex; gap: 14px; align-items: flex-start; }
.acct-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; }
.acct-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.acct-row { display: flex; gap: 10px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; flex-wrap: wrap; }
.acct-row select { width: auto; padding: 6px 8px; font-size: 13px; }

.sched-day { margin-bottom: 18px; }
.sched-day h3 { font-size: 14px; color: var(--text-secondary); margin: 0 0 8px; }
.sched-item { display: flex; gap: 12px; align-items: center; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.sched-item .cap { flex: 1; min-width: 180px; font-size: 14px; }
.sched-item .when { font-variant-numeric: tabular-nums; font-weight: 600; width: 72px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface-3); border: 1px solid var(--border); padding: 12px 18px; border-radius: 12px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: 90vw; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.notice { background: var(--surface-2); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 8px; font-size: 13px; color: var(--text-secondary); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; padding: 20px; width: 100%; max-width: 460px; }

/* phone */
.mobile-nav { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  main { padding: 18px 14px 96px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface-1); border-top: 1px solid var(--border); justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 30; }
  .mobile-nav .nav-btn { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 4px; width: auto; align-items: center; }
  .media-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .bars .bar-row { grid-template-columns: 90px 1fr 60px; }
  .tile .del { display: block; }
}
