:root {
  color-scheme: dark;
  --bg: #0c1118;
  --panel: #131b26;
  --panel-soft: #182331;
  --panel-hover: #1d2a3a;
  --line: #263548;
  --line-strong: #3a4d66;
  --text: #e7edf6;
  --text-muted: #8e9caf;
  --text-dim: #637187;
  --blue: #68a1ff;
  --blue-soft: rgba(104, 161, 255, .14);
  --green: #5bdd9a;
  --green-soft: rgba(91, 221, 154, .14);
  --orange: #f6b45a;
  --orange-soft: rgba(246, 180, 90, .14);
  --purple: #bd98ff;
  --purple-soft: rgba(189, 152, 255, .14);
  --red: #ff7878;
  --red-soft: rgba(255, 120, 120, .14);
  --shadow: 0 18px 48px rgba(0, 0, 0, .22);
  --radius: 10px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

:root.light {
  color-scheme: light;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-soft: #f5f8fc;
  --panel-hover: #eef4fb;
  --line: #dbe4ef;
  --line-strong: #c5d2e2;
  --text: #172232;
  --text-muted: #5e6d80;
  --text-dim: #8c9aae;
  --blue: #2869d8;
  --blue-soft: rgba(40, 105, 216, .10);
  --green: #168650;
  --green-soft: rgba(22, 134, 80, .10);
  --orange: #af6900;
  --orange-soft: rgba(175, 105, 0, .10);
  --purple: #7447b8;
  --purple-soft: rgba(116, 71, 184, .10);
  --red: #c53b3b;
  --red-soft: rgba(197, 59, 59, .10);
  --shadow: 0 14px 36px rgba(27, 48, 75, .10);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.55 var(--sans); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.app-shell { min-height: 100vh; }
.topbar { height: 62px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 90%, transparent); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(16px); }
.brand { display: flex; gap: 11px; align-items: center; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: linear-gradient(145deg, #467eea, #5eb0ff); font-size: 22px; box-shadow: 0 6px 16px rgba(71, 126, 234, .3); }
.brand strong { display: block; letter-spacing: .02em; font-size: 14px; }
.brand span:last-child { display: block; color: var(--text-muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.topbar-actions, .header-inline, .heading-actions { display: flex; gap: 10px; align-items: center; }

.workspace { display: flex; min-height: calc(100vh - 62px); }
.sidebar { width: 230px; flex: 0 0 230px; padding: 26px 16px; border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; }
.side-section + .side-section { margin-top: 28px; }
.side-footer { margin-top: auto !important; }
.side-label, .eyebrow { color: var(--text-dim); font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 10px; }
.nav-item { width: 100%; display: flex; gap: 10px; align-items: center; padding: 10px 12px; margin: 3px 0; border: 1px solid transparent; border-radius: 8px; color: var(--text-muted); background: transparent; text-align: left; transition: .18s ease; }
.nav-item span { width: 16px; color: currentColor; font-size: 15px; text-align: center; }
.nav-item:hover { color: var(--text); background: var(--panel-soft); }
.nav-item.active { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 24%, transparent); background: var(--blue-soft); }

.main-content { width: min(1360px, 100%); padding: 38px clamp(20px, 4vw, 54px) 70px; margin: 0 auto; }
.view { display: none; animation: enter .18s ease-out; }
.view.active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.page-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 26px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(26px, 3vw, 34px); letter-spacing: -.02em; line-height: 1.15; }
h2 { font-size: 15px; letter-spacing: .01em; }
.subtitle { color: var(--text-muted); margin-top: 8px; }

.button, .icon-button, .text-button { border: 1px solid var(--line-strong); color: var(--text); background: var(--panel-soft); border-radius: 7px; transition: .18s ease; }
.button { padding: 8px 13px; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.button:hover, .icon-button:hover { border-color: var(--blue); background: var(--panel-hover); }
.button.primary { color: #fff; border-color: #4e88ef; background: #3974dd; }
.button.primary:hover { background: #4d87ef; }
.button.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 50%, var(--line)); background: var(--red-soft); }
.button.small { padding: 5px 9px; font-size: 12px; }
.button.full { width: 100%; justify-content: center; margin-top: 10px; }
.icon-button { width: 30px; height: 30px; display: grid; place-items: center; padding: 0; font-size: 15px; }
.text-button { border: 0; padding: 3px 0; background: transparent; color: var(--blue); font-size: 12px; }
.text-button:hover { text-decoration: underline; }
.text-button.danger { color: var(--red); }

.status-pill, .panel-badge, .tag, .country-tag { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 99px; padding: 4px 9px; color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.online { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, var(--line)); background: var(--green-soft); }
.status-pill.error { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); background: var(--red-soft); }
.status-pill.neutral { color: var(--text-muted); }
.panel-badge { font-size: 10px; padding: 3px 8px; }
.panel-badge.muted { color: var(--text-dim); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 18px; }
.metric-card { position: relative; overflow: hidden; min-height: 122px; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.metric-card::after { content: ""; position: absolute; width: 72px; height: 72px; right: -25px; bottom: -25px; border: 1px solid currentColor; border-radius: 50%; opacity: .18; }
.metric-card.accent-blue { color: var(--blue); } .metric-card.accent-green { color: var(--green); } .metric-card.accent-orange { color: var(--orange); } .metric-card.accent-purple { color: var(--purple); }
.metric-label { display: block; color: var(--text-muted); font-size: 11px; }
.metric-card strong { display: block; margin-top: 11px; color: var(--text); font: 600 29px/1 var(--mono); }
.metric-card small { display: block; margin-top: 8px; color: var(--text-dim); }

.content-grid { display: grid; gap: 15px; margin-bottom: 15px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.directpay-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); }
.panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.panel-header { min-height: 65px; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-header .eyebrow { margin-bottom: 4px; }
.panel-form { min-width: 0; }
.form-stack { padding: 18px; }
.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.workflow-chip { padding: 7px 11px; border: 1px solid color-mix(in srgb, var(--blue) 42%, var(--line)); border-radius: 99px; color: var(--blue); background: var(--blue-soft); font: 11px var(--mono); white-space: nowrap; }
.result-panel { min-height: 220px; }
.result-body { padding: 21px 18px; color: var(--text-muted); }
.result-body strong { color: var(--text); font-size: 14px; }
.result-info { color: var(--blue); }
.result-success { color: var(--green); }
.result-error { color: var(--red); }
.result-meta { margin-top: 8px; color: var(--text-dim); font-size: 12px; }
.success-banner { margin-bottom: 16px; padding: 10px 12px; border-left: 3px solid var(--green); color: var(--green); background: var(--green-soft); }
.result-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.result-grid > div { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-soft); }
.result-grid span { display: block; color: var(--text-dim); font-size: 10px; }
.result-grid code, .result-grid strong { display: block; overflow: hidden; margin-top: 6px; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.url-row { display: flex; gap: 8px; align-items: center; }
.url-row input { min-width: 0; font-family: var(--mono); font-size: 11px; }
.proxy-status { padding: 17px 18px; }
.proxy-status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.proxy-status-grid > div { min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-soft); }
.proxy-status-grid span { display: block; color: var(--text-dim); font-size: 10px; }
.proxy-status-grid strong { display: block; overflow: hidden; margin-top: 5px; color: var(--text); font: 600 12px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin-bottom: 13px; }
.field > span, .check-field > span { color: var(--text-muted); font-size: 11px; }
.field em { color: var(--text-dim); font-style: normal; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 7px; outline: 0; color: var(--text); background: var(--panel-soft); padding: 9px 10px; transition: .18s ease; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
textarea { resize: vertical; min-height: 72px; font-family: var(--mono); font-size: 12px; }
select { appearance: auto; }
.check-field { display: flex; align-items: center; gap: 8px; min-height: 40px; padding-top: 17px; }
.check-field input { width: 15px; height: 15px; accent-color: var(--blue); }
.form-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; padding: 0 18px 18px; }
.form-stack .form-actions { padding: 4px 0 0; }
.inline-result { min-height: 20px; color: var(--text-muted); font-size: 12px; }
.inline-result.success { color: var(--green); }.inline-result.error { color: var(--red); }.inline-result.info { color: var(--blue); }

.address-preview { margin: 0 18px 17px; padding: 11px 12px; border-left: 3px solid var(--green); background: var(--green-soft); color: var(--text-muted); font-family: var(--mono); font-size: 11px; }
.hidden { display: none !important; }
.card-add-form { display: grid; grid-template-columns: 1.4fr .55fr .65fr .55fr 1fr auto; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-add-form input { min-width: 0; padding: 8px 9px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 540px; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--text-dim); font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
td { color: var(--text-muted); font-size: 12px; } td strong, .cell-strong { color: var(--text); font-weight: 600; }
tbody tr:hover { background: var(--panel-hover); }
code, .mono { font-family: var(--mono); font-size: 11px; }
.empty-state { padding: 30px 18px; color: var(--text-dim); text-align: center; }
.table-check { width: 15px; height: 15px; accent-color: var(--blue); }
.table-actions { display: flex; gap: 6px; }

.node-summary { padding: 10px 18px 16px; }
.node-summary-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px 75px; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.node-summary-row:last-child { border-bottom: 0; }
.node-name { overflow: hidden; text-overflow: ellipsis; color: var(--text); white-space: nowrap; }
.health-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.health-dot.healthy { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.health-dot.unhealthy { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.traffic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 16px 18px 18px; }
.traffic-item { padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); }
.traffic-item label { display: block; color: var(--text-muted); font-size: 11px; }.traffic-item strong { display: block; margin-top: 5px; color: var(--text); font: 600 13px var(--mono); }
.activity-log { max-height: 240px; overflow-y: auto; padding: 7px 18px 13px; }.log-line { display: flex; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 11px; }.log-time { color: var(--text-dim); font-family: var(--mono); }.log-line.ok { color: var(--green); }.log-line.err { color: var(--red); }.log-line.info { color: var(--text-muted); }

.hero-panel { margin-bottom: 15px; }.seven-details { padding: 18px; }.flow-chain { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-bottom: 18px; color: var(--text-muted); font-family: var(--mono); font-size: 11px; }.flow-node { padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--text); background: var(--panel-soft); }.flow-node.accent { border-color: color-mix(in srgb, var(--blue) 50%, var(--line)); color: var(--blue); background: var(--blue-soft); }.flow-arrow { color: var(--text-dim); }.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }.detail-cell { padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); }.dc-label { color: var(--text-dim); font-size: 10px; }.dc-value { margin-top: 5px; overflow: hidden; color: var(--text); font: 600 12px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.qg-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 16px 18px 18px; }.qg-item { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); }.qg-label { color: var(--text-muted); font-size: 11px; }.qg-value { margin-top: 8px; color: var(--text); font: 600 14px var(--mono); }
.subscription-controls { display: flex; gap: 8px; padding: 15px 18px 10px; }.wide-textarea { display: block; width: calc(100% - 36px); margin: 0 18px 10px; min-height: 100px; }.subscription-controls input { flex: 1; min-width: 0; }

