/* Поточен рак · общ вид
   Минимализъм: неутрален фон, тънки линии, един акцент, монохромни икони. */
:root{
  --bg:#fafaf9; --surface:#fff; --surface-2:#f5f5f4;
  --fg:#1c1917; --muted:#78716c; --line:#e7e5e4; --line-strong:#d6d3d1;
  --accent:#298096; --accent-soft:#e6f1f4;
  --ok:#2f7d4f; --warn:#9a6700; --err:#b4231f;
  --arch:#a8a29e;
  --r:9px;
}
@media (prefers-color-scheme:dark){ :root:not([data-theme="light"]){
  --bg:#141b1a; --surface:#1b2423; --surface-2:#222d2c;
  --fg:#f1f3f2; --muted:#9aa5a3; --line:#2c3836; --line-strong:#3b4a47;
  --accent:#4aa8bf; --accent-soft:#1d3a41;
  --ok:#6cc08b; --warn:#d9a441; --err:#e0756f; --arch:#6b7471; } }
:root[data-theme="dark"]{
  --bg:#141b1a; --surface:#1b2423; --surface-2:#222d2c;
  --fg:#f1f3f2; --muted:#9aa5a3; --line:#2c3836; --line-strong:#3b4a47;
  --accent:#4aa8bf; --accent-soft:#1d3a41;
  --ok:#6cc08b; --warn:#d9a441; --err:#e0756f; --arch:#6b7471; }

*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{background:var(--bg);color:var(--fg);
  font:15px/1.5 "Sofia Sans",system-ui,-apple-system,"Segoe UI",sans-serif;
  -webkit-text-size-adjust:100%}
svg{stroke:currentColor;fill:none;stroke-width:1.65;stroke-linecap:round;stroke-linejoin:round}

/* ── рамка ─────────────────────────────────────────────────────────────── */
.app{display:grid;grid-template-columns:216px 1fr;min-height:100vh}
aside{border-right:1px solid var(--line);background:var(--surface);
  padding:14px 10px;position:sticky;top:0;height:100vh;overflow:auto}
.brand{display:flex;gap:10px;align-items:flex-start;padding:2px 6px 14px}
.brand .mark{width:32px;height:32px;border:1px solid var(--line);border-radius:8px;
  display:grid;place-items:center;flex:0 0 auto}
.brand .mark svg{width:19px;height:19px}
.brand h1{font-size:.93rem;font-weight:600;margin:0;line-height:1.25}
.brand-ver{font-size:11px;color:var(--muted);margin-top:2px}
nav{display:flex;flex-direction:column;gap:1px}
nav a{display:flex;align-items:center;gap:9px;padding:7px 9px;border-radius:7px;
  color:var(--fg);text-decoration:none;font-size:.9rem}
nav a svg{width:16px;height:16px;color:var(--muted);flex:0 0 auto}
nav a:hover{background:var(--surface-2)}
nav a[aria-current]{background:var(--accent-soft);color:var(--accent);font-weight:600}
nav a[aria-current] svg{color:var(--accent)}
nav .count{margin-left:auto;font-size:11px;color:var(--muted);font-variant-numeric:tabular-nums}
nav hr{border:0;border-top:1px solid var(--line);margin:9px 4px}
main{padding:18px 22px 60px;min-width:0}

/* ── лента на състоянието ──────────────────────────────────────────────── */
.bar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:14px}
.bar h2{font-size:1.1rem;font-weight:600;margin:0}
.sp{flex:1}
.pill{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--muted);
  border:1px solid var(--line);border-radius:99px;padding:3px 10px;background:var(--surface)}
.pill svg{width:13px;height:13px}
.pill.off{color:var(--warn);border-color:var(--warn)}
.pill.pend{color:var(--accent);border-color:var(--accent)}
button,select,input,textarea{font:inherit;color:inherit}
button{background:var(--surface);border:1px solid var(--line);border-radius:7px;
  padding:5px 11px;cursor:pointer}
button:hover{border-color:var(--line-strong)}
button.primary{background:var(--accent);border-color:var(--accent);color:#fff}
button.danger{color:var(--err);border-color:var(--err)}
button.icon{padding:4px 7px;line-height:0}
button.icon svg{width:15px;height:15px}
input[type=text],input[type=search],input[type=number],input[type=date],select,textarea{
  background:var(--surface);border:1px solid var(--line);border-radius:7px;padding:5px 9px;min-width:0}
input:focus,select:focus,textarea:focus{outline:2px solid var(--accent-soft);border-color:var(--accent)}

/* ── таблици ───────────────────────────────────────────────────────────── */
.tablewrap{border:1px solid var(--line);border-radius:var(--r);overflow:auto;background:var(--surface)}
table{border-collapse:collapse;width:100%;font-size:.88rem}
th,td{padding:6px 10px;border-bottom:1px solid var(--line);border-right:1px solid var(--line);
  text-align:left;white-space:nowrap;vertical-align:top}
th:last-child,td:last-child{border-right:0}
thead th{position:sticky;top:0;background:var(--surface-2);z-index:2;font-weight:600;
  font-size:.78rem;color:var(--muted);letter-spacing:.01em}
tbody tr:hover td{background:var(--surface-2)}
td.num,th.num{text-align:right;font-variant-numeric:tabular-nums}
td.editable{cursor:text}
td.editable:hover{box-shadow:inset 0 0 0 1px var(--accent)}
td.empty{color:var(--muted)}
tr.arch td{color:var(--arch);background:repeating-linear-gradient(
  -45deg,transparent,transparent 7px,var(--surface-2) 7px,var(--surface-2) 14px)}
td.pending{box-shadow:inset 2px 0 0 var(--accent)}
.tag{display:inline-block;font-size:11px;border:1px solid var(--line);border-radius:5px;
  padding:0 5px;color:var(--muted)}
.wrapcell{white-space:normal;max-width:30rem}

/* ── редактор ──────────────────────────────────────────────────────────── */
.pop{position:fixed;z-index:50;background:var(--surface);border:1px solid var(--line-strong);
  border-radius:var(--r);box-shadow:0 8px 28px rgba(0,0,0,.16);padding:10px;min-width:260px;max-width:min(94vw,30rem)}
.pop h4{margin:0 0 7px;font-size:.82rem;color:var(--muted);font-weight:600}
.pop .row{display:flex;gap:7px;margin-top:9px}
.optlist{max-height:46vh;overflow:auto;border:1px solid var(--line);border-radius:7px;margin-top:6px}
.optlist label{display:flex;align-items:center;gap:8px;padding:3px 9px;font-size:.87rem;cursor:pointer}
.optlist label:hover{background:var(--surface-2)}
.optlist label.on{background:var(--accent-soft)}
.optlist input{width:15px;height:15px;margin:0;flex:0 0 auto;accent-color:var(--accent)}
.pop input[type=text],.pop input[type=number],.pop textarea,.pop input[type=search]{width:100%}
.backdrop{position:fixed;inset:0;z-index:40}

/* ── карти, справки ────────────────────────────────────────────────────── */
.cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(168px,1fr));gap:10px;margin-bottom:18px}
.card{border:1px solid var(--line);border-radius:var(--r);padding:11px 13px;background:var(--surface)}
.card .k{font-size:.76rem;color:var(--muted)}
.card .v{font-size:1.5rem;font-weight:600;font-variant-numeric:tabular-nums;line-height:1.2}
h3{font-size:.95rem;font-weight:600;margin:22px 0 8px}
.m{color:var(--muted);font-size:.85rem}
.bars{display:grid;gap:3px;margin-top:6px}
.barrow{display:grid;grid-template-columns:11rem 1fr 3rem;gap:9px;align-items:center;font-size:.85rem}
.barrow .t{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.barrow .b{height:11px;background:var(--accent-soft);border-radius:3px;overflow:hidden}
.barrow .b i{display:block;height:100%;background:var(--accent)}
.barrow .n{text-align:right;font-variant-numeric:tabular-nums;color:var(--muted)}

/* ── детайл на трансект ────────────────────────────────────────────────── */
.kv{display:grid;grid-template-columns:auto 1fr;gap:1px 0;border:1px solid var(--line);
  border-radius:var(--r);overflow:hidden;background:var(--line)}
.kv>div{background:var(--surface);padding:6px 11px;font-size:.88rem}
.kv .k{color:var(--muted);white-space:nowrap}
.kv .v{cursor:text}
.kv .v:hover{box-shadow:inset 0 0 0 1px var(--accent)}

.gal{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:9px}
.gal figure{margin:0;border:1px solid var(--line);border-radius:var(--r);overflow:hidden;background:var(--surface)}
.gal .ph{aspect-ratio:4/3;display:grid;place-items:center;background:var(--surface-2);color:var(--muted)}
.gal .ph svg{width:26px;height:26px}
.gal figcaption{padding:6px 9px;font-size:.78rem;color:var(--muted);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

.notice{border:1px solid var(--line);border-left:3px solid var(--accent);border-radius:7px;
  padding:9px 13px;background:var(--surface);font-size:.87rem;margin:10px 0}
.notice.warn{border-left-color:var(--warn)}
.notice.err{border-left-color:var(--err)}

/* ── телефон ───────────────────────────────────────────────────────────── */
@media (max-width:820px){
  .app{grid-template-columns:1fr}
  aside{position:static;height:auto;border-right:0;border-bottom:1px solid var(--line);
    padding:10px;display:grid;grid-template-columns:1fr}
  nav{flex-direction:row;overflow:auto;gap:4px;padding-bottom:2px}
  nav a{white-space:nowrap;font-size:.85rem;padding:6px 10px}
  nav a .count,nav hr{display:none}
  main{padding:14px 12px 72px}
  input,select,textarea{font-size:16px}
  table{font-size:.84rem}
  .barrow{grid-template-columns:8rem 1fr 2.6rem}
}
@media print{
  aside,.bar button,.pill{display:none}
  .app{display:block} main{padding:0}
  .tablewrap{border:0} thead th{position:static}
}
