/* 每日出貨：安靜的工作工具。顏色一律走 wiwi-colors.css 的語意 token（橘／藍綠只當底色）。 */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--wiwi-bg); color: var(--wiwi-text); line-height: 1.6;
  font-family: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
main { max-width: 62rem; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 1.6rem; margin: 8px 0 4px; line-height: 1.3; }
h2 { font-size: 1.15rem; margin: 32px 0 12px; }
h3 { font-size: 1rem; margin: 0 0 6px; }
p { margin: 0 0 8px; }
.lede { color: var(--wiwi-text-muted); margin-bottom: 20px; }
.muted { color: var(--wiwi-text-muted); }
a { color: var(--wiwi-thermal-text); }
:focus-visible { outline: 3px solid var(--wiwi-focus-ring); outline-offset: 2px; }
[hidden] { display: none !important; }

/* 頁首 */
.topbar {
  display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; padding: 8px 16px;
  background: var(--wiwi-surface); border-bottom: 1px solid var(--wiwi-border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--wiwi-text); }
.brand img { display: block; height: 47px; width: auto; }
.brand-name { font-weight: 700; font-size: 1.05rem; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 8px 12px; border-radius: 6px; color: var(--wiwi-text); text-decoration: none; }
.nav a:hover { background: var(--wiwi-surface-sunken); }
.nav a[aria-current="page"] { font-weight: 700; box-shadow: inset 0 -3px 0 var(--wiwi-thermal-fill); }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 0.95rem; }
.who-name { display: inline-flex; gap: 8px; align-items: center; }
.logout { color: var(--wiwi-text-muted); }

/* 測試模式橫幅：明顯但不刺眼 */
.mode-banner {
  background: var(--wiwi-info-tint); color: var(--wiwi-info); border-bottom: 1px solid var(--wiwi-info);
  padding: 8px 16px; font-size: 0.95rem; text-align: center;
}

/* 按鈕與表單 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 18px;
  font: inherit; font-weight: 600; color: var(--wiwi-text); background: var(--wiwi-surface);
  border: 1px solid var(--wiwi-border-strong); border-radius: 8px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--wiwi-surface-sunken); }
.btn-solid { background: var(--wiwi-thermal-solid); color: var(--wiwi-thermal-on-solid); border-color: var(--wiwi-thermal-solid); }
.btn-solid:hover { background: var(--wiwi-thermal-solid-hover); }
.btn-solid:active { background: var(--wiwi-thermal-solid-active); }
.btn-big { min-height: 52px; padding: 10px 32px; font-size: 1.1rem; }
.btn-small { min-height: 36px; padding: 4px 12px; font-size: 0.9rem; }
.btn:disabled { background: var(--wiwi-surface-sunken); color: var(--wiwi-text-muted); border-color: var(--wiwi-border); cursor: not-allowed; }
input[type="text"], input:not([type]), input[type="password"], select {
  font: inherit; min-height: 44px; padding: 8px 10px; color: var(--wiwi-text); background: var(--wiwi-surface);
  border: 1px solid var(--wiwi-border-strong); border-radius: 8px; max-width: 100%;
}
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--wiwi-thermal-solid); }
.check-title { font-weight: 700; font-size: 1.05rem; }

/* 狀態小標籤：文字＋圖示，不只靠顏色 */
.chip {
  display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; white-space: nowrap;
  border: 1px solid currentColor;
}
.chip-ok { color: var(--wiwi-success); background: var(--wiwi-success-tint); }
.chip-warn { color: var(--wiwi-warning); background: var(--wiwi-warning-tint); }
.chip-bad { color: var(--wiwi-danger); background: var(--wiwi-danger-tint); }
.chip-info { color: var(--wiwi-info); background: var(--wiwi-info-tint); }
.chip-muted { color: var(--wiwi-text-muted); background: var(--wiwi-surface-sunken); }

