:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --ink: #1b1f27;
  --ink-soft: #3c4450;
  --muted: #6b7480;
  --line: #e3e7ec;
  --line-strong: #d3d9e0;
  --brand: #167a5b;
  --brand-strong: #0f5f46;
  --brand-soft: #e8f5ef;
  --accent: #2bb673;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --warn: #9a6700;
  --warn-soft: #fffaeb;
  --info: #1d4ed8;
  --info-soft: #eff4ff;
  --sidebar: #151a21;
  --sidebar-2: #1c232c;
  --sidebar-ink: #c3cad4;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 27, 36, .06), 0 8px 24px rgba(20, 27, 36, .05);
  --shadow-sm: 0 1px 2px rgba(20, 27, 36, .08);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 16.5px; }
h3 { font-size: 15px; }

code, pre {
  font-family: "Cascadia Code", "Consolas", "SFMono-Regular", monospace;
  font-size: 12.5px;
}
code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}
pre {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow: auto;
  max-height: 420px;
  margin: 10px 0 0;
}

.icon { vertical-align: -2px; flex: 0 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  height: 64px; padding: 0 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 11px;
  color: var(--ink); text-decoration: none; margin-right: auto;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #1f9d73, #11644b);
  color: #fff; font-weight: 800; font-size: 14px; letter-spacing: .02em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15.5px; letter-spacing: -.01em; }
.brand-text small { color: var(--muted); font-size: 11.5px; }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.source-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 12px; white-space: nowrap;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px rgba(43,182,115,.16);
  flex: 0 0 auto;
}
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px 4px 4px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-strong);
  display: grid; place-items: center; font-weight: 700; font-size: 12.5px;
}
.user-name { display: flex; flex-direction: column; line-height: 1.1; font-size: 12.5px; }
.user-name small { color: var(--muted); font-size: 10.5px; }
.logout-form { margin: 0; }
.logout-label { margin-left: 4px; }

.conn-form { margin: 0; }
.conn-select {
  max-width: 190px; padding: 6px 26px 6px 9px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--ink-soft); font-size: 12.5px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #7b8490 50%),
                    linear-gradient(135deg, #7b8490 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.nav-toggle {
  display: none; width: 38px; height: 38px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 17px; cursor: pointer; color: var(--ink-soft);
}

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 246px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar {
  position: sticky; top: 64px; align-self: start;
  height: calc(100vh - 64px);
  background: var(--sidebar);
  padding: 18px 12px;
  display: flex; flex-direction: column; gap: 18px;
  overflow-y: auto;
}
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 8px;
  color: var(--sidebar-ink); font-size: 13.5px;
  text-decoration: none; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--sidebar-2); color: #fff; text-decoration: none; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(43,182,115,.18), rgba(43,182,115,.06));
  color: #fff; box-shadow: inset 3px 0 0 var(--accent);
}
.nav-item.active .icon { color: var(--accent); }
.sidebar-note {
  margin-top: auto; padding: 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px; color: #8d97a4; font-size: 11.5px; line-height: 1.45;
  background: rgba(255,255,255,.02);
}
.main { padding: 26px clamp(16px, 2.4vw, 34px) 44px; min-width: 0; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.page-actions { display: flex; gap: 8px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin-bottom: 18px; overflow: hidden;
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 16px 18px 0;
}
.card-sub { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.card-actions { display: flex; gap: 8px; flex-shrink: 0; }
.card-body { padding: 14px 18px 18px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 .card { margin-bottom: 0; }

.stats-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow-sm);
}
.stat-label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.stat-hint { color: var(--muted); font-size: 11.5px; }

.state-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.state-dot { width: 10px; height: 10px; border-radius: 50%; }
.state-success { background: var(--accent); box-shadow: 0 0 0 4px rgba(43,182,115,.16); }
.state-error { background: var(--danger); box-shadow: 0 0 0 4px rgba(180,35,24,.12); }
.blockers {
  margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--warn-soft); border: 1px solid #f2dfa8; color: #6b4a00;
}
.blockers ul { margin: 6px 0 0; padding-left: 20px; }

