/* Grouper Cloud：白底、鋼構藍主色；系統字型 (不依賴外部字型服務，區網也能用) */
:root {
  --paper: #ffffff;
  --ink: #1d2329;
  --ink-soft: #5b6670;
  --rule: #dfe3e7;
  --tint: #f4f6f8;
  --steel: #2f5d7c;
  --steel-dark: #234a63;
  --ok: #2e7d4f;
  --ok-bg: #e7f4ec;
  --warn: #9a6200;
  --warn-bg: #fdf3e1;
  --bad: #b3261e;
  --bad-bg: #fbeceb;
  --font: -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.6; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }

.top { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px; border-bottom: 1px solid var(--rule); position: sticky; top: 0; background: var(--paper); z-index: 5; }
.brand { font-weight: 700; color: var(--steel); white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { padding: 6px 12px; border-radius: 6px; color: var(--ink-soft); text-decoration: none; white-space: nowrap; }
.nav a:hover { background: var(--tint); color: var(--ink); }
.nav a.on { background: var(--tint); color: var(--steel); font-weight: 600; }
.who { display: flex; gap: 12px; align-items: center; font-size: 14px; color: var(--ink-soft); white-space: nowrap; }

.view { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; display: flex; flex-direction: column; gap: 24px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0; }
.sub { color: var(--ink-soft); margin: 0; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

.card { border: 1px solid var(--rule); border-radius: 8px; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.tbl { overflow-x: auto; border: 1px solid var(--rule); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
th { background: var(--tint); color: var(--ink-soft); font-weight: 500; font-size: 13px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, .num { font-variant-numeric: tabular-nums; }
td.mono, .mono { font-family: var(--mono); font-size: 13px; }
.empty { color: var(--ink-soft); padding: 20px; text-align: center; }

form.stack { display: flex; flex-direction: column; gap: 12px; }
form.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-soft); min-width: 160px; flex: 1; }
input, select { border: 1px solid var(--rule); border-radius: 6px; padding: 8px 10px; background: var(--paper); color: var(--ink); min-width: 0; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--steel); outline-offset: 1px; }
input.code { font-family: var(--mono); font-size: 20px; letter-spacing: .2em; text-align: center; text-transform: uppercase; }

.btn { border: 1px solid var(--steel); background: var(--steel); color: #fff; border-radius: 6px; padding: 8px 16px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--steel-dark); }
.btn.ghost { background: var(--paper); color: var(--steel); }
.btn.ghost:hover { background: var(--tint); }
.btn.danger { background: var(--paper); color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 3px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
button.link { background: none; border: 0; color: var(--steel); cursor: pointer; padding: 0; }

.pill { display: inline-block; font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 10px; white-space: nowrap; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.off { color: var(--ink-soft); background: var(--tint); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.role { color: var(--steel); background: #e8f0f6; }

.note { border-radius: 8px; padding: 12px 16px; font-size: 14px; }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.secret { font-family: var(--mono); font-size: 16px; background: var(--paper); padding: 2px 8px; border-radius: 4px; border: 1px solid var(--rule); user-select: all; }

.stat { display: flex; gap: 20px; flex-wrap: wrap; }
.stat div { display: flex; flex-direction: column; }
.stat b { font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--ink-soft); }

/* 總覽、工地頁 */
a.link-card { color: inherit; text-decoration: none; }
a.link-card:hover { border-color: var(--steel); }
ul.list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
table.plain td { border: 0; padding: 4px 8px 4px 0; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--paper); padding: 6px 12px; cursor: pointer; color: var(--ink-soft); }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button.on { background: var(--tint); color: var(--steel); font-weight: 600; }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--rule); stroke-width: 1; }
.chart .axis { fill: var(--ink-soft); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .cursor { stroke: var(--ink-soft); stroke-dasharray: 3 3; }
.chart .tip { position: absolute; top: 8px; right: 8px; background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; padding: 6px 10px; font-size: 13px; pointer-events: none; }
.tbl td:first-child { white-space: nowrap; }
table.nowrap th, table.nowrap td { white-space: nowrap; }   /* 數值表：手機上左右捲動，不擠成直排 */
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }

.chart .thr-line { stroke: var(--bad); stroke-width: 1.5; stroke-dasharray: 6 4; }
.chart .thr-label { fill: var(--bad); font-size: 11px; }
a.alert-banner { display: block; text-decoration: none; font-weight: 600; }

/* 登入頁 */
.auth { max-width: 400px; margin: 8vh auto 0; }
.auth .card { padding: 28px; }
.auth .brand-big { font-size: 20px; font-weight: 700; color: var(--steel); }
.qr { align-self: center; border: 1px solid var(--rule); border-radius: 8px; padding: 6px; background: #fff; line-height: 0; }
.qr svg { width: 220px; height: 220px; display: block; }
ol.steps { margin: 0; padding-left: 20px; color: var(--ink-soft); font-size: 14px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 10; max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); }

@media (max-width: 720px) {
  .top { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px 16px; }
  .nav { order: 3; flex-basis: 100%; }
  .view { padding: 20px 16px 48px; }
}
@media (prefers-reduced-motion: no-preference) { .btn, .nav a { transition: background-color .12s; } }
