/* dynservices-domains – UI stylesheet
 * Design tokens on :root, dark theme via [data-theme="dark"] or prefers-color-scheme.
 * Component reference: docs/UI.md
 */

@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --surface-3: #f1f0ed;
  --border: #e6e4df;
  --border-strong: #d4d1cb;
  --text: #1b1a18;
  --text-2: #55524c;
  --text-3: #8b877f;
  --accent: #004994;
  --accent-hover: #003a78;
  --accent-soft: #e8f0f9;
  --accent-text: #ffffff;
  --success: #17794a; --success-soft: #e7f4ec;
  --warning: #93600a; --warning-soft: #fbf2df;
  --danger: #c22f2a;  --danger-soft: #fcebea;
  --info: #004994;    --info-soft: #e8f0f9;
  --neutral: #5c5953; --neutral-soft: #efeeeb;
  --focus: 0 0 0 3px rgba(0, 73, 148, .22);
  --shadow-sm: 0 1px 2px rgba(20, 18, 14, .05);
  --shadow-md: 0 4px 16px rgba(20, 18, 14, .08), 0 1px 3px rgba(20, 18, 14, .06);
  --shadow-lg: 0 18px 50px rgba(20, 18, 14, .18);
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar: 236px;
  --chart-1: #004994;
  --chart-2: #9fbde0;
  --chart-3: #17794a;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1012;
  --surface: #17181b;
  --surface-2: #1c1d21;
  --surface-3: #232429;
  --border: #2a2b30;
  --border-strong: #3a3b41;
  --text: #ecebe8;
  --text-2: #b4b1ab;
  --text-3: #858179;
  --accent: #8cb8ee;
  --accent-hover: #a9caf2;
  --accent-soft: #16263b;
  --accent-text: #0f1012;
  --success: #4cc286; --success-soft: #15291f;
  --warning: #e0a63e; --warning-soft: #2c2213;
  --danger: #f0716b;  --danger-soft: #331a19;
  --info: #8cb8ee;    --info-soft: #16263b;
  --neutral: #a9a59e; --neutral-soft: #26272b;
  --focus: 0 0 0 3px rgba(140, 184, 238, .3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
  --chart-1: #8cb8ee;
  --chart-2: #2c4566;
  --chart-3: #4cc286;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1012; --surface: #17181b; --surface-2: #1c1d21; --surface-3: #232429;
    --border: #2a2b30; --border-strong: #3a3b41;
    --text: #ecebe8; --text-2: #b4b1ab; --text-3: #858179;
    --accent: #8cb8ee; --accent-hover: #a9caf2; --accent-soft: #16263b; --accent-text: #0f1012;
    --success: #4cc286; --success-soft: #15291f; --warning: #e0a63e; --warning-soft: #2c2213;
    --danger: #f0716b; --danger-soft: #331a19; --info: #8cb8ee; --info-soft: #16263b;
    --neutral: #a9a59e; --neutral-soft: #26272b;
    --focus: 0 0 0 3px rgba(140, 184, 238, .3);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow-md: 0 4px 16px rgba(0,0,0,.35); --shadow-lg: 0 18px 50px rgba(0,0,0,.55);
    --chart-1: #8cb8ee; --chart-2: #2c4566; --chart-3: #4cc286;
    color-scheme: dark;
  }
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.011em; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 12px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
code, .mono { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto; font-size: 12.5px; line-height: 1.55; margin: 0; white-space: pre-wrap; word-break: break-word; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon-lg { width: 20px; height: 20px; }
.num, .table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.warn-text { color: var(--warning); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------------ app shell */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; background: linear-gradient(to right, var(--surface) var(--sidebar), transparent var(--sidebar)); }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 10px 12px;
}
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 6px 10px 18px; color: var(--text); }
.brand .logo { height: 43px; width: auto; display: block; }
.brand small { font-size: 11px; font-weight: 500; color: var(--text-3); letter-spacing: .02em; padding-left: 2px; }
.logo-dark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none !important; }
  :root:not([data-theme="light"]) .logo-dark { display: block !important; }
}
.brand:hover { color: var(--text); }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--text); color: var(--surface); display: grid; place-items: center; font-size: 13px; font-weight: 700; letter-spacing: -0.04em; }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--text-3); letter-spacing: 0; margin-top: -2px; }
.nav-group { margin-bottom: 14px; }
.nav-label { font-size: 11px; font-weight: 600; color: var(--text-3); padding: 0 10px 4px; letter-spacing: .02em; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 13.5px; margin-bottom: 1px;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a .count { margin-left: auto; font-size: 11.5px; font-weight: 600; min-width: 20px; text-align: center; padding: 0 6px; border-radius: 10px; background: var(--warning-soft); color: var(--warning); }
.sidebar-foot { margin-top: auto; padding: 10px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.sidebar-foot .who { min-width: 0; flex: 1; line-height: 1.25; }
.sidebar-foot .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; font-size: 13px; }
.sidebar-foot .who span { font-size: 11.5px; color: var(--text-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 28px;
  border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.topbar .search { flex: 1; max-width: 420px; position: relative; }
.topbar .search input { padding-left: 34px; background: var(--surface-2); }
.topbar .search .icon { position: absolute; left: 11px; top: 10px; color: var(--text-3); }
.topbar .spacer { flex: 1; }
.topbar .menu-toggle { display: none; }
.content { padding: 28px 32px 48px; width: 100%; max-width: 1280px; }
.content-wide { max-width: none; }

.banner { padding: 9px 32px; font-size: 13px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.banner-warning { background: var(--warning-soft); color: var(--warning); }
.banner-info { background: var(--info-soft); color: var(--info); }
.banner form { margin-left: auto; }

/* ------------------------------------------------------------------ page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-3); margin-top: 4px; font-size: 13.5px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--text-3); }
.crumbs a:hover { color: var(--text); }

/* ------------------------------------------------------------------ cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); min-height: 52px; }
.card-head h2 { font-size: 14px; }
.card-head .sub { color: var(--text-3); font-size: 12.5px; font-weight: 400; margin-left: 6px; }
.card-head .actions { display: flex; gap: 6px; align-items: center; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 8px; align-items: center; justify-content: flex-end; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 16px; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 16px; overflow: hidden; }
.kpi { padding: 16px 18px; border-right: 1px solid var(--border); min-width: 0; }
.kpi:last-child { border-right: 0; }
.kpi .label { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.kpi a.value { color: var(--text); display: block; }
.kpi a.value:hover { color: var(--accent); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--text-3); padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table td.actions { text-align: right; white-space: nowrap; width: 1%; }
.table td.check, .table th.check { width: 36px; padding-right: 0; }
.table .primary { font-weight: 500; color: var(--text); }
.table a.primary:hover { color: var(--accent); }
.table .sub { font-size: 12px; color: var(--text-3); }
.table tr.row-muted td { color: var(--text-3); }
.table tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
.table tr.row-danger td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.table input.input-sm { width: 92px; text-align: right; }
.card .table th:first-child, .card .table td:first-child { padding-left: 18px; }
.card .table th:last-child, .card .table td:last-child { padding-right: 18px; }

.dl { display: grid; grid-template-columns: 170px 1fr; gap: 9px 16px; margin: 0; font-size: 13.5px; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 1px 8px 1px 7px; border-radius: 20px; white-space: nowrap; line-height: 20px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral); }
.tag { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 0 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); line-height: 19px; border: 1px solid var(--border); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-3); }
.dot-ok { background: var(--success); }
.dot-bad { background: var(--danger); }
.dot-unknown { background: var(--border-strong); }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-3); color: var(--text); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { filter: brightness(.95); background: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; gap: 5px; }
.btn-icon { width: 34px; padding: 0; }
.btn-sm.btn-icon { width: 28px; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn.active { background: var(--surface-3); color: var(--text); }
form.inline { display: inline; }

/* ------------------------------------------------------------------ forms */
.form { max-width: 760px; }
.field { margin-bottom: 16px; }
.field > label, .label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.field .help { font-size: 12.5px; color: var(--text-3); margin-top: 5px; }
.field .error { font-size: 12.5px; color: var(--danger); margin-top: 5px; }
.field.has-error .input { border-color: var(--danger); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 14px; }
.row-2-1 { grid-template-columns: 2fr 1fr; }
.row-1-3 { grid-template-columns: 1fr 3fr; }
.input, select.input, textarea.input {
  width: 100%; height: 36px; padding: 0 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; min-height: 96px; padding: 9px 11px; line-height: 1.5; resize: vertical; }
textarea.input.mono { font-size: 12.5px; }
select.input { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b877f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input::placeholder { color: var(--text-3); }
.input-sm { height: 30px; font-size: 13px; padding: 0 8px; }
.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; height: 36px; box-shadow: none; }
.input-affix { position: relative; }
.input-affix .affix { position: absolute; right: 11px; top: 8px; color: var(--text-3); font-size: 13px; pointer-events: none; }
.input-affix .input { padding-right: 32px; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; cursor: pointer; margin-bottom: 8px; }
.check input { margin: 3px 0 0; accent-color: var(--accent); width: 15px; height: 15px; flex: none; }
.check .help { display: block; color: var(--text-3); font-size: 12.5px; }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.radio-card { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; background: var(--surface); }
.radio-card:has(input:checked) { border-color: var(--accent); box-shadow: var(--focus); }
.radio-card input { accent-color: var(--accent); margin-top: 3px; }
.radio-card strong { display: block; font-weight: 600; font-size: 13.5px; }
.radio-card span { font-size: 12.5px; color: var(--text-3); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 34px; height: 20px; border-radius: 20px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px 4px; margin: 0 0 18px; }
.fieldset legend { font-weight: 600; font-size: 13.5px; padding: 0 6px; margin-left: -6px; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input { width: auto; min-width: 150px; height: 32px; font-size: 13px; }
.filters .search-input { min-width: 240px; }

/* ------------------------------------------------------------------ tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 12px; color: var(--text-2); font-weight: 500; font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 7px; align-items: center; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11.5px; background: var(--surface-3); color: var(--text-2); padding: 0 6px; border-radius: 10px; font-weight: 600; }
.segmented { display: inline-flex; background: var(--surface-3); border-radius: var(--radius-sm); padding: 2px; gap: 2px; }
.segmented a { padding: 4px 10px; border-radius: 5px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------------ alerts / flash */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius); font-size: 13.5px; margin-bottom: 16px; border: 1px solid transparent; }
.alert .icon { margin-top: 2px; }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-error, .alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert p:last-child { margin: 0; }
.alert a { color: inherit; text-decoration: underline; }
.toasts { position: fixed; top: 14px; right: 14px; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 28px)); }
.toast { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 11px 14px 11px 12px; display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; animation: toast-in .18s ease-out; }
.toast .icon { margin-top: 2px; }
.toast-success .icon { color: var(--success); }
.toast-error .icon { color: var(--danger); }
.toast-warning .icon { color: var(--warning); }
.toast-info .icon { color: var(--info); }
.toast .close { margin-left: auto; background: none; border: 0; color: var(--text-3); cursor: pointer; padding: 0 0 0 6px; }
.toast.leaving { opacity: 0; transform: translateY(-4px); transition: all .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ dialog */
dialog.modal { border: 1px solid var(--border); border-radius: 10px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(15, 14, 12, .45); }
dialog.modal-wide { width: min(760px, calc(100vw - 32px)); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 15px; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 10px 10px; }

/* ------------------------------------------------------------------ dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 4px); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 4px; z-index: 30; display: none; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border-radius: 5px; color: var(--text); font: inherit; font-size: 13.5px; background: none; border: 0; cursor: pointer; text-align: left; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); }
.dropdown-menu .sep { height: 1px; background: var(--border); margin: 4px 0; }
.dropdown-menu .danger { color: var(--danger); }

/* ------------------------------------------------------------------ misc components */
.empty { text-align: center; padding: 44px 20px; color: var(--text-3); }
.empty .icon { width: 28px; height: 28px; color: var(--border-strong); margin-bottom: 8px; }
.empty h3 { color: var(--text); font-size: 14px; margin-bottom: 4px; }
.empty p { margin-bottom: 14px; }
.pagination { display: flex; gap: 4px; align-items: center; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-3); }
.pagination .pages { display: flex; gap: 4px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); min-height: 48px; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .meta { font-size: 12px; color: var(--text-3); }
.progress { height: 6px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.progress.bad > span { background: var(--danger); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: inherit; font-size: 11px; fill: var(--text-3); }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .bar-1 { fill: var(--chart-1); }
.chart .bar-2 { fill: var(--chart-2); }
.chart rect:hover { opacity: .85; }
.ns-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.ns-tile { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.ns-tile .host { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.ns-tile .loc { font-size: 12px; color: var(--text-3); }
.ns-tile .state { font-size: 12px; margin-top: 6px; color: var(--text-2); }
.price-cell { line-height: 1.25; }
.price-cell .sub { display: block; }
.diff-up { color: var(--danger); }
.diff-down { color: var(--success); }
.copy { cursor: pointer; }
.secret { font-family: ui-monospace, Menlo, monospace; background: var(--surface-3); border: 1px dashed var(--border-strong); padding: 8px 12px; border-radius: var(--radius-sm); display: inline-flex; gap: 10px; align-items: center; font-size: 14px; }
.domain-check { display: flex; gap: 8px; }
.domain-check .input { height: 44px; font-size: 16px; }
.domain-check .btn { height: 44px; padding: 0 18px; }
.check-result { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 14px; }
.check-result .name { font-weight: 600; font-size: 15px; }
.check-result .price { margin-left: auto; text-align: right; }
.check-result.ok { border-color: var(--success); background: var(--success-soft); }
.check-result.bad { border-color: var(--danger); background: var(--danger-soft); }
.steps { counter-reset: step; }
.step { display: grid; grid-template-columns: 28px 1fr; gap: 14px; margin-bottom: 22px; }
.step::before { counter-increment: step; content: counter(step); width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; font-weight: 600; font-size: 12.5px; border: 1px solid var(--border); }
.step h3 { margin: 3px 0 10px; }
.summary-box { position: sticky; top: 76px; }
.summary-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.5px; }
.summary-row.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-weight: 600; }

/* ------------------------------------------------------------------ auth page */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { align-items: center; padding-bottom: 22px; }
.auth-card .brand .logo { height: 64px; }
.auth-card .card-body { padding: 26px; }
.auth-card h1 { font-size: 18px; margin-bottom: 4px; }
.auth-foot { text-align: center; color: var(--text-3); font-size: 12.5px; margin-top: 16px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .grid-main { grid-template-columns: 1fr; }
  .summary-box { position: static; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; background: none; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: none; visibility: hidden; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); visibility: visible; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .topbar .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 40px; }
  .banner { padding: 9px 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpi { border-right: 0; border-bottom: 1px solid var(--border); }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  .row-2-1, .row-1-3 { grid-template-columns: 1fr; }
  .filters .input, .filters .search-input { min-width: 0; flex: 1 1 140px; }
  .hide-sm { display: none !important; }
}
@media print {
  .sidebar, .topbar, .banner, .actions, .btn { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; }
}

/* ------------------------------------------------------------------ responsive: phones
 * Tables become stacked cards. app.js copies each <th> text into td[data-label].
 * Opt out per table with .table-keep (horizontal scroll instead).
 */
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .content { padding: 16px 12px 40px; }
  h1 { font-size: 20px; }
  .page-head { margin-bottom: 16px; align-items: stretch; }
  .page-head > div:first-child { width: 100%; }
  .page-head .actions { width: 100%; }
  .page-head .actions > .btn, .page-head .actions > form, .page-head .actions > a { flex: 1 1 auto; }
  .page-head .actions form .btn { width: 100%; }
  .card-head { flex-wrap: wrap; padding: 12px 14px; }
  .card-head .actions { flex-wrap: wrap; }
  .card-body { padding: 14px; }
  .card-foot { padding: 10px 14px; flex-wrap: wrap; }
  .card-foot .btn { flex: 1 1 auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 12px 14px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .kpi:nth-child(2n) { border-right: 0; }
  .kpi .value { font-size: 19px; }
  .filters { gap: 6px; }
  .filters > * { flex: 1 1 140px; }
  .filters .segmented { flex-basis: 100%; overflow-x: auto; }
  .segmented { max-width: 100%; overflow-x: auto; }
  .segmented a { white-space: nowrap; }
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar .search { min-width: 0; }
  .topbar .btn-primary { padding: 0 11px; }
  .domain-check { flex-direction: column; }
  .check-result { flex-wrap: wrap; }
  .check-result .price { margin-left: 0; text-align: left; }
  .radio-cards { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; }
  .step { grid-template-columns: 1fr; gap: 6px; }
  .step::before { display: none; }
  dialog.modal, dialog.modal-wide { width: calc(100vw - 16px); max-height: calc(100vh - 16px); margin: auto auto 8px; }
  .modal-body { padding: 14px; }
  .toasts { top: auto; bottom: 12px; right: 8px; left: 8px; width: auto; }
  .ns-grid { grid-template-columns: 1fr; }
  .list li { padding: 10px 14px; flex-wrap: wrap; }
  .pagination { padding: 10px 14px; }
  .banner { display: block; padding: 8px 12px; line-height: 1.45; }
  .banner .icon { margin-right: 4px; }
  .banner form { margin: 6px 0 0; }
  .topbar .search { flex: 1 1 auto; max-width: none; }
  .topbar .btn .btn-label { display: none; }
  .topbar .btn { padding: 0 10px; }
  .table:not(.table-keep) td .cell-val { text-align: right; display: block; }
  .table:not(.table-keep) td .cell-val .sub { display: inline; }

  /* stacked tables */
  .table:not(.table-keep) thead { display: none; }
  .table:not(.table-keep), .table:not(.table-keep) tbody, .table:not(.table-keep) tr, .table:not(.table-keep) td { display: block; width: 100%; }
  .table:not(.table-keep) tr { padding: 10px 14px; border-bottom: 1px solid var(--border); position: relative; }
  .table:not(.table-keep) tbody tr:last-child { border-bottom: 0; }
  .table:not(.table-keep) tbody tr:hover td { background: none; }
  .table:not(.table-keep) td { border: 0; padding: 3px 0 !important; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; text-align: right; min-height: 0; }
  .table:not(.table-keep) td::before { content: attr(data-label); color: var(--text-3); font-size: 12.5px; font-weight: 500; text-align: left; flex: none; max-width: 45%; }
  .table:not(.table-keep) td[data-label=""]::before, .table:not(.table-keep) td:not([data-label])::before { display: none; }
  .table:not(.table-keep) td.num { justify-content: space-between; }
  .table:not(.table-keep) td > * { min-width: 0; }
  /* first meaningful cell = card title */
  .table:not(.table-keep) td.cell-title { display: block; text-align: left; font-size: 15px; padding-bottom: 6px !important; padding-right: 40px !important; }
  .table:not(.table-keep) td.cell-title::before { display: none; }
  .table:not(.table-keep) td.check { position: absolute; top: 10px; right: 14px; width: auto; display: block; padding: 0 !important; }
  .table:not(.table-keep) td.check::before { display: none; }
  .table:not(.table-keep) td.actions { justify-content: flex-end; flex-wrap: wrap; padding-top: 8px !important; width: 100%; }
  .table:not(.table-keep) td.actions::before { display: none; }
  .table:not(.table-keep) td:empty { display: none; }
  .table:not(.table-keep) tr.row-warn { box-shadow: inset 3px 0 0 var(--warning); }
  .table:not(.table-keep) tr.row-danger { box-shadow: inset 3px 0 0 var(--danger); }
  .table:not(.table-keep) tr.row-warn td:first-child, .table:not(.table-keep) tr.row-danger td:first-child { box-shadow: none; }
  .table:not(.table-keep) td .input-sm, .table:not(.table-keep) input.input-sm { width: 110px; }
  .table:not(.table-keep) td .price-cell { text-align: right; }
  .table-wrap { overflow-x: visible; }
  .table-keep-wrap { overflow-x: auto; }
  .dl { grid-template-columns: 1fr !important; }
  .secret { flex-wrap: wrap; word-break: break-all; }
  .sidebar-foot .dropdown-menu { right: auto; left: 0; }
}

/* cards placed side by side in a grid must not get the stacked-card spacing */
.grid > .card + .card, .grid > form.card + .card, .grid > .card + form.card { margin-top: 0; }
.grid { align-items: start; }

/* margin hints inside tables keep their colour and stay on one line */
.table .sub.neg, .table .neg .sub, .table span.neg { color: var(--danger); }
.table .sub.warn-text { color: var(--warning); }
[data-price-row] [data-margin] { white-space: nowrap; display: block; font-size: 11.5px; }
[data-price-row] input[data-vk] { width: 76px !important; }

/* switches inside .field: keep track and text on one line (overrides `.field > label { display:block }`) */
.field > label.switch, label.switch { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 0; font-weight: 400; cursor: pointer; }
.switch .track { display: inline-block; flex: none; }
.switch > span:last-child { line-height: 1.4; }


/* ------------------------------------------------------------------ help assistant (customers) */
.help-fab { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px 0 14px; border-radius: 22px; border: 0; background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; box-shadow: var(--shadow-md); }
.help-fab:hover { background: var(--accent-hover); }
.help-panel { position: fixed; right: 20px; bottom: 76px; z-index: 61; width: 390px; max-width: calc(100vw - 24px); height: min(620px, calc(100vh - 110px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; }
.help-panel[hidden] { display: none; }
.help-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--border); }
.help-head-actions { display: flex; gap: 2px; }
.help-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.hm { max-width: 92%; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; line-height: 1.5; }
.hm p { margin: 0 0 6px; }
.hm p:last-child { margin-bottom: 0; }
.hm-a { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.hm-q { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 3px; }
.help-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.help-chip { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 16px; padding: 5px 11px; font: inherit; font-size: 12.5px; cursor: pointer; text-align: left; }
.help-chip:hover { border-color: var(--accent); color: var(--accent); }
.help-steps { margin: 6px 0; padding-left: 20px; }
.help-steps li { margin-bottom: 4px; }
.help-tip { margin-top: 8px; padding: 8px 10px; border-radius: 6px; background: var(--info-soft); color: var(--info); font-size: 12.5px; }
.help-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.help-input { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--border); background: var(--surface); }
@media (max-width: 760px) {
  .help-fab { right: 12px; bottom: 12px; height: 42px; padding: 0 14px 0 12px; }
  .help-fab span { display: none; }
  .help-panel { right: 0; left: 0; bottom: 0; width: 100%; max-width: none; height: 85vh; border-radius: 14px 14px 0 0; }
  body.help-open .help-fab { display: none; }
  .toasts { bottom: 64px; }
}
@media print { .help-fab, .help-panel { display: none !important; } }



/* ------------------------------------------------------------------ info pages (NIS-2) */
.info-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 32px; border-bottom: 1px solid var(--border); background: var(--surface); }
.info-top .logo { height: 40px; width: auto; }
.info-content { margin: 0 auto; }
.info-page .card { scroll-margin-top: 80px; }
.info-list { margin: 0; padding-left: 20px; }
.info-list li { margin-bottom: 4px; }
.traffic { display: flex; flex-direction: column; gap: 12px; }
.traffic-row { display: flex; gap: 12px; align-items: flex-start; }
.tl { width: 14px; height: 14px; border-radius: 50%; flex: none; margin-top: 4px; box-shadow: 0 0 0 3px var(--surface-3); }
.tl-green { background: #2e9e5b; } .tl-orange { background: #e08a1e; } .tl-red { background: #d23b33; }
.nis2-link { font-size: 12.5px; }
@media (max-width: 760px) { .info-top { padding: 12px 16px; } .info-top .logo { height: 32px; } }
