:root {
  --bg: #0b0c0e;
  --panel: #131418;
  --panel-2: #1a1c21;
  --line: #262931;
  --line-2: #333742;
  --ink: #eceef2;
  --ink-2: #a3a8b4;
  --ink-3: #6b7080;
  --accent: #e8ff47;
  --accent-ink: #11130a;
  --ok: #5ee6b8;
  --warn: #ffb547;
  --bad: #ff6b6b;
  --r: 14px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Space Grotesk", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.45; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }

.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; gap: 22px; background: linear-gradient(180deg, #0f1013, var(--bg)); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .18em; font-size: 13px; padding: 0 8px; }
.meters { display: inline-flex; gap: 3px; align-items: flex-end; height: 18px; }
.meters i { width: 4px; border-radius: 2px; background: var(--accent); animation: lvl 1.6s ease-in-out infinite; }
.meters i:nth-child(1) { height: 50%; animation-delay: -.3s; }
.meters i:nth-child(2) { height: 100%; animation-delay: -.9s; }
.meters i:nth-child(3) { height: 70%; }
@keyframes lvl { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(.55); } }
@media (prefers-reduced-motion: reduce) { .meters i { animation: none; } }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 10px; text-decoration: none; color: var(--ink-2); font-weight: 500; }
nav a .ic { width: 22px; text-align: center; font-size: 12px; color: var(--ink-3); font-family: var(--mono); }
nav a:hover { background: var(--panel); color: var(--ink); }
nav a.on { background: var(--panel-2); color: var(--ink); box-shadow: inset 2px 0 0 var(--accent); }
nav a.on .ic { color: var(--accent); }
nav a .badge { margin-left: auto; }
.rail-foot { margin-top: auto; font-size: 12px; color: var(--ink-3); padding: 0 8px; word-break: break-all; }

main { padding: 32px clamp(16px, 4vw, 48px) 120px; max-width: 1180px; width: 100%; }
h1 { font-size: clamp(26px, 3.4vw, 36px); line-height: 1.1; margin: 0 0 6px; letter-spacing: -.02em; }
h2 { font-size: 18px; margin: 0 0 14px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 0 0 8px; }
.sub { color: var(--ink-2); margin: 0 0 28px; }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.card.tight { padding: 14px; }
.card + .card { margin-top: 0; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.mono { font-family: var(--mono); }
.small { font-size: 13px; }

.kpi .v { font-family: var(--mono); font-size: 30px; font-weight: 600; letter-spacing: -.02em; }
.kpi .l { color: var(--ink-2); font-size: 13px; }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); background: var(--panel-2); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .chip:focus-visible, nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label.f { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=password], input[type=url], input[type=datetime-local], textarea, select {
  width: 100%; background: #0e0f12; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; outline: none;
}
textarea { min-height: 150px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.field + .field { margin-top: 14px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); padding: 7px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600; background: transparent; user-select: none; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.chip.on { border-color: var(--accent); background: rgba(232,255,71,.08); }
.chip.on .dot { background: var(--accent); }
.chip.off { opacity: .45; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: rgba(94,230,184,.35); }
.badge.warn { color: var(--warn); border-color: rgba(255,181,71,.35); }
.badge.bad { color: var(--bad); border-color: rgba(255,107,107,.35); }
.badge.acc { color: var(--accent); border-color: rgba(232,255,71,.35); }

.todo { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line); }
.todo:first-of-type { border-top: 0; }
.todo .n { font-family: var(--mono); font-size: 12px; color: var(--accent-ink); background: var(--accent); border-radius: 6px; padding: 2px 7px; margin-top: 2px; }
.todo .n.done { background: var(--panel-2); color: var(--ok); }

.list > .item { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line); }
.list > .item:first-child { border-top: 0; padding-top: 0; }
.thumb { width: 64px; height: 64px; border-radius: 10px; background: var(--panel-2) center/cover no-repeat; flex: none; border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink-3); font-size: 11px; font-family: var(--mono); overflow: hidden; }
.thumb video { width: 100%; height: 100%; object-fit: cover; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.grow { flex: 1; min-width: 0; }

.day { margin-top: 26px; }
.day h3 { font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); border-bottom: 1px solid var(--line); padding-bottom: 8px; }

.drop { border: 1.5px dashed var(--line-2); border-radius: var(--r); padding: 22px; text-align: center; color: var(--ink-2); cursor: pointer; transition: border-color .15s, background .15s; }
.drop.hot { border-color: var(--accent); background: rgba(232,255,71,.05); }
.media-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.media-row .thumb { width: 88px; height: 88px; position: relative; }
.media-row .x { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.7); border: 0; border-radius: 6px; cursor: pointer; padding: 2px 6px; color: #fff; }

.counters { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.counter { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.counter.over { color: var(--bad); }

.md { color: var(--ink); }
.md h1, .md h2, .md h3 { margin: 1.2em 0 .5em; }
.md h1 { font-size: 22px; } .md h2 { font-size: 18px; } .md h3 { font-size: 15px; }
.md p, .md li { color: #d5d8df; }
.md table { border-collapse: collapse; width: 100%; font-size: 13px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.md code { font-family: var(--mono); background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 500; color: var(--ink-3); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data td.n { font-family: var(--mono); text-align: right; }
.scroll-x { overflow-x: auto; }

.empty { text-align: center; padding: 34px 16px; color: var(--ink-2); }
.empty .big { font-size: 28px; margin-bottom: 8px; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--panel-2), #22252c, var(--panel-2)); background-size: 200% 100%; animation: sh 1.2s linear infinite; }
@keyframes sh { to { background-position: -200% 0; } }
.err { color: var(--bad); font-size: 13px; white-space: pre-wrap; }
.sep { height: 1px; background: var(--line); margin: 18px 0; border: 0; }
.spark { width: 100%; height: 56px; display: block; margin-top: 10px; }
.proj-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.plat { display: inline-flex; width: 26px; height: 26px; border-radius: 8px; align-items: center; justify-content: center; background: var(--panel-2); border: 1px solid var(--line-2); font-size: 11px; font-weight: 700; font-family: var(--mono); }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--panel-2); flex: none; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); z-index: 50; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--bad); color: #fff; }

.lock { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; }
.meters.big { height: 46px; gap: 6px; margin-bottom: 14px; }
.meters.big i { width: 10px; border-radius: 5px; }
body.locked .rail { display: none; }
body.locked .shell { grid-template-columns: 1fr; }
@media (display-mode: standalone) { main { padding-top: max(32px, calc(env(safe-area-inset-top) + 16px)); } }

dialog { background: var(--panel); color: var(--ink); border: 1px solid var(--line-2); border-radius: 16px; padding: 22px; width: min(640px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }

@media (max-width: 960px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 20; flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); background: rgba(11,12,14,.96); backdrop-filter: blur(10px); }
  .brand, .rail-foot { display: none; }
  nav { flex-direction: row; overflow-x: auto; width: 100%; gap: 0; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav a { flex-direction: column; gap: 2px; font-size: 10px; padding: 6px 10px; min-width: 64px; }
  nav a .ic { font-size: 14px; }
  nav a.on { box-shadow: inset 0 2px 0 var(--accent); }
  main { padding: 22px 16px 110px; }
  .g2 { grid-template-columns: 1fr; }
}
