:root {
  --bg: #f3f6f9;
  --panel: #ffffff;
  --text: #17212b;
  --muted: #718096;
  --line: #dce4ec;
  --nav: #101923;
  --blue: #1577d4;
  --blue-dark: #0f5eaa;
  --cyan: #27b7c5;
  --green: #198754;
  --red: #d83a4d;
  --amber: #d38b00;
  --shadow: 0 12px 32px rgba(30, 50, 70, .07);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.55 Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
code { font-family: "SFMono-Regular", Consolas, monospace; font-size: .9em; word-break: break-all; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(26px, 3vw, 38px); line-height: 1.2; letter-spacing: -.03em; }
h2 { margin-bottom: 16px; font-size: 19px; letter-spacing: -.01em; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 248px;
  flex-direction: column;
  color: #e8eff6;
  background: linear-gradient(165deg, #121e29, #0c141d 70%);
  border-right: 1px solid rgba(255,255,255,.06);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 28px 24px 24px; color: #fff; }
.brand span:last-child { display: flex; flex-direction: column; }
.brand small { color: #7f93a7; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; }
.brand-mark {
  display: inline-grid;
  width: 39px;
  height: 39px;
  place-items: center;
  color: white;
  font-weight: 800;
  letter-spacing: -.08em;
  background: linear-gradient(145deg, #259ded, #1262c1);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(19,112,203,.35);
}
.brand-mark.large { width: 54px; height: 54px; border-radius: 16px; }
.sidebar nav { display: flex; flex: 1; flex-direction: column; gap: 4px; padding: 6px 14px; overflow-y: auto; }
.sidebar nav a { padding: 10px 13px; color: #a9b7c5; border-radius: 9px; transition: .18s ease; }
.sidebar nav a:hover { color: #fff; background: rgba(255,255,255,.05); }
.sidebar nav a.active { color: #fff; background: linear-gradient(90deg, rgba(31,137,224,.32), rgba(31,137,224,.12)); box-shadow: inset 3px 0 #2da0f1; }
.nav-label { margin: 18px 13px 5px; color: #627487; font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.sidebar-footer { padding: 18px 26px 24px; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-footer > span, .sidebar-footer > small { display: block; }
.sidebar-footer small { color: #778a9d; }
.link-button { padding: 8px 0 0; color: #9fb1c3; background: none; border: 0; }

.main { min-height: 100vh; margin-left: 248px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 13px clamp(20px, 4vw, 46px);
  background: rgba(255,255,255,.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.topbar > div:first-child { display: flex; flex-direction: column; }
.topbar > div:first-child strong { font-variant-numeric: tabular-nums; }
.top-actions, .actions, .inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.content { width: min(1540px, 100%); margin: 0 auto; padding: 34px clamp(20px, 4vw, 46px) 60px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow { display: block; margin-bottom: 5px; color: #6d8398; font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.back-link { display: inline-block; margin-bottom: 11px; color: var(--muted); }
.muted { color: var(--muted); }

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  color: var(--text);
  font-weight: 700;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(20, 40, 60, .03);
  transition: .15s ease;
}
.button:hover { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(20, 60, 100, .09); }
.button.primary { color: white; background: var(--blue); border-color: var(--blue); }
.button.primary:hover { background: var(--blue-dark); }
.button.danger { color: white; background: var(--red); border-color: var(--red); }
.button.warning { color: white; background: var(--amber); border-color: var(--amber); }
.button.ghost { color: #31506a; background: transparent; }
.button.small { min-height: 33px; padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.button.full { width: 100%; }
.icon-button { width: 32px; height: 32px; color: var(--muted); font-size: 24px; background: none; border: 0; }

.status-pill, .tag {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  padding: 4px 9px;
  color: #4a6176;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  background: #edf2f6;
  border-radius: 999px;
  white-space: nowrap;
}
.status-pill.success { color: #087545; background: #e6f7ef; }
.status-pill.danger { color: #b62034; background: #fdebee; }

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 22px;
  overflow: hidden;
  background: #162332;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.status-strip > div { padding: 17px 20px; color: #fff; border-right: 1px solid rgba(255,255,255,.08); }
.status-strip span, .status-strip strong { display: block; }
.status-strip span { color: #8fa2b5; font-size: 11px; }
.status-strip strong { margin-top: 4px; font-size: 17px; }

.card-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 22px; }
.metric-card, .panel, .account-card {
  background: var(--panel);
  border: 1px solid rgba(214,224,233,.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.metric-card { position: relative; min-height: 130px; padding: 20px; overflow: hidden; }
.metric-card::after { position: absolute; right: -24px; bottom: -37px; width: 90px; height: 90px; content: ""; background: #edf4fa; border-radius: 50%; }
.metric-card.accent { color: white; background: linear-gradient(145deg, #1488db, #1269be); border: 0; }
.metric-card.accent::after { background: rgba(255,255,255,.09); }
.metric-card.warning-card { background: #fffbf0; }
.metric-card > span, .metric-card > strong, .metric-card > small { position: relative; z-index: 1; display: block; }
.metric-card > span { color: var(--muted); font-size: 12px; }
.metric-card.accent > span, .metric-card.accent > small { color: #cfeaff; }
.metric-card > strong { margin: 7px 0; font-size: 32px; font-variant-numeric: tabular-nums; }
.metric-card > small { color: var(--muted); }

.split-grid, .detail-grid, .settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.sub-tabs { display: inline-flex; gap: 6px; margin-bottom: 18px; padding: 5px; background: #eaf0f5; border: 1px solid var(--line); border-radius: 13px; }
.sub-tabs a { display: flex; min-width: 190px; flex-direction: column; gap: 2px; padding: 10px 15px; color: var(--muted); border: 1px solid transparent; border-radius: 9px; }
.sub-tabs a span { color: var(--text); font-size: 13px; font-weight: 800; }
.sub-tabs a small { font-size: 10px; }
.sub-tabs a.active { background: white; border-color: #cfdce7; box-shadow: 0 5px 14px rgba(28,54,77,.08); }
.sub-tabs a.active span { color: var(--blue); }
.panel { margin-bottom: 18px; padding: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.table-panel { padding: 0; overflow: hidden; }
.table-panel .panel-head { padding: 20px 22px 0; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 14px; color: #6b7f92; font-size: 10px; letter-spacing: .08em; text-align: left; text-transform: uppercase; background: #f7f9fb; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 14px; vertical-align: middle; border-bottom: 1px solid #e8eef3; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfd; }
td > strong, td > small { display: block; }
td > small { margin-top: 3px; color: var(--muted); }
.clickable-row { cursor: pointer; }
.empty { padding: 34px !important; color: var(--muted); text-align: center; }
.error-text { max-width: 300px; color: var(--red) !important; white-space: normal; }

.timeline { display: flex; flex-direction: column; }
.timeline-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 0; color: var(--text); border-bottom: 1px solid #edf1f5; }
.timeline-item:last-child { border-bottom: 0; }
.timeline-item small { display: block; color: var(--muted); }
.timeline-dot { width: 9px; height: 9px; background: var(--blue); border: 3px solid #d6edff; border-radius: 50%; box-sizing: content-box; }
.danger-dot { background: var(--red); border-color: #fde4e8; }

.filter-bar, .save-bar, .decision-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 13px;
}
.filter-bar input, .filter-bar select { width: min(260px, 100%); }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--text);
  background: white;
  border: 1px solid #cbd6df;
  border-radius: 9px;
  outline: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(20,119,212,.12); }
button:disabled { cursor: not-allowed; opacity: .52; transform: none !important; }
label { display: flex; flex-direction: column; gap: 6px; color: #3c5266; font-size: 12px; font-weight: 700; }
.field-help { color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.55; }
.protocol-import-grid { align-items: start; }
.protocol-import-grid input[type="file"] { padding: 8px; }
.proxy-summary .data-list { margin-top: 18px; }
.pin-input { width: 95px; min-height: 33px; padding: 5px 8px; text-align: center; letter-spacing: .12em; }
.pin-input.wide { width: 150px; min-height: 42px; }
.stack-form { display: flex; flex-direction: column; gap: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.span-2 { grid-column: span 2; }
.check-row { flex-direction: row; align-items: center; }
.check-row input, .toggle-row input { width: 19px; min-height: 19px; }
.toggle-row { flex-direction: row; align-items: center; justify-content: space-between; padding: 15px 0 18px; border-bottom: 1px solid var(--line); }
.toggle-row span, .toggle-row small { display: block; }
.toggle-row small { color: var(--muted); font-weight: 400; }

.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 16px; color: var(--muted); border-top: 1px solid var(--line); }
.pagination > :last-child { justify-self: end; }
.data-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; margin: 0; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 10px; }
.data-list div { padding: 12px; background: white; }
.data-list dt { color: var(--muted); font-size: 11px; }
.data-list dd { margin: 3px 0 0; font-weight: 700; }
.json-view { max-height: 420px; margin: 0; padding: 16px; overflow: auto; color: #dce8f2; background: #101b26; border-radius: 10px; font: 12px/1.65 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; }
.json-view.compact { min-width: 340px; max-height: 260px; }
details.panel summary { cursor: pointer; font-weight: 800; }
details.panel[open] summary { margin-bottom: 18px; }
.decision-bar { justify-content: space-between; border-color: #bcdcf5; box-shadow: var(--shadow); }
.decision-bar p { margin: 3px 0 0; color: var(--muted); }

dialog { width: min(680px, calc(100% - 30px)); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 30px 90px rgba(10,30,50,.28); }
dialog::backdrop { background: rgba(7,15,24,.57); backdrop-filter: blur(3px); }
.dialog-card { padding: 24px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.alert { margin-bottom: 18px; padding: 13px 15px; color: #31506a; background: #eaf4fc; border: 1px solid #cbe4f8; border-radius: 10px; }
.alert.error { color: #9d2434; background: #fff0f2; border-color: #f2cbd1; }
.alert.success { color: #126c45; background: #ecf9f2; border-color: #ccebdc; }
.alert.warning { color: #865d00; background: #fff8e6; border-color: #f0dfad; }
.callout { margin-top: 18px; padding: 15px 17px; background: #f0f7fc; border-left: 4px solid var(--blue); border-radius: 8px; }
.callout.warning { color: #6f4d00; background: #fff9e9; border-left-color: var(--amber); }
.callout p { margin: 4px 0 0; }

.account-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 15px; margin-bottom: 18px; padding: 20px; }
.avatar { display: grid; width: 50px; height: 50px; place-items: center; color: white; font-weight: 800; background: linear-gradient(145deg, var(--blue), var(--cyan)); border-radius: 50%; }
.account-card h2, .account-card p { margin: 0; }
.account-card p { color: var(--muted); }
.account-stats { display: flex; flex-wrap: wrap; gap: 18px 28px; }
.account-stats span, .account-stats strong { display: block; }
.account-stats span { color: var(--muted); font-size: 11px; }
.account-stats strong { margin-top: 3px; color: var(--text); font-size: 13px; }
.account-card > form { grid-column: 1 / -1; padding-top: 14px; border-top: 1px solid var(--line); }
.save-bar { position: sticky; bottom: 15px; z-index: 10; justify-content: flex-end; margin-top: 18px; box-shadow: 0 14px 38px rgba(23,51,75,.15); }
.save-bar label { flex-direction: row; align-items: center; }
.restore-form { display: flex; min-width: 520px; gap: 6px; }
.restore-form input { min-height: 33px; padding: 5px 8px; }

.log-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; }
.log-files { display: flex; flex-direction: column; padding: 9px; }
.log-files a { display: flex; justify-content: space-between; gap: 7px; padding: 10px; color: var(--text); border-radius: 8px; }
.log-files a.active { background: #eaf4fc; }
.log-files small { color: var(--muted); }
.log-view pre { max-height: 68vh; margin: 0; padding: 15px; overflow: auto; color: #d4e2ed; background: #0e1720; border-radius: 10px; font: 11px/1.6 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; color: white; background: radial-gradient(circle at 20% 20%, #1f4b70, #101a24 55%); }
.login-shell { display: grid; width: min(940px, 100%); grid-template-columns: 1.15fr .85fr; overflow: hidden; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 26px; box-shadow: 0 40px 100px rgba(0,0,0,.3); backdrop-filter: blur(16px); }
.login-visual { padding: 70px 58px; background: linear-gradient(145deg, rgba(21,119,212,.36), rgba(12,29,43,.18)); }
.login-visual h1 { margin: 40px 0 20px; font-size: 46px; }
.login-visual p { max-width: 440px; color: #b7c9d9; }
.login-card { display: flex; flex-direction: column; justify-content: center; padding: 54px 44px; color: var(--text); background: white; }
.login-card h2 { margin-bottom: 3px; font-size: 28px; }

@media (max-width: 1200px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
  .status-strip { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .sidebar { position: static; width: 100%; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar-footer, .nav-label { display: none; }
  .main { margin-left: 0; }
  .topbar { position: static; align-items: flex-start; }
  .top-actions { justify-content: flex-end; }
  .split-grid, .detail-grid, .settings-grid, .log-layout { grid-template-columns: 1fr; }
  .account-card { grid-template-columns: auto 1fr; }
  .account-stats { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
  .content { padding: 24px 14px 45px; }
  .topbar { padding: 12px 14px; }
  .topbar > div:first-child { display: none; }
  .card-grid, .status-strip, .form-grid, .data-list { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-bar input, .filter-bar select { width: 100%; }
  .sub-tabs { display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sub-tabs a { min-width: 0; padding: 10px; }
  .sub-tabs a small { display: none; }
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-card { padding: 40px 25px; }
}
