/* ============================================================
   鼎兆元管理系統｜基礎樣式
   reset、排版基礎、body 背景、中文字型。
   手機優先：以下規則先寫手機版，桌機用 @media (min-width:768px) 疊加。
   顏色一律取自 tokens.css，本檔不得出現色碼。
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

/* hidden 屬性一律真的隱藏：.field、.toast 這類有自己 display 的元件會蓋掉瀏覽器預設的 hidden
   （2026-10-11 e2e ⑧ 抓到：部門欄設了 hidden 仍顯示） */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: var(--fw-normal);
  line-height: var(--lh-base);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-3);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  color: var(--ink);
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4, h5, h6 { font-size: var(--fs-md); }

p {
  margin: 0 0 var(--space-3);
}
p:last-child { margin-bottom: 0; }

small, .text-muted {
  color: var(--muted);
  font-size: var(--fs-sm);
}

a {
  color: var(--brand);
  text-decoration: none;
}
a:hover, a:focus-visible {
  text-decoration: underline;
}

ul, ol {
  margin: 0 0 var(--space-3);
  padding-left: var(--space-5);
}

img, svg {
  max-width: 100%;
  display: block;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: var(--space-4) 0;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* 任何寬內容（表格等）都在自己的容器內捲動，頁面本身永不橫向捲動 */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---- 版面容器：手機優先，單欄、留白足夠 ---- */
.page {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-4);
}

.section {
  margin-bottom: var(--space-5);
}
.section:last-child { margin-bottom: 0; }

.section-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--muted);
  letter-spacing: .02em;
  margin-bottom: var(--space-2);
}

.stack > * + * {
  margin-top: var(--gap);
}

@media (min-width: 768px) {
  body {
    font-size: var(--fs-md);
  }

  .page {
    max-width: 960px;
    padding: var(--space-6);
  }
}

/* 讀屏器專用：視覺上完全隱藏、輔助技術仍讀得到（登入頁系統名用它——
   視覺上的品牌由背景照片承擔，不重複一行字） */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
