/* 八方歐 品牌層 DS（brand layer）
 *
 * 來源：Claude Design 畫布「八方歐 DS」（2026-11-08 Charlie 定稿，claude.ai/artifact/9Ws3zJ6cXEaitRHPapgppk）。
 * 畫布改了，這份要跟著改；這份是網站實際用的值。
 *
 * 兩層：這一份是「品牌層」——網站、加盟主入口、平台後台共用。
 * 產品層（app）是 design/tokens.json；兩層目前的差異列在 site/ds.html〈和 app 的差別〉。
 *
 * 規則（畫布上寫的）：只用一種字體（思源黑體），手寫的只有字標；不用任何楷體。
 * 靠字級和字重分層。數字逐列對齊，像店裡的單據。赤陶主按鈕一頁一個。
 */
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700&display=swap");

:root {
  /* 色：麵粉紙、墨、赤陶、鼠尾草＋狀態三色。對比度全部過 4.5（赤陶底白字只配 19px 粗） */
  --paper: #EFEBE5;      /* 頁面底 */
  --paper-2: #F9F4ED;    /* 次要面：側欄、分組列、說明框 */
  --surface: #FFFFFF;    /* 卡、單據、表格、輸入框 */
  --sand: #E3DED6;       /* 次要按鈕、分段切換底、額度條底 */
  --ink: #201E1D;
  --ink-2: #645C50;      /* 說明、表頭、未選 */
  --ink-3: #6F6658;      /* 更次要：座標軸、代碼 */
  --line: rgba(32, 30, 29, .16);
  --line-strong: rgba(32, 30, 29, .32);
  --terra: #C67139;      /* 主色：赤陶 */
  --terra-deep: #B2622D;
  --terra-ink: #8C491A;  /* 淺底上的赤陶字、小主要按鈕底 */
  --terra-soft: #FFE1D0;
  --terra-hatch: #FBE6D6;
  --sage: #56633F;       /* 輔色：進行中、合作開發期 */
  --sage-soft: #E1EECC;
  --sage-ink: #3F4A2D;
  --ok: #55691F;  --ok-soft: #E2EDD0;
  --warn: #8A5210; --warn-soft: #FCE3CD;
  --bad: #AB3F2B;  --bad-soft: #FFDFD7;
  --on-terra: #FFFFFF;

  --font-sans: "Noto Sans TC", "PingFang TC", "Heiti TC", "Microsoft JhengHei", system-ui, sans-serif;

  /* 字級：頁標題 30／區塊 22／強調 19／內文 17／說明 15（老花，內文地板 17、小字地板 15） */
  --fs-caption: 15px; --fs-body: 17px; --fs-callout: 19px;
  --fs-headline: 22px; --fs-title: 26px; --fs-title-l: 30px;
  --fs-display: clamp(34px, 6vw, 56px);
  --fs-display-s: clamp(28px, 4.2vw, 40px);

  /* 間距：依關係——同一件事 4／件與件 12／段與段 40；網頁大段 72 */
  --gap-inside: 4px; --gap-item: 12px; --gap-section: 40px; --gap-band: 72px;
  --pad-sm: 8px; --pad-md: 12px; --pad-lg: 16px; --pad-xl: 24px;

  /* 圓角：小 8 標籤內框／中 16 輸入框／卡 22 卡與單據／大 28 登入、彈窗 */
  --r-xs: 8px; --r-sm: 16px; --r-card: 22px; --r-lg: 28px; --r-nav: 12px;

  --t-feedback: 160ms; --t-transition: 280ms;
  --measure: 34em;
}
/* 只有淺色（2026-11-10 Charlie：「我不要深色模式」）。不要再加 prefers-color-scheme: dark。 */
:root { color-scheme: light; }

/* ── 基礎 ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--font-sans); font-size: var(--fs-body); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; text-wrap: balance; font-weight: 700; line-height: 1.3; }
h1 { font-size: var(--fs-title-l); }
h2 { font-size: var(--fs-headline); }
p { margin: 0; }
a { color: var(--terra-ink); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--terra); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: var(--fs-caption); }
.note { font-size: var(--fs-caption); color: var(--ink-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap {
  max-width: 1120px; margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* 字標：手寫向量，走 mask 讓顏色跟著主題。淺底用墨、深底用麵粉色、赤陶底只用白 */
.wordmark {
  display: inline-block; aspect-ratio: 160.7 / 53.4; height: 1em;
  background: currentColor;
  -webkit-mask: url("assets/wordmark.svg") center / contain no-repeat;
          mask: url("assets/wordmark.svg") center / contain no-repeat;
}
.wordmark-v {
  display: inline-block; aspect-ratio: 63.6 / 155.5; width: 1em;
  background: currentColor;
  -webkit-mask: url("assets/wordmark-vertical.svg") center / contain no-repeat;
          mask: url("assets/wordmark-vertical.svg") center / contain no-repeat;
}

