/* ===== 基本設定 ===== */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --ok-bg: #ecfdf5;  --ok: #047857;
  --err-bg: #fef2f2; --err: #b91c1c;
  --warn-bg: #fffbeb; --warn: #92400e;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}
a { color: var(--primary); }

/* ===== 上方導覽列 ===== */
.topbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 12px 24px; background: #1e293b; color: #fff;
}
.topbar .brand { color: #fff; font-weight: bold; text-decoration: none; font-size: 18px; }
.topbar nav { display: flex; gap: 16px; align-items: center; }
.topbar nav a { color: #cbd5e1; text-decoration: none; }
.topbar nav a:hover { color: #fff; }
.topbar .who { color: #e2e8f0; }

/* ===== 版面 ===== */
.page { max-width: 1200px; margin: 24px auto; padding: 0 16px; }
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; flex-direction: column; }

.card {
  background: var(--card); border-radius: 12px; padding: 28px 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.04);
}
.card h1 { margin: 0 0 20px; font-size: 22px; }
.narrow { max-width: 440px; width: 100%; margin: 0 auto; }
.login  { max-width: 380px; width: 100%; }
.login h1 { text-align: center; }

/* ===== 表單 ===== */
label { display: block; margin-bottom: 16px; font-weight: 600; font-size: 15px; }
label small { font-weight: normal; color: var(--muted); }
input[type=text], input[type=password], input:not([type]), select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid #d1d5db; border-radius: 8px; font-size: 16px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: var(--primary); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: normal; }
label.check input { width: 18px; height: 18px; margin: 0; }

.captcha-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.captcha-row input { margin-top: 0; flex: 1; letter-spacing: 4px; }
.captcha-row img { height: 44px; border-radius: 6px; cursor: pointer; border: 1px solid var(--line); }

button, .button {
  display: inline-block; width: 100%; padding: 11px; border: 0; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 16px; font-weight: 600;
  cursor: pointer; text-align: center; text-decoration: none; font-family: inherit;
}
button:hover, .button:hover { background: var(--primary-dark); }

/* ===== 提示訊息 ===== */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 15px; }
.alert.ok   { background: var(--ok-bg);   color: var(--ok); }
.alert.err  { background: var(--err-bg);  color: var(--err); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.page > .alert { max-width: 1200px; }
code { background: #f1f5f9; padding: 1px 6px; border-radius: 4px; }

/* ===== 取號頁 ===== */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 20px; }
.req { color: var(--err); }
input:disabled { background: #f3f4f6; color: var(--muted); }
details.optional { margin: 4px 0 20px; border: 1px dashed #cbd5e1; border-radius: 8px; padding: 10px 16px; }
details.optional summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: 4px 0; }
details.optional[open] summary { margin-bottom: 12px; }

button.secondary, .button.secondary { background: #e2e8f0; color: var(--text); }
button.secondary:hover, .button.secondary:hover { background: #cbd5e1; }

.result { text-align: center; max-width: 560px; margin: 0 auto; }
.result-label { color: var(--ok); font-weight: bold; margin: 0; }
.doc-no { font-size: 40px; font-weight: bold; letter-spacing: 1px; margin: 8px 0 16px; color: #0f172a; word-break: break-all; }
.doc-no.preview { font-size: 30px; color: var(--primary); }
button.copy { width: auto; padding: 10px 28px; margin-bottom: 20px; }
.result-info { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; text-align: left; margin: 0 auto 24px; max-width: 360px; }
.result-info dt { color: var(--muted); }
.result-info dd { margin: 0; }

/* ===== 確認視窗 ===== */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 12px; padding: 28px; max-width: 460px; width: 100%; text-align: center; }
.modal-card h2 { margin: 0 0 8px; }
.hint { font-size: 14px; color: var(--muted); }
.actions { display: flex; gap: 12px; }
@media (max-width: 480px) {
  .doc-no { font-size: 28px; }
  .doc-no.preview { font-size: 24px; }
  .card { padding: 22px 18px; }
}

/* ===== 列表頁 ===== */
.search { display: flex; flex-wrap: wrap; gap: 0 16px; align-items: flex-end; }
.search label { flex: 1 1 200px; }
.search .range { display: flex; align-items: center; gap: 6px; }
.search .range input { margin-top: 6px; }
.search input[type=date] { display: block; width: 100%; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 15px; font-family: inherit; }
.search-btns { display: flex; gap: 8px; margin-bottom: 16px; }
.search-btns button, .search-btns .button { width: auto; padding: 10px 20px; }

.list-toolbar { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 10px; flex-wrap: wrap; gap: 8px; }
button.small { width: auto; padding: 8px 16px; font-size: 14px; background: #047857; }
button.small:hover { background: #065f46; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { background: #f1f5f9; text-align: left; padding: 10px; white-space: nowrap; position: sticky; top: 0; }
table.list td { padding: 9px 10px; border-top: 1px solid var(--line); vertical-align: top; }
table.list tbody tr:hover { background: #f8fafc; }
table.list .nowrap { white-space: nowrap; }
table.list .strong { font-weight: 600; }
table.list .empty { text-align: center; color: var(--muted); padding: 32px; }
table.list tr.cancelled td { color: #9ca3af; }
table.list tr.cancelled td:nth-child(n+3):nth-child(-n+9) { text-decoration: line-through; }
table.list input[type=checkbox] { width: 16px; height: 16px; }
.reason { font-size: 12px; color: var(--muted); }

.badge { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: 13px; }
.badge.on  { background: var(--ok-bg); color: var(--ok); }
.badge.off { background: #f3f4f6; color: var(--err); }

button.link { background: none; color: var(--primary); width: auto; padding: 0 0 0 10px; font-weight: normal; font-size: 14px; text-decoration: underline; }
button.link:hover { background: none; }
button.link.danger { color: var(--err); }
button.danger { background: #dc2626; }
button.danger:hover { background: #b91c1c; }
label.left { text-align: left; }
.narrow.wide { max-width: 560px; }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.pager a, .pager b { padding: 4px 10px; border-radius: 6px; }
.pager b { background: var(--primary); color: #fff; }
button.link.danger, button.link.danger:hover { background: none; }

/* ===== 後台 ===== */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 20px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--text); transition: .15s; }
.tile:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(29,78,216,.12); }
.tile b { font-size: 18px; }
.tile span { color: var(--muted); font-size: 14px; }
.tile small { color: var(--primary); margin-top: 6px; }
.crumb { margin: 0 0 4px; font-size: 14px; color: var(--muted); }
.hint.left { text-align: left; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: flex-end; margin: 12px 0 8px; }
.inline-form label { flex: 1 1 160px; }
.inline-form button, .inline-form .button { width: auto; padding: 10px 20px; margin-bottom: 16px; }
.inline-form.compact { margin: 0; }
form.inline { display: inline; }
form.order { display: flex; gap: 4px; }
form.order button { width: 30px; height: 30px; padding: 0; font-size: 15px; background: #e2e8f0; color: var(--text); }
form.order button:hover:not(:disabled) { background: #cbd5e1; }
form.order button:disabled { opacity: .35; cursor: default; }
table.list tr.inactive td { color: #9ca3af; }
table.list tr.editing td { background: #eff6ff; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.topbar a.who { color: #e2e8f0; }
.stat { display: flex; gap: 16px; margin-bottom: 16px; }
.stat > div { flex: 1; background: #f1f5f9; border-radius: 10px; padding: 14px 18px; }
.stat small { display: block; color: var(--muted); }
.stat b { font-size: 32px; }
h2.sub { font-size: 18px; margin: 28px 0 10px; }
input[type=number] { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 16px; }

/* ===== 歸檔（2026-10） ===== */
.badge.done { background: #e0e7ff; color: #3730a3; }
.badge.void { background: #fee2e2; color: #b91c1c; }
.doc-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.doc-head h1.doc-no { margin: 0; }
.info-grid { display: grid; grid-template-columns: 90px 1fr 90px 1fr; gap: 8px 16px; margin: 0 0 20px; }
.info-grid dt { color: var(--muted); }
.info-grid dd { margin: 0; }
@media (max-width: 640px) { .info-grid { grid-template-columns: 80px 1fr; } }
.danger-text { color: var(--err); }
.button.auto { width: auto; padding: 9px 18px; }
a.plain { color: inherit; text-decoration: none; }
a.plain:hover { color: var(--primary); text-decoration: underline; }
h2.sub.first { margin-top: 0; }
.page > .card + .card { margin-top: 20px; }

ul.files { list-style: none; padding: 0; margin: 0 0 12px; }
ul.files li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
ul.files li small { color: var(--muted); }
ul.files .pdf { background: #dc2626; color: #fff; font-size: 11px; font-weight: bold; padding: 2px 6px; border-radius: 4px; }
ul.files .small-link { margin-left: auto; font-size: 14px; }
ul.files.gone li { opacity: .6; }
input[type=file] { display: block; width: 100%; margin-top: 6px; padding: 8px; border: 1px dashed #94a3b8; border-radius: 8px; background: #f8fafc; font-family: inherit; }

.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.action-box { border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; }
.action-box h3 { margin: 0 0 4px; font-size: 18px; }
.action-box .hint { margin-top: 0; }
.action-box button { margin-top: auto; }
.action-box.ok { border-color: #a5b4fc; background: #f5f7ff; }
.action-box.void { border-color: #fecaca; background: #fffafa; }

/* ===== B 版 ===== */
.search label.check.mine { flex: 0 0 auto; margin-bottom: 26px; }
.search-users { max-width: 520px; margin-top: 8px; }
ol.steps { padding-left: 22px; line-height: 1.9; }
ol.steps ul { margin: 4px 0 8px; color: var(--muted); font-size: 15px; }
ul.errs { margin: 8px 0 0; padding-left: 20px; }
