/* 沿用舊版 ChatGPT Sites 的設計語彙(tokens/類名/版面實測抓自 index-BLzsYw6r.css,
   見 docs/DISCOVERY.md §3.3)。同事看到的畫面應該跟以前幾乎一樣。 */

:root {
  --ink: #17212b;
  --muted: #66717d;
  --line: #dfe3e5;
  --paper: #fff;
  --canvas: #f3f3ef;
  --accent: #e96532;
  --accent-dark: #bd4318;
  --teal: #0c766d;
  --soft-teal: #e8f4f1;
  --warning: #a84524;
  --soft-warning: #fff0e9;
  --danger: #b42318;
  --soft-danger: #fee4e2;
  --blue: #285f91;
  --soft-blue: #eaf1f7;
  --shadow: 0 12px 30px #17212b12;
}

* { box-sizing: border-box; }
html, body { background: var(--canvas); }
body {
  color: var(--ink);
  margin: 0;
  font-family: Arial, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, summary:focus-visible { outline: 3px solid #0c766d40; outline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(21px, 2vw, 28px); letter-spacing: -.03em; line-height: 1.1; margin-bottom: 0; }
h2 { font-size: 20px; letter-spacing: -.02em; margin-bottom: 0; }
h3 { margin-bottom: 0; font-size: 16px; }

.app-shell { width: min(1480px, 100%); margin: 0 auto; padding: 28px 32px 24px; }

/* 頂欄 */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 16px; }
.brand-mark {
  background: var(--ink); color: #fff; font-weight: 700; font-size: 15px;
  padding: 14px 18px; border-radius: 14px; letter-spacing: .02em;
}
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.today { color: var(--muted); font-size: 14px; }
.quiet-button {
  background: var(--paper); border: 1px solid var(--line); color: var(--ink);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font-size: 14px;
}
.quiet-button:hover { border-color: var(--muted); }

/* 角色列(新版只顯示身分,不能自由切換) */
.role-switcher {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px;
  background: #e7e7e1; border-radius: 14px; padding: 6px; margin-bottom: 20px;
}
.role-switcher .slot {
  display: block; text-align: left; padding: 14px 20px; border-radius: 10px;
  color: var(--muted); font-weight: 700; font-size: 15px;
  background: transparent; border: 0; font-family: inherit;
}
.role-switcher .slot.active { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.role-switcher button.slot { cursor: pointer; }
.role-switcher button.slot:hover:not(.active) { color: var(--ink); }

/* 交接提醒 */
.notice {
  background: var(--soft-warning); border: 1px solid #f2d3c4; color: var(--warning);
  border-radius: 12px; padding: 14px 18px; margin-bottom: 20px; font-size: 14px;
}
.notice b { margin-right: 10px; color: var(--warning); }

/* 小節標題 */
.eyebrow { color: var(--teal); font-size: 12px; font-weight: 700; letter-spacing: .08em; margin-bottom: 8px; }
.eyebrow .sep { color: var(--line); margin: 0 6px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.hint { color: var(--muted); font-size: 13px; text-align: right; }

/* KPI 卡 */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi {
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px 22px; box-shadow: var(--shadow);
}
.kpi.lead { background: var(--ink); border-color: var(--ink); color: #fff; }
.kpi .label { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.kpi.lead .label { color: #fff; }
.kpi .value-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.kpi .value { font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -.03em; }
.kpi .unit { color: var(--muted); font-size: 13px; padding-bottom: 4px; }
.kpi.lead .unit { color: #ffffffa8; }

/* 卡片 */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 20px;
  padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card.muted { background: #eeeeea; box-shadow: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.split { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 980px) { .grid-2, .split { grid-template-columns: 1fr; } }

/* badge */
.badge { display: inline-block; padding: 5px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; }
.badge.grey { background: #eceff0; color: var(--muted); }
.badge.teal { background: var(--soft-teal); color: var(--teal); }
.badge.warn { background: var(--soft-warning); color: var(--warning); }
.badge.red { background: var(--soft-danger); color: var(--danger); }
.badge.blue { background: var(--soft-blue); color: var(--blue); }

/* 待辦卡 */
.todo { border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 12px; background: var(--paper); }
.todo.active { border: 2px solid var(--teal); background: #fbfefd; }
.todo-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.todo-count { color: var(--teal); font-size: 13px; font-weight: 700; }
.todo h3 { margin: 0 0 6px; }
.todo .meta { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.todo-actions { display: flex; align-items: center; justify-content: space-between; }
.pill {
  border: 0; border-radius: 10px; padding: 10px 18px; font-weight: 700;
  font-size: 14px; cursor: pointer; background: var(--ink); color: #fff;
}
.pill.on { background: var(--teal); }
.pill:disabled { opacity: .45; cursor: not-allowed; }
.link { color: var(--teal); font-size: 13px; text-decoration: none; font-weight: 700; }
.link.off { color: var(--muted); pointer-events: none; }

/* 分頁 */
.tabs { display: inline-grid; grid-auto-flow: column; gap: 4px; background: #eeeeea; border-radius: 12px; padding: 5px; margin-bottom: 18px; }
.tabs button { border: 0; background: transparent; padding: 11px 26px; border-radius: 9px; font-weight: 700; color: var(--muted); cursor: pointer; }
.tabs button.active { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }

/* 步驟表單 */
.summary-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 20px;
}
.summary-strip div { background: var(--soft-teal); padding: 12px 16px; }
.summary-strip .k { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.summary-strip .v { font-weight: 700; font-size: 15px; }
.step { display: flex; gap: 14px; margin-bottom: 22px; }
.step-no {
  flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.step-no.accent { background: var(--accent); }
.step-body { flex: 1; }
.step-title { font-weight: 700; margin-bottom: 3px; }
.step-sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.scan-row { display: flex; gap: 12px; }
.scan-row input {
  flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px;
  background: var(--paper); color: var(--ink);
}
.scan-row input:focus { border-color: var(--teal); outline: none; }
.scan-state { background: #eceff0; color: var(--muted); border-radius: 12px; padding: 16px 20px; font-size: 14px; white-space: nowrap; }
.scan-state.ok { background: var(--soft-teal); color: var(--teal); font-weight: 700; }

.ids { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.ids label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.ids input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }

.checks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 900px) { .checks { grid-template-columns: repeat(2, 1fr); } .ids { grid-template-columns: 1fr; } }
.check {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; cursor: pointer; background: var(--paper); font-weight: 700; font-size: 14px;
}
.check input { width: 18px; height: 18px; accent-color: var(--teal); }
.check.on { border-color: var(--teal); background: #fbfefd; }
.check .auto { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--teal); background: var(--soft-teal); padding: 2px 7px; border-radius: 6px; }
.checks-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ghost { background: var(--paper); border: 1px solid var(--line); color: var(--teal); font-weight: 700; border-radius: 10px; padding: 9px 16px; cursor: pointer; }

.submit {
  width: 100%; border: 0; border-radius: 14px; padding: 20px; font-weight: 700; font-size: 16px;
  background: #e3e3de; color: #9aa1a7; cursor: not-allowed;
}
.submit.ready { background: var(--ink); color: #fff; cursor: pointer; }

/* 遙控測試站 */
.remote {
  border: 2px dashed var(--teal); border-radius: 14px; padding: 18px;
  margin-bottom: 22px; background: #fbfefd;
}
.remote-head { margin-bottom: 12px; }
.remote-checks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
@media (max-width: 900px) { .remote-checks { grid-template-columns: 1fr; } }
.remote-go { width: 100%; padding: 16px; font-size: 15px; }
.remote-status { margin-top: 12px; font-size: 14px; color: var(--muted); }

/* 表格 */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; background: #f6f6f2; color: var(--muted); font-size: 13px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 700;
}
thead th:first-child { border-radius: 10px 0 0 10px; }
thead th:last-child { border-radius: 0 10px 10px 0; }
tbody td { padding: 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
.cell-main { font-weight: 700; }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* 出貨歷史篩選列 */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters input, .filters select {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  background: var(--paper); color: var(--ink); font-size: 13px;
}
.filters input:focus, .filters select:focus { border-color: var(--teal); outline: none; }
.filters input[placeholder="客戶"], .filters input[placeholder="備註"] { width: 140px; }
.filters input[placeholder="SN 搜尋"] { width: 160px; font-family: ui-monospace, Menlo, Consolas, monospace; }
@media (max-width: 700px) { .filters input, .filters select { flex: 1 1 45%; width: auto; } }

/* 需求列 */
.req { border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 12px; }
.req-top { display: flex; align-items: center; gap: 12px; }
.req-top .who { font-weight: 700; font-size: 16px; }
.req-top .qty { margin-left: auto; font-weight: 700; }
.req-sub { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-top: 8px; }
.req details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
/* 自己畫 ▶,所以要關掉瀏覽器預設的三角形,否則會出現兩個箭頭 */
.req summary { color: var(--teal); font-size: 13px; font-weight: 700; cursor: pointer; list-style: none; }
.req summary::-webkit-details-marker { display: none; }
.req details p { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

/* 出貨 SN 對應(進出貨助理) */
.sn-box { background: var(--soft-blue); border: 1px solid #d5e2ef; border-radius: 10px; padding: 10px 12px; margin: 4px 0 12px; }
.sn-box b { color: var(--blue); font-size: 13px; }
/* MDM 報告掛在任務底下 */
.mdm-attach { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px;
  padding: 10px 12px; background: var(--soft-blue); border-radius: 10px; }
.mdm-attach-label { font-weight: 700; color: var(--blue); font-size: 13px; }

.sn-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sn-chip { background: var(--paper); border: 1px solid #cdd9e6; border-radius: 6px; padding: 4px 9px; font-size: 13px; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* 空狀態 */
.empty {
  border: 1px dashed var(--line); border-radius: 12px; padding: 28px; text-align: center;
  color: var(--muted); font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.empty .dot { width: 26px; height: 26px; border-radius: 50%; background: var(--soft-teal); color: var(--teal); display: grid; place-items: center; font-size: 13px; font-weight: 700; }

/* 登入 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login {
  width: min(420px, 100%); background: var(--paper); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px; box-shadow: var(--shadow);
}
.login .brand-mark { display: inline-block; margin-bottom: 18px; }
.login label { display: block; font-size: 13px; font-weight: 700; margin: 14px 0 6px; }
.login input { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.login button { width: 100%; margin-top: 20px; border: 0; border-radius: 12px; padding: 16px; background: var(--ink); color: #fff; font-weight: 700; cursor: pointer; }
.err { color: var(--warning); background: var(--soft-warning); border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-top: 14px; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 0 8px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow); z-index: 50; max-width: 90vw;
}
.toast.bad { background: var(--accent-dark); }
.hide { display: none !important; }
