@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700;800&display=swap');

:root {
  --ink: #1a2e22;
  --muted: #5a7264;
  --line: #c9d9cf;
  --bg: #e6efe9;
  --surface: #ffffff;
  --primary: #1f7a4c;
  --primary-deep: #163d2a;
  --accent: #c44536;
  --warn: #c98512;
  --font: 'Noto Sans TC', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-decoration: none; }

/* ===== 登入 ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(700px 360px at 15% 0%, rgba(31, 122, 76, 0.18), transparent 60%),
    linear-gradient(180deg, #e8f3ec 0%, var(--bg) 100%);
}
.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 24px;
  box-shadow: 0 12px 32px rgba(22, 61, 42, 0.08);
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.45rem;
  color: var(--primary-deep);
}
.login-card p { margin: 0 0 16px; color: var(--muted); font-size: 0.9rem; }
.login-meta {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.6;
}
.login-meta a { font-weight: 600; }
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-block { width: 100%; }
.alert {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 0.92rem;
}
.alert-error { background: #fde2de; color: #8a2b22; }

/* ===== 檢貨平板 ===== */
.pick-app {
  background: #dfeae3;
  overflow-x: hidden;
}

.pick-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #163d2a 0%, #1f7a4c 100%);
  color: #eef8f1;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
.pick-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.pick-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.pick-nav-btn {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  background: rgba(255,255,255,0.14);
  line-height: 1;
  user-select: none;
}
.pick-nav-btn:active { background: rgba(255,255,255,0.28); }
.pick-vehicle { min-width: 0; }
.pick-plate {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.15;
}
.pick-vehicle-meta {
  margin-top: 2px;
  font-size: 0.82rem;
  opacity: 0.85;
}
.pick-day-tabs {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.pick-day-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  text-decoration: none;
  border: 2px solid transparent;
  line-height: 1.15;
}
.pick-day-tab strong {
  font-size: 0.95rem;
  font-weight: 800;
}
.pick-day-tab small {
  margin-top: 2px;
  font-size: 0.75rem;
  opacity: 0.8;
}
.pick-day-tab.active {
  background: #fff;
  color: #163d2a;
  border-color: #f0c14a;
  box-shadow: 0 0 0 2px rgba(240, 193, 74, 0.45);
}
.pick-day-tab.active small {
  color: #163d2a;
  opacity: 0.72;
}
.pick-user {
  font-size: 0.85rem;
  opacity: 0.9;
}
.pick-logout {
  color: #fff;
  background: rgba(255,255,255,0.14);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

.pick-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  background: #edf5f0;
  border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}
.pick-tab {
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.88rem;
}
.pick-tab small {
  margin-left: 4px;
  color: var(--muted);
  font-weight: 500;
}
.pick-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.pick-tab.active small { color: rgba(255,255,255,0.85); }

.pick-board {
  padding: 12px;
  min-height: calc(100vh - 90px);
}
body.pick-app:has(.pick-totals-bar) .pick-board {
  padding-bottom: 110px;
  min-height: calc(100vh - 200px);
}
.pick-empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 1.05rem;
}

