/* 股東後台共用樣式（股東頁與主席頁共用；現行定案改自建帳密，不再分 Access 路徑，主席頁直接載入 /portal.css）。
   CSP：style-src 'self'，所以不寫 style 屬性、不用行內 <style>。手機優先（375px 寬）：窄螢幕表格改卡片。 */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #16181d;
  --muted: #5d6470;
  --line: #e2e5ea;
  --brand: #1f4fd1;
  --brand-ink: #ffffff;
  --ok: #137a3a;
  --warn: #9a5b00;
  --bad: #b42318;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --card: #1a1d23;
    --text: #e9ecf1;
    --muted: #9aa3b2;
    --line: #2c313a;
    --brand: #6d95ff;
    --brand-ink: #0b0d10;
    --ok: #4cc77f;
    --warn: #e0a94a;
    --bad: #ff7a6e;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif; font-size: 16px; line-height: 1.5; background: var(--bg); color: var(--text); }
a { color: var(--brand); }
[hidden] { display: none !important; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 700; }
.topbar .who { margin-left: auto; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 16px 0; background: var(--card); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs button { flex: 0 0 auto; border: 0; background: none; color: var(--muted); padding: 10px 12px; font-size: 15px; border-bottom: 3px solid transparent; cursor: pointer; min-height: 44px; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }

main { max-width: 960px; margin: 0 auto; padding: 16px; }
main.narrow { max-width: 440px; padding-top: 48px; }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 18px; margin: 24px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 16px; }
.grid:empty { display: none; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; word-break: break-all; }
.stat .sub { color: var(--muted); font-size: 13px; margin-top: 4px; font-variant-numeric: tabular-nums; }

.status { padding: 10px 12px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); margin: 0 0 12px; }
.status.error { border-color: var(--bad); color: var(--bad); }
.status.ok { border-color: var(--ok); color: var(--ok); }
.status:empty { display: none; }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; background: var(--bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.bad { color: var(--bad); border-color: var(--bad); }

form .row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); flex: 1 1 160px; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; color: var(--text); font-size: 15px; }
label.check input { width: 20px; height: 20px; margin-top: 2px; flex: 0 0 auto; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 44px; width: 100%; }
textarea { min-height: 140px; font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

button, .button { font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
button.primary, .button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.small, .button.small { min-height: 36px; padding: 4px 10px; font-size: 14px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.full { width: 100%; }
.stack > * + * { margin-top: 12px; }
.consent-text { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 18px; letter-spacing: 1px; padding: 8px 12px; background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; user-select: all; word-break: break-all; }

.secret { white-space: pre-wrap; font-size: 15px; letter-spacing: 0; font-family: inherit; }
.fig-row { align-items: flex-end; }
.figures { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.figures .stat .value { font-size: 20px; }
ul.tree { list-style: none; margin: 0; padding-left: 18px; border-left: 2px solid var(--line); }
.card > ul.tree { padding-left: 8px; }
ul.tree li { margin: 8px 0; }
.tree-node { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
h3 { font-size: 16px; margin: 0 0 8px; }
fieldset { border: 1px solid var(--line); }

/* 手機：表格改成一列一張卡片，每格前面顯示欄名（data-label） */
@media (max-width: 640px) {
  main { padding: 12px; }
  .topbar .who { max-width: 45%; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards { border: 0; background: none; }
  table.cards thead { display: none; }
  table.cards tr { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 6px 0; }
  table.cards td { border: 0; padding: 6px 12px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex: 0 0 auto; }
  table.cards td.num { white-space: normal; }
  table.cards td .actions { justify-content: flex-end; }
  /* 待核准等操作列：手機上按鈕撐滿、夠大，一鍵按得到 */
  table.cards td[data-label="處理"] { display: block; }
  table.cards td[data-label="處理"]::before { display: none; }
  table.cards td[data-label="處理"] .actions button { flex: 1 1 0; min-height: 48px; font-size: 16px; }
  .tabs button { padding: 10px 10px; font-size: 14px; }
}
