:root {
  --color-primary: #1e3a5f;
  --color-on-primary: #ffffff;
  --color-secondary: #334155;
  --color-accent: #059669;
  --color-accent-strong: #10b981;
  --color-background: #0f172a;
  --color-surface: #121d32;
  --color-surface-raised: #17243c;
  --color-muted: #10192e;
  --color-border: rgba(255, 255, 255, 0.11);
  --color-border-strong: rgba(255, 255, 255, 0.2);
  --color-foreground: #f8fafc;
  --color-text: #d9e2ef;
  --color-text-muted: #9fb0c7;
  --color-destructive: #ef4444;
  --color-warning: #f59e0b;
  --color-ring: #38bdf8;
  --shadow-1: 0 12px 36px rgba(2, 6, 23, 0.22);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --sidebar-width: 244px;
  font-family: "Fira Sans", "Microsoft YaHei UI", "Segoe UI", system-ui, sans-serif;
  color: var(--color-foreground);
  background: var(--color-background);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--color-background); }
body { margin: 0; min-height: 100dvh; background: radial-gradient(circle at 76% 8%, rgba(30, 58, 95, .56), transparent 36%), var(--color-background); color: var(--color-text); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
a { color: #7dd3fc; }
h1, h2, h3, p { margin-top: 0; }
h1 { color: var(--color-foreground); letter-spacing: -.03em; }
h2, h3 { color: var(--color-foreground); }
.hidden { display: none !important; }
.skip-link { position: fixed; z-index: 2000; left: 16px; top: -80px; padding: 12px 16px; border-radius: 8px; background: white; color: #0f172a; transition: top .2s ease; }
.skip-link:focus { top: 16px; }
:focus-visible { outline: 3px solid var(--color-ring); outline-offset: 2px; }

.visually-hidden {
  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-bottom: 6px; color: #7dd3fc; font: 600 .72rem/1.3 "Fira Code", Consolas, monospace; letter-spacing: .13em; }
.glass-card, .auth-panel, .sidebar, .topbar, .panel, .modal-frame { background: rgba(16, 25, 46, .83); border: 1px solid var(--color-border); box-shadow: var(--shadow-1); backdrop-filter: blur(16px); }

.auth-screen { min-height: 100dvh; display: grid; grid-template-columns: minmax(360px, 520px) minmax(420px, 1fr); gap: 48px; align-items: center; max-width: 1240px; margin: 0 auto; padding: 48px; }
.auth-panel { border-radius: var(--radius-lg); padding: 40px; }
.brand-lockup, .sidebar-brand { display: flex; align-items: center; gap: 14px; }
.brand-lockup h1 { margin: 0; font-size: 2.1rem; }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px; background: linear-gradient(135deg, #1e3a5f, #047857); color: white; box-shadow: 0 10px 32px rgba(5, 150, 105, .2); }
.brand-mark svg { width: 28px; height: 28px; }
.brand-mark.small { width: 40px; height: 40px; border-radius: 11px; }
.brand-mark.small svg { width: 22px; height: 22px; }
.auth-lead { margin: 24px 0 28px; color: var(--color-text-muted); line-height: 1.7; }
.stack { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; }
.field label { font-weight: 600; font-size: .9rem; color: var(--color-foreground); }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); background: rgba(2, 6, 23, .42); color: var(--color-foreground); transition: border-color .18s ease, background .18s ease; }
.field textarea { min-height: 96px; resize: vertical; }
.field input:hover, .field select:hover { border-color: rgba(125, 211, 252, .5); }
.field input:focus, .field select:focus { border-color: var(--color-ring); background: rgba(2, 6, 23, .68); }
.password-field { position: relative; }
.password-field input { padding-right: 52px; }
.password-toggle { position: absolute; right: 2px; top: 1px; }
.helper, .field-error { margin: 0; font-size: .82rem; line-height: 1.45; }
.helper { color: var(--color-text-muted); }
.field-error { min-height: 1.2em; color: #fca5a5; }
.button, .icon-button, .nav-item { border: 0; cursor: pointer; touch-action: manipulation; transition: background .18s ease, border-color .18s ease, color .18s ease, opacity .18s ease; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 650; }
.button-primary { background: var(--color-accent); color: white; }
.button-primary:hover { background: #047857; }
.button-secondary { background: rgba(51, 65, 85, .72); border-color: var(--color-border); }
.button-secondary:hover { background: #475569; }
.button-danger { background: rgba(127, 29, 29, .28); color: #fecaca; border-color: rgba(239, 68, 68, .35); }
.button-danger:hover { background: rgba(153, 27, 27, .52); }
.button-quiet { background: transparent; color: var(--color-text-muted); border-color: var(--color-border); }
.button-quiet:hover { color: white; background: rgba(255,255,255,.05); }
.button-small { min-height: 36px; padding: 6px 11px; font-size: .82rem; }
.button[disabled], .icon-button[disabled] { opacity: .42; cursor: not-allowed; }
.icon-button { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 10px; background: transparent; }
.icon-button:hover { background: rgba(255,255,255,.07); }
.notice { display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid var(--color-border); line-height: 1.5; }
.notice-warning { background: rgba(245, 158, 11, .09); border-color: rgba(245, 158, 11, .35); color: #fde68a; }
.trust-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; color: var(--color-text-muted); font: .72rem "Fira Code", Consolas, monospace; }
.trust-row span { padding: 6px 9px; border: 1px solid var(--color-border); border-radius: 999px; }
.auth-visual { position: relative; min-height: 560px; display: grid; place-items: center; overflow: hidden; }
.signal-orbit { position: absolute; border: 1px solid rgba(56, 189, 248, .2); border-radius: 50%; }
.signal-orbit-a { width: 520px; height: 520px; }
.signal-orbit-b { width: 360px; height: 360px; border-color: rgba(16, 185, 129, .24); }
.topology-card { position: relative; width: min(620px, 92%); border-radius: var(--radius-lg); padding: 28px; }
.topology-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 30px 0; }
.topology-line span { min-width: 74px; padding: 12px 10px; border-radius: 10px; text-align: center; background: rgba(30,58,95,.65); border: 1px solid rgba(125,211,252,.18); color: white; font: 600 .75rem "Fira Code", Consolas, monospace; }
.topology-line i { flex: 1; height: 1px; background: linear-gradient(90deg, #38bdf8, #10b981); position: relative; }
.topology-line i::after { content: ""; position: absolute; right: -1px; top: -3px; width: 7px; height: 7px; border-radius: 50%; background: #10b981; }
.health-inline { display: flex; align-items: center; gap: 9px; color: var(--color-text-muted); font-size: .9rem; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #64748b; box-shadow: 0 0 0 4px rgba(100,116,139,.12); }
.status-ok { background: #34d399; box-shadow: 0 0 0 4px rgba(52,211,153,.12); }
.status-warn { background: #fbbf24; box-shadow: 0 0 0 4px rgba(251,191,36,.12); }
.status-error { background: #f87171; box-shadow: 0 0 0 4px rgba(248,113,113,.12); }

.app-shell { min-height: 100dvh; display: grid; grid-template-columns: var(--sidebar-width) 1fr; }
.sidebar { position: fixed; z-index: 50; inset: 0 auto 0 0; width: var(--sidebar-width); display: flex; flex-direction: column; padding: 18px 14px; border-width: 0 1px 0 0; }
.sidebar-brand { padding: 4px 8px 20px; }
.sidebar-brand strong, .sidebar-brand small { display: block; }
.sidebar-brand small { margin-top: 3px; color: var(--color-text-muted); font-size: .72rem; }
.nav-list { display: grid; gap: 5px; }
.nav-item { min-height: 44px; display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border-radius: 9px; background: transparent; color: var(--color-text-muted); text-align: left; }
.nav-item:hover { color: white; background: rgba(255,255,255,.045); }
.nav-item.active { color: white; background: linear-gradient(90deg, rgba(5,150,105,.26), rgba(30,58,95,.3)); box-shadow: inset 3px 0 #34d399; }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; border-top: 1px solid var(--color-border); padding: 16px 6px 0; }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-chip > span { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--color-primary); font-weight: 700; }
.user-chip strong, .user-chip small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { color: var(--color-text-muted); margin-top: 2px; }
.workspace { grid-column: 2; min-width: 0; }
.topbar { position: sticky; z-index: 30; top: 0; min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px clamp(18px, 3vw, 38px); border-width: 0 0 1px; }
.topbar h1 { margin: 0; font-size: 1.35rem; }
.topbar-status { display: flex; align-items: center; gap: 9px; color: var(--color-text-muted); font-size: .82rem; }
.topbar-status time { font-family: "Fira Code", Consolas, monospace; }
.content { padding: 26px clamp(18px, 3vw, 38px) 56px; max-width: 1500px; margin: 0 auto; }
.mobile-only { display: none; }

.page-heading { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-heading h2 { margin-bottom: 5px; font-size: 1.1rem; }
.page-heading p { margin: 0; color: var(--color-text-muted); font-size: .9rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.search-input { min-height: 40px; min-width: min(280px, 100%); padding: 8px 12px; border: 1px solid var(--color-border); border-radius: 8px; background: rgba(2,6,23,.35); color: white; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card, .panel { border-radius: var(--radius-md); }
.metric-card { position: relative; min-height: 130px; padding: 18px; overflow: hidden; background: linear-gradient(145deg, rgba(23,36,60,.92), rgba(15,23,42,.78)); border: 1px solid var(--color-border); }
.metric-card::after { content: ""; position: absolute; width: 90px; height: 90px; right: -26px; bottom: -42px; border-radius: 50%; background: var(--metric-glow, rgba(56,189,248,.13)); }
.metric-label { color: var(--color-text-muted); font-size: .82rem; }
.metric-value { margin: 13px 0 8px; color: white; font: 650 1.8rem/1 "Fira Code", Consolas, monospace; letter-spacing: -.04em; }
.metric-meta { color: #a7f3d0; font-size: .76rem; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 16px; }
.panel { padding: 18px; }
.panel-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.panel-header h3 { margin: 0; font-size: .98rem; }
.panel-subtle { color: var(--color-text-muted); font-size: .78rem; }
.health-list { display: grid; gap: 10px; }
.health-row { display: grid; grid-template-columns: 12px minmax(110px,1fr) auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.health-row:last-child { border-bottom: 0; }
.health-row strong { font-size: .86rem; }
.health-row span:last-child { color: var(--color-text-muted); font: .76rem "Fira Code", Consolas, monospace; }
.flow-line { display: grid; grid-template-columns: repeat(7, auto); align-items: center; justify-content: space-between; gap: 8px; padding: 28px 10px; }
.flow-node { padding: 12px; border-radius: 9px; background: rgba(30,58,95,.55); border: 1px solid var(--color-border); text-align: center; font: .76rem "Fira Code", Consolas, monospace; }
.flow-arrow { color: #34d399; }

.table-panel { overflow: hidden; padding: 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.data-table th { padding: 12px 14px; text-align: left; color: #b9c7d9; background: rgba(30,58,95,.24); font-size: .75rem; letter-spacing: .02em; }
.data-table td { padding: 13px 14px; border-top: 1px solid var(--color-border); vertical-align: middle; }
.data-table tbody tr:hover { background: rgba(255,255,255,.025); }
.data-table .mono { font-family: "Fira Code", Consolas, monospace; font-size: .76rem; font-variant-numeric: tabular-nums; }
.cell-primary { display: block; color: white; font-weight: 600; }
.cell-secondary { display: block; margin-top: 3px; color: var(--color-text-muted); font-size: .75rem; }
.status-badge { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--color-border); font-size: .75rem; font-weight: 650; }
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; }
.status-badge.ok { color: #a7f3d0; background: rgba(5,150,105,.1); border-color: rgba(16,185,129,.28); }
.status-badge.ok::before { background: #34d399; }
.status-badge.warn { color: #fde68a; background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.25); }
.status-badge.warn::before { background: #fbbf24; }
.status-badge.error { color: #fecaca; background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.25); }
.status-badge.error::before { background: #f87171; }
.actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.empty-state { display: grid; justify-items: center; gap: 8px; padding: 56px 20px; text-align: center; color: var(--color-text-muted); }
.empty-state svg { width: 34px; height: 34px; color: #64748b; }

.modal { width: min(620px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); padding: 0; border: 0; border-radius: var(--radius-lg); background: transparent; color: var(--color-text); }
.modal::backdrop { background: rgba(2,6,23,.72); backdrop-filter: blur(5px); }
.modal-frame { border-radius: var(--radius-lg); overflow: hidden; }
.modal-frame > header { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--color-border); }
.modal-frame h2 { margin: 0; font-size: 1.15rem; }
.modal-body { display: grid; gap: 16px; max-height: calc(100dvh - 210px); overflow-y: auto; padding: 20px; }
.modal-frame > footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--color-border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid .full { grid-column: 1 / -1; }
.secret-box { padding: 16px; border: 1px dashed rgba(52,211,153,.48); border-radius: 10px; background: rgba(5,150,105,.08); }
.secret-value { display: block; margin: 10px 0; color: #a7f3d0; font: 600 .96rem/1.5 "Fira Code", Consolas, monospace; overflow-wrap: anywhere; }
.toast-region { position: fixed; z-index: 1200; right: 18px; bottom: 18px; display: grid; gap: 10px; width: min(360px, calc(100vw - 36px)); }
.toast { padding: 13px 15px; border-radius: 10px; background: #17243c; border: 1px solid var(--color-border-strong); box-shadow: var(--shadow-1); color: white; animation: toast-in .2s ease-out; }
.toast.error { border-color: rgba(248,113,113,.5); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.skeleton { min-height: 94px; border-radius: var(--radius-md); background: linear-gradient(90deg, rgba(255,255,255,.035), rgba(255,255,255,.08), rgba(255,255,255,.035)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 1050px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .auth-screen { grid-template-columns: minmax(0, 560px); justify-content: center; }
  .auth-visual { display: none; }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .workspace { grid-column: 1; }
  .sidebar { transform: translateX(-102%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; }
  .topbar { justify-content: flex-start; }
  .topbar-status { margin-left: auto; }
  .hide-tablet { display: none; }
}
@media (max-width: 620px) {
  .auth-screen { display: block; padding: 18px; }
  .auth-panel { padding: 24px 20px; }
  .brand-lockup h1 { font-size: 1.7rem; }
  .metrics-grid { grid-template-columns: 1fr; }
  .topbar { min-height: 72px; padding: 10px 14px; }
  .topbar-status span:not(.status-dot), .topbar-status time { display: none; }
  .content { padding: 18px 14px 42px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .data-table tr { padding: 12px 14px; border-top: 1px solid var(--color-border); }
  .data-table td { display: grid; grid-template-columns: minmax(90px, .45fr) 1fr; gap: 12px; padding: 7px 0; border: 0; }
  .data-table td::before { content: attr(data-label); color: var(--color-text-muted); font-size: .75rem; }
  .data-table td.actions-cell { display: block; padding-top: 12px; }
  .data-table td.actions-cell::before { display: none; }
  .actions { justify-content: flex-start; }
  .flow-line { grid-template-columns: 1fr; }
  .flow-arrow { transform: rotate(90deg); text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
