/* PAACAR 工厂端：手機優先。字要大、按鈕要好點、一頁只做一件事。 */
:root {
  --accent: #7799CC;
  --accent-dark: #5577AA;
  --accent-soft: #EEF3FA;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --bg: #f5f5f7;
  --card: #ffffff;
  --red: #c62828;
  --red-soft: #fdecea;
  --green: #2e7d32;
  --green-soft: #e8f5e9;
  --radius: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* 底部導覽是固定的：捲到某個輸入框或按鈕時，別讓它被導覽蓋住。 */
html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: 96px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
h1 { font-size: 24px; margin: 4px 0 14px; }
h2 { font-size: 19px; margin: 22px 0 8px; }
a { color: var(--accent-dark); }
img { max-width: 100%; }

#top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  color: var(--muted); font-size: 15px;
}
#app { max-width: 720px; margin: 0 auto; padding: 8px 14px calc(96px + env(safe-area-inset-bottom)); }
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
#nav a {
  flex: 1; min-height: 56px; display: flex; align-items: center; justify-content: center;
  text-decoration: none; color: var(--muted); font-size: 17px; font-weight: 600;
}
#nav a.active { color: var(--accent-dark); box-shadow: inset 0 3px 0 var(--accent); }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
a.card, button.card { display: block; width: 100%; text-align: left; color: inherit; text-decoration: none; border: 0; font: inherit; cursor: pointer; }
.row { display: flex; gap: 12px; align-items: center; }
.row-top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.muted { color: var(--muted); font-size: 15px; }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; }
.error-text { color: var(--red); font-weight: 600; }
.big { font-size: 30px; font-weight: 700; line-height: 1.2; letter-spacing: .5px; }
.qty { font-size: 24px; font-weight: 700; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 15px; font-weight: 600; background: var(--accent-soft); color: var(--accent-dark); }
.chip-red { background: var(--red-soft); color: var(--red); }
.chip-green { background: var(--green-soft); color: var(--green); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.thumb { width: 84px; height: 84px; flex: none; border-radius: 10px; background: #e9e9ee; object-fit: contain; }
.thumb-lg { width: 120px; height: 120px; }
.thumb-sm { width: 56px; height: 56px; }
div.thumb { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
img.broken { visibility: hidden; }
.wide-photo { width: 100%; border-radius: 10px; background: #e9e9ee; }

label.field { display: block; font-weight: 600; }
label.field > span { display: block; margin-bottom: 4px; }
.input, select.input {
  width: 100%; min-height: 52px; padding: 8px 14px; font: inherit; color: inherit;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
}
.input:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.input.num { font-size: 36px; font-weight: 700; text-align: center; min-height: 72px; letter-spacing: 1px; }
.btn {
  min-height: 52px; padding: 10px 18px; border-radius: 12px; border: 1.5px solid var(--line);
  background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: .55; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; font-size: 20px; min-height: 60px; }
.btn-primary:active { background: var(--accent-dark); }
.btn-wide { width: 100%; }
.btn-ghost { background: transparent; }
.btn-small { min-height: 48px; padding: 6px 14px; }
.link { background: none; border: 0; padding: 12px 4px; min-height: 48px; font: inherit; color: var(--accent-dark); text-decoration: underline; cursor: pointer; }

.preview { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; font-size: 19px; font-weight: 600; }
.preview .warn { color: var(--red); }
.preview .good { color: var(--green); }
.kv { margin: 0; }
.kv dt { color: var(--muted); font-size: 15px; margin-top: 10px; }
.kv dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.pn-list { margin-top: 8px; }
.pn-option { display: flex; gap: 12px; align-items: center; width: 100%; min-height: 64px; padding: 6px 8px; margin-bottom: 6px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font: inherit; text-align: left; cursor: pointer; }
.pn-picked { margin-top: 8px; }

.sub-row { padding: 10px 0; border-top: 1px solid var(--line); }
.sub-row:first-child { border-top: 0; }

#toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 30;
  padding: 14px 16px; border-radius: 12px; background: #333; color: #fff; text-align: center; font-weight: 600;
  pointer-events: none; /* 提示出現時不擋住下面的按鈕 */
}
#toast.ok { background: var(--green); }
#toast.error { background: var(--red); }
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; padding: 20px; }
.dialog { background: #fff; border-radius: var(--radius); padding: 20px; width: 100%; max-width: 420px; }
.dialog p { font-size: 21px; font-weight: 700; margin: 0 0 18px; }
.dialog .row > * { flex: 1; }

.login { max-width: 420px; margin: 8vh auto 0; }
.login h1 { text-align: center; }

/* 牆上螢幕：只看、不點，字更大 */
body.wall { font-size: 24px; }
body.wall #app { max-width: none; padding-bottom: 16px; }
body.wall .todo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
body.wall .big { font-size: 46px; }
body.wall .qty { font-size: 36px; }
body.wall .chip, body.wall .muted { font-size: 21px; }
body.wall .thumb { width: 130px; height: 130px; }

@media (min-width: 900px) {
  #app { max-width: 1100px; }
}

/* ---------- 電腦端：建單、查單、總覽、管理 ---------- */
#nav { overflow-x: auto; }
#nav a { flex: 1 0 auto; padding: 0 12px; white-space: nowrap; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; text-decoration: none; display: inline-flex; align-items: center; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.btn-danger { color: var(--red); border-color: var(--red); }
.alert { display: block; background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 10px 14px; margin: 0 0 10px; font-weight: 600; text-decoration: none; }
.alert-info { background: var(--accent-soft); color: var(--accent-dark); margin: 6px 0 0 34px; }
.card-alert { outline: 2px solid var(--red); }
.block { display: block; color: inherit; text-decoration: none; }
.w-220 { width: 220px; }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters label { font-size: 15px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; margin-bottom: 12px; }
.form-grid-3 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; align-items: start; }
.card-grid .card { margin: 0; }
textarea.input { min-height: 64px; resize: vertical; }
details > summary { cursor: pointer; color: var(--accent-dark); min-height: 44px; display: flex; align-items: center; }

.lines { overflow-x: auto; }
.line-grid { display: grid; grid-template-columns: 28px minmax(170px, 1.6fr) 84px 84px 84px 1fr 1.3fr 1.1fr 1fr 36px; gap: 6px; align-items: start; min-width: 980px; }
.line-head { font-size: 15px; color: var(--muted); margin-bottom: 4px; }
.line-row { margin-bottom: 10px; }
.line-row .input { min-height: 44px; padding: 6px 8px; font-size: 16px; }
.line-no { padding-top: 10px; color: var(--muted); }
.pn-compact .pn-option { min-height: 52px; }

.sheet h1 { text-align: center; letter-spacing: 6px; }
.sheet table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.sheet th, .sheet td { border: 1px solid #333; padding: 6px 8px; text-align: left; vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }
.sheet th { background: #f0f0f0; white-space: nowrap; }
.print-marks td { height: 70px; width: 50%; }

@media (max-width: 700px) {
  .filters { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
  html { scroll-padding-bottom: 0; }
  body { display: flex; flex-direction: column; min-height: 100vh; }
  #top { order: -2; width: 100%; max-width: 1100px; margin: 0 auto; }
  #nav { order: -1; position: static; border-top: 0; border-bottom: 1px solid var(--line); justify-content: center; }
  #nav a { flex: 0 0 auto; padding: 0 22px; min-height: 48px; }
  #app { width: 100%; padding-bottom: 48px; }
  #toast { left: auto; right: 24px; bottom: 24px; max-width: 440px; }
}
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  #nav, #top, #toast, .no-print { display: none !important; }
  body { background: #fff; font-size: 11pt; display: block; }
  #app { max-width: none; padding: 0; }
  .sheet th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
