/* 風格參考：扁平化資訊圖表（青綠 + 橘 + 灰，圓環、橫條箭頭、人形圖、時間軸） */
:root {
  --bg: #efefec;
  --card: #ffffff;
  --text: #4a4a4a;
  --muted: #8a8a86;
  --line: #e1e1dc;
  --teal: #2fae93;
  --teal-d: #1f8a74;
  --teal-l: #d3ece5;
  --orange: #ec6b2d;
  --orange-l: #fbe0d2;
  --grey: #6f6f6f;
  --grey-l: #d9d9d5;
  --ok: var(--teal-d);
  --ok-bg: var(--teal-l);
  --warn: #b4530f;
  --warn-bg: var(--orange-l);
  --err: #d9361a;
  --err-bg: #fde6e1;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
[hidden] { display: none !important; }
.red { color: var(--err); font-weight: 700; }

.sim-banner {
  background: var(--orange-l); color: var(--warn);
  padding: 8px 16px; font-size: 13px; text-align: center;
}

.site-header { background: #fff; border-bottom: 4px solid var(--teal); position: sticky; top: 0; z-index: 10; }
.header-inner { padding-top: 10px; padding-bottom: 10px; }
.site-header h1 { margin: 0 0 8px; font-size: 22px; color: var(--grey); letter-spacing: 0.02em; }
.site-header h1 .accent { color: var(--orange); }
.site-header nav { display: flex; gap: 6px; flex-wrap: wrap; }
.site-header nav a {
  position: relative; text-decoration: none; font-size: 14px; color: var(--teal-d);
  padding: 5px 14px; border-radius: 999px; background: var(--teal-l);
}
.site-header nav a:hover, .site-header nav a:focus-visible { background: #b9e0d6; }
.site-header nav a.active { background: var(--teal); color: #fff; font-weight: 700; }
.nb { position: absolute; top: -4px; right: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--orange); border: 2px solid #fff; }

.global-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; padding-top: 16px; }
main { padding-top: 14px; padding-bottom: 30px; }
.card { background: var(--card); padding: 20px; margin-bottom: 18px; border-top: 4px solid var(--grey-l); }
.card h2 { margin: 0; font-size: 18px; color: #444; text-transform: uppercase; letter-spacing: 0.04em; }
.card h2::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--orange); margin-right: 8px; }
.card h3 { margin: 0; font-size: 15px; color: var(--teal-d); }
.sec-sub { font-size: 12px; color: var(--muted); margin: 2px 0 14px; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--text); margin: 12px 0 4px; font-size: 14px; }
input[type="text"], input[type="number"], input[type="month"], select {
  font: inherit; padding: 8px 10px; border: 1px solid #c4c4be; border-radius: 4px;
  background: #fff; color: var(--text); width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid #8fd6c4; outline-offset: 1px;
}
input.invalid { border-color: var(--err); background: var(--err-bg); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--teal); }

