:root {
  --ink: #172037;
  --muted: #667085;
  --line: #e5e9f0;
  --panel: #fff;
  --bg: #f4f7fb;
  --navy: #172a46;
  --navy-2: #213957;
  --blue: #2867d8;
  --blue-soft: #eaf2ff;
  --green: #12845c;
  --green-soft: #e8f7f0;
  --amber: #b66a08;
  --amber-soft: #fff7e5;
  --red: #c23b48;
  --red-soft: #fff0f1;
  --shadow: 0 18px 45px rgba(28, 45, 75, .09);
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.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; }
.eyebrow { margin: 0 0 .55rem; color: var(--blue); font-size: .73rem; font-weight: 800; letter-spacing: .13em; }

.brand-mark { display: flex; align-items: end; gap: 5px; width: 49px; height: 42px; margin-bottom: 1.25rem; }
.brand-mark span { display: block; width: 11px; border-radius: 3px 3px 1px 1px; background: linear-gradient(180deg, #4b8df1, var(--blue)); }
.brand-mark span:nth-child(1) { height: 21px; }
.brand-mark span:nth-child(2) { height: 39px; }
.brand-mark span:nth-child(3) { height: 29px; }
.brand-mark.small { width: 35px; height: 30px; margin: 0; gap: 3px; }
.brand-mark.small span { width: 8px; }
.brand-mark.small span:nth-child(1) { height: 15px; }
.brand-mark.small span:nth-child(2) { height: 28px; }
.brand-mark.small span:nth-child(3) { height: 21px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem; background: radial-gradient(circle at 75% 15%, rgba(64, 121, 218, .2), transparent 28%), linear-gradient(135deg, #eef4fd, #f8fafc 56%, #edf2f8); }
.login-card { width: min(100%, 430px); padding: 2.7rem; border: 1px solid rgba(255, 255, 255, .8); border-radius: 20px; background: rgba(255, 255, 255, .94); box-shadow: 0 28px 80px rgba(30, 55, 95, .15); }
.login-card h1 { margin: 0; font-size: 2.25rem; letter-spacing: -.045em; }
.login-copy { margin: .75rem 0 2rem; color: var(--muted); line-height: 1.55; }
.login-card label, dialog label { display: block; margin: .95rem 0 .45rem; font-size: .82rem; font-weight: 700; }
.login-card input, textarea { width: 100%; border: 1px solid #ccd4e0; border-radius: 9px; padding: .78rem .85rem; color: var(--ink); background: #fff; outline: none; }
.login-card input:focus, textarea:focus, select:focus, .search-field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(40, 103, 216, .13); }
.form-error { min-height: 1.15rem; margin: .55rem 0; color: var(--red); font-size: .82rem; }
.secure-note { margin-top: 1.3rem; padding-top: 1.15rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; line-height: 1.4; }
.secure-note span { color: var(--green); margin-right: .35rem; }

.button { border: 0; border-radius: 8px; padding: .68rem 1rem; font-weight: 750; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.wide { width: 100%; }
.button.primary { color: #fff; background: var(--blue); box-shadow: 0 8px 20px rgba(40, 103, 216, .22); }
.button.secondary { color: var(--blue); background: var(--blue-soft); }
.button.ghost { color: #526078; background: #eef1f5; }
.button.danger { color: #fff; background: var(--red); }
.button.enable { color: #fff; background: var(--green); }

.topbar { min-height: 72px; padding: 0 clamp(1rem, 4vw, 3.5rem); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 2rem; background: var(--navy); color: #fff; }
.brand-lockup, .account { display: flex; align-items: center; gap: .85rem; }
.brand-lockup strong, .brand-lockup span, .account strong, .account span { display: block; }
.brand-lockup span, .account span { color: #aab7ca; font-size: .72rem; margin-top: .15rem; }
.account { justify-self: end; text-align: right; }
.account .button { margin-left: .7rem; color: #dbe4f0; background: rgba(255, 255, 255, .1); }
.main-nav { align-self: stretch; display: flex; gap: .2rem; }
.nav-button { position: relative; border: 0; padding: 0 1.15rem; color: #adbbce; background: transparent; font-size: .84rem; font-weight: 700; }
.nav-button:hover { color: #fff; }
.nav-button.active { color: #fff; }
.nav-button.active::after { content: ""; position: absolute; height: 3px; left: .8rem; right: .8rem; bottom: 0; border-radius: 3px 3px 0 0; background: #5f9af2; }

.content { width: min(1440px, calc(100% - 2rem)); margin: 0 auto; padding: 2.6rem 0 4rem; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 1.7rem; }
.page-heading h1 { margin: 0; font-size: 2rem; letter-spacing: -.035em; }
.page-heading p:not(.eyebrow) { margin: .55rem 0 0; color: var(--muted); }
.heading-actions { display: flex; align-items: center; gap: .8rem; }
.updated-at { color: var(--muted); font-size: .75rem; white-space: nowrap; }

.family-tabs { display: inline-grid; grid-template-columns: 1fr 1fr; gap: .35rem; margin-bottom: 1.2rem; padding: .3rem; border: 1px solid #dbe2ec; border-radius: 11px; background: #e9eef5; }
.family-tab { min-width: 150px; padding: .62rem 1.2rem; border: 0; border-radius: 8px; color: #5d6a7f; background: transparent; text-align: left; }
.family-tab span, .family-tab small { display: block; }
.family-tab span { font-size: .88rem; font-weight: 800; }
.family-tab small { margin-top: .08rem; color: #8290a4; font-size: .67rem; }
.family-tab.active { color: var(--blue); background: #fff; box-shadow: 0 2px 7px rgba(30, 48, 77, .1); }
.family-tab.active small { color: #6680a8; }

.metric-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.metric-card, .stat-card { padding: 1.15rem 1.25rem; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 5px 16px rgba(31, 47, 76, .04); }
.metric-card { position: relative; overflow: hidden; }
.metric-card::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 4px; background: #6f82a0; }
.metric-card.good::before { background: var(--green); }
.metric-card.warning::before { background: var(--amber); }
.metric-card span, .stat-card span { display: block; color: var(--muted); font-size: .75rem; font-weight: 680; }
.metric-card strong, .stat-card strong { display: block; margin-top: .22rem; font-size: 1.7rem; letter-spacing: -.04em; }
.metric-card small { display: block; margin-top: .1rem; color: #929bab; font-size: .66rem; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card.healthy { border-left: 4px solid var(--green); }
.stat-card.muted { border-left: 4px solid #a5adbb; }

.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.topology-panel { margin-bottom: 1.25rem; }
.topology-header { align-items: center; }
.topology-controls { display: flex; align-items: center; gap: .65rem; }
.topology-controls label { color: var(--muted); font-size: .72rem; font-weight: 700; white-space: nowrap; }
.topology-controls select { height: 38px; min-width: 220px; max-width: 340px; border: 1px solid #d3d9e3; border-radius: 8px; padding: 0 2rem 0 .7rem; color: var(--ink); background: #fff; outline: none; }
.topology-stage { position: relative; min-height: 620px; overflow: hidden; color: #d9efff; background: #071727; isolation: isolate; }
#topology-canvas { display: block; width: 100%; height: 620px; touch-action: none; cursor: grab; }
#topology-canvas:active { cursor: grabbing; }
.mesh-hud, .mesh-selection { position: absolute; z-index: 2; border: 1px solid rgba(104, 172, 215, .35); border-radius: 10px; color: #d9efff; background: rgba(6, 24, 39, .82); box-shadow: 0 12px 34px rgba(0, 0, 0, .18); backdrop-filter: blur(8px); pointer-events: none; }
.mesh-hud { top: 18px; left: 18px; min-width: 285px; padding: .8rem .9rem; }
.mesh-hud > strong { display: flex; align-items: center; gap: .35rem; font-size: .78rem; letter-spacing: .02em; }
.mesh-hud > strong > i { width: 9px; height: 9px; border-radius: 50%; background: #35d3a0; box-shadow: 0 0 12px rgba(53, 211, 160, .75); }
.mesh-hud > span { display: block; margin-top: .2rem; color: #819cb2; font-size: .66rem; text-transform: uppercase; }
.mesh-hud-stats { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .65rem; }
.mesh-hud-stats b { display: flex; align-items: center; gap: .3rem; padding: .3rem .45rem; border: 1px solid rgba(105, 162, 196, .13); border-radius: 4px; color: #95aabd; background: rgba(20, 52, 75, .52); font-size: .64rem; font-weight: 700; text-transform: uppercase; }
.mesh-hud-stats b i, .mesh-legend span i { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #7b8da3; }
.mesh-hud-stats .healthy i, .mesh-legend .healthy i { background: #35d3a0; }
.mesh-hud-stats .warning i, .mesh-legend .warning i { background: #ffbd38; }
.mesh-hud-stats .disabled i, .mesh-legend .disabled i { background: #486276; }
.mesh-legend { position: absolute; z-index: 2; top: 126px; left: 20px; display: grid; gap: .35rem; pointer-events: none; }
.mesh-legend span { display: flex; align-items: center; gap: .4rem; color: #8da6ba; font-size: .67rem; }
.mesh-legend .core i { background: #63aefc; }
.mesh-legend .down i { background: #ff6478; }
.mesh-selection { left: 18px; bottom: 18px; width: min(250px, calc(100% - 36px)); padding: .75rem .85rem; }
.mesh-selection strong, .mesh-selection span { display: block; }
.mesh-selection strong { font-size: .78rem; }
.mesh-selection span { margin-top: .25rem; color: #8da6ba; font-size: .68rem; line-height: 1.4; }
.mesh-controls { position: absolute; z-index: 3; right: 18px; bottom: 18px; display: flex; gap: .45rem; }
.mesh-controls button { border: 1px solid rgba(108, 171, 211, .45); border-radius: 7px; padding: .55rem .75rem; color: #d8eaf7; background: rgba(25, 58, 82, .88); font-size: .7rem; font-weight: 650; box-shadow: 0 8px 24px rgba(0, 0, 0, .14); }
.mesh-controls button:hover, .mesh-controls button:focus-visible { border-color: #63aefc; background: rgba(39, 82, 112, .94); }
.mesh-hint { position: absolute; z-index: 2; right: 20px; top: 18px; color: rgba(157, 187, 207, .72); font-size: .65rem; pointer-events: none; }
.topology-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 48px; padding: .7rem 1.35rem; border-top: 1px solid var(--line); background: #fff; }
.topology-footer p { margin: 0; color: var(--muted); font-size: .72rem; text-align: right; }
.dashboard-panel { min-height: 300px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding: 1.25rem 1.35rem; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 1.05rem; }
.panel-header p { margin: .25rem 0 0; color: var(--muted); font-size: .78rem; }
.status-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .75rem; }
.legend { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .69rem; }
.legend::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #9ca6b5; }
.legend.healthy::before { background: var(--green); }
.legend.degraded::before { background: var(--amber); }
.legend.down::before { background: var(--red); }
.filters { display: flex; gap: .65rem; }
.filters input, .filters select { height: 39px; border: 1px solid #d3d9e3; border-radius: 8px; padding: 0 .75rem; background: #fff; color: var(--ink); outline: none; }
.filters input { width: 270px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: .78rem 1rem; text-align: left; color: #707b8f; background: #fafbfc; border-bottom: 1px solid var(--line); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
td { padding: 1rem; border-bottom: 1px solid #edf0f4; vertical-align: middle; font-size: .82rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.disabled-row { background: #fafbfc; color: #6f7888; }
.location strong, .node-name strong { display: block; font-size: .86rem; }
.location span, .node-name span { display: block; margin-top: .2rem; color: var(--muted); font-size: .73rem; }
.probe-route { display: flex; align-items: center; min-width: 290px; gap: .55rem; }
.probe-route strong { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .79rem; }
.route-arrow { display: grid; place-items: center; flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%; color: var(--blue); background: var(--blue-soft); font-weight: 800; }
.address, .metric-value { font-family: "SFMono-Regular", Consolas, monospace; font-size: .74rem; white-space: nowrap; }
.observed { color: var(--muted); white-space: nowrap; }
.badge, .health-badge { display: inline-flex; align-items: center; gap: .4rem; padding: .32rem .55rem; border-radius: 999px; font-size: .7rem; font-weight: 760; white-space: nowrap; }
.badge::before, .health-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.enabled, .health-badge.healthy { color: var(--green); background: var(--green-soft); }
.badge.disabled, .health-badge.no_data { color: #778092; background: #edf0f4; }
.health-badge.degraded { color: var(--amber); background: var(--amber-soft); }
.health-badge.down { color: var(--red); background: var(--red-soft); }
.link-down { background: #fffafb; }
.row-action { padding: .5rem .7rem; font-size: .74rem; }
.loading-state, .empty-state { padding: 3rem; text-align: center; color: var(--muted); }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { margin-bottom: .35rem; color: var(--ink); }
.empty-state span { font-size: .8rem; }
.auto-refresh-note { margin: .8rem .25rem 0; color: var(--muted); font-size: .7rem; }
.auto-refresh-note span { color: var(--green); margin-right: .3rem; }

dialog { width: min(92vw, 480px); padding: 0; border: 0; border-radius: 15px; box-shadow: 0 28px 80px rgba(20, 32, 52, .3); }
dialog::backdrop { background: rgba(12, 22, 38, .58); backdrop-filter: blur(2px); }
dialog form { padding: 1.8rem; }
.dialog-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; margin-bottom: 1.1rem; color: var(--red); background: var(--red-soft); font-weight: 900; }
.dialog-icon.enable { color: var(--green); background: var(--green-soft); }
dialog h2 { margin: 0; font-size: 1.35rem; }
dialog p:not(.eyebrow):not(.form-error) { color: var(--muted); line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .65rem; margin-top: 1.2rem; }
.toast { position: fixed; z-index: 20; right: 1.25rem; bottom: 1.25rem; max-width: 430px; padding: .9rem 1.05rem; border-radius: 9px; color: #fff; background: var(--navy); box-shadow: var(--shadow); font-size: .84rem; }
.toast.error { background: var(--red); }

@media (max-width: 1080px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .metric-card:nth-child(4), .metric-card:nth-child(5) { grid-column: span 1; }
}
@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto; gap: .5rem; }
  .main-nav { grid-row: 2; grid-column: 1 / -1; min-height: 44px; justify-content: center; border-top: 1px solid rgba(255, 255, 255, .08); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-header { align-items: stretch; flex-direction: column; }
  .topology-header { align-items: stretch; }
  .topology-controls { justify-content: space-between; }
  .topology-footer { align-items: flex-start; flex-direction: column; }
  .topology-footer p { text-align: left; }
  .status-legend { justify-content: flex-start; }
  .filters input { width: 100%; }
  .filters { display: grid; grid-template-columns: 1fr auto; }
}
@media (max-width: 640px) {
  .login-card { padding: 2rem 1.4rem; }
  .topbar { padding: .8rem 1rem 0; }
  .brand-lockup span { display: none; }
  .account > div { display: none; }
  .content { width: min(100% - 1rem, 1440px); padding-top: 1.4rem; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 1rem; }
  .heading-actions { justify-content: space-between; }
  .family-tabs { width: 100%; }
  .family-tab { min-width: 0; }
  .topology-controls { align-items: stretch; flex-direction: column; }
  .topology-controls select { width: 100%; max-width: none; }
  .topology-stage, #topology-canvas { min-height: 540px; height: 540px; }
  .mesh-hud { top: 12px; left: 12px; min-width: 0; width: calc(100% - 24px); }
  .mesh-hint, .mesh-legend { display: none; }
  .mesh-selection { left: 12px; bottom: 66px; width: calc(100% - 24px); }
  .mesh-controls { right: 12px; bottom: 12px; left: 12px; justify-content: flex-end; }
  .mesh-controls button { flex: 1; padding: .6rem .35rem; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card:last-child { grid-column: 1 / -1; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .metric-card, .stat-card { padding: .9rem; }
  .filters { grid-template-columns: 1fr; }
  #nodes-table, #nodes-table tbody, #nodes-table tr, #nodes-table td { display: block; }
  #nodes-table thead { display: none; }
  #nodes-table tbody tr { padding: .85rem; border-bottom: 1px solid var(--line); }
  #nodes-table td { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem; border: 0; }
  #nodes-table td::before { content: attr(data-label); color: var(--muted); font-size: .69rem; text-transform: uppercase; letter-spacing: .06em; }
  .row-action { width: 100%; margin-top: .35rem; }
}