/* 大拖放區：整頁的主角 */
.dropzone {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; cursor: pointer;
  padding: 40px 16px; background: var(--wiwi-thermal-tint); border: 3px dashed var(--wiwi-thermal-border); border-radius: 16px;
  min-height: 240px; justify-content: center;
}
.dropzone:hover, .dropzone.over { background: var(--wiwi-thermal-tint-strong); }
.dropzone.over { border-style: solid; }
.drop-icon { font-size: 2.4rem; line-height: 1; color: var(--wiwi-thermal-text-strong); }
.drop-title { font-size: 1.4rem; font-weight: 700; margin: 8px 0 0; }
.drop-hint { color: var(--wiwi-text-muted); }
.drop-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.upload-status { min-height: 1.6em; color: var(--wiwi-text-muted); margin: 8px 0 0; }

/* 辨識結果表 */
.table-wrap { border: 1px solid var(--wiwi-border); border-radius: 10px; }
table.files { width: 100%; border-collapse: collapse; }
.files th, .files td { text-align: left; padding: 10px 12px; vertical-align: top; border-bottom: 1px solid var(--wiwi-border); }
.files thead th { background: var(--wiwi-surface-sunken); font-size: 0.9rem; color: var(--wiwi-text-muted); }
.files tbody tr:last-child td { border-bottom: 0; }
.files .name { word-break: break-all; }
.files .sub { display: block; font-size: 0.85rem; color: var(--wiwi-text-muted); }
.files .reason { color: var(--wiwi-danger); }
.files select { width: 100%; max-width: 16rem; }
.files .btn { margin-top: 6px; }
tr.flag td { background: var(--wiwi-warning-tint); }
tr.flag-unknown td { background: var(--wiwi-danger-tint); }

/* 流程卡片 */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 12px; }
.card { padding: 14px 16px; border: 1px solid var(--wiwi-border); border-radius: 12px; background: var(--wiwi-surface-sunken); min-width: 0; }
.card h3 { font-size: 1.05rem; }
.card-off { color: var(--wiwi-text-muted); }
.card-on { background: var(--wiwi-success-tint); border-color: var(--wiwi-success); color: var(--wiwi-text); }
.card-part { background: var(--wiwi-warning-tint); border-color: var(--wiwi-warning); color: var(--wiwi-text); }
.card-line { margin: 0 0 4px; font-size: 0.95rem; }
.card-line-on { color: var(--wiwi-success); font-weight: 600; }
.card-line-part { color: var(--wiwi-warning); font-weight: 600; }
.card-check { background: var(--wiwi-surface); border-width: 2px; border-color: var(--wiwi-border-strong); }
.card-check.card-on { background: var(--wiwi-success-tint); border-color: var(--wiwi-success); }
.note { font-size: 0.9rem; margin: 8px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--wiwi-surface-sunken); color: var(--wiwi-text); }
.note-info { background: var(--wiwi-info-tint); color: var(--wiwi-info); }
.note-warn { background: var(--wiwi-warning-tint); color: var(--wiwi-warning); }
.note-bad { background: var(--wiwi-danger-tint); color: var(--wiwi-danger); }
.orders { margin-top: 6px; font-size: 0.9rem; }
.orders summary { cursor: pointer; padding: 4px 0; }
.order-text { word-break: break-all; margin: 4px 0 0; color: var(--wiwi-text); max-height: 9rem; overflow-y: auto; }

/* 開始 */
.action { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--wiwi-border); }
.admin-box { margin-bottom: 12px; padding: 10px 12px; background: var(--wiwi-info-tint); border-radius: 8px; color: var(--wiwi-text); }
.start-hint { min-height: 1.6em; color: var(--wiwi-text); }

