/* =========================================================================
 * 補助案顧問工作台 — 樣式
 * 色票、字級、圓角取自「6. 系統原型/顧問工作台.html」最上方的 :root（主視覺：淺灰底、圓角、黑白加一個綠色）。
 * 這裡只放空殼需要的基本元件；各階段的正式畫面由 UI/UX 那邊設計後再接進來。
 * 公司的安全規定不允許引用外部資源，所以沒有載入 Google Fonts：電腦裡有 Inter、Noto Sans TC 就用，沒有就用系統字型。
 * ========================================================================= */
:root {
  --page: #fafaf9;   /* 頁面底 */
  --tile: #f2f3f0;   /* 淺灰面板、欄位底 */
  --sunk: #e7e8e4;   /* 深一階的灰：欄位 hover、細線 */
  --mid: #d9dad5;
  --card: #ffffff;   /* 白卡片 */
  --ink: #121212;    /* 第一階：標題、數值 */
  --ink-1: #2a2b28;  /* 第二階：內文 */
  --ink-2: #5f615c;  /* 第三階：欄位名稱、說明 */
  --veil: rgba(18, 18, 18, .07);
  --line: #e7e8e4;
  --accent: #3cc455; /* 唯一強調色 */
  --accent-2: #a8e221;
  --grad: linear-gradient(90deg, var(--accent), var(--accent-2));

  --font: "Inter", "Noto Sans TC", -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
  --fs-label: 12px;
  --fs-meta: 13px;
  --fs-dense: 14px;
  --fs-body: 15px;
  --fs-lead: 16px;
  --fs-h3: 15px;
  --fs-h2: clamp(18px, 16px + .5vw, 20px);
  --lh-head: 1.3;
  --lh-ui: 1.5;
  --lh-body: 1.7;
  --ls-head: .02em;
  --ls-label: .04em;
  --measure: 38em;

  --r-tile: 24px;
  --r-card: 16px;
  --r-field: 12px;
  --pill: 999px;
  --shadow: 0 1px 2px rgba(18, 18, 18, .08), 0 0 0 1px rgba(18, 18, 18, .03);
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink-1);
  font-family: var(--font); font-size: var(--fs-body); font-weight: 400; line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-kerning: normal; font-synthesis: none;
  line-break: strict; text-autospace: normal;
}
h1, h2 { margin: 0; color: var(--ink); font-weight: 700; line-height: var(--lh-head); letter-spacing: var(--ls-head); text-wrap: balance; }
h1 { font-size: var(--fs-h2); }
h2 { font-size: var(--fs-h3); }
p { margin: 0; }
[hidden] { display: none !important; }

/* ---------- 版面 ---------- */
.topbar-inner, .wrap { width: min(1080px, 100%); margin: 0 auto; padding-inline: 20px; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 16px; flex-wrap: wrap; }
.brand { color: var(--ink); font-size: var(--fs-lead); font-weight: 700; letter-spacing: var(--ls-head); line-height: var(--lh-head); }
.topbar-actions { display: flex; gap: 8px; }
.wrap { padding-block: 8px 48px; }

.panel { background: var(--tile); border-radius: var(--r-tile); padding: 24px; display: grid; gap: 16px; }
.panel-head { display: grid; gap: 6px; }
.card { background: var(--card); border-radius: var(--r-card); padding: 20px; display: grid; gap: 16px; min-width: 0; font-size: var(--fs-dense); }
.hint { color: var(--ink-2); font-size: var(--fs-meta); max-width: var(--measure); }

