:root {
  --bg: #05070e;
  --bg2: #080c17;
  --panel: rgba(17, 23, 40, .72);
  --panel2: rgba(255, 255, 255, .025);
  --stroke: rgba(255, 255, 255, .08);
  --stroke2: rgba(255, 255, 255, .14);
  --cyan: #00b4ff;
  --green: #2fd07a;
  --amber: #ffb020;
  --red: #ff5c6c;
  --text: #eef2fb;
  --muted: #8b93a9;
  --dim: #59617a;
  --fd: ui-sans-serif, "SF Pro Display", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fb: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fm: ui-monospace, "SF Mono", Menlo, "Cascadia Code", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--fd);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* layout */
.layout { display: flex; min-height: 100vh; }

.nav {
  width: 200px;
  flex: 0 0 200px;
  border-right: 1px solid var(--stroke);
  background: var(--bg2);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.nav .brand {
  font-size: 13px;
  color: var(--muted);
  padding: 4px 10px 14px;
  letter-spacing: .03em;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--panel2); color: var(--text); text-decoration: none; }
.nav a.active { background: rgba(255, 176, 32, .08); color: var(--amber); }
.nav a .ic { width: 18px; height: 18px; flex: 0 0 18px; }
.nav a svg { display: block; }

.main {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 60px;
  max-width: 1400px;
}

/* typography / common */
h1 { font-size: 24px; font-weight: 650; margin: 0 0 4px; }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }

.mon { font-family: var(--fm); }
.num { font-variant-numeric: tabular-nums; }

.card {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card.pad0 { padding: 0; }
.card-title {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 0 0 12px;
}

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 14px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* counters strip */
.counters { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; margin-bottom: 20px; }
.counter {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 14px 16px;
}
.counter .v { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.counter .l { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 8px;
  border: 1px solid var(--stroke2);
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}
.chip.green { color: var(--green); border-color: rgba(47,208,122,.35); background: rgba(47,208,122,.08); }
.chip.amber { color: var(--amber); border-color: rgba(255,176,32,.35); background: rgba(255,176,32,.08); }
.chip.red { color: var(--red); border-color: rgba(255,92,108,.35); background: rgba(255,92,108,.08); }
.chip.cyan { color: var(--cyan); border-color: rgba(0,180,255,.32); background: rgba(0,180,255,.08); }
.chip.muted { color: var(--muted); }
.chip.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

.pulse { animation: pulse 1.3s infinite ease-in-out; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--stroke2);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--panel2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--amber); color: #080c17; border-color: var(--amber); font-weight: 600; }
.btn.primary:hover { background: #ffc04e; }
.btn.danger { color: var(--red); border-color: rgba(255,92,108,.35); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.ghost { border-color: transparent; color: var(--muted); }

/* forms */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=time], select, textarea {
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--stroke2);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { border-color: var(--cyan); }
.field { margin-bottom: 12px; }
.field.error input, .field.error select { border-color: var(--red); }
.field .hint { font-size: 12px; color: var(--red); margin-top: 3px; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--stroke); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--stroke);
  white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--stroke); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--panel2); }
.num { font-variant-numeric: tabular-nums; }

/* skeleton */
.skel {
  display: inline-block;
  background: var(--panel2);
  border-radius: 8px;
  height: 14px;
  animation: pulse 1.2s infinite ease-in-out;
}

/* empty state */
.empty {
  background: var(--panel);
  border: 1px dashed var(--stroke2);
  border-radius: 12px;
  padding: 32px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* alert banner */
.banner {
  border-radius: 12px;
  border: 1px solid var(--stroke);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.banner.warn { border-color: rgba(255,176,32,.4); background: rgba(255,176,32,.06); color: var(--amber); }
.banner.critical { border-color: rgba(255,92,108,.4); background: rgba(255,92,108,.06); color: var(--red); }
.banner.info { border-color: var(--stroke2); color: var(--muted); }

/* toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel);
  border: 1px solid var(--stroke2);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  max-width: 340px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.error { border-color: rgba(255,92,108,.5); color: var(--red); }
.toast.ok { border-color: rgba(47,208,122,.5); color: var(--green); }

/* detail header */
.detail-head { margin-bottom: 16px; }
.detail-head .price { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.back { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; margin-bottom: 10px; }

/* kv rows */
.kv { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--stroke); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); flex: 0 0 200px; }
.kv .v { flex: 1; min-width: 0; }

/* requirements / collapsible */
.collapse summary { cursor: pointer; color: var(--cyan); font-size: 13px; }
.collapse .body { margin-top: 8px; white-space: pre-wrap; color: var(--text); }

/* agent cards */
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.agent { background: var(--panel); border: 1px solid var(--stroke); border-radius: 12px; padding: 16px; }
.agent .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.agent .role { font-size: 14px; font-weight: 600; }
.agent .name { font-size: 12px; color: var(--muted); }

/* toggle switch */
.switch { position: relative; width: 40px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 22px;
  background: rgba(255,255,255,.1); transition: .15s;
}
.switch .track::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--muted); transition: .15s;
}
.switch input:checked + .track { background: rgba(47,208,122,.35); }
.switch input:checked + .track::before { transform: translateX(18px); background: var(--green); }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters .field { margin: 0; }
.filters input[type=text], .filters input[type=number], .filters select { width: auto; min-width: 90px; }

