:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1f2733;
  --ink2: #5b6472;
  --line: #d8dde5;
  --primary: #185FA5;
  --primary-deep: #0C447C;
  --primary-bg: #E6F1FB;
  --danger: #A32D2D;
  --ok: #0F6E56;
  --radius: 10px;
}

* { box-sizing: border-box; }
/* 关键：让 hidden 属性永远生效——否则 .modal-mask/.login-wrap/.form-grid 等带
   display 规则的元素会压过浏览器默认的 [hidden]{display:none}，导致弹窗常驻 */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.muted { color: var(--ink2); font-size: 12.5px; }
.error { color: var(--danger); font-size: 12.5px; min-height: 1em; margin: 6px 0 0; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px 26px; text-align: center; }
.login-logo { margin-bottom: 4px; }
.login-box h1 { font-size: 20px; margin: 4px 0 6px; }
.login-box .muted { margin: 0 0 18px; }
.login-box input { margin-bottom: 12px; }

/* ---------- 顶栏与 Tab ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--primary-deep); color: #fff; }
.topbar-title { font-size: 16px; font-weight: 600; letter-spacing: 1px; }
.topbar-actions { display: flex; gap: 8px; }
.topbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.45); background: transparent; }
.topbar .btn.ghost:hover { background: rgba(255,255,255,.12); }

.tabs { position: sticky; top: 45px; z-index: 19; display: flex; background: var(--surface); border-bottom: 1px solid var(--line); }
.tab { flex: 1; border: 0; background: none; padding: 11px 4px; font-size: 14px; color: var(--ink2); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

main { max-width: 980px; margin: 0 auto; padding: 14px 14px 60px; }
.tabpane { display: none; }
.tabpane.active { display: block; }

/* ---------- 卡片与面板 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card .k { font-size: 12px; color: var(--ink2); }
.card .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.card .v small { font-size: 12px; font-weight: 400; color: var(--ink2); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 14px; }
.panel canvas { width: 100%; display: block; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; align-items: center; }
.toolbar select, .toolbar input { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13.5px; }
.toolbar input[type=search] { flex: 1; min-width: 120px; }
.toolbar .btn.primary { margin-left: auto; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.grid th { color: var(--ink2); font-weight: 500; background: #fafbfc; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid td.num { font-variant-numeric: tabular-nums; }
table.grid td.wrap { white-space: normal; min-width: 120px; max-width: 260px; }
.row-actions button { border: 0; background: none; color: var(--primary); cursor: pointer; padding: 2px 6px; font-size: 12.5px; }
.row-actions button.del { color: var(--danger); }
.empty { text-align: center; color: var(--ink2); padding: 26px 0; }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; }

/* ---------- 按钮与表单 ---------- */
.btn { display: inline-block; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 7px 14px; font-size: 13.5px; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-deep); color: #fff; }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.btn-row.right { justify-content: flex-end; }

input[type=text], input[type=number], input[type=password], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: var(--surface); color: var(--ink); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-bg); border-color: var(--primary); }

label { display: block; font-size: 12.5px; color: var(--ink2); }
label input, label select, label textarea { margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 10px; }
.checks { display: flex; gap: 16px; margin: 4px 0 10px; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink); }
.checks input { width: auto; margin: 0; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 32, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; padding: 20px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; }
.modal h3 { margin: 0 0 14px; font-size: 16px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #1f2733; color: #fff; padding: 9px 18px; border-radius: 20px; font-size: 13.5px; z-index: 99; box-shadow: 0 4px 16px rgba(0,0,0,.25); }

@media (max-width: 560px) {
  .toolbar .btn.primary { margin-left: 0; width: 100%; }
  .card .v { font-size: 18px; }
}