/* 進度與結果 */
.progress-list { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; }
.prow {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 14px;
  border: 1px solid var(--wiwi-border); border-radius: 10px; background: var(--wiwi-surface);
}
.pname { font-weight: 700; }
.pdetail { grid-column: 1 / -1; font-size: 0.95rem; }
.pdetail p { margin: 0 0 4px; word-break: break-word; }
.pwarn { color: var(--wiwi-warning); }
.perr { color: var(--wiwi-danger); font-weight: 600; }
.alert { padding: 12px 14px; border-radius: 10px; font-weight: 600; background: var(--wiwi-info-tint); color: var(--wiwi-info); }
.alert-ok { background: var(--wiwi-success-tint); color: var(--wiwi-success); }
.alert-warn { background: var(--wiwi-warning-tint); color: var(--wiwi-warning); }
.alert-danger { background: var(--wiwi-danger-tint); color: var(--wiwi-danger); }
.done-mode { color: var(--wiwi-info); font-weight: 600; margin-top: 12px; }
.done-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* 對話視窗 */
.modal {
  width: min(36rem, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; padding: 20px;
  border: 1px solid var(--wiwi-border-strong); border-radius: 14px; background: var(--wiwi-surface-raised); color: var(--wiwi-text);
}
.modal::backdrop { background: var(--wiwi-overlay); }
.modal-title { margin: 0 0 12px; font-size: 1.2rem; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.warn-item { padding: 10px 12px; margin-bottom: 10px; border-radius: 10px; background: var(--wiwi-warning-tint); }
.warn-item h3 { color: var(--wiwi-warning); }
.warn-unknown { background: var(--wiwi-danger-tint); }
.warn-unknown h3 { color: var(--wiwi-danger); }
.plain { margin: 4px 0; padding-left: 1.2em; }
.pick { border: 1px solid var(--wiwi-border-strong); border-radius: 8px; margin: 8px 0 0; padding: 6px 10px; }
.pick label { margin-left: 6px; word-break: break-all; }

/* 登入 */
.login { max-width: 24rem; margin-top: 8vh; text-align: center; }
.login-form { display: grid; gap: 8px; text-align: left; margin-top: 16px; }
.login-form label { font-weight: 600; }
.login-form .btn { margin-top: 12px; }
.login .alert { text-align: left; }

/* 手機：表格改成一列一張卡，不水平捲動 */
@media (max-width: 40rem) {
  main { padding: 16px 16px 48px; }
  .who { margin-left: 0; width: 100%; }
  .dropzone { padding: 28px 12px; min-height: 200px; }
  .drop-title { font-size: 1.2rem; }
  .files thead { position: absolute; left: -9999px; }
  .files, .files tbody, .files tr, .files td { display: block; width: 100%; }
  .files tr { border-bottom: 1px solid var(--wiwi-border); padding: 6px 0; }
  .files tbody tr:last-child { border-bottom: 0; }
  .files td { border: 0; padding: 4px 12px; }
  .files td::before { content: attr(data-label) "　"; color: var(--wiwi-text-muted); font-size: 0.85rem; }
  .files td.name::before { display: none; }
  .files select { max-width: 100%; }
  .btn-big { width: 100%; }
}

/* 標記失敗的隔離提示、預覽過期的中止提示：要比一般說明更醒目 */
.quarantine { border: 2px solid var(--wiwi-danger); border-radius: 6px; padding: 8px 10px; background: transparent; }
/* 已標記：這份就是要交郵局的檔——用成功色醒目標出，不用紅色（紅色是「不要交」） */
.marked-ok { border: 2px solid var(--wiwi-success); border-radius: 6px; padding: 8px 10px; background: var(--wiwi-success-tint); color: var(--wiwi-success); font-weight: 600; }
.interrupt-banner { background: var(--wiwi-warning-tint); color: var(--wiwi-warning); border-bottom: 1px solid var(--wiwi-warning); padding: 8px 16px; font-size: 0.95rem; text-align: center; font-weight: 600; }
.interrupt-banner a { color: inherit; text-decoration: underline; }
.stale { border-left: 4px solid var(--wiwi-warning); padding-left: 8px; font-weight: 600; }

/* 帳號管理 */
.user-add { margin-bottom: 28px; }
.user-form { display: grid; gap: 8px; max-width: 26rem; }
.user-form label { font-weight: 600; }
.user-form .check-row { font-weight: normal; display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.user-form .btn { justify-self: start; margin-top: 4px; }
.form-msg { min-height: 1.4em; margin: 0; color: var(--wiwi-danger); font-weight: 600; }
.users .chip { margin-left: 8px; }
.user-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.user-actions .btn { margin-top: 0; }
@media (max-width: 40rem) {
  .users td.user-actions { display: flex; }
}