/* ── 按鈕：膠囊形，高 48（小的 44） ─────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 999px; border: 0;
  font: 700 var(--fs-body)/1 var(--font-sans); text-decoration: none; cursor: pointer;
  transition: background var(--t-feedback), transform var(--t-feedback);
}
.btn:active { transform: scale(.97); }
.btn svg { width: 20px; height: 20px; flex: none; }
/* 主要：赤陶底白字 19 粗，一頁一個 */
.btn-primary { background: var(--terra); color: var(--on-terra); font-size: var(--fs-callout); padding: 0 24px; }
.btn-primary:hover { background: var(--terra-deep); color: var(--on-terra); }
/* 小主要：赤陶字色當底，表單裡的送出、加入 */
.btn-strong { background: var(--terra-ink); color: #FFFFFF; }
.btn-strong:hover { background: var(--ink); color: #FFFFFF; }
.btn-quiet { background: var(--sand); color: var(--ink); }
.btn-quiet:hover { background: var(--line-strong); color: var(--ink); }
.btn-line { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.btn-danger { background: var(--bad-soft); color: var(--bad); }
.btn-sm { min-height: 44px; padding: 0 16px; font-size: var(--fs-caption); }
.btn-icon { width: 44px; min-height: 44px; padding: 0; border-radius: var(--r-nav); background: transparent; color: var(--ink-2); }
.btn-icon:hover, .btn-icon[aria-pressed="true"] { background: var(--sand); color: var(--ink); }
/* 返回：沙底小膠囊 */
.back { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 16px 0 10px; border: 0; border-radius: 999px; background: var(--sand); color: var(--ink); font: 700 var(--fs-caption) var(--font-sans); text-decoration: none; cursor: pointer; }
.back svg { width: 18px; height: 18px; }

/* ── 狀態標籤：圓點＋顏色，不只靠色 ── */
.pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 3px 12px; border-radius: 999px; font-size: var(--fs-caption); font-weight: 500;
  background: var(--sand); color: var(--ink-2);
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.pill.plain::before { display: none; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-sage { background: var(--sage-soft); color: var(--sage); }
.pill-terra { background: var(--terra-soft); color: var(--terra-ink); }
/* 小標記：矩陣裡的「全部店」「進階版」 */
.tag { display: inline-block; font-size: 13px; padding: 1px 8px; border-radius: 999px; background: var(--sand); color: var(--ink-2); white-space: nowrap; font-weight: 400; }
.tag-terra { background: var(--terra-soft); color: var(--terra-ink); }

/* ── 面 ─────────────────────────────── */
.card { background: var(--surface); border-radius: var(--r-card); padding: var(--pad-xl); display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card > h2 { font-size: var(--fs-headline); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel { background: var(--paper-2); border-radius: var(--r-sm); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.panel .muted { color: var(--ink-2); }
.callout-sage { background: var(--sage-soft); color: var(--sage-ink); border-radius: var(--r-sm); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.callout-sage b { color: var(--ink); }

/* ── 輸入 ─────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: var(--fs-caption); color: var(--ink-2); font-weight: 500; }
.input, select.input, textarea.input {
  min-height: 48px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1.5px solid var(--ink-3); background: var(--surface); color: var(--ink); /* 2026-11-12：--line 只有約 1.4:1，輸入框邊界要 3:1（WCAG 1.4.11） */
  font: var(--fs-body) var(--font-sans); width: 100%;
}
textarea.input { padding: 12px 14px; line-height: 1.6; resize: vertical; }
.input:focus { outline: none; border-color: var(--terra); }
.input:disabled { opacity: .55; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }

/* 開關：改完就存 */
.switch { position: relative; display: inline-block; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background var(--t-feedback); }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform var(--t-feedback); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--terra); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .45; }
.switch input:focus-visible + span { outline: 3px solid var(--terra); outline-offset: 2px; }

/* 分段切換：方案、狀態 */
.seg { display: inline-flex; flex-wrap: wrap; background: var(--sand); border-radius: 999px; padding: 4px; }
.seg button { border: 0; background: none; min-height: 40px; padding: 0 18px; border-radius: 999px; font: 500 var(--fs-body) var(--font-sans); color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 700; }

/* 步進器：加購秤 */
.stepper { display: inline-flex; align-items: center; gap: 10px; }
.stepper button { width: 44px; height: 44px; border: 0; border-radius: 999px; background: var(--sand); color: var(--ink); font: 700 20px var(--font-sans); cursor: pointer; }
.stepper button:disabled { opacity: .45; cursor: default; }
.stepper b { min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }

/* 分頁：換內容（切換改設定用 .seg） */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button, .tabs a { border: 0; background: none; padding: 12px 14px; margin-bottom: -1px; border-bottom: 3px solid transparent; font: 500 var(--fs-body) var(--font-sans); color: var(--ink-2); white-space: nowrap; cursor: pointer; text-decoration: none; }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--terra); }

/* ── 單據：價格、帳單、明細一律逐列對齊 ── */
.slip-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding-block: 12px; border-bottom: 1px dashed var(--line-strong);
}
.slip-row:last-child { border-bottom: 0; }
.slip-row small { display: block; font-size: var(--fs-caption); color: var(--ink-2); }
.slip-row .v { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; white-space: nowrap; }
.slip-row.last { border-bottom: 0; }
.slip-total { border-top: 2px solid var(--ink); border-bottom: 0; padding: 14px 0 0; font-weight: 700; font-size: var(--fs-callout); }
.slip-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--line-strong); }
.slip-head h2 { font-size: var(--fs-headline); }

