:root {
  color-scheme: dark;
  --bg: #0b1016;
  --surface: #111923;
  --surface-2: #172230;
  --surface-3: #1e2c3c;
  --line: #2a3a4c;
  --text: #f2f6fa;
  --muted: #92a2b5;
  --blue: #3d8bfd;
  --blue-hover: #69a6ff;
  --green: #38c783;
  --red: #ef6262;
  --amber: #eab85b;
  --radius: 6px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select { font: inherit; letter-spacing: 0; }
a { color: inherit; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.topbar { position: sticky; top: 0; z-index: 20; height: 64px; border-bottom: 1px solid var(--line); background: rgba(11, 16, 22, .96); backdrop-filter: blur(12px); }
.topbar-inner { max-width: 1380px; height: 100%; margin: 0 auto; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; }
.brand, .account, .server-card-head, .actions, .dialog-head, .dialog-actions { display: flex; align-items: center; }
.brand { gap: 10px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; }
.brand span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: var(--radius); background: var(--blue); color: white; }
.brand-mark.small { width: 34px; height: 34px; }
.account { gap: 10px; color: var(--muted); }
.account form, .actions form { margin: 0; }

.workspace { max-width: 1380px; margin: 0 auto; padding: 24px 28px 56px; }
.tabs { display: flex; gap: 3px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.tab { position: relative; border: 0; background: transparent; color: var(--muted); padding: 10px 14px 13px; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--blue); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-heading h1 { margin: 0; font-size: 22px; line-height: 1.2; }
.section-heading p { margin: 6px 0 0; color: var(--muted); }

.button, .icon-button { border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.button { min-height: 38px; gap: 8px; padding: 0 14px; font-weight: 650; }
.button.primary { background: var(--blue); color: white; }
.button.primary:hover { background: var(--blue-hover); }
.button.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.icon-button { width: 34px; height: 34px; padding: 0; background: transparent; color: var(--muted); }
.icon-button:hover { background: var(--surface-2); color: var(--text); }
.icon-button.danger:hover { color: var(--red); }

.notice { margin-bottom: 18px; padding: 11px 13px; border: 1px solid; border-radius: var(--radius); }
.notice.ok { color: #b9f4d7; background: #103324; border-color: #236c4d; }
.notice.error { color: #ffd0d0; background: #3a181b; border-color: #7e3238; }

.server-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.server-card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.server-card-head { min-height: 74px; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.location-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius); background: var(--surface-3); color: var(--blue-hover); }
.server-card h2 { margin: 0; font-size: 16px; }
.server-card p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; font-size: 12px; }
.status span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.online { color: var(--green); }
.status.off { color: var(--muted); }
.server-card-head .status { margin-left: auto; }
.server-stats { display: grid; grid-template-columns: 100px 100px minmax(0, 1fr); margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.server-stats div { min-width: 0; }
.server-stats dt { color: var(--muted); font-size: 11px; }
.server-stats dd { margin: 5px 0 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; }
.protocol-list { display: grid; }
.protocol-row { min-width: 0; min-height: 46px; display: grid; grid-template-columns: 66px minmax(100px, 1fr) minmax(110px, .8fr) 28px 20px; align-items: center; gap: 10px; padding: 6px 16px; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.protocol-row:first-child { border-top: 0; }
.protocol-row:hover { background: var(--surface-2); }
.protocol-row svg { color: var(--muted); }
.protocol-kind { display: inline-flex; align-items: center; width: fit-content; min-height: 22px; padding: 0 6px; border: 1px solid #38638b; border-radius: 4px; color: #9bcbff; font-size: 10px; font-weight: 750; text-transform: uppercase; white-space: nowrap; }
.protocol-kind.awg2 { border-color: #376e55; color: #8de1b5; }
.source-badge { display: inline-flex; min-height: 20px; align-items: center; margin-left: 7px; padding: 0 5px; border: 1px solid #526274; border-radius: 4px; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; vertical-align: middle; }
.current-badge { display: inline-flex; min-height: 20px; align-items: center; margin-left: 7px; padding: 0 5px; border: 1px solid #277b58; border-radius: 4px; color: #8de1b5; font-size: 9px; font-weight: 700; text-transform: uppercase; vertical-align: middle; }
.protocol-kind.awg3 { border-color: #6a568d; color: #cdb2ff; }
.protocol-kind.trojan, .protocol-kind.tuic { border-color: #8a6532; color: #f5c87c; }
.protocol-name, .protocol-endpoint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.protocol-endpoint { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
.protocol-count { color: var(--muted); text-align: right; }

.route-node-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 24px; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.route-node-tab { min-width: 0; min-height: 54px; display: flex; align-items: center; gap: 10px; padding: 8px 11px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--muted); text-align: left; cursor: pointer; }
.route-node-tab:hover { background: var(--surface-2); color: var(--text); }
.route-node-tab.active { border-color: #3c5470; background: var(--surface-3); color: var(--text); }
.route-node-tab > svg { flex: 0 0 auto; color: var(--blue-hover); }
.route-node-tab span, .route-node-tab strong, .route-node-tab small { min-width: 0; display: block; }
.route-node-tab strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.route-node-tab small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.route-node-panel { display: none; }
.route-node-panel.active { display: block; }
.route-overview { min-height: 104px; display: flex; align-items: start; justify-content: space-between; gap: 28px; padding: 0 0 20px; border-bottom: 1px solid var(--line); }
.route-overview > div { min-width: 0; }
.route-title-line { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.route-title-line h2 { margin: 0; font-size: 19px; }
.route-overview p { max-width: 760px; margin: 8px 0 0; color: var(--muted); line-height: 1.5; }
.route-mode { min-height: 24px; display: inline-flex; align-items: center; padding: 0 8px; border: 1px solid #376e55; border-radius: 4px; color: #8de1b5; font-size: 11px; font-weight: 700; }
.route-mode.split { border-color: #8a6532; color: #f5c87c; }
.route-entries { max-width: 520px; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.route-label { width: 100%; color: var(--muted); font-size: 11px; text-align: right; text-transform: uppercase; }
.entry-chip { min-height: 25px; display: inline-flex; align-items: center; padding: 0 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: #bed0e3; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; white-space: nowrap; }
.route-runtime { min-height: 66px; display: grid; grid-template-columns: 40px repeat(3, minmax(130px, 1fr)) auto; align-items: center; gap: 14px; margin: 16px 0; padding: 10px 14px; border: 1px solid #375778; border-radius: var(--radius); background: #101e2c; }
.route-runtime-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 4px; background: #173452; color: var(--blue-hover); }
.route-runtime div span, .route-runtime div strong { display: block; }
.route-runtime div span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.route-runtime div strong { margin-top: 4px; overflow-wrap: anywhere; font-size: 13px; }
.runtime-note { color: var(--muted); font-size: 11px; text-align: right; }
.singbox-summary { min-height: 48px; display: flex; align-items: center; gap: 14px; margin: 0 0 16px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.singbox-summary-title { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; color: var(--text); font-size: 11px; font-weight: 700; white-space: nowrap; }
.singbox-summary-title svg { width: 15px; height: 15px; color: var(--blue-hover); }
.singbox-summary > div { min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.singbox-summary > div span { min-height: 23px; display: inline-flex; align-items: center; padding: 0 7px; border: 1px solid #344b64; border-radius: 4px; color: #b9cce0; font-size: 10px; white-space: nowrap; }
.route-lanes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.route-lane { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; border: 1px solid var(--line); border-left: 3px solid #4779ad; border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.route-lane.local { border-left-color: var(--green); }
.route-lane.dns { border-left-color: #b58bdf; }
.route-lane.special { border-left-color: var(--amber); }
.route-lane-head { min-height: 76px; display: flex; align-items: start; justify-content: space-between; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.route-lane-head h3 { margin: 0; font-size: 14px; }
.route-lane-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.route-current { flex: 0 0 auto; max-width: 180px; display: inline-flex; align-items: center; gap: 5px; padding: 4px 6px; border-radius: 4px; background: #173452; color: #a9d1ff; font-size: 10px; }
.route-current svg { width: 13px; height: 13px; }
.route-flow { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr) 18px minmax(0, 1fr); align-items: center; gap: 4px; padding: 14px; }
.route-step { min-width: 0; display: flex; align-items: center; gap: 8px; }
.route-step-icon { flex: 0 0 auto; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 4px; background: var(--surface-3); color: var(--blue-hover); }
.route-step-icon svg { width: 15px; height: 15px; }
.route-step div, .route-step strong, .route-step span { min-width: 0; display: block; }
.route-step strong { font-size: 11px; }
.route-step div > span { margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.3; overflow-wrap: anywhere; }
.route-arrow { width: 14px; color: #607187; }
.route-result { min-height: 39px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; border-top: 1px solid var(--line); background: #0f1720; }
.route-result span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.route-result strong { min-width: 0; overflow-wrap: anywhere; text-align: right; font-size: 11px; }
.fallback-section { margin-top: 24px; }
.fallback-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.fallback-heading > svg { color: var(--blue-hover); }
.fallback-heading h3 { margin: 0; font-size: 15px; }
.fallback-heading p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.fallback-table { border-top: 1px solid var(--line); }
.fallback-row { min-width: 0; display: grid; grid-template-columns: 120px minmax(220px, .75fr) minmax(320px, 1.5fr); align-items: center; gap: 16px; min-height: 72px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.fallback-channel strong, .fallback-channel span { display: block; }
.fallback-channel strong { font-size: 13px; }
.fallback-channel span { margin-top: 4px; color: var(--green); font-size: 10px; }
.fallback-row > p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.fallback-chain { min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.fallback-chain > span { min-height: 25px; display: inline-flex; align-items: center; gap: 5px; padding: 0 7px 0 5px; border: 1px solid var(--line); border-radius: 4px; color: #b8c6d5; font-size: 10px; white-space: nowrap; }
.fallback-chain > span.current { border-color: #277b58; background: #123325; color: #a8ebca; }
.fallback-chain b { width: 16px; height: 16px; display: grid; place-items: center; border-radius: 3px; background: var(--surface-3); color: var(--muted); font-size: 9px; }
.fallback-chain svg { width: 12px; height: 12px; color: #607187; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--surface); }
.sessions-table { min-width: 900px; }
.session-platform, .session-browser { display: block; }
.session-browser { margin-top: 3px; color: var(--muted); font-size: 11px; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { height: 48px; padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.strong { font-weight: 650; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--muted); }
.actions { justify-content: flex-end; gap: 2px; }
.empty { color: var(--muted); text-align: center; padding: 30px; }

.audit-list { border-top: 1px solid var(--line); }
.audit-row { min-height: 54px; display: grid; grid-template-columns: 30px minmax(160px, 1fr) 160px 160px; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.audit-row div strong, .audit-row div span { display: block; }
.audit-row div span, .audit-ip, .audit-row time { margin-top: 3px; color: var(--muted); font-size: 12px; }
.audit-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #3b2023; color: var(--red); }
.audit-icon.success { background: #173728; color: var(--green); }
.audit-icon svg { width: 14px; height: 14px; }

dialog { width: min(500px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 24px 70px rgba(0,0,0,.55); }
dialog::backdrop { background: rgba(0, 0, 0, .7); }
.dialog-form { padding: 20px; }
.dialog-head { justify-content: space-between; align-items: start; margin-bottom: 18px; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-head p { margin: 5px 0 0; color: var(--muted); }
.dialog-form label { display: grid; gap: 7px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.dialog-form input, .dialog-form select { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); padding: 0 11px; outline: none; }
.dialog-form input:focus, .dialog-form select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(61,139,253,.14); }
.dialog-actions { justify-content: flex-end; gap: 8px; margin-top: 22px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: #0b1016; }
.login-panel { width: min(420px, 100%); display: grid; gap: 22px; padding: 30px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.login-panel .brand-mark { width: 52px; height: 52px; }
.login-panel h1 { margin: 6px 0 0; font-size: 28px; }
.eyebrow { margin: 0; color: var(--blue-hover); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.muted { margin: 10px 0 0; color: var(--muted); line-height: 1.55; }
.login-button { width: 100%; }

@media (max-width: 900px) {
  .server-grid, .route-lanes { grid-template-columns: 1fr; }
  .topbar-inner, .workspace { padding-left: 16px; padding-right: 16px; }
  .account > span { display: none; }
  .route-node-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .route-overview { flex-direction: column; gap: 14px; }
  .route-entries { max-width: none; justify-content: flex-start; }
  .route-label { text-align: left; }
  .route-runtime { grid-template-columns: 40px repeat(3, minmax(100px, 1fr)); }
  .runtime-note { grid-column: 2 / -1; text-align: left; }
  .fallback-row { grid-template-columns: 100px minmax(180px, .7fr) minmax(260px, 1.3fr); }
}

@media (max-width: 620px) {
  .section-heading { align-items: stretch; flex-direction: column; }
  .section-heading .button { width: 100%; }
  .server-stats { grid-template-columns: 80px 80px minmax(0, 1fr); }
  .protocol-row { grid-template-columns: 60px minmax(90px, 1fr) 26px 18px; }
  .protocol-endpoint { display: none; }
  .audit-row { grid-template-columns: 30px 1fr 110px; }
  .audit-ip { display: none; }
  .route-node-tabs { grid-template-columns: 1fr 1fr; }
  .route-node-tab { min-height: 50px; }
  .route-runtime { grid-template-columns: 34px 1fr; align-items: start; }
  .route-runtime-icon { grid-row: 1 / 4; }
  .runtime-note { grid-column: 2; }
  .singbox-summary { align-items: flex-start; flex-direction: column; gap: 8px; }
  .route-lane-head { flex-direction: column; }
  .route-current { max-width: none; }
  .route-flow { grid-template-columns: 1fr; gap: 7px; }
  .route-step { width: 100%; }
  .route-arrow { margin-left: 7px; transform: rotate(90deg); }
  .fallback-row { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 14px 0; }
  .fallback-chain { align-items: flex-start; }
  .fallback-chain svg { display: none; }
  .login-panel { padding: 22px; }
}



