:root {
  --bg: #f3f6f5;
  --paper: #ffffff;
  --panel: #ffffff;
  --border: #dfe4e2;
  --text: #17201e;
  --text-2: #3e4846;
  --muted: #68716f;
  --primary: #087f6a;
  --primary-2: #056a59;
  --primary-soft: #e6f4f0;
  --green: #087f6a;
  --green-soft: #e6f4f0;
  --red: #b43b45;
  --red-soft: #fdecee;
  --amber: #a7650b;
  --amber-soft: #fff4df;
  --sidebar: #151b1a;
  --sidebar-2: #202826;
  --sidebar-muted: #99a4a1;
  --radius: 6px;
  --shadow: 0 4px 16px rgba(23, 32, 30, 0.025);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: Inter, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea {
  font-family: inherit;
  font-size: 13px;
}

button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.65; }
.hidden { display: none !important; }

/* ---------- 通用品牌 ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(8, 127, 106, 0.25);
}

.brand-mark.large {
  width: 48px;
  height: 48px;
  border-radius: 6px;
}

.brand b {
  display: block;
  font-size: 17px;
  letter-spacing: 0.04em;
}

.brand em {
  display: block;
  font-style: normal;
  font-size: 11px;
  color: #aab4b1;
  margin-top: 2px;
}

/* ---------- 按钮 ---------- */
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 5px;
  padding: 8px 14px;
  min-height: 38px;
  font-weight: 650;
  font-size: 13px;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  box-shadow: none;
}

.btn-primary:hover { background: var(--primary-2); }
.btn-primary:active { transform: translateY(1px); }