/* pagination */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.pager .btn { font-size: 13px; }

/* dropzone */
.dropzone {
  border: 1px dashed var(--stroke2);
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s;
}
.dropzone.drag { background: rgba(0,180,255,.06); border-color: var(--cyan); }
.dropzone input { display: none; }

/* smeta positions */
.pos-tree .pos { display: flex; gap: 8px; padding: 7px 8px; border-bottom: 1px solid var(--stroke); flex-wrap: wrap; }
.pos-tree .pos.head { background: var(--panel2); }
.pos-tree .pos .pno { flex: 0 0 40px; color: var(--dim); font-family: var(--fm); }
.pos-tree .pos .pcode { flex: 0 0 150px; font-family: var(--fm); color: var(--cyan); }
.pos-tree .pos .pname { flex: 1; min-width: 200px; }
.pos-tree .pos .punit { flex: 0 0 70px; color: var(--muted); text-align: right; }
.pos-tree .pos .pqty { flex: 0 0 70px; text-align: right; font-variant-numeric: tabular-nums; }
.pos-tree .pos .pcost { flex: 0 0 120px; text-align: right; font-variant-numeric: tabular-nums; }
.pos-tree .children { margin-left: 20px; border-left: 2px solid var(--stroke); padding-left: 8px; }
.pos-tree .children .pos { border-bottom: 1px solid var(--stroke); }

/* auth screen */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth .box { background: var(--panel); border: 1px solid var(--stroke); border-radius: 12px; padding: 28px; width: 360px; }

/* светлая тема (18.10.2026): переключатель в меню, выбор помнится на устройстве */
:root[data-theme=light] {
  --bg: #f4f2ed; --bg2: #ece9e2; --panel: rgba(255, 255, 255, .9); --panel2: rgba(0, 0, 0, .04);
  --stroke: rgba(0, 0, 0, .09); --stroke2: rgba(0, 0, 0, .18);
  --cyan: #0b6fb0; --green: #1d8f54; --amber: #d9880f; --red: #cf3d4b;
  --text: #1c2130; --muted: #5b6478; --dim: #8b93a6;
}
:root[data-theme=light] .btn.primary { background: #f0a52a; border-color: #f0a52a; color: #1c2130; }
:root[data-theme=light] .btn.primary:hover { background: #f7b445; }
:root[data-theme=light] .nav a.active { background: rgba(217, 136, 15, .14); }
:root[data-theme=light] input[type=text], :root[data-theme=light] input[type=number], :root[data-theme=light] input[type=password], :root[data-theme=light] select, :root[data-theme=light] textarea { background: #fff; }
:root[data-theme=light] .toast { box-shadow: 0 8px 24px rgba(0,0,0,.15); }

/* верхняя полоска — только на телефоне */
.topbar { display: none; }
.nav .who { padding: 0 10px 10px; font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.nav a.bell { font-weight: 600; position: relative; }
.inboxBadge { display: none; background: #e5484d; color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; line-height: 1.5; }
.nav .bottom { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.nav a .lbl { white-space: nowrap; }

/* responsive nav (18.10.2026: на телефоне меню — панель внизу, как в приложениях; имя и выход — вверху) */
@media (max-width: 720px) {
  .layout { display: block; }
  .topbar {
    display: flex; position: sticky; top: 0; z-index: 11; align-items: center; gap: 10px;
    padding: 9px 14px; background: var(--bg2); border-bottom: 1px solid var(--stroke); font-size: 14px;
  }
  .topbar .brand { font-weight: 650; }
  .topbar .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
  .topbar a, .topbar button { color: var(--muted); font: inherit; background: none; border: none; padding: 4px 6px; cursor: pointer; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: 100%; height: auto; z-index: 10;
    flex-direction: row; overflow-x: auto; gap: 0; border-right: none; border-top: 1px solid var(--stroke);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--bg2);
  }
  .nav .brand, .nav .who, .nav .bottom { display: none; }
  .nav a { flex: 1 0 64px; flex-direction: column; justify-content: center; gap: 3px; padding: 6px 2px; font-size: 11px; text-align: center; border-radius: 10px; position: relative; }
  .nav a .ic { width: 22px; height: 22px; flex-basis: 22px; }
  .nav a .emoji { font-size: 20px; line-height: 22px; }
  .nav a .inboxBadge { position: absolute; top: 0; right: 6px; }
  .main { padding: 14px 14px 100px; }
  .table-wrap table { min-width: 560px; }
  #asst-btn { bottom: 86px !important; }
  #asst-box { bottom: 150px !important; max-height: calc(100vh - 170px) !important; }
}