/* 固定五欄客戶格（平板橫向） */
.pick-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.cust-cell {
  background: #fff;
  border: 2px solid #2a4d38;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 0 rgba(0,0,0,0.04);
  min-width: 0;
}
.cust-cell.is-done {
  border-color: #1f7a4c;
  background: #eef8f2;
  box-shadow: inset 0 0 0 2px rgba(31, 122, 76, 0.15);
}
.cust-done-stamp {
  margin: 0;
  padding: 8px 12px;
  background: #1f7a4c;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.04em;
}
.pick-vehicle-done-banner {
  margin: 0 0 12px;
  padding: 14px 16px;
  border-radius: 10px;
  background: linear-gradient(90deg, #1f7a4c, #2a9a62);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 14px rgba(31, 122, 76, 0.28);
}
.pick-vehicle.is-vehicle-done .pick-plate::after {
  content: ' ✓完畢';
  font-size: 0.85em;
  color: #b8f0cf;
}
.pick-vehicle.is-vehicle-done .pick-vehicle-meta {
  color: #b8f0cf;
  font-weight: 700;
}
.cust-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 6px;
  background: #f0f6f2;
  border-bottom: 1px solid var(--line);
}
.cust-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary-deep);
  line-height: 1.25;
  word-break: break-word;
}
.cust-progress {
  font-size: 1rem;
  font-weight: 800;
  color: var(--muted);
  white-space: nowrap;
}
.cust-cell.is-done .cust-progress {
  color: #fff;
  background: #1f7a4c;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.92rem;
}
.cust-items {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}
.pick-line {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  border-bottom: 1px dashed #e2ebe5;
  cursor: pointer;
  user-select: none;
  font-size: 1.28rem;
  line-height: 1.4;
  transition: background .12s ease;
}
.pick-line.is-cleared {
  display: none !important;
}
.pick-keynum {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  margin-right: 4px;
  border-radius: 8px;
  background: var(--primary-deep);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 800;
}
.pick-line.pick-flash {
  background: #fff3bf !important;
}
.cust-cell.is-active-pick {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 122, 76, 0.22);
}
.pick-key-hint {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #163d2a;
  color: #e8f6ee;
  font-size: 0.95rem;
  font-weight: 600;
}
.pick-key-hint strong { color: #fff; }
.pick-key-buf {
  font-size: 1.2rem;
  letter-spacing: 0.06em;
  color: #ffd089 !important;
}
.pick-key-miss { color: #ffb4a8; font-weight: 800; }
.pick-line:last-child { border-bottom: none; }
.pick-line:active { background: #eef7f1; }
.pick-name { font-weight: 700; min-width: 0; flex: 1; word-break: break-word; }
.pick-qty {
  flex-shrink: 0;
  margin-left: auto;
  font-weight: 800;
  font-size: 1.32rem;
  color: var(--primary-deep);
  white-space: nowrap;
}
.pick-line.picked {
  background: #fafafa;
}
.pick-line.picked .pick-name,
.pick-line.picked .pick-qty {
  color: #9aa89f;
  text-decoration: line-through;
  text-decoration-thickness: 3px;
  text-decoration-color: var(--accent);
}
.pick-line.picked .pick-keynum {
  background: #9aa89f;
}
.pick-line.muted { color: var(--muted); cursor: default; }
.pick-line.busy { opacity: 0.6; pointer-events: none; }

.pick-totals-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--primary-deep);
  color: #fff;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.18);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.pick-totals-label {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 10px 14px;
  min-width: 108px;
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.15);
}
.pick-totals-label strong {
  font-size: 0.95rem;
  font-weight: 800;
  white-space: nowrap;
}
.pick-totals-label span {
  font-size: 0.82rem;
  font-weight: 700;
  opacity: 0.85;
}
.pick-totals-scroll {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.pick-total-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.pick-total-chip:active { transform: scale(0.97); }
.pick-total-chip.is-active {
  background: #fff;
  border-color: #fff;
  color: var(--primary-deep);
}
.pick-total-name { font-weight: 700; font-size: 1rem; }
.pick-total-qty {
  font-weight: 800;
  font-size: 1.05rem;
  opacity: 0.95;
}
.pick-total-chip.is-active .pick-total-qty { color: var(--primary); }

.pick-line.is-highlight {
  background: #fff3bf !important;
  box-shadow: inset 3px 0 0 #e0a800;
}
.pick-line.is-highlight.picked {
  background: #f5ecc0 !important;
}
.cust-cell.has-highlight {
  border-color: #e0a800;
  box-shadow: 0 0 0 3px rgba(224, 168, 0, 0.28);
}

.pick-plate { font-size: 1.8rem; }

@media (max-width: 1200px) {
  .pick-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .pick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cust-name { font-size: 1.2rem; }
  .pick-line { font-size: 1.15rem; padding: 12px 10px; }
  .pick-qty { font-size: 1.18rem; }
}
@media (max-width: 700px) {
  .pick-user { display: none; }
  .pick-plate { font-size: 1.25rem; }
  .pick-nav-btn { width: 44px; height: 44px; font-size: 1.6rem; }
  .pick-grid { grid-template-columns: 1fr; }
}