.btn-secondary {
  background: var(--paper);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: #f9fbfa; border-color: #b8c1be; }

.btn-block { width: 100%; }
.btn-block + .btn-block { margin-top: 10px; }

.link-btn {
  background: none;
  border: none;
  color: var(--sidebar-muted);
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 8px;
}

.link-btn.active { color: #fff; background: rgba(255, 255, 255, 0.1); }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(320px, 43%) 1fr;
  background: var(--paper);
}

.login-top {
  padding: 56px;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  align-items: flex-start;
  gap: 15px;
  position: relative;
  overflow: hidden;
}

.login-top .brand-mark {
  width: 48px;
  height: 48px;
}

.brand-name {
  margin: 2px 0 3px;
  font-size: 18px;
  font-weight: 760;
  color: #fff;
}

.brand-caption {
  margin: 0;
  color: #aab4b1;
  font-size: 13px;
}

.login-top:after {
  content: "";
  position: absolute;
  left: 56px;
  right: 56px;
  bottom: 56px;
  height: 1px;
  background: #34403d;
}

.login-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-card {
  width: min(460px, 100%);
  background: transparent;
  padding: 0;
  box-shadow: none;
  animation: rise 0.42s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.login-logo { display: none; }

.login-card h1 {
  text-align: left;
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.login-subtitle {
  text-align: left;
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 34px;
}

.login-tabs {
  display: flex;
  gap: 3px;
  background: var(--bg);
  border-radius: 6px;
  padding: 3px;
  margin-bottom: 24px;
  width: max-content;
}

.login-tabs .tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
}

.login-tabs .tab.active {
  background: var(--paper);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #3e4846;
  font-size: 13px;
  font-weight: 650;
  margin: 16px 0 7px;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #cfd6d4;
  border-radius: 5px;
  padding: 0 11px;
  background: var(--paper);
  color: #7b8582;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 127, 106, 0.1);
}

.input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  min-height: 42px;
  padding: 9px 0;
  color: var(--text);
}

.input-wrap input::placeholder { color: #9ca6a3; }

.login-card .btn-block { margin-top: 24px; min-height: 45px; }

.guest-scan-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding: 11px 13px;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid #cce6df;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}

.guest-scan-link:hover { border-color: #9bcfc2; }
.login-foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 18px 0 0;
}

/* ---------- 工作台布局 ---------- */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #aab6d0;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 25px;
  border-bottom: 1px solid #303836;
}
.sidebar-brand .brand-mark { width: 36px; height: 36px; }
.sidebar-brand-text { min-width: 0; }
.sidebar-brand-text strong { display: block; font-size: 14px; color: #fff; }
.sidebar-brand-text small { display: block; color: var(--sidebar-muted); margin-top: 2px; font-size: 12px; }

.nav {
  display: grid;
  gap: 4px;
  margin-top: 22px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--sidebar-muted);
  font-size: 13px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--sidebar-2); color: #fff; }

.nav-item.active {
  background: #293431;
  color: #fff;
  box-shadow: none;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 18px 8px 0;
  border-top: 1px solid #303836;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #35413e;
  color: #dce4e1;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.avatar.small { width: 28px; height: 28px; font-size: 11px; }

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info b { display: block; color: #fff; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info span { font-size: 11px; color: var(--sidebar-muted); }

.logout-btn {
  border: none;
  background: transparent;
  color: var(--sidebar-muted);
  padding: 6px;
  border-radius: 4px;
  display: inline-flex;
}

.logout-btn:hover { background: #293431; color: #fff; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 69px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--border);
  padding: 0 34px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.topbar h2 { margin: 0; font-size: 18px; }

.topbar-right { display: flex; align-items: center; gap: 18px; }

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}

.sync-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

#pageContent {
  flex: 1;
  overflow-y: auto;
  padding: 30px 34px 54px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.22s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 卡片与面板 ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel + .panel { margin-top: 18px; }

.panel-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-head.between { align-items: center; justify-content: space-between; }

.panel-head h3 { margin: 0; font-size: 16px; }
.panel-sub { color: var(--muted); font-size: 12px; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.stats-row.cols-4 { grid-template-columns: repeat(4, 1fr); }

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.stats-row .stat-card:first-child {
  background: var(--sidebar);
  border-color: var(--sidebar);
}

.stats-row .stat-card:first-child .stat-label,
.stats-row .stat-card:first-child .unit,
.stats-row .stat-card:first-child .slash,
.stats-row .stat-card:first-child .accent {
  color: #9ba5a2;
}

.stats-row .stat-card:first-child .stat-value {
  color: #fff;
  font-size: 34px;
}

.stats-row .stat-card:first-child .balance-value { color: #fff !important; }

.stat-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.stat-value .unit {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-2);
  margin-left: 3px;
}

.stat-value .slash { color: var(--muted); font-weight: 600; margin: 0 4px; font-size: 20px; }
.stat-value .accent { color: var(--primary); }
.muted { color: var(--muted); font-weight: 400; }

.balance-value { color: var(--primary) !important; }

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
  gap: 18px;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.main-col { min-width: 0; }
.side-stack { display: flex; flex-direction: column; gap: 16px; }
.side-stack .stat-card { box-shadow: var(--shadow); }

.availability-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid #efc9ce;
  border-radius: 5px;
  background: var(--red-soft);
  color: var(--red);
}

.availability-alert .availability-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-weight: 700;
  line-height: 1;
}

.availability-alert strong { display: block; font-size: 14px; }
.availability-alert p { margin: 4px 0 0; color: #845057; font-size: 12px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 650;
  font-size: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: #f8faf9;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #e8ecea;
  color: var(--text);
  white-space: nowrap;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:not(.empty-row):hover { background: #fbfcfc; }
.empty-row td { text-align: center; color: var(--muted); padding: 26px 0; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 4px;
  padding: 3px 8px;
  background: var(--bg);
  color: #596360;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8e9895;
}

.status-success { background: var(--primary-soft); color: var(--primary); }
.status-running { background: var(--primary-soft); color: var(--primary); }
.status-waiting { background: var(--amber-soft); color: var(--amber); }
.status-error { background: var(--red-soft); color: var(--red); }
.status-success::before, .status-running::before { background: var(--primary); }
.status-waiting::before { background: var(--amber); }
.status-error::before { background: var(--red); }

.change-plus { color: var(--primary); font-weight: 700; }
.change-minus { color: var(--red); font-weight: 700; }

.text-ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }

.row-action {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
}

.row-action:hover { border-color: #b8c1be; color: var(--text); }

/* ---------- 文本域与代码 ---------- */
.code-textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid #cfd6d4;
  border-radius: 5px;
  padding: 12px;
  background: var(--paper);
  color: var(--text);
  line-height: 1.55;
  outline: none;
  font-family: Consolas, "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 12px;
}

.code-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(8, 127, 106, 0.1); }
.code-textarea::placeholder { color: #9ca6a3; }

.code-block {
  margin: 0;
  padding: 15px 16px;
  background: var(--sidebar);
  color: #dbe7e3;
  border-radius: 5px;
  font-family: Consolas, "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 12px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
}

.counter {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  margin-top: 8px;
}

.counter span { color: var(--primary); font-weight: 700; }

.panel-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.hint-line {
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
}

.quota-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 0;
}

/* ---------- 流水列表 ---------- */
.flow-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.flow-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 2px;
  border-bottom: 1px solid #e8ecea;
}

.flow-list li:last-child { border-bottom: none; }

.flow-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.flow-type .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.flow-type.recharge .dot { background: var(--primary); }
.flow-type.deduct .dot { background: var(--red); }

.flow-detail { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.flow-time { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.flow-amount { font-size: 13px; font-weight: 700; white-space: nowrap; }

/* ---------- 信息列表 ---------- */
.info-list { margin: 0; }

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #e8ecea;
}

.info-row:last-child { border-bottom: none; }
.info-row dt { font-size: 13px; color: var(--text-2); }
.info-row dd { margin: 0; font-size: 14px; font-weight: 700; }

/* ---------- 系统配置表单 ---------- */
.settings-form { display: grid; gap: 16px; }

.settings-form label {
  display: grid;
  gap: 8px;
  color: #3e4846;
  font-size: 13px;
  font-weight: 650;
}

.settings-form input[type="number"] {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #cfd6d4;
  border-radius: 5px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.settings-form input[type="number"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 127, 106, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.check-row {
  grid-template-columns: 18px 1fr;
  align-items: start;
  gap: 10px !important;
  padding: 13px;
  background: var(--bg);
  border-radius: 5px;
  cursor: pointer;
}

.check-row input {
  width: 17px;
  min-height: 17px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

.check-row span,
.check-row strong,
.check-row small {
  display: block;
}

.check-row strong { font-size: 13px; color: var(--text); }
.check-row small { margin-top: 4px; color: var(--muted); font-weight: 400; line-height: 1.5; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 4px;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 18, 16, 0.58);
  backdrop-filter: blur(3px);
}

.modal {
  width: 420px;
  background: #fff;
  border-radius: 7px;
  padding: 24px;
  box-shadow: 0 16px 44px rgba(17, 29, 26, 0.08);
}

.modal h3 { margin: 0 0 20px; font-size: 18px; }
.modal-sub { margin: 0 0 18px; color: var(--muted); font-size: 12px; }

.modal label {
  display: block;
  font-size: 13px;
  font-weight: 650;
  color: var(--text-2);
  margin: 12px 0 7px;
}

.modal input {
  width: 100%;
  border: 1px solid #cfd6d4;
  border-radius: 5px;
  min-height: 42px;
  padding: 9px 11px;
  outline: none;
  background: var(--paper);
}

.modal input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(8, 127, 106, 0.1); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.secret-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary-soft);
  border: 1px solid #c9e8df;
  border-radius: 5px;
  padding: 14px;
}

.secret-box code {
  flex: 1;
  color: var(--primary-2);
  font-size: 12px;
  word-break: break-all;
  font-family: Consolas, monospace;
  line-height: 1.6;
}

.secret-box .btn-secondary { flex-shrink: 0; padding: 7px 12px; font-size: 12px; }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--sidebar);
  color: #fff;
  border-radius: 5px;
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: 0 16px 44px rgba(17, 29, 26, 0.08);
  animation: toastIn 0.2s ease;
  max-width: 380px;
}

