:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 16px;
  --bg: #0d0f12;
  --panel: #15181d;
  --panel-2: #1b1f25;
  --line: #2a2f37;
  --muted: #969da8;
  --text: #f4f6f8;
  --gold: #d99a52;
  --gold-dark: #aa6e32;
  --green: #42cc86;
  --red: #ef6b67;
  --blue: #60a5fa;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-view { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 470px) 1fr; background: #0a0c0f; }
.login-panel { min-height: 100vh; padding: max(42px, 8vh) clamp(30px, 6vw, 72px); background: #12151a; border-right: 1px solid #262b32; display: flex; flex-direction: column; justify-content: center; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand strong { display: block; font-size: 18px; white-space: nowrap; }
.brand small { display: block; margin-top: 5px; color: var(--gold); font-size: 9px; letter-spacing: 4px; }
.brand-mark { width: 31px; height: 24px; display: flex; align-items: center; gap: 5px; }
.brand-mark i { display: block; width: 5px; background: var(--gold); }
.brand-mark i:nth-child(1) { height: 12px; }
.brand-mark i:nth-child(2) { height: 23px; }
.brand-mark i:nth-child(3) { height: 8px; }
.brand-login { margin-bottom: clamp(58px, 10vh, 96px); }
.login-copy h1 { margin: 0; font-size: 34px; }
.login-copy p { margin: 12px 0 30px; color: var(--muted); line-height: 1.7; }
.login-form { display: grid; gap: 18px; }
label { color: #c9ced5; font-size: 13px; }
input, select { display: block; width: 100%; margin-top: 8px; height: 42px; padding: 0 12px; color: var(--text); background: #0f1216; border: 1px solid #343a44; border-radius: 5px; outline: none; }
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217,154,82,.12); }
.form-error { min-height: 20px; margin: -4px 0 0; color: var(--red); font-size: 13px; }
.primary, .secondary, .ghost, .text-button { min-height: 40px; border: 0; border-radius: 5px; padding: 0 16px; }
.primary { background: var(--gold); color: #17120c; font-weight: 700; }
.primary:hover { background: #e7aa65; }
.secondary { color: var(--gold); background: rgba(217,154,82,.1); border: 1px solid rgba(217,154,82,.35); }
.ghost { color: #d5d9df; background: transparent; border: 1px solid var(--line); }
.wide { width: 100%; }
.login-foot { margin: 30px 0 0; color: #6f7781; font-size: 12px; text-align: center; }
.login-status { display: flex; align-items: flex-end; gap: 13px; padding: 56px; background: #0d1014; border-left: 1px solid #20252c; }
.login-status strong, .login-status small { display: block; }
.login-status small { margin-top: 4px; color: #aeb5bf; }
.pulse, .status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 6px rgba(66,204,134,.1); flex: 0 0 auto; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 30px 20px 22px; border-right: 1px solid var(--line); background: #101318; display: flex; flex-direction: column; }
.main-nav { display: grid; gap: 7px; margin-top: 48px; }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 14px; border: 1px solid transparent; border-radius: 5px; color: #aeb5bf; background: transparent; text-align: left; }
.nav-item:hover { color: var(--text); background: #181c22; }
.nav-item.active { color: #f8d6af; border-color: rgba(217,154,82,.25); background: rgba(217,154,82,.1); }
.nav-icon { width: 20px; color: var(--gold); text-align: center; font-size: 18px; }
.count-badge { margin-left: auto; min-width: 21px; height: 21px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; color: #fff; background: var(--red); font-size: 11px; font-weight: 700; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 16px; }
.node-mini { display: flex; align-items: center; gap: 12px; padding: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.node-mini small, .node-mini strong { display: block; }
.node-mini small { margin-bottom: 4px; color: var(--muted); font-size: 11px; }

.main-content { width: 100%; max-width: 1540px; margin: 0 auto; padding: 34px clamp(24px, 4vw, 62px) 70px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 5px 0 0; font-size: 28px; }
.eyebrow { margin: 0; color: var(--gold); font-size: 10px; letter-spacing: 3px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.last-updated { color: var(--muted); font-size: 12px; }
.icon-button { width: 38px; height: 38px; padding: 0; border-radius: 5px; border: 1px solid var(--line); color: #dce1e7; background: var(--panel); font-size: 20px; }
.icon-button:hover { border-color: #535b67; }
.icon-button.danger { color: var(--red); }
.view { display: none; padding-top: 30px; }
.view.active-view { display: block; }
.status-banner, .notice-band { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); color: #d4d9e0; font-size: 13px; }
.status-banner.error { color: #ffc0bc; border-color: rgba(239,107,103,.4); }
.status-banner.error .pulse { background: var(--red); box-shadow: 0 0 0 6px rgba(239,107,103,.1); }
.notice-band { margin-bottom: 28px; color: #f0c38f; border-color: rgba(217,154,82,.26); background: rgba(217,154,82,.07); }
code { color: #f5d2a8; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-top: 18px; }
.metric { min-height: 142px; padding: 22px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; margin: 18px 0 7px; font-size: 30px; }
.metric small { font-size: 11px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 38px 0 16px; }
.section-heading .primary { flex: 0 0 auto; white-space: nowrap; }
.section-heading h2, .settings-section h2 { margin: 0; font-size: 18px; }
.section-heading p, .subsection-heading p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.text-button { color: var(--gold); background: transparent; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 15px 16px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
th { color: #8f97a2; background: #12151a; font-size: 11px; font-weight: 500; }
tbody tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 25px; padding: 0 9px; border-radius: 12px; color: #b8f0d2; background: rgba(66,204,134,.12); font-size: 11px; }
.badge.offline { color: #c1c6cd; background: #292e35; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.empty-row { color: var(--muted); text-align: center; padding: 30px; }

.client-list { display: grid; gap: 16px; }
.client-card { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); overflow: hidden; }
.client-card-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.client-card-head h3 { margin: 0; font-size: 16px; }
.title-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.title-line h3 { margin: 0; font-size: 16px; }
.client-card-head p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.client-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.client-actions button, .client-actions a { min-height: 34px; display: inline-flex; align-items: center; border-radius: 4px; padding: 0 11px; border: 1px solid var(--line); background: #111419; color: #d8dde4; text-decoration: none; font-size: 12px; }
.client-actions .download { color: #f1c28d; border-color: rgba(217,154,82,.35); }
.client-actions .approve { color: #b8f0d2; border-color: rgba(66,204,134,.4); }
.review-badge { min-height: 23px; padding: 0 8px; display: inline-flex; align-items: center; border-radius: 12px; font-size: 11px; }
.review-badge.pending { color: #f5cf9f; background: rgba(217,154,82,.14); }
.review-badge.approved { color: #b8f0d2; background: rgba(66,204,134,.12); }
.review-badge.rejected { color: #ffc0bc; background: rgba(239,107,103,.12); }
.review-note { padding: 11px 22px; color: #ffc0bc; border-bottom: 1px solid var(--line); background: rgba(239,107,103,.06); font-size: 12px; }
.client-meta { display: flex; gap: 28px; padding: 13px 22px; color: var(--muted); font-size: 12px; background: #12151a; }
.client-proxies { padding: 0 22px 14px; }
.client-proxy-row { display: grid; grid-template-columns: minmax(140px,1.2fr) 80px minmax(150px,1fr) minmax(150px,1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.client-proxy-row:last-child { border-bottom: 0; }
.client-proxy-row span { color: var(--muted); }
.filter-bar { display: flex; gap: 8px; margin: -2px 0 18px; overflow-x: auto; }
.filter { min-height: 34px; padding: 0 14px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: var(--panel); white-space: nowrap; }
.filter.active { color: #f8d6af; border-color: rgba(217,154,82,.4); background: rgba(217,154,82,.1); }
.account-list { display: grid; gap: 12px; }
.account-row { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 19px 22px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.account-row p { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-section { padding: 24px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
dl { margin: 22px 0 0; }
dl div { display: flex; justify-content: space-between; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
dl div:last-child { border-bottom: 0; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 600; }
.check-list { margin: 20px 0 0; padding: 0; list-style: none; }
.check-list li { position: relative; padding: 12px 0 12px 27px; border-bottom: 1px solid var(--line); color: #cbd0d7; line-height: 1.6; }
.check-list li::before { content: '✓'; position: absolute; left: 2px; color: var(--green); }

.modal { width: min(1050px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; color: var(--text); border: 1px solid #3a404a; border-radius: 7px; background: #15181d; }
.modal::backdrop { background: rgba(0,0,0,.72); }
.modal form { padding: 24px; }
.modal-header, .subsection-heading, .modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.modal-header { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 5px 0 0; font-size: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.single { grid-template-columns: 1fr; }
.small-modal { width: min(560px, calc(100vw - 28px)); }
.subsection-heading { margin: 26px 0 13px; }
.subsection-heading h3 { margin: 0; font-size: 15px; }
.proxy-editor { display: grid; gap: 10px; }
.proxy-row { position: relative; display: grid; grid-template-columns: 1.1fr .6fr 1.1fr .8fr 1fr 1fr 38px; gap: 9px; padding: 14px; border: 1px solid var(--line); border-radius: 5px; background: #111419; }
.proxy-row .remove-proxy { align-self: end; }
.modal-actions { justify-content: flex-end; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.modal-actions button { min-width: 100px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: min(420px, calc(100vw - 40px)); padding: 13px 16px; border: 1px solid var(--line); border-radius: 5px; background: #20252c; box-shadow: 0 16px 40px rgba(0,0,0,.4); transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: rgba(239,107,103,.5); color: #ffc0bc; }

@media (max-width: 1000px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .proxy-row { grid-template-columns: 1fr 1fr 1fr; }
  .proxy-row .remove-proxy { position: absolute; right: 8px; top: 8px; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .login-view { grid-template-columns: 1fr; }
  .login-panel { min-height: 100vh; padding: max(34px, env(safe-area-inset-top)) 24px 34px; border-right: 0; }
  .login-status { display: none; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: max(18px, env(safe-area-inset-top)) 16px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .main-nav { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; margin-top: 18px; padding-bottom: 2px; }
  .nav-item { min-width: 0; min-height: 38px; padding: 0 11px; }
  .nav-icon { width: auto; }
  .sidebar-bottom { display: none; }
  .main-content { padding: 22px 15px 48px; }
  .topbar h1 { font-size: 23px; }
  .last-updated { display: none; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric { min-height: 124px; padding: 17px; }
  .metric strong { margin-top: 14px; font-size: 25px; }
  .section-heading { align-items: center; margin-top: 28px; }
  .client-card-head { align-items: flex-start; flex-direction: column; }
  .account-row { align-items: flex-start; flex-direction: column; }
  .client-meta { gap: 12px; flex-direction: column; }
  .client-proxy-row { grid-template-columns: 1fr 1fr; }
  .form-grid, .proxy-row { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .modal form { padding: 17px; }
  .modal-actions { position: sticky; bottom: -17px; margin-left: -17px; margin-right: -17px; padding: 13px 17px max(13px, env(safe-area-inset-bottom)); background: #15181d; }
}
