/* ASTRA IR портал */
:root {
  color-scheme: light;
  --bg: #EEF2F3;
  --surface: #FFFFFF;
  --ink: #15232B;
  --muted: #5B6B74;
  --line: #D6DEE2;
  --accent: #0E6E78;
  --accent-ink: #FFFFFF;
  --warn: #B3261E;
  --ok: #2E7D5B;
  --side: #15232B;
  --side-ink: #D8E3E8;
  --side-muted: #8FA2AC;
  --radius: 6px;
  --font: "Golos Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --display: "Unbounded", "Golos Text", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0E161A;
    --surface: #152127;
    --ink: #E3ECEF;
    --muted: #93A4AD;
    --line: #26353D;
    --accent: #4FB3BE;
    --accent-ink: #08262A;
    --warn: #FF8A80;
    --ok: #7FD1A8;
    --side: #0A1114;
    --side-ink: #D8E3E8;
    --side-muted: #7E929C;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .75em; }
code { font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.warn { color: var(--warn); }
.error { color: var(--warn); }

/* ---------- Оформление ---------- */
body.with-nav { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.main { padding: 28px 32px 64px; max-width: 1360px; width: 100%; }
body.guest .main { max-width: 1080px; margin: 0 auto; padding-top: 8vh; }

.side {
  background: var(--side); color: var(--side-ink); padding: 22px 18px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px;
}
.brand { text-decoration: none; color: inherit; display: block; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 1.35rem; letter-spacing: .02em; display: block; }
.brand-name.big { font-size: clamp(2.4rem, 6vw, 3.6rem); line-height: 1; margin-bottom: 14px; }
.brand-sub { color: var(--side-muted); font-size: .85rem; }

/* Лентата с осемте филтъра върху 2–11 µm */
.strip { position: relative; height: 18px; border-radius: 3px; background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.10)); }
.strip i { position: absolute; top: 0; bottom: 0; background: var(--c); opacity: .9; border-radius: 1px; min-width: 3px; }
.strip-wide { height: 34px; margin-bottom: 22px; background: var(--surface); border: 1px solid var(--line); }
.strip-wide i { top: 4px; bottom: 4px; }

.device-switch label { display: block; font-size: .8rem; color: var(--side-muted); margin-bottom: 4px; }
.device-switch select { width: 100%; background: rgba(255,255,255,.06); color: var(--side-ink); border: 1px solid rgba(255,255,255,.15); }
.device-switch option { color: #15232B; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav .linklike {
  color: var(--side-ink); text-decoration: none; padding: 7px 10px; border-radius: 4px; text-align: left; font-size: .95rem;
}
.nav a:hover, .nav .linklike:hover { background: rgba(255,255,255,.07); }
.nav a[aria-current="page"] { background: rgba(255,255,255,.12); box-shadow: inset 3px 0 0 var(--accent); }
.nav-secondary { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: 12px; }
.side-user { font-size: .85rem; margin: 0; }
.side-user span { color: var(--side-muted); }

@media (max-width: 900px) {
  body.with-nav { grid-template-columns: minmax(0, 1fr); }
  .side { min-width: 0; }
  .filters input[type=search] { width: 100%; }
  .filters > label { flex: 1 1 140px; }
  .side { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-secondary { margin-top: 0; }
  .main { padding: 20px 16px 48px; }
}

/* ---------- Елементи ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { max-width: 70ch; }
.page-head > div { min-width: 0; }
#summary td:first-child { white-space: nowrap; }
.sn { font-family: var(--display); font-weight: 700; font-size: clamp(2rem, 4vw, 2.8rem); letter-spacing: .01em; margin: 0 0 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; gap: 14px; margin-bottom: 10px; font-size: .9rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; overflow-x: auto; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 18px; }
.grid2 > .panel { margin-bottom: 0; }
.grid2 + .panel, .grid2 + .grid2 { margin-top: 18px; }
.grid-detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 18px; margin-bottom: 18px; }
.grid-detail > .panel { margin-bottom: 0; }

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 18px; }
.figures > div { padding: 14px 18px; border-right: 1px solid var(--line); }
.figures > div:last-child { border-right: 0; }
.figures strong { display: block; font-size: 1.35rem; font-weight: 600; }
.figures span { color: var(--muted); font-size: .85rem; }

.btn, button.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: .92rem;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 4px;
  padding: 8px 14px; text-decoration: none; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-small { padding: 4px 10px; font-size: .85rem; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.nav .linklike { text-decoration: none; width: 100%; }
.danger { color: var(--warn); }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  padding: 7px 9px; min-width: 0;
}
input:disabled { color: var(--muted); }
label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; font-weight: 500; }
label.inline { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
.opt { color: var(--muted); font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 14px; margin: 0; }
legend { font-size: .85rem; color: var(--muted); padding: 0 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; max-width: 520px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 14px; }
.inline-form.tight { margin-top: 6px; gap: 6px; }
.inline-form.tight input { padding: 4px 8px; font-size: .85rem; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.filters input[type=search] { width: 240px; }

.notice { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; border: 1px solid var(--line); background: var(--surface); }
.notice p:last-child { margin: 0; }
.notice-success { border-color: var(--ok); box-shadow: inset 4px 0 0 var(--ok); }
.notice-error { border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }
.notice-code { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.notice-code .code { font-family: var(--display); font-size: 1.6rem; letter-spacing: .08em; margin: 4px 0; user-select: all; }

.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 32px; max-width: 640px; }

/* ---------- Таблици ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-weight: 600; color: var(--muted); font-size: .82rem; border-bottom-width: 2px; white-space: nowrap; }
.num { text-align: right; white-space: nowrap; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.table-wrap { overflow-x: auto; }
td small { display: block; }
th[data-sort] { cursor: pointer; user-select: none; }
th[aria-sort="ascending"]::after { content: " ▲"; font-size: .7em; }
th[aria-sort="descending"]::after { content: " ▼"; font-size: .7em; }
.chk { width: 28px; }
tr.is-excluded td { opacity: .55; }
.kv th { width: 46%; font-weight: 500; color: var(--muted); }
.kv td { overflow-wrap: anywhere; }
.qbars th { display: flex; gap: 8px; align-items: baseline; font-weight: 500; white-space: nowrap; }
.qbars .qname small { display: block; font-weight: 400; }
.qbars td.num { width: 1%; }
.row-actions { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }

.cls {
  display: inline-block; font-size: .8rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
}
.tag { display: inline-block; font-size: .8rem; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; margin-left: 6px; }
.dose { font-weight: 600; margin-left: 8px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; background: var(--c); vertical-align: -1px; }
.qcode { display: inline-block; min-width: 2.2em; font-weight: 700; color: var(--c); }

.bar { height: 10px; background: color-mix(in srgb, var(--ink) 7%, transparent); border-radius: 2px; min-width: 80px; }
.bar span { display: block; height: 100%; width: var(--w); background: var(--c); border-radius: 2px; }
.bars td:nth-child(3) { width: 45%; }
.qbars td:nth-child(2) { width: 45%; vertical-align: middle; }

.batch { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.batch:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.batch p { max-width: 90ch; }

.pager { display: flex; gap: 12px; align-items: center; justify-content: flex-end; }
.pager button { font: inherit; padding: 5px 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 4px; cursor: pointer; }
.pager button:disabled { opacity: .4; cursor: default; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 6px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 4px 1px 10px; margin: 0 4px 4px 0; font-size: .82rem; }
.x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 4px; }
.x:hover { color: var(--warn); }

/* ---------- Графики ---------- */
.chart-box { position: relative; height: 340px; }
.chart-box.tall { height: min(62vh, 520px); }
.chart-box.square { height: 420px; }
.spec-controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-bottom: 12px; }
.seg { display: inline-flex; padding: 0; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.seg label { flex-direction: row; font-weight: 500; padding: 5px 12px; cursor: pointer; border-right: 1px solid var(--line); }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-ink); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.spec-controls select { padding: 4px 8px; }

.compare-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.compare-layout > .panel { margin-bottom: 0; }
.compare-side form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.picker { position: relative; margin-bottom: 10px; }
.picker input { width: 100%; }
.pick-results { list-style: none; margin: 4px 0 0; padding: 0; max-height: 260px; overflow-y: auto; }
.pick-results button { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 6px 4px; font: inherit; font-size: .88rem; color: var(--ink); cursor: pointer; }
.pick-results button:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.pick-results button:disabled { opacity: .45; }
.chosen { list-style: none; margin: 0 0 12px; padding: 0; }
.chosen li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.chosen li a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1000px) { .compare-layout { grid-template-columns: 1fr; } }

/* ---------- Вход и регистрация ---------- */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: start; }
.auth-intro { padding-top: 12px; }
.auth-intro .brand-name { color: var(--ink); }
.lede { font-size: 1.15rem; max-width: 46ch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 28px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .btn { align-self: flex-start; }
@media (max-width: 820px) { .auth { grid-template-columns: 1fr; gap: 24px; } .row2 { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media print { .side, .actions, .filters, .pager, .spec-controls { display: none !important; } body.with-nav { display: block; } }
