: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; 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; }
.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; }

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--surface); }
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 { grid-template-columns: 1fr; }
  .topbar-inner, .workspace { padding-left: 16px; padding-right: 16px; }
  .account > span { display: none; }
}

@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; }
  .login-panel { padding: 22px; }
}

