:root {
  --bg: #eef3f9;
  --panel: #ffffff;
  --soft: #f6f9fd;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #d8e2ee;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --good: #0f766e;
  --warn: #b45309;
  --bad: #b91c1c;
  --shadow: 0 12px 28px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif; }
button, input, select { font: inherit; }
h1, h2, h3, p { margin: 0; }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.55; }
.subtle { color: var(--muted); font-size: 12px; }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: 0; text-transform: uppercase; }
.page { width: min(1440px, calc(100% - 28px)); margin: 0 auto; padding: 18px 0 36px; }
.auth { width: min(460px, calc(100% - 24px)); margin: 9vh auto 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 26px; }
.auth-header { display: grid; gap: 8px; margin-bottom: 18px; }

.topbar { display: grid; grid-template-columns: minmax(230px, .8fr) minmax(170px, 220px) minmax(430px, 1.25fr); gap: 14px; align-items: center; margin-bottom: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px; }
.brand-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: var(--accent); font-size: 20px; font-weight: 900; }
.brand-block h1 { font-size: 20px; line-height: 1.2; }
.brand-block p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.time-block { min-height: 44px; min-width: 178px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); display: grid; place-items: center; padding: 6px 16px; }
.clock { font-size: 22px; line-height: 1; font-weight: 900; color: var(--ink); }
.date-label { color: var(--muted); font-size: 12px; margin-top: 4px; }
.accountbar { display: flex; align-items: center; gap: 10px; justify-content: flex-end; min-width: 0; }
.membership-card { min-height: 44px; min-width: 178px; border: 1px solid rgba(37, 99, 235, .22); background: #f8fbff; border-radius: 10px; padding: 7px 10px; display: grid; gap: 2px; cursor: pointer; }
.membership-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .09); }
.user-block { min-height: 44px; min-width: 130px; display: grid; align-content: center; gap: 3px; border-left: 1px solid var(--line); padding-left: 12px; }
.user-name { font-size: 13px; font-weight: 800; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vip-title { font-size: 13px; color: var(--accent); font-weight: 900; white-space: nowrap; }
.vip-desc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { height: 44px; display: grid; grid-template-columns: repeat(2, 64px); gap: 8px; align-items: stretch; }
.top-actions button { min-width: 0; min-height: 44px; padding: 0 10px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 16px 16px 0; }
.panel-body { padding: 16px; }
.metric-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { font-size: 26px; }
.accounts-panel { min-height: 520px; }

.status { min-height: 40px; margin-top: 12px; border-radius: 8px; padding: 10px 12px; background: #f8fafc; border: 1px solid var(--line); color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.status.compact { min-height: 34px; margin-top: 0; padding: 8px 10px; }
.status.ok { color: var(--good); background: #f0fdfa; }
.status.err { color: var(--warn); background: #fff7ed; }

.pill { display: inline-flex; align-items: center; min-height: 24px; border-radius: 999px; padding: 0 10px; background: #e2f0ff; color: #1e40af; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.off { background: #eef2f7; color: var(--muted); }
.pill.warn { background: #fff7ed; color: var(--warn); }
.pill.bad { background: #fff1f2; color: var(--bad); }

form { display: grid; gap: 12px; margin-top: 12px; }
label { display: grid; gap: 6px; color: #334155; font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fbfdff; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); background: #fff; }
input:disabled, select:disabled { color: #94a3b8; background: #eef2f7; cursor: not-allowed; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row.single { grid-template-columns: 1fr; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
button { min-height: 36px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); padding: 0 13px; cursor: pointer; font-weight: 700; }
button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-dark); }
button.ghost { background: transparent; }
button.danger { border-color: rgba(185, 28, 28, .2); color: var(--bad); }
.plan-form { gap: 14px; }
.mode-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.mode-tabs button { border-radius: 7px; background: transparent; border-color: transparent; }
.mode-tabs button.active { color: #fff; background: var(--accent); border-color: var(--accent); box-shadow: 0 8px 18px rgba(37, 99, 235, .2); }

.account-list { display: grid; gap: 10px; }
.account-row { display: grid; grid-template-columns: minmax(230px, 1fr) minmax(210px, .75fr) minmax(180px, .65fr) 260px; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.account-title { display: grid; gap: 4px; min-width: 0; }
.account-title h3 { font-size: 16px; overflow-wrap: anywhere; }
.account-meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.account-stats { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mini { display: grid; gap: 4px; min-width: 88px; color: var(--muted); font-size: 12px; }
.mini strong { color: var(--ink); font-size: 15px; }
.account-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.admin-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; }
.admin-nav { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 14px; display: grid; gap: 8px; align-content: start; }
.admin-nav button { width: 100%; justify-content: flex-start; }
.admin-nav button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.admin-status-box { margin-top: 10px; display: grid; gap: 8px; }
.admin-main { display: grid; gap: 14px; }
.admin-main-head { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 16px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.admin-panel-wide { min-width: 0; }
.admin-panel-side { min-width: 0; }

table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 6px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 700; }

.dialog { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(15, 23, 42, .38); z-index: 20; }
.dialog-card { width: min(900px, 100%); max-height: min(92vh, 900px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 30px 70px rgba(2, 6, 23, .22); padding: 18px; }
.dialog-card.narrow { width: min(520px, 100%); }
.dialog-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 14px; }

@media (max-width: 1180px) {
  .admin-shell, .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1100px) {
  .topbar { grid-template-columns: 1fr; }
  .time-block { justify-self: start; }
  .accountbar { justify-content: space-between; }
  .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-row { grid-template-columns: 1fr; }
  .account-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .topbar, .panel-head { display: block; }
  .brand-block { margin-bottom: 12px; }
  .time-block { width: 100%; margin-bottom: 12px; }
  .accountbar { justify-content: stretch; display: grid; }
  .membership-card, .user-block { width: 100%; min-width: 0; }
  .user-block { border-left: 0; border-top: 1px solid var(--line); padding: 12px 0 0; }
  .top-actions { width: 100%; margin-top: 10px; }
  .top-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-row, .row, .mode-tabs { grid-template-columns: 1fr; }
  .actions, .account-actions { grid-template-columns: 1fr; justify-content: stretch; }
  button { flex: 1; }
}