.quick-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.quick {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  color: var(--ink); text-decoration: none; box-shadow: var(--shadow-sm);
  transition: border-color .12s, transform .12s;
}
.quick:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-1px); }
.quick .icon { color: var(--brand); }
.quick span { display: flex; flex-direction: column; line-height: 1.25; }
.quick small { color: var(--muted); font-size: 11.5px; }

.kpi-note {
  margin: -4px 0 18px; color: var(--muted); font-size: 12px;
  padding: 10px 14px; background: var(--surface-2);
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 4px -18px -18px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 600; color: var(--muted);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 14px; border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line); background: var(--surface-2);
  white-space: nowrap;
}
.table td {
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table tbody tr:hover { background: #fafcfb; }
.table tbody tr:last-child td { border-bottom: 0; }
.col-date { white-space: nowrap; color: var(--ink-soft); }
.col-num { white-space: nowrap; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.col-status { white-space: nowrap; }
.col-qty { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.col-inn { white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-action { text-align: right; }
.cell-main { font-weight: 550; }
.cell-sub { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.cell-hint {
  display: inline-block; margin-left: 6px; padding: 0 5px;
  font-size: 10px; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface-2); vertical-align: 1px;
}
.num { text-align: right; font-variant-numeric: tabular-nums; }
.wrap-cell { white-space: normal; min-width: 220px; color: var(--ink-soft); }
.row-link { color: var(--ink); font-weight: 550; }
.row-link:hover { color: var(--brand); }
.empty-state {
  padding: 30px 18px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  margin: 6px 0; background: var(--surface-2);
}
.empty-state strong { display: block; color: var(--ink-soft); margin-bottom: 4px; }
.empty-state p { margin: 0; font-size: 12.5px; }
.empty-inline { color: var(--muted); padding: 10px 0; font-size: 13px; }

/* ---------- Badges & refs ---------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-success { background: var(--brand-soft); color: var(--brand-strong); border-color: #bfe7d4; }
.badge-error { background: var(--danger-soft); color: var(--danger); border-color: #f5c9c5; }
.badge-accent { background: #eef8f2; color: #1b6a4f; border-color: #c9e9d8; }
.badge-neutral { background: #eef1f4; color: #4d5866; border-color: #dde2e8; }
.badge-muted { background: #eef1f4; color: #4f5a68; border-color: #dde2e8; }
.badge-info { background: var(--info-soft); color: #1e40af; border-color: #d5e2ff; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: #f2dfa8; }

.ref {
  display: inline-flex; align-items: center; gap: 4px;
  max-width: 260px; vertical-align: bottom;
}
.ref-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-resolve {
  border: 0; background: none; padding: 0 2px; cursor: pointer;
  color: var(--muted); line-height: 1; border-radius: 4px;
}
.ref-resolve:hover { color: var(--brand); background: var(--brand-soft); }
.ref-resolve[disabled] { opacity: .4; cursor: default; }

/* ---------- Alerts ---------- */
.alert {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2);
  margin-bottom: 14px;
}
.alert-icon { margin-top: 1px; }
.alert-body { min-width: 0; }
.alert-body strong { display: block; }
.alert-body p { margin: 3px 0 0; color: var(--ink-soft); font-size: 13px; }
.alert-error { background: var(--danger-soft); border-color: #f5c9c5; color: var(--danger); }
.alert-warn { background: var(--warn-soft); border-color: #f2dfa8; color: var(--warn); }
.alert-success { background: var(--brand-soft); border-color: #bfe7d4; color: var(--brand-strong); }
.alert-info { background: var(--info-soft); border-color: #d5e2ff; color: #1e40af; }
.err-code { margin-left: 8px; background: rgba(255,255,255,.7); border-color: currentColor; }

.notice {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 12.5px; margin: 8px 0 14px;
}
.notice-warn { background: var(--warn-soft); border: 1px solid #f2dfa8; color: #6b4a00; }
.notice-info { background: var(--info-soft); border: 1px solid #d5e2ff; color: #1e40af; }

/* ---------- Filters & forms ---------- */
.filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
  margin-bottom: 14px;
}
.filters-inline .filter-search { flex: 1 1 320px; }
.filter-field { display: flex; flex-direction: column; gap: 4px; min-width: 132px; }
.filter-field label, .form-field label {
  font-size: 11.5px; color: var(--muted); font-weight: 600;
}
.filter-field input, .filter-field select,
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 13.5px;
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.filter-field input:focus, .filter-field select:focus,
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22,122,91,.12);
}
.filter-search { flex: 1 1 260px; }
.filter-limit { min-width: 90px; }
.filter-actions { display: flex; gap: 8px; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.span-2 { grid-column: span 2; }
.form-field textarea { resize: vertical; }
.form-hint { color: var(--muted); font-size: 11.5px; }
.req { color: var(--danger); }
.opt { color: var(--muted); font-weight: 400; }
.form-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
}
.filter-details { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.filter-details summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.filter-details p { margin: 6px 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid transparent; font: inherit; font-size: 13.5px;
  font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s, color .12s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-strong); background: var(--brand-soft); }
.btn-sm { padding: 5px 9px; font-size: 12px; border-radius: 7px; }
.btn-lg { padding: 11px 20px; font-size: 14.5px; }
.btn-block { width: 100%; justify-content: center; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--muted); cursor: pointer; font-size: 17px;
  line-height: 1;
}
.icon-btn:hover { color: var(--danger); border-color: #f5c9c5; background: var(--danger-soft); }

/* ---------- Record card ---------- */
.record-head { margin-bottom: 14px; }
.record-title { font-size: 22px; margin-bottom: 6px; }
.record-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.record-id { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.copy-btn {
  border: 0; background: none; color: var(--brand); cursor: pointer;
  font-size: 11.5px; padding: 0; text-decoration: underline;
}
.anonym-note {
  display: flex; gap: 7px; align-items: center;
  padding: 8px 12px; margin-bottom: 14px;
  background: var(--warn-soft); border: 1px solid #f2dfa8;
  border-radius: var(--radius-sm); color: #6b4a00; font-size: 12px;
}
.kv {
  display: grid; grid-template-columns: 220px minmax(0, 1fr);
  gap: 0; margin: 0;
}
.field-row {
  display: contents;
}
.field-row dt {
  padding: 8px 14px 8px 0; color: var(--muted); font-size: 12px;
  border-bottom: 1px solid var(--line); font-weight: 600;
}
.field-row dd {
  margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line);
  min-width: 0; overflow-wrap: anywhere;
}
.kv-card .field-row:last-of-type dt,
.kv-card .field-row:last-of-type dd { border-bottom: 0; }
.field-hint { display: block; color: var(--muted); font-size: 11px; }
.text-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.raw { margin-top: 14px; }
.raw summary { cursor: pointer; color: var(--muted); font-size: 12px; }

.plain-list { margin: 0; padding-left: 18px; }
.plain-list li { margin: 3px 0; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li {
  display: grid; grid-template-columns: 26px 1fr; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
  counter-increment: step;
}
.steps li > div { min-width: 0; }
.steps li:last-child { border-bottom: 0; }
.steps li::before {
  content: counter(step);
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-strong);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700;
}
.steps li span { display: block; color: var(--muted); font-size: 12px; }

/* ---------- Documents ---------- */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.doc-main .card, .doc-side .card { margin-bottom: 16px; }
.doc-form .type-search {
  padding: 12px 14px; margin-bottom: 14px;
  background: var(--surface-2); border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}
.type-search label { font-size: 11.5px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 5px; }
.inline-input { display: flex; gap: 8px; }
.inline-input input { flex: 1; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; font: inherit; }
.contractor-search { position: relative; }
.selected-contractor { margin-top: 7px; min-height: 0; }
.chip {
  display: inline-flex; padding: 3px 9px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-strong);
  border: 1px solid #bfe7d4; font-size: 12px; font-weight: 600;
}
.pick-list {
  list-style: none; margin: 8px 0 0; padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden; max-height: 280px; overflow-y: auto;
}
.pick-list li { border-bottom: 1px solid var(--line); }
.pick-list li:last-child { border-bottom: 0; }
.pick {
  width: 100%; text-align: left; border: 0; background: var(--surface);
  padding: 9px 12px; cursor: pointer; font: inherit;
  display: flex; flex-direction: column; gap: 1px;
}
.pick:hover { background: var(--brand-soft); }
.pick span { color: var(--muted); font-size: 11.5px; }
.positions-editor { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.positions-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.positions-table { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.pos-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 110px 120px 34px;
  gap: 8px; align-items: center;
}
.pos-row input {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line-strong);
  border-radius: 7px; font: inherit; font-size: 12.5px;
}
.pos-header { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.pos-header span { padding-left: 2px; }
.confirm-form { margin-top: 18px; }
.report-form textarea { font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; }

/* ---------- Reports ---------- */
.report-body { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.report-table th, .report-table td {
  border: 1px solid var(--line); padding: 6px 9px; text-align: left;
  vertical-align: top;
}
.report-table th { background: var(--surface-2); font-weight: 600; }
.report-table td.num, .report-table th.num { text-align: right; }
.report-meta { color: var(--muted); font-size: 11.5px; margin: 10px 0 0; }
.md-list { margin: 6px 0; padding-left: 20px; }
.small-code { font-size: 11.5px; }

/* ---------- Messenger ---------- */
.messenger-frame-wrap {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2); margin-top: 8px;
}
.messenger-frame { width: 100%; height: 520px; border: 0; display: block; }
.messenger-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center; padding: 34px 18px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink-soft); margin-top: 8px;
}
.messenger-placeholder h3 { margin: 0; }
.messenger-placeholder p { margin: 0; max-width: 520px; color: var(--muted); }
.messenger-placeholder .icon { color: var(--brand); }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--line); background: var(--surface);
  padding: 12px 22px; margin-left: 246px;
}
.footer-inner {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  color: var(--muted); font-size: 11.5px; align-items: center;
}
.footer-version { margin-left: auto; }
.footer-link { color: var(--muted); }

/* ---------- Login ---------- */
.login-body { background: #0f141a; min-height: 100vh; }
.login-shell {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  min-height: 100vh;
}
.login-aside {
  padding: 44px clamp(28px, 5vw, 72px);
  background:
    radial-gradient(1200px 500px at -10% -20%, rgba(43,182,115,.24), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(22,122,91,.22), transparent 55%),
    #10161d;
  color: #e8edf2; display: flex; flex-direction: column;
}
.brand-light { color: #fff; margin-bottom: 56px; }
.brand-light .brand-text small { color: #9aa6b3; }
.login-aside h1 { font-size: clamp(28px, 3.4vw, 42px); line-height: 1.14; margin: 0 0 16px; }
.login-aside > p { color: #a9b4c0; max-width: 520px; font-size: 14.5px; }
.login-points { list-style: none; margin: 32px 0 0; padding: 0; max-width: 520px; }
.login-points li {
  display: flex; gap: 12px; align-items: baseline;
  padding: 11px 0; border-top: 1px solid rgba(255,255,255,.08);
  color: #c9d2dc; font-size: 13.5px;
}
.login-points span {
  font-size: 11px; color: var(--accent); font-weight: 700; letter-spacing: .06em;
}
.login-status {
  margin-top: auto; padding-top: 26px;
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: #9aa6b3;
}
.login-status-down .dot { background: #f97066; box-shadow: 0 0 0 3px rgba(249,112,102,.18); }
.login-main {
  background: var(--surface); padding: 44px clamp(24px, 4vw, 60px);
  display: flex; flex-direction: column; justify-content: center;
}
.login-main > * { max-width: 420px; width: 100%; margin-left: auto; margin-right: auto; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.login-head { margin-bottom: 6px; }
.login-head h2 { font-size: 22px; letter-spacing: -.02em; }
.login-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.login-form .form-field label { font-size: 12px; color: var(--ink-soft); }
.login-form input { padding: 10px 12px; font-size: 14px; }
.login-links {
  display: flex; flex-direction: column; gap: 6px; margin-top: 18px;
  font-size: 12.5px;
}
.login-foot { margin-top: 24px; color: var(--muted); font-size: 11.5px; line-height: 1.5; }

/* ---------- Misc ---------- */
.nav-backdrop {
  position: fixed; inset: 0; background: rgba(15,20,26,.45); z-index: 45;
}
[hidden] { display: none !important; }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1020px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 64px; z-index: 50;
    width: 260px; transform: translateX(-102%);
    transition: transform .18s ease; box-shadow: 8px 0 30px rgba(0,0,0,.25);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .nav-toggle { display: inline-grid; place-items: center; }
  .footer { margin-left: 0; }
  .doc-layout { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .logout-label { display: none; }
}
@media (max-width: 760px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .brand-text small { display: none; }
  .source-chip { display: none; }
  .conn-select { max-width: 120px; }
  .main { padding: 18px 12px 36px; }
  .stats-grid, .quick-grid { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 1fr; }
  .field-row dt { border-bottom: 0; padding-bottom: 0; }
  .field-row dd { padding-top: 2px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.span-2 { grid-column: auto; }
  .filters { flex-direction: column; align-items: stretch; }
  .filter-actions { justify-content: flex-start; flex-wrap: wrap; }
  .pos-row { grid-template-columns: 1fr 82px 92px 30px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .login-main { padding: 32px 20px; min-height: 100vh; }
  .page-head { flex-wrap: wrap; }
  .card-head { flex-wrap: wrap; }
  .card-actions { width: 100%; justify-content: flex-start; }
}
@media (max-width: 560px) {
  .brand-text, .user-chip, .conn-form { display: none; }
  .topbar { height: 64px; }
  .topbar-right { gap: 0; }
  .sidebar { top: 64px; height: calc(100vh - 64px); }
}


/* ==========================================================================
   Turbo RAG reference theme (95.31.12.40:8011): graphite header, green accents,
   light background, top tabs. Appended last so it overrides the base theme.
   ========================================================================== */
:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --ink: #17181c;
  --ink-soft: #2e3038;
  --muted: #5c6070;
  --line: #e3e4e8;
  --line-strong: #d7d9e0;
  --brand: #1b7f6b;
  --brand-strong: #146352;
  --brand-soft: #e9f7f2;
  --accent: #3bb888;
  --danger: #b00020;
  --danger-soft: #fdf0f1;
  --warn: #8a5a00;
  --warn-soft: #fff8e6;
  --info: #1d4ed8;
  --info-soft: #eff4ff;
  --header: #2f3039;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(23,24,28,.05), 0 8px 24px rgba(23,24,28,.04);
  --shadow-sm: 0 1px 2px rgba(23,24,28,.05);
}

body { background: var(--bg); color: var(--ink); }

a { color: var(--brand); }

/* Header */
.topbar {
  height: 64px;
  background: var(--header);
  border-bottom: 0;
  box-shadow: 0 2px 10px rgba(23,24,28,.18);
  padding: 0 clamp(12px, 2vw, 32px);
  gap: 14px;
}
.brand { color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: #3bb888; color: #142620; font-size: 16px;
  box-shadow: none;
}
.brand-text strong { color: #fff; font-size: 18px; }
.brand-text small { color: #b6bac4; }
.topbar-right { gap: 8px; }
.source-chip {
  background: transparent; border-color: rgba(255,255,255,.22);
  color: #d8dbe2;
}
.source-chip .dot { background: #3bb888; box-shadow: 0 0 0 3px rgba(59,184,136,.2); }
.conn-select {
  background-color: #fff; color: #17181c;
  border-color: rgba(255,255,255,.45);
}
.user-chip {
  background: transparent; border-color: rgba(255,255,255,.22); color: #fff;
}
.user-name { color: #fff; }
.user-name small { color: #b6bac4; }
.avatar { background: #3bb888; color: #142620; }
.topbar-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: #8fe3c6; font-size: 12.5px; text-decoration: none;
  padding: 6px 8px; border-radius: 7px; white-space: nowrap;
}
.topbar-link:hover { background: rgba(255,255,255,.1); text-decoration: none; color: #b7f3dc; }
.btn-top { background: #3bb888; border-color: #3bb888; color: #142620; font-weight: 600; }
.btn-top:hover { background: #2fa87c; border-color: #2fa87c; color: #142620; }
.btn-green { background: #3bb888; border-color: #3bb888; color: #142620; font-weight: 600; }
.btn-green:hover { background: #2fa87c; border-color: #2fa87c; color: #142620; }
.btn-primary { background: #2e3038; border-color: #2e3038; color: #fff; }
.btn-primary:hover { background: #1f2128; border-color: #1f2128; }
.btn-ghost { background: #fff; color: #2e3038; border-color: #d7d9e0; }
.btn-ghost:hover { background: #f1f2f4; border-color: #bfc3cc; color: #17181c; }
.btn-sm { padding: 5px 10px; }

/* Tabs */
.tabs {
  display: flex; gap: 2px; flex-wrap: nowrap;
  overflow-x: auto; background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 clamp(12px, 2vw, 32px);
  position: sticky; top: 64px; z-index: 30;
  scrollbar-width: thin;
}
.tab {
  display: inline-flex; align-items: center;
  padding: 11px 15px; border-bottom: 2px solid transparent;
  color: var(--muted); text-decoration: none; font-size: 13.5px;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--ink); border-bottom-color: #3bb888; }

/* Page shell */
.shell { display: block; min-height: auto; }
.sidebar, .nav-toggle, .nav-backdrop { display: none !important; }
.main {
  max-width: 1760px; margin: 0 auto;
  padding: 24px clamp(16px, 2.5vw, 32px) 48px;
}
.page-head { margin-bottom: 18px; align-items: center; }
.page-head h1 { font-size: 24px; letter-spacing: -.02em; }

.card {
  border-color: var(--line); border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
.card-head { padding: 16px 20px 0; }
.card-body { padding: 14px 20px 20px; }
.card h2 { font-size: 16px; }
.stat { border-color: var(--line); border-radius: 10px; box-shadow: var(--shadow-sm); }
.stat-value { font-size: 21px; }
.quick { border-color: var(--line); border-radius: 10px; box-shadow: var(--shadow-sm); }
.quick:hover { border-color: #3bb888; }
.quick .icon { color: #1b7f6b; }
.table-wrap { margin: 4px -20px -20px; }
.table th { background: #f7f7f8; color: var(--muted); border-color: var(--line); }
.table td { border-color: #e9eaee; }
.table tbody tr:hover { background: #fafbfc; }
.badge-success { background: #e9f7f2; color: #146352; border-color: #bfe7d4; }
.badge-accent { background: #e9f7f2; color: #146352; border-color: #bfe7d4; }
.badge-muted { background: #f0f1f4; color: #4f5665; border-color: #e1e3e8; }
.alert { border-radius: 8px; }
.footer { margin-left: 0; border-color: var(--line); }
.footer-inner { max-width: 1760px; margin: 0 auto; }

/* Login: compact form in the graphite header, light content below */
.login-body { background: var(--bg); }
.login-topbar {
  height: auto; min-height: 64px; flex-wrap: wrap;
  padding: 8px clamp(12px, 2vw, 32px); row-gap: 8px;
}
.login-inline { flex: 1 1 680px; min-width: 0; }
.login-form-inline {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
}
.login-form-inline input {
  width: 165px; height: 38px; padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.3); border-radius: 7px;
  background: #fff; color: #17181c; font: inherit; font-size: 13px;
}
.login-form-inline input.login-company { width: 220px; }
.login-form-inline input:focus {
  outline: 2px solid #3bb888; border-color: #3bb888;
}
.login-form-inline .btn { height: 38px; }
.login-admin-link { flex: 0 0 auto; }
.login-main {
  display: block; max-width: 1380px;
  margin: 24px auto 40px; padding: 0 clamp(16px, 2.5vw, 32px);
  min-height: 0;
}
.login-main .card { margin-bottom: 18px; }
.login-intro-grid {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(220px, 1fr);
  gap: 28px; align-items: start;
}
.login-intro-grid p { margin-top: 0; }
.login-server {
  display: flex; flex-direction: column; gap: 5px;
  padding: 14px 16px; border: 1px solid var(--line);
  border-radius: 9px; background: #f7f7f8;
}
.login-server strong { font-size: 16px; }
.login-server code { align-self: flex-start; }
.login-server .badge { align-self: flex-start; margin-top: 4px; }
.login-status { display: inline-flex; align-items: center; gap: 7px; }
.login-status.ok .dot { background: #3bb888; }
.login-status.down .dot { background: #f97066; }
.login-head, .login-links { display: none; }

/* Admin */
.admin-login-main {
  display: flex; justify-content: center; align-items: flex-start;
  min-height: calc(100vh - 64px - 47px); padding-top: 56px;
}
.admin-login-card {
  width: min(470px, 100%); background: #fff;
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 26px 28px;
}
.admin-login-card h1 { font-size: 22px; margin-bottom: 4px; }
.admin-login-form { margin-top: 16px; }
.admin-login-form .form-field label { color: var(--ink-soft); }
.inline-form { display: inline-block; margin: 0; }
.inline-form + .inline-form { margin-left: 4px; }
.admin-form .form-grid { margin-top: 4px; }
.radio-row { display: flex; flex-direction: column; gap: 9px; margin: 10px 0 4px; }
.radio-row label {
  display: flex; gap: 8px; align-items: flex-start;
  color: var(--ink); font-size: 13.5px;
}
.radio-row input { margin-top: 3px; accent-color: #3bb888; }
.check-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px; margin: 14px 0 4px;
}
.check {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; cursor: pointer;
}
.check:hover { border-color: #3bb888; }
.check input { margin-top: 3px; accent-color: #3bb888; }
.check span { display: flex; flex-direction: column; gap: 1px; }
.check small { color: var(--muted); font-size: 11.5px; }
.admin-app .page-head h1 { font-size: 24px; }

@media (max-width: 1020px) {
  .login-inline { flex-basis: 100%; }
  .login-form-inline input { width: auto; flex: 1 1 170px; }
  .login-intro-grid { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { height: auto; min-height: 64px; flex-wrap: wrap; padding: 8px 12px; row-gap: 8px; }
  .tabs { top: 0; position: static; padding: 0 12px; }
  .main { padding: 18px 12px 36px; }
  .login-form-inline { width: 100%; }
  .login-form-inline input, .login-form-inline input.login-company { width: 100%; flex: 1 1 100%; }
  .login-form-inline .btn { width: 100%; justify-content: center; }
  .login-main { margin-top: 16px; }
  .admin-login-main { padding-top: 20px; }
  .source-chip { display: none; }
}
@media (max-width: 560px) {
  .brand-text, .user-name, .conn-form { display: none; }
  .topbar { height: auto; }
  .topbar-link span { display: none; }
  .logout-label { display: none; }
}

/* Old split-login rule constrained every child to 420px; the reference
   layout uses full-width cards below the header. */
.login-main > * {
  max-width: none;
  width: auto;
  margin-left: 0;
  margin-right: 0;
}

/* Demo login button (reference header style) */
.login-forms {
  display: flex; align-items: center; gap: 7px;
  flex-wrap: wrap; min-width: 0;
}
.demo-form { margin: 0; }
.btn-demo {
  height: 38px; background: transparent;
  border-color: rgba(255,255,255,.45);
  color: #8fe3c6; font-weight: 400;
}
.btn-demo:hover {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.65);
  color: #b7f3dc;
}
@media (max-width: 760px) {
  .login-forms { width: 100%; }
  .demo-form, .demo-form .btn { width: 100%; }
  .demo-form .btn { justify-content: center; }
}

/* ===== Our Services dropdown (Turbo RAG reference) ===== */
.svcmenu { position: relative; display: inline-flex; flex: 0 0 auto; }
.svc-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent; color: #fff; cursor: pointer;
  border: 1px solid rgba(255,255,255,.32); border-radius: 8px;
  padding: 6px 11px; font: inherit; font-size: 12.5px; line-height: 1.2;
  white-space: nowrap;
}
.svc-btn:hover, .svcmenu.open .svc-btn {
  background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.5);
}
.svc-btn:focus-visible { outline: 2px solid #8fe3c6; outline-offset: 1px; }
.svc-caret { display: inline-flex; opacity: .8; transition: transform .15s ease; }
.svcmenu.open .svc-caret { transform: rotate(180deg); }
.svc-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 90;
  display: none; min-width: 318px; background: #fff; color: #17181c;
  border: 1px solid #dfe2ea; border-radius: 12px; padding: 6px;
  box-shadow: 0 18px 44px rgba(18,22,33,.30);
}
.svcmenu.open .svc-panel { display: block; }
.svc-panel a {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 10px; border-radius: 9px; color: #17181c;
  text-decoration: none;
}
.svc-panel a:hover, .svc-panel a:focus-visible { background: #eef8f4; }
.svc-panel a:hover .svc-name { color: #17624d; }
.svc-ico {
  width: 28px; height: 28px; flex: 0 0 auto; border-radius: 8px;
  background: #eef8f4; color: #1b7f6b;
  display: flex; align-items: center; justify-content: center;
}
.svc-name { display: block; font-size: 13px; font-weight: 600; }
.svc-desc { display: block; margin-top: 1px; font-size: 11.5px; color: #5c6070; }
.svc-ext { margin-left: auto; padding-left: 8px; color: #9aa0ae; font-size: 12px; }
.login-topbar-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
@media (max-width: 1020px) {
  .svc-label { display: none; }
  .svc-panel { min-width: min(318px, calc(100vw - 24px)); }
}
@media (max-width: 560px) {
  .svc-btn { padding: 6px 8px; }
  .login-topbar-right { margin-left: auto; }
}

/* ===== Top bar: reference two-line layout ===== */
.topbar {
  height: auto; padding: 0; display: block;
}
.topbar-inner {
  width: 100%; padding: 12px 32px;
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 10px 14px;
}
.topbar-inner > .brand { flex: 0 0 100%; }
.topbar-controls {
  display: flex; align-items: center; gap: 8px;
  width: 100%; flex-wrap: wrap;
}
.topbar-controls .svcmenu { margin-left: auto; }
.login-controls .login-inline { flex: 1 1 auto; min-width: 0; }
.login-controls .login-topbar-right { margin-left: 0; }
.tabs { position: static; top: auto; }
@media (max-width: 760px) {
  .topbar-inner { padding: 10px 14px; }
  .topbar-controls { gap: 7px; }
}

.topbar-controls { justify-content: flex-end; }
.topbar-controls > .conn-form { margin-right: auto; }
.topbar-controls .svcmenu { margin-left: 0; }

/* Dropdown must stay above tabs and fit the viewport */
.topbar { z-index: 60; }
.svcmenu.open { z-index: 70; }
.svc-panel {
  z-index: 100;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ===== «Наши Сервисы»: раскладка как на 95.31.12.40:8011 ===== */
.svc-panel {
  width: min(740px, calc(100vw - 20px));
  min-width: 0;
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.svc-group {
  padding: 8px 9px 3px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: #8a90a0;
}
.svc-group:not(:first-child) {
  margin-top: 4px; border-top: 1px solid #eef0f6;
}
.svc-panel a {
  align-items: baseline; gap: 9px; padding: 7px 9px;
}
.svc-ico {
  width: 26px; height: 26px; align-self: center;
}
.svc-name {
  display: inline; white-space: nowrap; line-height: 1.25;
}
.svc-desc {
  display: inline; margin-top: 0; white-space: normal; line-height: 1.3;
}
.svc-desc::before {
  content: "· "; color: #9aa0ae;
}
.svc-ext { padding-left: 10px; }
@media (max-width: 900px) {
  .svc-panel { width: min(560px, calc(100vw - 20px)); }
  .svc-panel a { flex-wrap: wrap; }
}
@media (max-width: 700px) {
  .svc-panel { width: calc(100vw - 20px); }
}
