:root {
  --bg: #0e1014; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a; --text: #e8eaf0; --muted: #8b93a5;
  --accent: #7c5cff; --accent2: #a48bff; --ok: #35c98a; --warn: #f2b84b; --err: #f06a6a;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent2); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; }
p.sub { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.layout { display: flex; min-height: 100vh; }
nav { width: 210px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
nav .brand { font-weight: 700; font-size: 17px; padding: 4px 10px 16px; }
nav .brand span { color: var(--accent2); }
nav a { display: block; padding: 9px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; }
nav a:hover { background: var(--panel2); color: var(--text); }
nav a.on { background: var(--accent); color: #fff; }
nav .foot { margin-top: auto; padding: 10px; font-size: 12px; color: var(--muted); }
main { flex: 1; padding: 26px 30px 60px; min-width: 0; max-width: 1200px; }
.banner { background: #3a2f12; border: 1px solid #6b5520; color: #f6d48a; padding: 10px 14px; border-radius: 10px; margin-bottom: 18px; }
.banner.err { background: #3a1616; border-color: #6b2525; color: #f5a3a3; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi b { display: block; font-size: 24px; }
.kpi span { color: var(--muted); font-size: 12px; }

button, .btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; }
button:hover { filter: brightness(1.1); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.danger { background: transparent; color: var(--err); border: 1px solid #5a2a2a; font-weight: 500; }
button.sm { padding: 4px 10px; font-size: 12px; }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
label.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text); margin: 0; cursor: pointer; }
.field { margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--panel2); color: var(--muted); }
.tag.ok { background: #143326; color: var(--ok); } .tag.warn { background: #3a2f12; color: var(--warn); } .tag.err { background: #3a1616; color: var(--err); }
.thumb { width: 38px; height: 52px; object-fit: cover; border-radius: 6px; background: var(--panel2); vertical-align: middle; }
.clip { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.media { position: relative; background: var(--panel2); border: 2px solid transparent; border-radius: 10px; overflow: hidden; cursor: pointer; }
.media img { width: 100%; aspect-ratio: 9/14; object-fit: cover; display: block; background: #000; }
.media .meta { padding: 6px 8px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media .badge { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.7); border-radius: 6px; padding: 1px 6px; font-size: 10px; }
.media .del { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.7); color: #fff; border-radius: 6px; padding: 1px 7px; font-size: 12px; display: none; }
.media:hover .del { display: block; }
.media.sel { border-color: var(--accent); }
.media.sel::after { content: "✓"; position: absolute; bottom: 30px; right: 6px; background: var(--accent); border-radius: 50%; width: 22px; height: 22px; text-align: center; line-height: 22px; font-weight: 700; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 26px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); color: var(--text); }

.acc { display: flex; gap: 14px; align-items: flex-start; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #ff7ab8); flex: none; object-fit: cover; display: grid; place-items: center; font-weight: 700; }
.slots { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.slot { background: var(--panel2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 4px 2px 10px; font-size: 12px; }
.slot button { background: none; color: var(--muted); padding: 0 6px; font-weight: 400; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 10px; }
.chart div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.chart div:hover { background: var(--accent2); }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button { background: var(--panel2); color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
.tabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.auth { max-width: 380px; margin: 9vh auto; padding: 0 16px; }
.auth input { width: 100%; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #fff; color: #111; padding: 10px 18px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 9; }
#toast.show { opacity: 1; }
#toast.err { background: var(--err); color: #fff; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  nav { width: auto; height: auto; position: static; flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  nav .brand, nav .foot { display: none; }
  nav a { white-space: nowrap; }
  main { padding: 16px; }
  .card { overflow-x: auto; }
}