.compact-field input { padding: 8px 9px; }.side-hint { margin-top: 9px; color: var(--text-dim); font-size: 10px; line-height: 1.5; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(340px, calc(100vw - 40px)); }.toast { padding: 11px 13px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--text); background: var(--panel); box-shadow: var(--shadow); animation: toast-in .2s ease-out; }.toast.success { border-color: color-mix(in srgb, var(--green) 45%, var(--line)); }.toast.error { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }.toast.info { border-color: color-mix(in srgb, var(--blue) 45%, var(--line)); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1050px) { .sidebar { width: 190px; flex-basis: 190px; }.metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }.directpay-grid { grid-template-columns: 1fr; }.card-add-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }.card-add-form button { width: 100%; justify-content: center; } }
.proxy-config-panel { border-color: color-mix(in srgb, var(--blue) 34%, var(--line)); }
.region-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; padding: 0 18px 16px; }
.country-tag { appearance: none; border-color: var(--line-strong); background: var(--panel-soft); color: var(--text-muted); cursor: default; }
.country-filter-button { cursor: pointer; transition: .18s ease; }
.country-filter-button:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.filter-field { display: inline-flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 11px; }
.filter-field select { width: auto; min-width: 118px; padding: 6px 8px; }

@media (max-width: 760px) { .topbar { padding: 0 16px; }.workspace { display: block; }.sidebar { width: 100%; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }.side-section { display: flex; align-items: center; gap: 5px; overflow-x: auto; }.side-section + .side-section { display: none; }.side-label { display: none; }.nav-item { width: auto; margin: 0; white-space: nowrap; }.main-content { padding: 25px 14px 55px; }.page-heading { align-items: flex-start; flex-direction: column; gap: 15px; }.heading-actions { flex-wrap: wrap; }.two-columns { grid-template-columns: 1fr; }.form-grid.two, .form-grid.three, .detail-grid, .result-grid, .proxy-status-grid { grid-template-columns: 1fr; }.qg-grid { grid-template-columns: 1fr; }.metric-grid { gap: 9px; }.metric-card { min-height: 112px; padding: 14px; }.metric-card strong { font-size: 23px; }.card-add-form { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; }.card-add-form input, .card-add-form button { width: 100%; }.panel-header { padding: 13px 14px; }.form-stack, .form-actions, .address-preview { margin-left: 0; }.form-stack { padding: 14px; }.form-stack .form-actions { padding-top: 2px; }.form-actions { padding: 0 14px 14px; }.subscription-controls { padding: 12px 14px 9px; flex-direction: column; }.wide-textarea { width: calc(100% - 28px); margin-left: 14px; margin-right: 14px; }.traffic-grid { padding-left: 14px; padding-right: 14px; }.activity-log { padding-left: 14px; padding-right: 14px; }.workflow-chip { white-space: normal; }.header-inline { align-items: flex-end; flex-wrap: wrap; }.filter-field { align-items: flex-start; flex-direction: column; gap: 3px; }.filter-field select { min-width: 108px; } }
