:root {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #121c2e;
  --surface-2: #18243a;
  --border: rgba(255,255,255,.1);
  --text: #f8fafc;
  --muted: #a8b3c5;
  --primary: #22c55e;
  --primary-hover: #34d66d;
  --danger: #ef4444;
  --warning: #f59e0b;
  --focus: #93c5fd;
  --shadow: 0 18px 60px rgba(0,0,0,.24);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100dvh; background: radial-gradient(circle at 80% -10%, rgba(34,197,94,.10), transparent 28rem), var(--bg); color: var(--text); line-height: 1.5; }
a { color: inherit; }
button, input, select { font: inherit; }
button, .button { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; transform: translateY(-160%); padding: 10px 14px; border-radius: 8px; background: white; color: #0f172a; }
.skip-link:focus { transform: translateY(0); }
.topbar { height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 max(24px, calc((100vw - 1180px)/2)); border-bottom: 1px solid var(--border); background: rgba(11,18,32,.88); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 17px; letter-spacing: -.02em; }
.brand strong { color: var(--primary); }
nav { display: flex; align-items: center; gap: 8px; }
nav > a, .nav-button { min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); text-decoration: none; cursor: pointer; }
nav > a:hover, .nav-button:hover, nav > a[aria-current="page"] { background: var(--surface); color: var(--text); }
nav form { margin: 0; }
.shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 48px 0 72px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 28px; }
.page-head.compact { align-items: center; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(30px, 4vw, 44px); line-height: 1.12; letter-spacing: -.04em; }
h2 { margin-bottom: 4px; font-size: 19px; letter-spacing: -.02em; }
h3 { margin-bottom: 6px; }
.eyebrow { margin-bottom: 10px; color: var(--primary); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.lede, .panel-head p, .muted { color: var(--muted); }
.lede { margin-bottom: 0; }
.back-link { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--text); }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 17px; border: 1px solid transparent; border-radius: 10px; font-weight: 650; text-decoration: none; cursor: pointer; transition: background-color .18s ease, border-color .18s ease, color .18s ease, opacity .18s ease; }
.button-primary { background: var(--primary); color: #07140c; }
.button-primary:hover { background: var(--primary-hover); }
.button-secondary { border-color: var(--border); background: var(--surface); color: var(--text); }
.button-secondary:hover { background: var(--surface-2); }
.button-danger { background: var(--danger); color: white; }
.button-full { width: 100%; }
.button:disabled { opacity: .55; cursor: wait; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stats article { padding: 18px 20px; border: 1px solid var(--border); border-radius: 12px; background: rgba(18,28,46,.72); }
.stats span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.stats strong { font-size: 28px; font-variant-numeric: tabular-nums; }
.success-text { color: var(--primary); }
.danger-text { color: #f87171; }
.panel { border: 1px solid var(--border); border-radius: 14px; background: rgba(18,28,46,.88); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { min-height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-head h2, .panel-head p { margin-bottom: 0; }
.panel-head p { margin-top: 3px; font-size: 13px; }
.topology-panel { margin-bottom: 18px; }
.topology-explainer { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 18px; padding: 14px 18px; border: 1px solid var(--border); border-radius: 12px; background: rgba(18,28,46,.58); color: var(--muted); }
.topology-explainer strong { color: var(--text); }
.topology-explainer i { color: var(--primary); font-style: normal; }
.node-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; padding: 18px; }
.node-card { min-width: 0; display: grid; gap: 7px; padding: 17px; border: 1px solid var(--border); border-radius: 11px; background: rgba(11,18,32,.62); color: inherit; text-decoration: none; transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease; }
.node-card:hover { border-color: rgba(34,197,94,.42); background: rgba(24,36,58,.9); box-shadow: 0 10px 28px rgba(0,0,0,.18); }
.node-card strong { font-size: 17px; }
.node-card code { overflow-wrap: anywhere; }
.node-card small { color: var(--muted); }
.node-role { color: var(--primary); font-size: 11px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.empty-inline { padding: 10px 2px; color: var(--muted); }
.compact-empty { padding: 36px 24px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 11px 18px; color: var(--muted); background: rgba(255,255,255,.018); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
td { padding: 16px 18px; border-top: 1px solid var(--border); color: #dbe4f0; }
tbody tr:hover { background: rgba(255,255,255,.025); }
.server-link { font-weight: 650; text-decoration: none; }
.server-link:hover { color: var(--primary); }
code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; color: #c9d7e8; font-size: .91em; }
.wrap-code { overflow-wrap: anywhere; }
.status { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--muted); font-size: 13px; font-weight: 650; }
.status i { width: 8px; height: 8px; border-radius: 999px; background: #64748b; box-shadow: 0 0 0 3px rgba(100,116,139,.14); }
.status-online i { background: var(--primary); box-shadow: 0 0 0 3px rgba(34,197,94,.14); }
.status-error i { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.14); }
.status-installing i, .status-checking i, .status-queued i { background: var(--warning); box-shadow: 0 0 0 3px rgba(245,158,11,.14); }
.status-importing i { background: #60a5fa; box-shadow: 0 0 0 3px rgba(96,165,250,.14); }
.route-state { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap; }
.route-available { border-color: rgba(34,197,94,.3); background: rgba(34,197,94,.08); color: #86efac; }
.route-pending { border-color: rgba(245,158,11,.28); background: rgba(245,158,11,.08); color: #fcd34d; }
.route-error { border-color: rgba(239,68,68,.3); background: rgba(239,68,68,.08); color: #fca5a5; }
.subscription-mark { display: block; margin-top: 6px; color: var(--primary); font-size: 11px; font-weight: 700; }
.empty-state { padding: 64px 24px; text-align: center; }
.empty-state img { margin-bottom: 14px; color: var(--muted); }
.empty-state p { color: var(--muted); }
.form-panel { max-width: 820px; padding: 24px; overflow: visible; }
fieldset { margin: 0 0 28px; padding: 0 0 28px; border: 0; border-bottom: 1px solid var(--border); }
fieldset:last-of-type { margin-bottom: 22px; padding-bottom: 0; border-bottom: 0; }
legend { margin-bottom: 17px; font-weight: 700; font-size: 17px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.form-grid.three { grid-template-columns: 2fr .7fr 1fr; }
.field { min-width: 0; }
.field.wide { grid-column: span 2; }
label { display: block; margin-bottom: 7px; color: #dce5f0; font-size: 14px; font-weight: 600; }
input, select { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #34435a; border-radius: 9px; background: #0c1525; color: var(--text); }
input:hover, select:hover { border-color: #4b5e77; }
input::placeholder { color: #738096; }
.field small { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }
.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.choice-card { min-height: 82px; display: flex; align-items: flex-start; gap: 12px; margin: 0; padding: 15px; border: 1px solid #34435a; border-radius: 10px; background: #0c1525; cursor: pointer; transition: border-color .18s ease, background-color .18s ease; }
.choice-card:hover { border-color: #4b5e77; }
.choice-card:has(input:checked) { border-color: rgba(34,197,94,.7); background: rgba(34,197,94,.07); }
.choice-card input { width: 18px; min-height: 18px; margin: 2px 0 0; accent-color: var(--primary); }
.choice-card span { display: grid; gap: 4px; }
.choice-card small { color: var(--muted); font-size: 12px; font-weight: 400; }
[hidden] { display: none !important; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.flash-error { border-color: rgba(239,68,68,.45); color: #fecaca; }
.flash-success { border-color: rgba(34,197,94,.4); color: #bbf7d0; }
.login-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 410px); padding: 34px; border: 1px solid var(--border); border-radius: 18px; background: rgba(18,28,46,.94); box-shadow: var(--shadow); }
.login-mark { width: 60px; height: 60px; display: grid; place-items: center; margin-bottom: 24px; border-radius: 16px; background: rgba(34,197,94,.1); }
.login-card h1 { font-size: 32px; }
.form-stack { display: grid; margin-top: 28px; }
.form-stack input { margin-bottom: 17px; }
.form-stack .button { margin-top: 8px; }
.title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.title-row h1 { margin-bottom: 0; }
.alert { margin-bottom: 18px; padding: 16px 18px; border-radius: 11px; }
.alert p { margin: 5px 0 0; overflow-wrap: anywhere; }
.alert-danger { border: 1px solid rgba(239,68,68,.38); background: rgba(127,29,29,.2); color: #fecaca; }
.detail-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; }
.data-list { margin: 0; }
.data-list div { display: grid; grid-template-columns: 145px 1fr; gap: 16px; padding: 14px 20px; border-top: 1px solid var(--border); }
.data-list div:first-child { border-top: 0; }
.data-list dt { color: var(--muted); }
.data-list dd { min-width: 0; margin: 0; text-align: right; }
.job-list { margin: 0; padding: 0; list-style: none; }
.job-list li { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 12px; padding: 13px 18px; border-top: 1px solid var(--border); }
.job-list li:first-child { border-top: 0; }
.job-list div { min-width: 0; }
.job-list strong, .job-list small { display: block; }
.job-list small, .job-list > li > span:last-child { color: var(--muted); font-size: 12px; }
.job-icon { width: 9px; height: 9px; border-radius: 50%; background: #64748b; }
.job-done { background: var(--primary); }
.job-error { background: var(--danger); }
.job-running, .job-queued { background: var(--warning); }
.retry-panel { margin-top: 18px; padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.retry-panel h2, .retry-panel p { margin-bottom: 3px; }
.retry-panel p { color: var(--muted); }
.inline-form { display: flex; gap: 10px; }
.inline-form input { min-width: 250px; }
.danger-zone { margin-top: 28px; border: 1px solid rgba(239,68,68,.22); border-radius: 12px; }
.danger-zone summary { min-height: 48px; display: flex; align-items: center; padding: 0 16px; color: #fca5a5; cursor: pointer; }
.danger-zone > div { padding: 0 16px 16px; }
.danger-zone p { color: var(--muted); }
.linked-nodes { margin-top: 18px; }
.panel-copy { margin: 0; padding: 18px 20px; }
.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; }
@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  .shell { width: min(100% - 28px, 1180px); padding-top: 30px; }
  .page-head, .retry-panel { align-items: stretch; flex-direction: column; }
  .page-head .button, .page-head form .button { width: 100%; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .choice-grid { grid-template-columns: 1fr; }
  .field.wide { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr; }
  .data-list div { grid-template-columns: 1fr; gap: 4px; }
  .data-list dd { text-align: left; }
  .inline-form { flex-direction: column; }
  .inline-form input { min-width: 0; }
  .table-wrap { overflow: visible; }
  .table-wrap table { min-width: 0; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap tr { padding: 14px 16px; border-top: 1px solid var(--border); }
  .table-wrap td { display: grid; grid-template-columns: minmax(108px, .7fr) minmax(0, 1fr); gap: 12px; align-items: start; padding: 7px 0; border: 0; overflow-wrap: anywhere; }
  .table-wrap td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
  .table-wrap td[data-label="Выходной узел"] { padding-top: 0; }
  .table-wrap td[data-label="Статус"] { padding-bottom: 0; }
  .topology-explainer { justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
