:root {
  --accent: #1C3E70;
  --accent-soft: #E8EEF7;
  --ink: #16233A;
  --muted: #61708A;
  --line: #DCE3EE;
  --bg: #F5F7FB;
  --ok: #1E7F52;
  --warn: #B4600C;
  --bad: #B3261E;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Segoe UI", "Microsoft JhengHei", "PingFang HK", system-ui, sans-serif;
  font-size: 15px; line-height: 1.6;
}
a { color: var(--accent); }

/* ---------- 登入頁 ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(420px, 100%); background: #fff; border: 1px solid var(--line);
  border-radius: 14px; padding: 32px; box-shadow: 0 12px 40px rgba(22,35,58,.09);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; color: var(--accent); }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 24px; }

/* ---------- 主框架 ---------- */
.shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar { background: var(--accent); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 600; font-size: 16px; padding: 4px 10px 16px; letter-spacing: .3px; }
.brand-logo { width: 28px; height: 28px; border-radius: 8px; vertical-align: -6px; margin-right: 8px; }
.login-logo { display: block; width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 18px; }
.brand small { display: block; font-weight: 400; opacity: .72; font-size: 12px; letter-spacing: 0; }
.nav-item {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  background: none; border: 0; color: #D9E3F3; font: inherit; font-size: 14px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.09); color: #fff; }
.nav-item.active { background: #fff; color: var(--accent); font-weight: 600; }
.nav-item .ic { font-size: 15px; line-height: 1.5; }
.sidebar-foot { margin-top: auto; font-size: 12px; opacity: .72; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.16); }

.main { padding: 26px 30px 60px; max-width: 1180px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 21px; }
.page-head .sub { color: var(--muted); font-size: 13px; }

/* ---------- 卡片與表單 ---------- */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px;
}
.card > h3 { margin: 0 0 12px; font-size: 15px; color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } .shell { grid-template-columns: 1fr; } }

label.field { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label.field > span { display: block; margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 14px; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }

button.btn, a.btn {
  display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 18px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  text-decoration: none; line-height: 1.2;
}
button.btn:hover, a.btn:hover { filter: brightness(1.08); }
button.btn:disabled { opacity: .55; cursor: progress; }
button.btn.ghost, a.btn.ghost { background: #fff; color: var(--accent); border: 1px solid var(--line); font-weight: 500; }
button.btn.small, a.btn.small { padding: 5px 12px; font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- 提示與狀態 ---------- */
.muted { color: var(--muted); font-size: 13px; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.badge.ok { background: #E4F4EB; color: var(--ok); }
.badge.warn { background: #FCF0E1; color: var(--warn); }
.badge.bad { background: #FBEAE8; color: var(--bad); }
.note {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: 13px; margin-bottom: 14px;
}
.note.warn { border-color: var(--warn); background: #FCF4EA; }
.error-text { color: var(--bad); font-size: 13px; }

/* ---------- 表格 ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.data th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: #FAFBFD; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 輸出區 ---------- */
pre.out {
  background: #0F1B2E; color: #DCE6F5; padding: 16px; border-radius: 8px;
  overflow: auto; font-size: 13px; line-height: 1.65; margin: 0;
  font-family: "Cascadia Mono", Consolas, "Microsoft JhengHei", monospace; white-space: pre-wrap;
}
.doc-body { white-space: pre-wrap; }
.doc-body h4 { margin: 16px 0 6px; color: var(--accent); }

/* ---------- 圖表 ---------- */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 130px; }
.bars .bar { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.bars .bar span { position: absolute; top: -19px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
.spark { display: flex; gap: 3px; align-items: flex-end; height: 34px; }
.spark i { width: 7px; background: var(--accent-soft); border-radius: 2px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { color: var(--muted); font-size: 12.5px; }
.tile .v { font-size: 24px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }

.spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; margin-right: 7px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 側欄分組 ---------- */
.nav-group { margin-bottom: 10px; }
.nav-group-title { font-size: 11px; letter-spacing: .12em; opacity: .55; padding: 8px 12px 4px; text-transform: uppercase; }

/* ---------- 頂欄與行動側欄 ---------- */
.topbar { display: none; }
.nav-scrim { display: none; }
.nav-toggle {
  background: rgba(255,255,255,.14); border: 0; color: #fff; font-size: 18px;
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer; line-height: 1;
}