.toast.success { background: var(--primary-2); }
.toast.error { background: #7d2931; }
.toast.info { background: var(--sidebar); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 1100px) {
  .panel-grid, .workbench { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr; }
  .stats-row.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 78px; }
  .sidebar-brand-text, .nav-item span, .sidebar-user-info, .logout-btn { display: none; }
  .nav-item { justify-content: center; }
  .sidebar-user { justify-content: center; padding: 12px 0; }
}

@media (max-width: 920px) {
  .login-page { grid-template-columns: 1fr; }
  .login-top { min-height: 116px; padding: 24px; }
  .login-top:after { display: none; }
  .login-center { padding: 38px 20px; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 20px; }
  #pageContent { padding: 22px 20px 42px; }
  .stats-row .stat-card:first-child .stat-value { font-size: 29px; }
  .stat-card { padding: 20px; }
  .stats-row.cols-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* ---------- 手机端适配：侧边栏转为底部导航 ---------- */
@media (max-width: 768px) {
  .app {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    width: 100%;
    flex-direction: row;
    align-items: stretch;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid #303836;
  }

  .sidebar-brand { display: none; }

  .nav {
    flex: 1;
    display: flex;
    gap: 2px;
    margin-top: 0;
  }

  .nav-item {
    flex: 1;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-height: 52px;
    padding: 4px 2px;
    border-radius: 6px;
  }

  .nav-item svg { width: 20px; height: 20px; }

  .nav-item span {
    display: block;
    font-size: 10px;
    line-height: 1;
    white-space: nowrap;
  }

  .sidebar-user {
    margin: 0 0 0 2px;
    padding: 0;
    border-top: none;
    justify-content: center;
  }

  .sidebar-user .avatar,
  .sidebar-user-info { display: none; }

  .logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    min-height: 52px;
  }

  .main { min-height: 0; }

  .topbar { min-height: 54px; padding: 0 16px; }
  .topbar h2 { font-size: 16px; }
  .topbar-right { gap: 10px; }
  .sync-badge { display: none; }

  #pageContent {
    padding: 16px 14px calc(86px + env(safe-area-inset-bottom));
  }

  .panel { padding: 16px 14px; }
  .panel + .panel { margin-top: 14px; }
  .panel-head { flex-wrap: wrap; row-gap: 4px; }
  .panel-head.between { flex-wrap: wrap; gap: 10px; }

  .stats-row { gap: 10px; margin-bottom: 14px; }
  .stats-row.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 20px; }
  .stats-row .stat-card:first-child .stat-value { font-size: 26px; }

  .panel-grid, .workbench { gap: 14px; }

  /* iOS 聚焦输入框时防止自动放大 */
  input, select, textarea { font-size: 16px; }

  .panel-actions { flex-wrap: wrap; }
  .panel-actions .btn-primary,
  .panel-actions .btn-secondary { flex: 1; min-height: 42px; }
  .form-actions .btn-primary,
  .form-actions .btn-secondary { flex: 1; }

  .table-wrap { -webkit-overflow-scrolling: touch; }
  .text-ellipsis { max-width: 160px; }

  .modal-mask { padding: 16px; }
  .modal {
    width: 100%;
    max-width: 420px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px 16px;
  }
  .modal-actions .btn-primary,
  .modal-actions .btn-secondary { flex: 1; }

  .toast-stack {
    left: 14px;
    right: 14px;
    bottom: calc(80px + env(safe-area-inset-bottom));
    align-items: center;
  }
  .toast { max-width: 100%; }

  .login-top { padding: 20px; min-height: 0; }
  .login-center { padding: 30px 18px 40px; }
  .login-subtitle { margin-bottom: 24px; }
}

