:root {
  color-scheme: dark;
  --bg: #07100e;
  --surface: #0c1714;
  --surface-2: #101f1b;
  --surface-3: #152722;
  --line: #213a33;
  --line-soft: rgba(91, 135, 120, .18);
  --text: #edf7f3;
  --muted: #8ea89f;
  --green: #70f0b5;
  --green-strong: #32d797;
  --yellow: #f3c76b;
  --red: #ff7d76;
  --blue: #79b7ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, .35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #edf4f1;
  --surface: #ffffff;
  --surface-2: #f4f8f6;
  --surface-3: #e6f0ec;
  --line: #c9d9d3;
  --line-soft: rgba(57, 91, 80, .14);
  --text: #13231e;
  --muted: #60766e;
  --green: #0c9d67;
  --green-strong: #20bd7f;
  --yellow: #a66d00;
  --red: #c7433d;
  --blue: #276fbd;
  --shadow: 0 20px 55px rgba(37, 69, 58, .12);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1180px; background: var(--bg); color: var(--text); font-size: 16px; }
[hidden] { display: none !important; }
.login-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; overflow: hidden; background: var(--bg); }
.login-ambient { position: absolute; width: 720px; height: 720px; border-radius: 50%; background: radial-gradient(circle, rgba(48, 215, 151, .16), transparent 66%); transform: translate(32%, -35%); }
.login-screen:before { content: ""; position: absolute; inset: 0; opacity: .16; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 42px 42px; mask-image: radial-gradient(circle at center, black, transparent 72%); }
.login-card { position: relative; width: min(440px, calc(100vw - 32px)); padding: 30px; border: 1px solid var(--line); border-radius: 18px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.login-brand { display: flex; align-items: center; gap: 11px; font-size: .86rem; font-weight: 800; }
.login-copy { margin: 30px 0 24px; }
.login-copy h1 { margin-top: 7px; font-size: 1.65rem; letter-spacing: -.035em; }
.login-copy p { margin-top: 10px; color: var(--muted); font-size: .82rem; line-height: 1.55; }
.login-card > label { display: grid; gap: 7px; margin-top: 15px; color: var(--muted); font-size: .76rem; }
.login-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: var(--surface-2); color: var(--text); }
.login-card input:focus { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 15%, transparent); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 42px; }
.password-field button { position: absolute; top: 50%; right: 7px; width: 32px; height: 32px; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.login-card .remember-row { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 9px; }
.remember-row input { width: 15px; height: 15px; accent-color: var(--green-strong); }
.login-submit { width: 100%; margin-top: 20px; }
.login-security { display: flex; justify-content: center; gap: 13px; margin-top: 17px; color: var(--muted); font-size: .63rem; }
.login-security span::first-letter { color: var(--green); }
.prototype-hint { margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: .67rem; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.app-shell { display: grid; grid-template-columns: 330px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: linear-gradient(180deg, #0b1713 0%, #09120f 100%); }
.brand { display: flex; gap: 12px; align-items: center; padding: 24px 24px 22px; border-bottom: 1px solid var(--line-soft); }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: #042017; background: var(--green); font-weight: 900; box-shadow: 0 0 32px rgba(112, 240, 181, .2); }
.brand strong, .brand span { display: block; }
.brand strong { letter-spacing: -.02em; }
.brand span { margin-top: 2px; color: var(--muted); font-size: .82rem; }
.fleet-heading { display: flex; align-items: end; justify-content: space-between; padding: 24px 22px 14px; }
.eyebrow { color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin: 0; }
h1 { margin-top: 4px; font-size: 1.25rem; }
h2 { margin-top: 4px; font-size: 2rem; letter-spacing: -.04em; }
h3 { font-size: 1.05rem; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 1.4rem; cursor: pointer; }
.icon-button:hover { border-color: var(--green); background: var(--surface-3); }
.search-box { display: flex; gap: 10px; align-items: center; margin: 0 22px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(0, 0, 0, .15); color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.fleet-summary { display: flex; gap: 16px; padding: 15px 22px 12px; color: var(--muted); font-size: .75rem; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; }
.status-dot.online { background: var(--green); box-shadow: 0 0 10px rgba(112, 240, 181, .7); }
.status-dot.warning { background: var(--yellow); }
.status-dot.offline { background: var(--red); }
.device-list { flex: 1; overflow: auto; padding: 3px 12px 18px; }
.device-item { width: 100%; display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; padding: 13px 12px; border: 1px solid transparent; border-radius: 12px; background: transparent; text-align: left; cursor: pointer; }
.device-item:hover { background: rgba(255,255,255,.025); }
.device-item.active { border-color: #2b594b; background: linear-gradient(90deg, rgba(48, 177, 127, .14), rgba(48, 177, 127, .03)); }
.device-item b, .device-item small { display: block; }
.device-item b { font-size: .9rem; }
.device-item small { margin-top: 3px; color: var(--muted); font-size: .74rem; }
.device-item .version { color: #77968b; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .68rem; }
.sidebar-footer { padding: 14px 18px 20px; border-top: 1px solid var(--line-soft); }
.quiet-button, .primary-button, .diff-button { border-radius: 10px; cursor: pointer; }
.quiet-button { padding: 9px 11px; border: 1px solid transparent; background: transparent; color: var(--muted); }
.quiet-button:hover { color: var(--text); background: rgba(255,255,255,.04); }
.danger-action { margin-right: auto; color: var(--red); }
.controller-health { display: grid; grid-template-columns: auto 1fr auto; align-items: center; margin-top: 10px; padding: 11px; border-radius: 10px; background: rgba(0,0,0,.18); color: var(--muted); font-size: .72rem; }
.controller-health b { color: var(--green); font-weight: 600; }
.workspace { min-width: 0; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(7, 16, 14, .8); backdrop-filter: blur(18px); }
.breadcrumbs { display: flex; gap: 10px; align-items: center; font-size: .82rem; }
.breadcrumbs span, .breadcrumbs b { color: var(--muted); font-weight: 500; }
.top-actions { display: flex; gap: 8px; }
.theme-toggle { display: flex; align-items: center; gap: 7px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--muted); cursor: pointer; font-size: .76rem; }
.theme-toggle:hover { color: var(--text); border-color: var(--green); }
.primary-button { padding: 11px 16px; border: 1px solid var(--green-strong); background: var(--green-strong); color: #042017; font-weight: 800; }
.primary-button:hover { background: var(--green); }
.primary-button.compact { padding: 8px 13px; font-size: .82rem; }
.device-hero { padding: 28px 30px 22px; border-bottom: 1px solid var(--line-soft); background: radial-gradient(circle at 85% 10%, rgba(52, 200, 145, .09), transparent 28%); }
.device-title-row { display: flex; align-items: flex-start; justify-content: space-between; }
.endpoint-line { display: flex; gap: 8px; align-items: center; margin-top: 11px; color: var(--muted); font-size: .78rem; }
.endpoint-line code { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #07100e; color: #b6d6cb; }
.endpoint-line span { padding-left: 8px; border-left: 1px solid var(--line); }
.hero-status { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; color: var(--muted); font-size: .76rem; }
.availability { padding: 7px 10px; border: 1px solid #285445; border-radius: 99px; color: var(--text); background: rgba(46, 187, 132, .08); }
.metrics-grid { display: grid; grid-template-columns: repeat(5, minmax(130px,1fr)); gap: 10px; margin-top: 26px; }
.metric-card { padding: 15px 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(11, 25, 21, .72); }
.metric-card span, .metric-card small, .metric-card strong { display: block; }
.metric-card span { color: var(--muted); font-size: .72rem; }
.metric-card strong { margin: 8px 0 4px; font-size: 1.05rem; }
.metric-card small { color: #6f8e83; font-size: .7rem; }
.metric-card.accent { border-color: #2b594b; }
.metric-card.accent strong { color: var(--green); }
.section-tabs { display: flex; gap: 2px; overflow-x: auto; padding: 0 30px; border-bottom: 1px solid var(--line); background: #091310; }
.section-tabs button { padding: 15px 13px 13px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); white-space: nowrap; cursor: pointer; font-size: .8rem; }
.section-tabs button:hover { color: var(--text); }
.section-tabs button.active { border-bottom-color: var(--green); color: var(--text); }
.content-layout { display: grid; grid-template-columns: minmax(0, 1fr) 315px; gap: 18px; padding: 22px 30px 40px; }
.content-panel, .changes-panel { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.panel-header p { margin-top: 5px; color: var(--muted); font-size: .78rem; }
.panel-actions { display: flex; gap: 8px; }
.panel-button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); cursor: pointer; font-size: .76rem; }
.bulk-toolbar { display: flex; align-items: center; gap: 7px; padding: 10px 20px; border-bottom: 1px solid var(--line-soft); background: var(--surface-2); }
.bulk-toolbar button { padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--muted); cursor: pointer; font-size: .68rem; }
.bulk-toolbar button:hover { color: var(--text); border-color: var(--green); }
.bulk-toolbar button.danger:hover { color: var(--red); border-color: var(--red); }
.bulk-count { margin-right: auto; color: var(--muted); font-size: .7rem; }
.stack { padding: 10px; }
.data-row { display: grid; grid-template-columns: 30px minmax(160px, 1fr) 1fr 1fr auto; gap: 12px; align-items: center; min-height: 58px; padding: 9px 10px; border-bottom: 1px solid var(--line-soft); }
.data-row.selectable { grid-template-columns: 18px 30px minmax(160px, 1fr) 1fr 1fr auto; }
.row-select { width: 15px; height: 15px; accent-color: var(--green-strong); }
.data-row:last-child { border-bottom: 0; }
.data-row b, .data-row small { display: block; }
.data-row b { font-size: .83rem; }
.data-row small, .data-row span { color: var(--muted); font-size: .73rem; }
.row-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface-3); color: var(--green); font-size: .72rem; font-weight: 900; }
.pill { display: inline-flex; width: fit-content; padding: 4px 8px; border: 1px solid var(--line); border-radius: 99px; font-size: .67rem !important; }
.pill.up { border-color: #295846; color: var(--green); }
.pill.warn { border-color: #5e4d28; color: var(--yellow); }
.overview-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 14px; padding: 14px; }
.subcard { min-height: 180px; padding: 16px; border: 1px solid var(--line-soft); border-radius: 11px; background: rgba(0,0,0,.12); }
.subcard h4 { margin: 0 0 13px; font-size: .85rem; }
.topology { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; min-height: 125px; }
.topology-node { padding: 12px; border: 1px solid var(--line); border-radius: 10px; text-align: center; background: var(--surface-2); }
.topology-node b, .topology-node small { display: block; }
.topology-node small { margin-top: 5px; color: var(--muted); font-size: .69rem; }
.link-line { width: 70px; height: 2px; background: linear-gradient(90deg, var(--green), #356355); position: relative; }
.link-line:after { content: "IPIP/IPsec"; position: absolute; top: -20px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: .62rem; white-space: nowrap; }
.health-list { display: grid; gap: 11px; }
.health-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.health-line span { color: var(--muted); font-size: .73rem; }
.bar { grid-column: 1 / -1; height: 5px; overflow: hidden; border-radius: 99px; background: #172a24; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.changes-panel { position: sticky; top: 84px; height: fit-content; padding: 17px; }
.changes-panel header { display: flex; align-items: center; justify-content: space-between; }
.changes-panel h3 { margin-top: 4px; }
.change-count { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: rgba(112,240,181,.12); color: var(--green); font-weight: 800; }
.change-list { margin: 16px 0; }
.change-list article { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.change-list b, .change-list small { display: block; }
.change-list b { font-size: .77rem; }
.change-list small { margin-top: 4px; color: var(--muted); font-size: .69rem; }
.change-type { font-family: ui-monospace, monospace; font-weight: 900; }
.change-type.add { color: var(--green); }
.change-type.edit { color: var(--yellow); }
.diff-button { width: 100%; padding: 9px; border: 1px solid var(--line); background: var(--surface-2); font-size: .76rem; }
.safe-apply { margin: 14px 0; padding: 11px; border-left: 2px solid var(--green); background: rgba(112,240,181,.04); }
.safe-apply b, .safe-apply span { display: block; }
.safe-apply b { font-size: .73rem; }
.safe-apply span { margin-top: 4px; color: var(--muted); font-size: .66rem; }
.changes-panel .primary-button, .quiet-button.full { width: 100%; }
.empty-changes { padding: 22px 4px; color: var(--muted); text-align: center; font-size: .75rem; }
dialog { width: min(620px, calc(100vw - 40px)); padding: 0; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: var(--text); box-shadow: 0 40px 120px rgba(0,0,0,.7); }
dialog::backdrop { background: rgba(2,7,5,.72); backdrop-filter: blur(5px); }
dialog form > header, dialog form > footer { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; }
dialog form > header { border-bottom: 1px solid var(--line); }
dialog form > footer { justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
dialog h3 { margin-top: 4px; font-size: 1.25rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 20px; }
.form-grid label { display: grid; gap: 7px; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid label > span { color: var(--muted); font-size: .75rem; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: #091310; color: var(--text); }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { border-color: var(--green); }
.form-grid textarea { min-height: 76px; resize: vertical; }
.credential-note { margin: 0 20px 20px; padding: 12px; border-radius: 10px; background: var(--surface-2); }
.credential-note b, .credential-note span { display: block; }
.credential-note b { font-size: .75rem; }
.credential-note span { margin-top: 4px; color: var(--muted); font-size: .7rem; }
.wide-dialog { width: min(820px, calc(100vw - 40px)); }
.config-diff { margin: 20px; padding: 18px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #050b09; color: #aec4bc; font: .78rem/1.8 ui-monospace, SFMono-Regular, Menlo, monospace; }
body[data-theme="light"] .config-diff { background: #10211b; }
body[data-theme="light"] .sidebar { background: linear-gradient(180deg, #f8fbfa 0%, #edf4f1 100%); }
body[data-theme="light"] .topbar { background: rgba(245, 250, 248, .86); }
body[data-theme="light"] .section-tabs { background: #f5faf8; }
body[data-theme="light"] .metric-card { background: rgba(255,255,255,.82); }
body[data-theme="light"] .metric-card small { color: var(--muted); }
body[data-theme="light"] .subcard { background: #f7faf9; }
body[data-theme="light"] .controller-health { background: rgba(63, 107, 92, .08); }
body[data-theme="light"] .bar { background: #dce8e3; }
body[data-theme="light"] .search-box, body[data-theme="light"] .endpoint-line code, body[data-theme="light"] .form-grid input, body[data-theme="light"] .form-grid select, body[data-theme="light"] .form-grid textarea { background: #fff; }
.config-diff span { display: block; }
.diff-add { color: var(--green); }
.diff-edit { color: var(--yellow); }
.validation-row { display: flex; gap: 16px; padding: 0 20px 18px; color: var(--muted); font-size: .7rem; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: 360px; padding: 13px 16px; border: 1px solid #2c5e4c; border-radius: 11px; background: #10251e; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; font-size: .8rem; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1300px) {
  body { min-width: 980px; }
  .app-shell { grid-template-columns: 285px 1fr; }
  .content-layout { grid-template-columns: 1fr; }
  .changes-panel { position: static; }
  .metrics-grid { grid-template-columns: repeat(3, 1fr); }
}