.hint { font-size: 13px; color: var(--muted); margin: 6px 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
button { font: inherit; padding: 9px 18px; border-radius: 4px; border: 2px solid var(--teal); cursor: pointer; }
button.primary { background: var(--teal); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--teal-d); border-color: var(--teal-d); }
button.ghost { background: #fff; color: var(--teal-d); }
button.ghost:hover:not(:disabled) { background: var(--teal-l); }
button.orange { background: var(--orange); border-color: var(--orange); color: #fff; }
button.small { padding: 3px 10px; font-size: 13px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.msg { min-height: 22px; margin: 8px 0 0; font-size: 14px; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--err); }
.msg.warn { color: var(--warn); }

.empty { border: 2px dashed #c9c9c3; padding: 18px; text-align: center; color: var(--muted); background: #fafaf8; }

/* 流程時間軸 */
.steps { list-style: none; margin: 0 0 16px; padding: 0; display: flex; position: relative; }
.steps li { flex: 1; text-align: center; font-size: 13px; color: var(--muted); position: relative; padding-top: 38px; }
.steps li span {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 30px; height: 30px; border-radius: 50%; background: var(--grey-l); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; z-index: 1;
}
.steps li::before { content: ""; position: absolute; top: 14px; left: -50%; width: 100%; height: 3px; background: var(--grey-l); }
.steps li:first-child::before { display: none; }
.steps li.done span, .steps li.done::before { background: var(--teal); }
.steps li.done { color: var(--teal-d); }
.steps li.now span { background: var(--orange); }
.steps li.now { color: var(--warn); font-weight: 700; }

.statusbar { padding: 8px 12px; background: #efefec; font-size: 14px; margin-bottom: 12px; border-left: 5px solid var(--grey-l); }
.statusbar.submitted { background: var(--teal-l); color: var(--teal-d); border-left-color: var(--teal); }
.statusbar.draft { background: var(--orange-l); color: var(--warn); border-left-color: var(--orange); }

.notice-box { padding: 8px 12px; background: var(--orange-l); border-left: 5px solid var(--orange); color: var(--warn); font-size: 14px; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice-box.mgr { background: var(--teal-l); border-left-color: var(--teal); color: var(--teal-d); }

/* 填寫卡片 */
.item { border: 1px solid var(--line); padding: 12px 14px; margin-bottom: 14px; background: #fff; border-left: 5px solid var(--teal); }
.item.flag { border-left-color: var(--err); background: #fffaf9; }
.item-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; align-items: center; }
.item-head b { font-size: 16px; color: #444; }
.item-head .meta { font-size: 12px; color: var(--muted); }
.tag-new { display: inline-block; font-size: 11px; padding: 0 8px; border-radius: 999px; background: var(--orange-l); color: var(--warn); margin-left: 6px; }
.hist { display: flex; gap: 4px; overflow-x: auto; padding: 10px 0 6px; }
.hist .col { flex: 1 0 56px; text-align: center; font-size: 12px; }
.hist .bar-area { height: 56px; display: flex; align-items: flex-end; justify-content: center; }
.hist .bar { width: 58%; min-height: 2px; background: var(--teal); }
.hist .col.cur .bar { background: var(--orange); }
.hist .col.cur .bar.flagged { background: var(--err); }
.hist .val { font-variant-numeric: tabular-nums; margin-top: 2px; }
.hist .mon { color: var(--muted); }
.hist .col.cur .mon { color: var(--orange); font-weight: 700; }
.refline { font-size: 13px; color: var(--muted); margin: 2px 0 8px; }
.entry { display: grid; grid-template-columns: minmax(160px, 220px) 1fr; gap: 12px; align-items: start; }
.entry input[type="number"] { text-align: right; font-size: 16px; }
.diff { font-size: 14px; min-height: 22px; margin-top: 4px; }
.diff.alert { color: var(--err); font-weight: 700; }
.diff.okdiff { color: var(--teal-d); }
.item.flag input[type="number"] { color: var(--err); font-weight: 700; border-color: var(--err); }
.totalbar { text-align: right; font-size: 16px; margin-top: 4px; }
.totalbar b { color: var(--teal-d); font-size: 22px; }

.addbox { border: 2px dashed var(--teal); padding: 14px; margin: 16px 0; background: #f6fbf9; }
.add-grid { display: grid; grid-template-columns: 2fr 1.5fr auto; gap: 12px; align-items: end; }

/* Dashboard */
.dash-top { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; margin-bottom: 14px; }
.rings { display: flex; gap: 18px; flex-wrap: wrap; }
.ring { text-align: center; width: 104px; }
.ring svg { width: 92px; height: 92px; }
.ring .rv { font-size: 22px; font-weight: 800; }
.ring .rl { font-size: 12px; color: var(--muted); }
.people-box { flex: 1; min-width: 240px; }
.people { display: flex; gap: 4px; }
.people svg { width: 26px; height: 44px; fill: var(--grey-l); }
.people svg.on { fill: var(--teal); }
.people svg.draft { fill: var(--orange); }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: #f4f4f1; padding: 10px 12px; border-bottom: 4px solid var(--teal); }
.stat b { display: block; font-size: 24px; color: var(--teal-d); }
.stat span { font-size: 12px; color: var(--muted); }
.stat.bad { border-bottom-color: var(--orange); }
.stat.bad b { color: var(--orange); }
.pending-box { padding: 10px 14px; background: var(--orange-l); color: var(--warn); font-size: 14px; border-left: 5px solid var(--orange); margin-bottom: 12px; }
.pending-box.done { background: var(--teal-l); color: var(--teal-d); border-left-color: var(--teal); }

.hbars { display: grid; gap: 8px; margin: 12px 0; }
.hrow { display: grid; grid-template-columns: 80px 1fr 60px; gap: 10px; align-items: center; font-size: 14px; }
.htrack { background: #e7e7e3; height: 24px; }
.hfill { height: 100%; background: var(--teal); clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); min-width: 2px; }
.hfill.draft { background: var(--orange); }
.hfill.none { background: var(--grey); }
.hrow .hv { font-weight: 700; text-align: right; color: var(--teal-d); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f1f1ee; font-weight: 700; white-space: nowrap; color: #555; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.red-cell { color: var(--err); font-weight: 700; }
tr.row-late { background: #fff8f4; }
tfoot td { font-weight: 700; background: #f7f7f4; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.badge.pending { background: #e7e7e3; color: #555; }
.badge.ok { background: var(--teal-l); color: var(--teal-d); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.warn { background: var(--orange-l); color: var(--warn); }

.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 16px 0 28px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: #444; color: #fff; padding: 10px 18px; border-radius: 6px;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
  max-width: 90vw; z-index: 50; font-size: 14px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .site-header h1 { font-size: 18px; }
  .card { padding: 14px; }
  .entry, .add-grid { grid-template-columns: 1fr; }
  .steps li { font-size: 11px; }
  .hrow { grid-template-columns: 56px 1fr 48px; }
  table.cards-m thead { display: none; }
  table.cards-m, table.cards-m tbody, table.cards-m tfoot, table.cards-m tr, table.cards-m td { display: block; width: 100%; }
  table.cards-m tr { border: 1px solid var(--line); margin-bottom: 10px; padding: 6px 8px; }
  table.cards-m td { border: 0; padding: 4px 2px; display: flex; justify-content: space-between; gap: 10px; align-items: center; text-align: right; }
  table.cards-m td::before { content: attr(data-label); color: var(--muted); font-size: 12px; flex: 0 0 90px; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .toast { transition: none; }
}

/* 人形圖標籤 */
.people .pp { text-align: center; }
.people .pp small { display: block; font-size: 12px; color: var(--muted); }

/* 批次上傳、篩選、緊湊填寫表 */
.upload-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.upload-row input[type="file"] { width: auto; flex: 1 1 260px; }
.filterbar { display: grid; grid-template-columns: 2fr 1fr auto; gap: 12px; align-items: end; margin: 8px 0; }
.fcount { font-size: 13px; color: var(--muted); padding-bottom: 8px; }
.fill-table td { vertical-align: top; }
.fill-table input[type="number"] { width: 130px; text-align: right; }
.fill-table input[type="text"] { min-width: 120px; }
.fill-table tr.line.flag { background: #fffaf9; }
.fill-table tr.line.flag input.amt { color: var(--err); font-weight: 700; border-color: var(--err); }
.fill-table .dtxt { font-size: 13px; white-space: nowrap; }
.fill-table .dtxt.alert { color: var(--err); font-weight: 700; }
.fill-table .dtxt.okdiff { color: var(--teal-d); }
.fill-table .sub { display: block; font-size: 12px; color: var(--muted); }
.spark { width: 112px; height: 30px; display: block; }
tr.histrow td { background: #f6fbf9; border-bottom: 1px solid var(--line); }
tr.histrow .hist { padding: 4px 0; }
.up-errors { list-style: none; padding: 0; margin: 8px 0; max-height: 180px; overflow: auto; font-size: 13px; }
.up-errors li { padding: 4px 10px; background: var(--err-bg); color: var(--err); margin-bottom: 3px; }
.up-sum { padding: 8px 12px; background: var(--teal-l); color: var(--teal-d); margin-top: 8px; font-size: 14px; border-left: 5px solid var(--teal); }
.up-sum.bad { background: var(--orange-l); color: var(--warn); border-left-color: var(--orange); }
.add-grid { grid-template-columns: 2fr 1fr 1.5fr auto; }
@media (max-width: 720px) {
  .filterbar, .add-grid { grid-template-columns: 1fr; }
  tr.histrow td::before { content: none; }
  .fill-table input[type="number"], .fill-table input[type="text"] { width: 100%; max-width: 220px; }
}