/* WebUI Refresh 20260921 */
:root {
  --bg: #f4f6fb;
  --paper: #ffffff;
  --panel: #ffffff;
  --border: #e0e6f0;
  --text: #182842;
  --ink: #182842;
  --text-2: #435570;
  --muted: #62748d;
  --primary: #315fdb;
  --primary-2: #234bb9;
  --primary-soft: #edf2ff;
  --green: #147b58;
  --green-soft: #e8f6ef;
  --red: #b53d50;
  --red-soft: #fff0f2;
  --amber: #98631b;
  --amber-soft: #fff5e5;
  --sidebar: #15243d;
  --sidebar-2: #213552;
  --sidebar-muted: #a7b8d2;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(24, 40, 66, .045);
}
body {
  font-family: "Segoe UI Variable", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
button, input, select, textarea { font-family: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:where(button, a, input, select, textarea):focus-visible {
  outline: 3px solid #769bfa !important;
  outline-offset: 3px;
}
::selection { background: #dce6ff; color: #182842; }
.brand-mark, .brand-mark.large {
  border-radius: 12px;
  background: var(--primary);
  box-shadow: 0 5px 14px rgba(49, 95, 219, .2);
}
.brand-caption, .brand em { color: #b9c8df; }
.brand-name { letter-spacing: .06em; }
.btn-primary, .btn-secondary, .row-action, .link-btn, .btn-danger {
  min-height: 44px;
  border-radius: 12px;
  padding: 10px 17px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.btn-primary { box-shadow: 0 4px 10px rgba(49, 95, 219, .14); }
.btn-primary:hover:not(:disabled) {
  background: var(--primary-2);
  border-color: var(--primary-2);
  box-shadow: 0 5px 14px rgba(49, 95, 219, .22);
}
.btn-secondary:hover:not(:disabled), .row-action:hover:not(:disabled) {
  background: #f4f7ff;
  border-color: #b7c8eb;
  color: var(--primary-2);
}
.btn-primary:active { transform: none; }
button:disabled { box-shadow: none; }
.logout-btn { min-width: 44px; min-height: 44px; align-items: center; justify-content: center; border-radius: 10px; }

/* A calm, framed identity panel and a dedicated white authentication card. */
.login-page {
  grid-template-columns: minmax(280px, .85fr) minmax(430px, 1.15fr);
  gap: 24px;
  padding: 24px;
  background: var(--bg);
}
.login-top {
  border: 1px solid #263e60;
  border-radius: 24px;
  padding: clamp(30px, 5vw, 72px);
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 26px;
  isolation: isolate;
  background:
    linear-gradient(135deg, transparent 62%, rgba(88, 132, 213, .08) 62%),
    var(--sidebar);
}
.login-top > * { position: relative; z-index: 1; }
.login-top .brand-mark {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: #315fdb;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .15);
}
.login-top .brand-mark svg { width: 34px; height: 34px; }
.login-top .brand-name {
  font-size: clamp(27px, 3.2vw, 42px);
  font-weight: 750;
  letter-spacing: .07em;
  margin-bottom: 10px;
}
.login-top .brand-caption { font-size: 16px; letter-spacing: .08em; }
.login-top::before {
  content: "";
  position: absolute;
  width: 330px;
  height: 330px;
  right: -150px;
  bottom: -105px;
  border: 1px solid rgba(158, 187, 238, .16);
  border-radius: 50%;
  box-shadow: 0 0 0 55px rgba(112, 153, 224, .035), 0 0 0 110px rgba(112, 153, 224, .03), 0 0 0 165px rgba(112, 153, 224, .025);
  pointer-events: none;
}
.login-top::after {
  left: clamp(30px, 5vw, 72px);
  right: clamp(30px, 5vw, 72px);
  bottom: 40px;
  background: rgba(167, 190, 226, .2);
}
.login-center { padding: 40px 20px; min-width: 0; }
.login-card {
  width: min(460px, 100%);
  padding: 38px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 12px 42px rgba(24, 40, 66, .065);
}
.login-card h1 { color: var(--text); font-size: 27px; line-height: 1.3; font-weight: 750; letter-spacing: -.035em; }
.login-subtitle { margin: 9px 0 28px; font-size: 14px; line-height: 1.6; }
.login-tabs { width: 100%; padding: 4px; gap: 4px; border-radius: 12px; margin-bottom: 22px; }
.login-tabs .tab { flex: 1; min-height: 44px; padding: 10px 16px; border-radius: 9px; font-size: 14px; }
.login-tabs .tab.active { color: var(--primary); box-shadow: 0 2px 6px rgba(24, 40, 66, .07); }
.login-card label { margin: 19px 0 8px; color: var(--text-2); font-size: 13px; }
.input-wrap { border-color: #d7e0ec; border-radius: 12px; padding: 0 14px; gap: 11px; background: #fbfcff; color: #7a8eab; }
.input-wrap input { min-height: 50px; min-width: 0; font-size: 14px; }
.input-wrap input::placeholder, .code-textarea::placeholder { color: #63738c; }
.input-wrap:focus-within { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(49, 95, 219, .09); }
.login-card .btn-block { margin-top: 26px; min-height: 50px; font-size: 14px; }
.guest-scan-link { min-height: 48px; gap: 12px; padding: 12px 14px; border-color: #dce5fa; border-radius: 12px; font-size: 12px; }
.guest-scan-link:hover { border-color: #a8beee; background: #e6edff; }
.login-foot { font-size: 12px; line-height: 1.6; margin-top: 22px; }

/* Shared workbench surfaces. Existing page and modal visibility is preserved. */
.sidebar { width: 240px; padding: 27px 17px; border-right: 1px solid #213653; }
.sidebar-brand { padding: 0 9px 26px; border-color: #2a3a54; }
.sidebar-brand-text strong { font-size: 15px; letter-spacing: .035em; }
.sidebar-brand-text small { font-size: 12px; }
.sidebar-user { border-color: #2a3a54; gap: 9px; }
.nav { gap: 7px; margin-top: 25px; }
.nav-item { min-height: 46px; border-radius: 12px; font-size: 13px; }
.nav-item.active { background: #2c4977; color: #fff; box-shadow: inset 3px 0 0 #88a9ff; }
.nav-item:hover { background: #243b5d; }
.avatar { background: #e9efff; color: #3157ae; border-radius: 11px; }
.sidebar .avatar { background: #2b4162; color: #d9e6ff; }
.topbar { min-height: 76px; padding: 0 32px; background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none; }
.topbar h2 { font-size: 21px; letter-spacing: -.025em; font-weight: 700; }
.topbar-right { gap: 18px; }
.sync-badge { font-size: 12px; }
.sync-badge i { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); animation: none; }
#pageContent { padding: 28px 32px 48px; }
.panel { border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.panel-head { margin-bottom: 21px; flex-wrap: wrap; gap: 8px 12px; }
.panel-head h3 { font-size: 16px; letter-spacing: -.015em; }
.panel-sub { font-size: 12px; line-height: 1.6; }
.panel-grid, .workbench { gap: 20px; }
.panel-grid > *, .workbench > * { min-width: 0; }
.stat-card { border-radius: var(--radius); padding: 22px 24px; min-width: 0; }
.stat-label { font-size: 12px; margin-bottom: 12px; line-height: 1.6; }
.stat-value { font-size: 28px; line-height: 1.25; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.stats-row .stat-card:first-child { background: #244da9; border-color: #244da9; }
.stats-row .stat-card:first-child :is(.stat-label, .unit, .slash, .accent, .muted) { color: #d8e4ff; }
.stats-row .stat-card:first-child .stat-value { font-size: 32px; }
.table-wrap { border: 1px solid #e5eaf3; border-radius: 12px; scrollbar-color: #c1cee2 transparent; scrollbar-width: thin; }
.data-table { font-size: 13px; }
.data-table th { background: #f5f7fc; color: #5c6f8b; padding: 13px 16px; font-size: 12px; }
.data-table td { padding: 15px 16px; border-color: #edf0f6; font-variant-numeric: tabular-nums; }
.data-table tbody tr:not(.empty-row):hover { background: #f8faff; }
.empty-row td { padding: 40px 16px; color: #63738c; }
.status-pill { padding: 5px 10px; border-radius: 7px; font-size: 12px; }
.status-success { background: var(--green-soft); color: var(--green); }
.status-success::before { background: var(--green); }
.status-running { background: var(--primary-soft); color: var(--primary); }
.change-plus { color: var(--green); }
.row-action { min-width: 44px; padding: 8px 12px; font-size: 12px; }
.code-textarea { min-height: 180px; padding: 15px; border-color: #d7e0ec; border-radius: 12px; background: #fbfcff; line-height: 1.8; }
.code-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(49, 95, 219, .09); }
.code-block { padding: 18px; border-radius: 12px; background: var(--sidebar); color: #dce6f7; }
.availability-alert, .secret-box, .check-row { border-radius: 12px; }
.secret-box { border-color: #d7e3ff; }
.flow-list li, .info-row { padding: 15px 0; border-color: #edf0f6; }
.flow-type.recharge .dot { background: var(--green); }
.settings-form { gap: 20px; }
.settings-form label { color: var(--text-2); line-height: 1.6; }
.settings-form input:not([type="checkbox"]):not([type="radio"]),
.settings-form input[type="number"], .settings-form select,
.modal input:not([type="checkbox"]):not([type="radio"]), .modal textarea {
  width: 100%;
  min-height: 46px;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid #d7e0ec;
  border-radius: 12px;
  color: var(--text);
  background: #fbfcff;
  font-size: 14px;
  outline: none;
}
.settings-form input:focus, .settings-form input[type="number"]:focus,
.settings-form select:focus, .modal input:focus, .modal textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(49, 95, 219, .09);
}
.check-row { min-height: 48px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
.modal-mask { background: rgba(15, 29, 52, .5); padding: 20px; }
.modal { border: 1px solid var(--border); border-radius: 18px; max-width: 100%; max-height: calc(100dvh - 40px); overflow-y: auto; padding: 28px; box-shadow: 0 24px 70px rgba(15, 29, 52, .2); }
.modal h3 { font-size: 20px; letter-spacing: -.025em; }
.modal-sub { line-height: 1.7; }
.modal-actions { flex-wrap: wrap; }
.toast { border-radius: 12px; box-shadow: 0 8px 25px rgba(24, 40, 66, .16); }
.toast.success { background: #17694f; }

@media (min-width: 769px) and (max-width: 1100px) {
  .sidebar { width: 80px; padding-left: 14px; padding-right: 14px; }
  .sidebar-brand { padding-left: 6px; padding-right: 6px; }
  #pageContent { padding: 24px; }
  .topbar { padding: 0 24px; }
}
@media (max-width: 920px) {
  .login-page { grid-template-columns: 1fr; gap: 0; padding: 20px; }
  .login-top { padding: 24px 28px; flex-direction: row; align-items: center; gap: 16px; border-radius: 18px; min-height: 120px; }
  .login-top .brand-mark { width: 52px; height: 52px; border-radius: 14px; }
  .login-top .brand-name { font-size: 23px; margin-bottom: 4px; }
  .login-top .brand-caption { font-size: 13px; letter-spacing: .04em; }
  .login-center { padding: 32px 0 24px; }
}
@media (max-width: 768px) {
  .login-page { padding: 14px; min-height: 100svh; align-content: start; }
  .login-top { padding: 22px; min-height: 104px; border-radius: 16px; }
  .login-top .brand-mark { width: 46px; height: 46px; border-radius: 12px; }
  .login-top .brand-mark svg { width: 27px; height: 27px; }
  .login-top .brand-name { font-size: 21px; }
  .login-center { padding: 20px 0 12px; }
  .login-card { padding: 28px 24px; border-radius: 16px; }
  .login-card h1 { font-size: 25px; }
  .login-subtitle { margin-bottom: 24px; }
  .sidebar { width: 100%; padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); border-top-color: #2b3e5b; border-right: 0; gap: 5px; }
  .nav { min-width: 0; margin: 0; gap: 4px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: #466087 transparent; }
  .nav-item { flex: 0 0 65px; min-width: 65px; min-height: 54px; gap: 5px; padding: 6px 4px; border-radius: 10px; }
  .nav-item span { font-size: 11px; line-height: 1.2; }
  .nav-item.active { box-shadow: inset 0 2px 0 #88a9ff; }
  .sidebar-user { flex: 0 0 44px; margin: 0; padding: 0; border-left: 1px solid #2b3e5b; border-top: 0; }
  .logout-btn { min-width: 44px; width: 44px; min-height: 54px; }
  .topbar { min-height: 68px; padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  .topbar h2 { font-size: 19px; }
  .topbar-right { gap: 10px; min-width: 0; }
  .topbar .user-chip { max-width: 135px; font-size: 12px; }
  .user-chip > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .avatar.small { flex-shrink: 0; }
  #pageContent { padding: 18px 14px calc(100px + env(safe-area-inset-bottom)); }
  .panel { padding: 20px 16px; border-radius: 14px; }
  .panel-head { margin-bottom: 16px; }
  .panel-grid, .workbench { gap: 16px; }
  .stats-row { gap: 12px; }
  .stat-card { padding: 18px; border-radius: 14px; }
  .stat-label { margin-bottom: 9px; }
  .stat-value, .stats-row .stat-card:first-child .stat-value { font-size: 26px; }
  .data-table th, .data-table td { padding: 12px; }
  .panel-actions { gap: 8px; }
  .panel-actions .btn-primary, .panel-actions .btn-secondary { min-height: 44px; }
  .input-wrap input, .settings-form input:not([type="checkbox"]):not([type="radio"]),
  .settings-form input[type="number"], .settings-form select, .code-textarea,
  .modal input:not([type="checkbox"]):not([type="radio"]), .modal textarea { font-size: 16px; }
  .modal-mask { padding: 14px; }
  .modal { max-width: 100%; padding: 24px 20px; max-height: calc(100dvh - 28px); border-radius: 16px; }
  .secret-box { flex-wrap: wrap; }
  .secret-box code { min-width: 0; }
  .toast-stack { bottom: calc(94px + env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  .login-card { padding: 24px 20px; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .stats-row.cols-4 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