/* ---------- 表單 ---------- */
.form-grid { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; align-items: start; }
.fld { display: grid; gap: 6px; min-width: 0; }
.fld label { color: var(--ink-2); font-size: var(--fs-label); font-weight: 500; letter-spacing: var(--ls-label); line-height: var(--lh-ui); }
.req { color: var(--ink); }
input, button { font: inherit; color: inherit; letter-spacing: inherit; }
.field {
  width: 100%; border: 0; border-radius: var(--r-field); padding: 10px 14px;
  background-color: var(--tile); color: var(--ink); font-size: var(--fs-body); line-height: var(--lh-ui);
  transition: background-color .15s;
}
.field::placeholder { color: var(--ink-2); opacity: 1; }
.field:hover { background-color: var(--sunk); }
.field:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; background-color: var(--card); }
.field[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--ink); }
/* 錯誤訊息不用紅色（主視覺只有黑、白、綠）：黑色粗一階，前面加一個實心方塊 */
.form-error { color: var(--ink); font-size: var(--fs-meta); font-weight: 500; line-height: var(--lh-ui); }
.form-error::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; background: var(--ink); border-radius: 2px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ---------- 按鈕、標籤 ---------- */
.btn {
  border: 0; background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--sunk);
  border-radius: var(--pill); padding: 8px 18px; font-size: var(--fs-dense); font-weight: 500; line-height: var(--lh-ui);
  letter-spacing: .01em; cursor: pointer; white-space: nowrap; transition: background-color .15s, filter .15s;
}
.btn:not([disabled]):hover { background: var(--tile); }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.primary { background: var(--grad); box-shadow: none; }
.btn.primary:not([disabled]):hover { background: var(--grad); filter: brightness(1.06); }
/* 待處理：黑框白底 */
.pill { display: inline-block; border-radius: var(--pill); padding: 2px 12px; background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-size: var(--fs-label); font-weight: 500; letter-spacing: var(--ls-label); line-height: 1.7; white-space: nowrap; }

/* ---------- 清單 ---------- */
.state { color: var(--ink-2); font-size: var(--fs-dense); display: grid; gap: 12px; justify-items: start; }
.table-wrap { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; font-size: var(--fs-dense); }
.grid th { text-align: left; color: var(--ink-2); font-size: var(--fs-label); font-weight: 500; letter-spacing: var(--ls-label); line-height: var(--lh-ui); padding: 0 12px 10px 0; white-space: nowrap; }
.grid td { padding: 12px 12px 12px 0; border-top: 1px solid var(--line); vertical-align: top; color: var(--ink-1); line-height: var(--lh-ui); }
.grid th:last-child, .grid td:last-child { padding-right: 0; }
.grid .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid .name { color: var(--ink); font-weight: 500; }
.grid a.name { text-decoration: underline; text-decoration-color: var(--mid); text-underline-offset: 3px; }
.grid a.name:hover { text-decoration-color: var(--ink); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid .sub { display: block; color: var(--ink-2); font-size: var(--fs-meta); }

/* ---------- 提示、對話框 ---------- */
.toast-zone { position: fixed; left: 0; right: 0; bottom: 24px; display: grid; justify-items: center; gap: 8px; padding-inline: 20px; pointer-events: none; z-index: 10; }
.toast { background: var(--ink); color: #fff; border-radius: var(--pill); padding: 10px 20px; font-size: var(--fs-dense); font-weight: 500; line-height: var(--lh-ui); box-shadow: var(--shadow); max-width: 100%; }
dialog { border: 0; border-radius: var(--r-card); padding: 0; background: var(--card); color: var(--ink-1); width: min(420px, calc(100% - 40px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(18, 18, 18, .35); }
.dlg { padding: 24px; }

/* ---------- 登入頁 ---------- */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-panel { width: min(420px, 100%); }
.login-head { display: grid; gap: 6px; }
.login-page .btn.primary { width: 100%; padding-block: 10px; }

/* ---------- 窄螢幕 ---------- */
@media (max-width: 720px) {
  .form-row { grid-template-columns: 1fr; }
  .panel { padding: 16px; border-radius: 20px; }
  .card { padding: 16px; }
  .form-actions .btn { flex: 1; }
}
/* 觸控裝置的輸入框至少 16px，否則 iPhone 點進去會自動放大畫面 */
@media (pointer: coarse) { .field { font-size: 16px; } }
