/* =========================================================================
   設計系統：明亮・簡潔・耐看
   淺灰白底＋白色卡片，用細線而不是陰影分層；一個清亮的藍色當主色，
   狀態用柔和的粉彩色；字重與留白放鬆，數字一律等寬對齊。
   ========================================================================= */
:root {
  --brand: #2e6be6;
  --brand-600: #2459c9;
  --brand-700: #1f4cad;
  --brand-50: #f0f5ff;
  --brand-100: #dde8fd;
  --brand-200: #bfd3fb;
  --mint: #12b886;

  --ink: #1b2333;
  --ink-2: #4a5568;
  --muted: #667085;
  --line: #e7eaf0;
  --line-2: #f1f3f7;
  --bg: #f6f7fa;
  --card: #ffffff;
  --hover: #f7f9fc;

  --green: #0a7652; --green-bg: #e7f7f0;
  --amber: #985a00; --amber-bg: #fff4de;
  --red: #c4313a; --red-bg: #ffeeee;
  --blue: #2459c9; --blue-bg: #edf3ff;
  --purple: #6f4ce8; --purple-bg: #f2eeff;
  --gray: #5f6b7d; --gray-bg: #f1f3f6;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(24, 39, 75, .04);
  --shadow-md: 0 6px 20px rgba(24, 39, 75, .06);
  --shadow-lg: 0 24px 56px rgba(24, 39, 75, .14);
  --ring: 0 0 0 3px var(--brand-100);
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-600); }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; color: var(--ink); font-weight: 600; letter-spacing: .01em; }
h1 { font-size: 22px; }
h2 { font-size: 19px; }
h3 { font-size: 15.5px; }
p { margin: 0 0 8px; }
b, strong { font-weight: 600; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; background: var(--line-2); padding: 1px 6px; border-radius: 6px; }
::selection { background: var(--brand-100); }
[v-cloak] { display: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }
.right { text-align: right; }
.center { text-align: center; }
.danger-text { color: var(--red); }
.ok-text { color: var(--green); }
.strong { font-weight: 600; }
.spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } }
.mt { margin-top: 18px; }
.mb { margin-bottom: 18px; }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; font-size: 14px; line-height: 1.3;
  padding: 8px 15px; min-height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
  text-decoration: none !important;
}
.btn:hover { background: var(--hover); border-color: #d9dee6; color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(46, 107, 230, .25); }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-success { background: #13a874; border-color: #13a874; color: #fff; box-shadow: 0 1px 2px rgba(19, 168, 116, .25); }
.btn-success:hover { background: #0f9465; border-color: #0f9465; color: #fff; }
.btn-danger { color: var(--red); border-color: #f5c9ca; background: #fff; }
.btn-danger:hover { background: var(--red-bg); border-color: #efb1b3; color: var(--red); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-2); border-color: transparent; }
.btn-sm { padding: 5px 11px; min-height: 32px; font-size: 13px; border-radius: 9px; }
.btn-lg { padding: 11px 18px; min-height: 46px; font-size: 15.5px; border-radius: 12px; }
.btn-block { width: 100%; }
.icon-btn { padding: 6px; min-height: 0; border-radius: 9px; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 15px 20px; border-bottom: 1px solid var(--line-2); }
.card-h h3 { flex: 1; font-size: 15px; }
.card-b { padding: 18px 20px; }
.card-b.flush { padding: 0; }

.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 3px; position: relative; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 27px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1.3; }
.stat .value small { font-size: 13.5px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.stat.link { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.stat.link:hover { border-color: var(--brand-200); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat.alert .value { color: var(--red); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; letter-spacing: .02em;
  padding: 11px 16px; background: transparent; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tfoot td { border-top: 1px solid var(--line); background: #fbfcfd; }
.table tbody tr.clickable { cursor: pointer; transition: background .12s; }
.table tbody tr.clickable:hover td { background: var(--hover); }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn { margin-left: 6px; }

/* ---------- 標籤（柔和底色＋小圓點） ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 1px 10px 1px 8px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap; line-height: 1.75;
  background: var(--gray-bg); color: var(--gray);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; flex: none; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.purple { background: var(--purple-bg); color: var(--purple); }
.chip { display: inline-block; padding: 1px 9px; border-radius: 7px; background: var(--line-2); font-size: 12.5px; color: var(--ink-2); }

/* ---------- 表單 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.req::after { content: " *"; color: var(--red); }
.input, select.input, textarea.input {
  font: inherit; font-size: 14.5px; width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid #e1e5ec; background: #fff; color: var(--ink); min-height: 40px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder { color: #a9b1bf; }
.input:hover { border-color: #d3d9e2; }
textarea.input { resize: vertical; min-height: 92px; line-height: 1.65; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.input:disabled { background: #f9fafb; color: var(--muted); }
.input-sm { padding: 6px 10px; min-height: 34px; font-size: 13.5px; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.form-grid { display: grid; gap: 15px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.checkbox input { width: 17px; height: 17px; accent-color: var(--brand); }
.seg { display: inline-flex; background: var(--line-2); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { font: inherit; font-size: 13.5px; border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; cursor: pointer; color: var(--ink-2); transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 1px 3px rgba(24, 39, 75, .1); }

/* ---------- 頁籤 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button {
  font: inherit; font-size: 14px; background: none; border: 0; padding: 10px 12px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color .15s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tabs .count { margin-left: 5px; font-size: 11.5px; background: var(--line-2); padding: 1px 7px; border-radius: 999px; color: var(--ink-2); font-weight: 500; }
.tabs button.on .count { background: var(--brand-50); color: var(--brand); }

/* ---------- 進度條 ---------- */
.progress { height: 6px; background: #edf0f5; border-radius: 999px; overflow: hidden; min-width: 80px; }
.progress > div { height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s ease; }
.progress.warn > div { background: #f2a33a; }
.progress.over > div { background: #e5484d; }
.progress.done > div { background: var(--mint); }

/* ---------- 對話框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(27, 35, 51, .28); backdrop-filter: blur(3px); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto;
  animation: fade-in .15s ease-out;
}
.modal { background: #fff; border-radius: 20px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: pop-in .18s ease-out; }
.modal.wide { max-width: 880px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 18px 22px 14px; }
.modal-h h3 { flex: 1; font-size: 17px; }
.modal-b { padding: 6px 22px 20px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line-2); background: #fbfcfd; border-radius: 0 0 20px 20px; flex-wrap: wrap; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

/* ---------- 其他 ---------- */
.empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.empty svg { width: 34px; height: 34px; opacity: .35; margin-bottom: 8px; }
.notice { padding: 11px 14px; border-radius: 12px; font-size: 13.5px; background: var(--blue-bg); color: #2a4f9e; line-height: 1.65; }
.notice.warn { background: var(--amber-bg); color: #8a5300; }
.notice.danger { background: var(--red-bg); color: #a92b2f; }
.notice.ok { background: var(--green-bg); color: #0b6b4a; }
.notice a { font-weight: 500; }
.kv { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 9px 14px; font-size: 14px; margin: 0; }
.kv > dt { color: var(--muted); }
.kv > dd { margin: 0; word-break: break-word; }
.sig-img { max-width: 100%; max-height: 120px; background: #fff; border: 1px dashed var(--line); border-radius: 10px; padding: 6px; }
.divider { height: 1px; background: var(--line-2); margin: 16px 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input { width: auto; }
.bar { display: flex; align-items: center; gap: 10px; }
.bar .track { flex: 1; height: 8px; background: #edf0f5; border-radius: 999px; overflow: hidden; }
.bar .track > div { height: 100%; background: linear-gradient(90deg, #5b8def, var(--brand)); border-radius: 999px; }
.loading { padding: 44px; text-align: center; color: var(--muted); }
.stars { display: inline-flex; gap: 2px; }
.stars button { font-size: 28px; background: none; border: 0; cursor: pointer; color: #dfe3ea; padding: 0 2px; line-height: 1; transition: color .1s, transform .1s; }
.stars button:hover { transform: scale(1.08); }
.stars button.on { color: #f5b524; }
.file-list { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 5px; }
.file-list li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.file-list svg { width: 15px; height: 15px; color: var(--muted); flex: none; }

/* ---------- 提示訊息 ---------- */
#toast-box { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #fff; color: var(--ink); padding: 11px 16px 11px 14px; border-radius: 12px; font-size: 14px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line); border-left: 4px solid var(--brand);
  animation: toast-in .2s ease-out; max-width: min(92vw, 520px);
}
.toast.err { border-left-color: #e5484d; }
.toast.ok { border-left-color: var(--mint); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- 簽名板 ---------- */
.sigpad { position: relative; border: 1.5px dashed #c9d3e2; border-radius: 14px; background: #fcfdff; touch-action: none; }
.sigpad canvas { display: block; width: 100%; height: 100%; cursor: crosshair; border-radius: 12px; }
.sigpad .hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #b8c1cf; font-size: 18px; pointer-events: none; letter-spacing: .2em; }
.sigpad .baseline { position: absolute; left: 6%; right: 6%; bottom: 26%; border-bottom: 1px solid #e6ebf2; pointer-events: none; }

/* ---------- 登入頁 ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(46, 107, 230, .09), transparent 60%),
    radial-gradient(700px 420px at 100% 110%, rgba(18, 184, 134, .07), transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 400px; padding: 34px 30px; border-radius: 22px; box-shadow: var(--shadow-md); }
.auth-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 11px; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 17px; flex: none;
  background: linear-gradient(140deg, #5b8def, var(--brand));
  box-shadow: 0 4px 12px rgba(46, 107, 230, .25);
}

/* ---------- 準備度檢核 ---------- */
.assess-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.assess-groups .card { text-align: left; padding: 12px 14px; font: inherit; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.assess-groups .card:hover { border-color: var(--brand-200); }
.assess-groups .card.on { border-color: var(--brand); box-shadow: var(--ring); }
.assess-item { border-top: 1px solid var(--line-2); }
.assess-item.open { background: var(--hover); }
.assess-row { display: flex; align-items: center; gap: 12px; padding: 9px 16px; flex-wrap: wrap; }
.assess-title { flex: 1; min-width: 220px; display: flex; align-items: center; gap: 10px; background: none; border: 0; font: inherit; text-align: left; cursor: pointer; color: var(--ink); padding: 4px 0; }
.assess-title code { font-size: 12px; background: var(--line-2); color: var(--ink-2); padding: 1px 7px; border-radius: 6px; flex: none; min-width: 54px; text-align: center; }
.assess-detail { padding: 2px 16px 14px; }
.seg-status button { padding: 5px 11px; font-size: 13px; }
.seg-status button.on.s-ok { background: var(--green-bg); color: var(--green); }
.seg-status button.on.s-part { background: var(--amber-bg); color: var(--amber); }
.seg-status button.on.s-no { background: var(--red-bg); color: var(--red); }
.seg-status button.on.s-na { background: #fff; color: var(--gray); }
@media (max-width: 640px) { .assess-row { padding: 9px 12px; } .seg-status { width: 100%; } .seg-status button { flex: 1; } }

/* ---------- 文件範本 ---------- */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.doc-card { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font: inherit; font-size: 14px; text-align: left; cursor: pointer; color: var(--ink); transition: border-color .15s, background .15s; }
.doc-card svg { color: var(--brand); flex: none; }
.doc-card:hover { border-color: var(--brand-200); background: var(--brand-50); }

/* ---------- 損益 ---------- */
.pos { color: var(--green); } .neg { color: var(--red); }
.margin-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--line-2); }
.margin-bar i { display: block; height: 100%; }
