:root {
  color-scheme: light;
  --bg: #f5f6f2; --surface: #ffffff; --surface-2: #eef0ea; --ink: #172019;
  --muted: #667168; --line: #dce1da; --accent: #126b4b; --accent-2: #e2f3eb;
  --danger: #a73838; --danger-bg: #f9e7e5; --warn: #a36a15; --ok: #16724e;
  --shadow: 0 14px 40px rgba(24,41,30,.07); --radius: 16px;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111713; --surface: #18201b; --surface-2: #222c25; --ink: #edf4ef;
  --muted: #9cab9f; --line: #344239; --accent: #6bd6a5; --accent-2: #1d3d2f;
  --danger: #ff8c88; --danger-bg: #482624; --warn: #f2bd6a; --ok: #6bd6a5;
  --shadow: 0 16px 44px rgba(0,0,0,.22);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
button,input,select,textarea { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 13px; cursor: pointer; transition: border-color .18s, background .18s, transform .18s; }
button:hover { border-color: var(--accent); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: progress; }
button.primary { color: #fff; background: #126b4b; border-color: #126b4b; font-weight: 700; }
[data-theme="dark"] button.primary { color: #102018; background: var(--accent); border-color: var(--accent); }
button.ghost { background: transparent; }
button.danger-soft { color: var(--danger); background: var(--danger-bg); border-color: transparent; }
.icon-button { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; background: transparent; }
h1,h2,p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(26px,3vw,38px); line-height: 1.08; letter-spacing: -.035em; }
h2 { margin-bottom: 14px; font-size: 19px; letter-spacing: -.015em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { margin-bottom: 5px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.topbar { position: sticky; z-index: 20; top: 0; min-height: 68px; display: flex; align-items: center; gap: 22px; padding: 10px max(18px,calc((100vw - 1440px)/2)); background: color-mix(in srgb,var(--bg) 90%,transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 230px; color: inherit; text-decoration: none; line-height: 1.2; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.brand-mark { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: #fff; background: linear-gradient(145deg,#126b4b,#194937); font-weight: 900; font-size: 14px; box-shadow: 0 7px 18px rgba(18,107,75,.2); }
.tabs { display: flex; gap: 3px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs button { white-space: nowrap; padding: 8px 10px; border: 0; background: transparent; color: var(--muted); }
.tabs button.active { color: var(--accent); background: var(--accent-2); font-weight: 700; }
.header-actions,.inline-actions { display: flex; gap: 8px; align-items: center; }
.shell { max-width: 1440px; margin: 0 auto; padding: 32px 22px 64px; }
.view { display: none; }
.view.active { display: block; animation: appear .2s ease; }
@keyframes appear { from { opacity: .35; transform: translateY(4px); } }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 22px; margin-bottom: 24px; }
.page-head p:last-child { margin-bottom: 0; }
.health-strip { display: grid; grid-template-columns: repeat(5,1fr); gap: 10px; margin-bottom: 14px; }
.health-item { display: flex; align-items: center; gap: 9px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 4px color-mix(in srgb,var(--warn) 15%,transparent); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb,var(--ok) 15%,transparent); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb,var(--danger) 15%,transparent); }
.metric-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 16px; }
.metric { min-height: 108px; padding: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 12px; font-size: 23px; line-height: 1; letter-spacing: -.03em; }
.metric small { color: var(--muted); }
.grid-two { display: grid; grid-template-columns: 1.25fr .75fr; gap: 16px; margin-bottom: 16px; }
.panel { padding: 20px; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.control-stack { display: grid; gap: 9px; }
.stats-block { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.stat-line { padding: 11px 12px; background: var(--surface-2); border-radius: 10px; }
.stat-line span { color: var(--muted); font-size: 12px; display: block; }
.stat-line strong { display: block; margin-top: 2px; font-size: 18px; }
.service-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 12px; margin-bottom: 16px; }
.service-card { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.service-card .service-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.service-card h2 { min-width: 0; margin: 0; font-size: 16px; }
.switch { position: relative; flex: 0 0 44px; width: 44px; height: 24px; overflow: hidden; padding: 0; border: 0; border-radius: 20px; background: var(--line); }
.switch::after { content:""; position:absolute; width:18px; height:18px; left:3px; top:3px; border-radius:50%; background:#fff; box-shadow:0 1px 4px #0003; transition:.2s; }
.switch.on { background: #126b4b; }
.switch.on::after { transform: translateX(20px); }
.service-card p { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.domain-toolbar { display: grid; grid-template-columns: minmax(260px,1fr) 230px; align-items: end; gap: 16px; margin-bottom: 20px; }
.latest-domain { min-width: 0; display: grid; grid-template-columns: auto minmax(0,1fr); gap: 2px 12px; align-items: baseline; padding: 14px 16px; background: var(--surface-2); border-radius: 12px; }
.latest-domain span { grid-column: 1/-1; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.latest-domain strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.latest-domain small { color: var(--muted); text-align: right; }
.sort-control { font-size: 12px; color: var(--muted); }
.domain-collection { display: grid; gap: 20px; }
.domain-section { display: grid; gap: 10px; }
.domain-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.domain-section-head h3 { margin: 0; font-size: 15px; }
.domain-section-head span { color: var(--muted); font-size: 12px; }
.domain-groups { display: grid; gap: 10px; }
.domain-group { overflow: clip; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.domain-group>summary { min-height: 68px; display: grid; grid-template-columns: auto minmax(0,1fr) auto auto; align-items: center; gap: 12px; padding: 13px 15px; cursor: pointer; list-style: none; }
.domain-group>summary::-webkit-details-marker { display: none; }
.domain-group[open]>summary { border-bottom: 1px solid var(--line); background: color-mix(in srgb,var(--surface-2) 55%,transparent); }
.group-caret { width: 22px; color: var(--muted); font-size: 19px; line-height: 1; transition: transform .18s; }
.domain-group[open] .group-caret { transform: rotate(90deg); }
.group-title { min-width: 0; }
.group-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.group-title small { color: var(--muted); }
.group-route { min-width: 96px; text-align: right; }
.domain-items { display: grid; }
.domain-row { display: grid; grid-template-columns: minmax(220px,1.4fr) minmax(150px,.7fr) minmax(170px,.8fr) auto; align-items: center; gap: 14px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.domain-row:last-child { border-bottom: 0; }
.domain-name { min-width: 0; }
.domain-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.domain-name small,.domain-added { color: var(--muted); font-size: 12px; }
.domain-route { display: flex; flex-wrap: wrap; gap: 6px; }
.domain-actions { display: flex; justify-content: flex-end; gap: 7px; }
.standalone-domains { overflow: clip; border: 1px solid var(--line); border-radius: 14px; }
.empty-group { padding: 20px; color: var(--muted); text-align: center; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th,td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.flash td { background: var(--accent-2); transition: background .3s; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; color: var(--ok); background: color-mix(in srgb,var(--ok) 12%,transparent); font-size: 11px; font-weight: 700; }
.badge.off,.badge.bad { color: var(--danger); background: var(--danger-bg); }
.filters { display: grid; grid-template-columns: 180px 160px 1fr auto; gap: 9px; margin-bottom: 14px; }
input,select,textarea { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); outline: 0; }
textarea { min-height: 116px; resize: vertical; line-height: 1.45; }
input:focus,select:focus,textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb,var(--accent) 13%,transparent); }
label { display: grid; gap: 6px; font-weight: 650; }
.diagnostic-form { display: grid; grid-template-columns: 1fr 190px auto; align-items: end; gap: 12px; }
.rank-list { display: grid; gap: 8px; }
.rank { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rank:last-child { border: 0; }
.empty { padding: 24px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 12px; }
.check-list { display: grid; gap: 8px; }
.check-row { display: grid; grid-template-columns: 22px 200px 1fr; gap: 9px; align-items: start; padding: 10px; background: var(--surface-2); border-radius: 10px; }
.check-row .result { font-weight: 900; color: var(--ok); }
.check-row.bad .result { color: var(--danger); }
dialog { width: min(620px,calc(100vw - 28px)); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 24px 90px #0005; }
dialog::backdrop { background: rgba(10,18,13,.54); backdrop-filter: blur(3px); }
dialog form { display: grid; gap: 15px; }
.dialog-head,.dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-head h2,.dialog-head p { margin: 0; }
.dialog-actions { justify-content: flex-end; }
.check { display: flex; align-items: center; gap: 9px; }
.check input { width: auto; }
pre { max-height: 60vh; overflow: auto; padding: 14px; background: var(--surface-2); border-radius: 10px; white-space: pre-wrap; font-size: 12px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; width: max-content; max-width: min(420px,calc(100vw - 32px)); overflow-wrap: anywhere; padding: 12px 16px; color: #fff; background: #193d2f; border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #7b2f2f; }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%,var(--accent-2),transparent 34%),var(--bg); }
.login-card { width: min(440px,100%); padding: 34px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.login-card .brand-mark { margin-bottom: 24px; }
.login-form { display: grid; gap: 16px; margin-top: 26px; }
.login-form button { margin-top: 4px; }
.login-note { margin: 18px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.loading { opacity: .65; }
@media (max-width:1100px) { .service-grid { grid-template-columns: repeat(3,1fr); } .metric-grid { grid-template-columns: repeat(2,1fr); } .health-strip { grid-template-columns: repeat(3,1fr); } .topbar { flex-wrap: wrap; } .tabs { order:3; flex-basis:100%; } }
@media (max-width:900px) { .domain-row { grid-template-columns:minmax(0,1fr) auto; } .domain-added { grid-column:1; } .domain-route { grid-column:1; } .domain-actions { grid-column:2; grid-row:1/4; align-self:center; } }
@media (max-width:720px) { .shell { padding: 22px 12px 46px; } .topbar { padding: 9px 12px; gap: 10px; } .brand { min-width:0; margin-right:auto; } .brand small { display:none; } .header-actions .ghost { display:none; } .page-head { display:grid; align-items:start; } .page-head>button { width:100%; } .health-strip,.metric-grid,.service-grid,.grid-two { grid-template-columns:1fr 1fr; } .grid-two { grid-template-columns:1fr; } .filters,.diagnostic-form,.domain-toolbar { grid-template-columns:1fr; } .inline-actions { align-items:stretch; display:grid; grid-template-columns:1fr 1fr; } .stats-block { grid-template-columns:1fr; } .check-row { grid-template-columns:22px 1fr; } .check-row span:last-child { grid-column:2; } .domain-group>summary { grid-template-columns:auto minmax(0,1fr) auto; } .group-route { display:none; } }
@media (max-width:540px) { .domain-row { grid-template-columns:1fr; gap:8px; } .domain-added,.domain-route,.domain-actions { grid-column:1; grid-row:auto; } .domain-actions { justify-content:stretch; } .domain-actions button { flex:1; } .domain-group>summary { gap:8px; padding:12px; } }
@media (max-width:460px) { .health-strip,.metric-grid,.service-grid { grid-template-columns:1fr; } .login-card { padding:25px; } }
