/* Angstrom Badge 設計系統 — Professional / Enterprise / Clean / Minimal（見 ADR-005） */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e7eaef;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #78849a;
  --line: #e2e6ec;
  --line-2: #cfd6e0;
  --brand: #0f172a;
  --accent: #0e7490;
  --accent-soft: #e0f2fe;
  --accent-ink: #075985;
  --ok: #0f766e;
  --ok-soft: #d9f2ee;
  --warn: #b45309;
  --warn-soft: #fdf1dc;
  --danger: #b91c1c;
  --danger-soft: #fdeaea;
  --info-soft: #eef2ff;
  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(15,23,42,.05), 0 8px 24px -12px rgba(15,23,42,.16);
  --shadow-lg: 0 24px 60px -28px rgba(15,23,42,.42);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC",
          "Microsoft JhengHei", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --maxw: 1200px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.3; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 1em; }
small { font-size: .82rem; }
.boot { padding: 4rem; text-align: center; color: var(--ink-3); }

/* ── 版面 ───────────────────────────────────────── */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.main { flex: 1; padding: 28px 0 64px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0,1fr) 320px; align-items: start; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 14px; }

/* ── 導覽列 ─────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .inner { display: flex; align-items: center; gap: 18px; height: 58px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--ink); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--brand);
  display: grid; place-items: center; color: #38bdf8; font-size: 15px; font-weight: 800;
}
.nav { display: flex; gap: 2px; align-items: center; }
.nav a {
  color: var(--ink-2); padding: 7px 11px; border-radius: var(--radius-sm);
  font-size: .92rem; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--ink); color: #fff; }

/* ── 卡片 ───────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.card.pad-lg { padding: 26px; }
.card.flat { box-shadow: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-sub { color: var(--ink-3); font-size: .86rem; margin: -8px 0 14px; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; margin-bottom: 10px; }

/* ── 按鈕 ───────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  padding: 8px 15px; border-radius: var(--radius-sm); font: inherit; font-size: .92rem; font-weight: 550;
  cursor: pointer; transition: .15s ease; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #1e293b; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: #0b6379; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); border-color: #f0c8c8; background: var(--danger-soft); }
.btn.sm { padding: 5px 10px; font-size: .84rem; }
.btn.lg { padding: 11px 22px; font-size: 1rem; }
.btn.block { width: 100%; }

/* ── 表單 ───────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: .78rem; color: var(--ink-3); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=url], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  font: inherit; font-size: .93rem; background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.checkbox input { width: 16px; height: 16px; }

/* ── 標籤 / 徽章 ────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: .76rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: #bae6fd; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: #b9e6df; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: #f4dcb4; }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: #f3cccc; }
.tag.dark { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ── 等級點 ─────────────────────────────────────── */
.levels { display: inline-flex; gap: 3px; align-items: center; }
.levels i { width: 8px; height: 8px; border-radius: 2px; background: var(--surface-3); display: block; }
.levels i.on { background: var(--accent); }
.levels i.req { background: transparent; border: 1px solid var(--accent); }

/* ── 進度條 ─────────────────────────────────────── */
.bar { height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
.bar.ok > span { background: var(--ok); }
.bar.warn > span { background: var(--warn); }

/* ── 表格 ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── 統計磚 ─────────────────────────────────────── */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px; }
.stat .label { font-size: .78rem; color: var(--ink-3); font-weight: 600; letter-spacing: .03em; }
.stat .value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat .delta { font-size: .8rem; color: var(--ink-3); }

/* ── 空狀態 / 提示 ─────────────────────────────── */
.empty { text-align: center; padding: 42px 20px; color: var(--ink-3); }
.empty .big { font-size: 2rem; opacity: .5; margin-bottom: 8px; }
.notice { padding: 11px 14px; border-radius: var(--radius-sm); font-size: .88rem; border: 1px solid; }
.notice.info { background: var(--info-soft); border-color: #dbe2fb; color: #3730a3; }
.notice.ok { background: var(--ok-soft); border-color: #b9e6df; color: var(--ok); }
.notice.warn { background: var(--warn-soft); border-color: #f4dcb4; color: var(--warn); }
.notice.danger { background: var(--danger-soft); border-color: #f3cccc; color: var(--danger); }

/* ── 首頁 ───────────────────────────────────────── */
.hero { padding: 78px 0 56px; background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%); border-bottom: 1px solid var(--line); }
.hero h1 { font-size: 2.7rem; letter-spacing: -.03em; max-width: 16ch; }
.hero .lead { font-size: 1.12rem; color: var(--ink-2); max-width: 56ch; }
.hero .eyebrow { font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-ink); font-weight: 700; margin-bottom: 14px; }
.flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 26px; }
.flow span { padding: 5px 11px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); font-size: .82rem; font-weight: 550; }
.flow b { color: var(--ink-3); font-weight: 400; }

/* ── 認證頁 ─────────────────────────────────────── */
.auth-wrap { max-width: 440px; margin: 48px auto; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 20px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 5px; font: inherit; font-size: .9rem; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ── 頁尾 ───────────────────────────────────────── */
.footer { border-top: 1px solid var(--line); padding: 22px 0; color: var(--ink-3); font-size: .84rem; background: var(--surface); }

/* ── 工具 ───────────────────────────────────────── */
.muted { color: var(--ink-3); }
.strong { font-weight: 650; }
.mono { font-family: var(--mono); font-size: .86em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: .9rem; animation: pop .2s ease; }
.toast.err { background: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 900px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.side { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2rem; }
}
@media (max-width: 620px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .nav { overflow-x: auto; }
}