/* 清單列（模組、折讓）：虛線分隔 */
.row-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px; border-bottom: 1px dashed var(--line-strong); }
.row-item:last-child { border-bottom: 0; }
.row-item small { display: block; font-size: var(--fs-caption); color: var(--ink-2); }
.list { display: flex; flex-direction: column; }

/* ── 表格：白卡圓角 22，表頭 15 ── */
.table-wrap { position: relative; overflow-x: auto; background: var(--surface); border-radius: var(--r-card); } /* relative：讓表內 .sr-only 不撐寬整頁 */
table.t { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.t th { text-align: left; font-weight: 500; font-size: var(--fs-caption); color: var(--ink-2); padding: 14px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t th:first-child, .t td:first-child { padding-left: 24px; }
.t th:last-child, .t td:last-child { padding-right: 24px; }
.t tbody tr:last-child td { border-bottom: 0; }
.t tfoot td { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 700; padding-block: 14px; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t .c { text-align: center; }
.t td small { display: block; font-size: var(--fs-caption); color: var(--ink-2); font-weight: 400; }
.t a.name { color: var(--ink); font-weight: 700; text-decoration: none; }
.t a.name:hover { text-decoration: underline; }
.t td.act { text-align: right; padding-block: 10px; }

/* 額度條：用量／額度；超額只標紅，不擋 */
.meter { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.meter-top { display: flex; justify-content: space-between; gap: 12px; font-size: var(--fs-caption); }
.meter-top span { color: var(--ink-2); }
.meter-top b { font-variant-numeric: tabular-nums; }
.meter-bar { height: 8px; border-radius: 999px; background: var(--sand); overflow: hidden; }
.meter-bar > i { display: block; height: 100%; background: var(--sage); border-radius: inherit; }
.meter.over .meter-bar > i { background: var(--bad); }
.meter.over .meter-top b, .meter.over .meter-top span { color: var(--bad); font-weight: 700; }

/* 空狀態：插畫一畫面最多一張 */
.empty { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; padding: 8px 0; }
.empty img { width: 104px; height: auto; }
.empty b { display: block; }

/* 浮出提示：改完即存的回饋 */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 12px 20px; border-radius: 999px; font-weight: 500; z-index: 20; max-width: calc(100vw - 32px); }

/* ── 應用程式外框（後台、加盟主入口共用） ── */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--paper-2); border-right: 1px solid var(--line);
  padding-block: 24px; padding-inline: 16px; display: flex; flex-direction: column; gap: 4px;
}
.side .brand { display: flex; justify-content: center; padding: 4px 10px 16px; font-size: 48px; color: var(--ink); }
.nav-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  min-height: 44px; padding: 0 12px; border-radius: var(--r-nav); border: 0; background: none;
  color: var(--ink-2); font: 500 var(--fs-body) var(--font-sans); cursor: pointer; text-decoration: none;
}
.nav-btn:hover { background: var(--sand); color: var(--ink); }
.nav-btn[aria-current="page"] { background: var(--terra-soft); color: var(--terra-ink); font-weight: 700; }
.nav-btn svg { width: 20px; height: 20px; flex: none; }
.side .foot { margin-top: 16px; }
.main { min-width: 0; padding-block: 32px 80px; padding-left: max(16px, min(3vw, 40px)); padding-right: max(16px, env(safe-area-inset-right, 0px), min(3vw, 40px)); }
.page { max-width: 1120px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.page-head .t-left { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.page-head h1 { font-size: var(--fs-title-l); }
.cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.cols > * { flex: 1 1 420px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sample { font-size: var(--fs-caption); color: var(--sage); background: var(--sage-soft); border-radius: 999px; padding: 4px 12px; white-space: nowrap; }
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { flex-direction: row; align-items: center; overflow-x: auto; padding: 10px max(16px, env(safe-area-inset-left, 0px)); border-right: 0; border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
  .side .brand { padding: 0 8px 0 0; font-size: 28px; }
  .side .foot { margin-top: 0; }
  .nav-btn { width: auto; white-space: nowrap; flex: none; }
  .main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
}
