/* PalletTrace — prototype styles. High contrast, big touch targets, mobile-first. */

:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #1d4ed8;
  --primary-ink: #ffffff;
  --good: #15803d;
  --good-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --inactive: #cbd5e1;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

.app { max-width: 520px; margin: 0 auto; padding: 12px 12px 32px; }
.app.admin { max-width: 980px; }

.screen { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------- topbar ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 12px; gap: 8px;
}
.topbar-name { font-size: 17px; font-weight: 700; }
.topbar-date { color: var(--muted); font-size: 14px; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 10px 18px; border: 0; border-radius: var(--radius);
  font-size: 17px; font-weight: 700; cursor: pointer; background: var(--surface);
  color: var(--ink); box-shadow: var(--shadow); user-select: none; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--primary); }
.btn.danger { background: var(--danger-bg); color: var(--danger); }
.btn.success { background: var(--good); color: #fff; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn.chip { min-height: 40px; padding: 6px 14px; font-size: 15px; border: 1px solid var(--line); box-shadow: none; }
.link-btn { background: none; border: 0; color: var(--muted); font-size: 15px; padding: 10px; cursor: pointer; text-decoration: underline; }

/* ---------------- login ---------------- */
.login-screen { max-width: 360px; margin: 8vh auto 0; text-align: center; }
.login-brand { font-size: 22px; font-weight: 800; letter-spacing: .5px; margin-bottom: 36px; }
.login-title { font-size: 15px; color: var(--muted); letter-spacing: 2px; margin-bottom: 18px; }
.login-input-wrap { margin-bottom: 20px; }
.pin-input {
  width: 220px;
  height: 60px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 14px;
  text-align: center;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  padding-left: 14px;
}
.pin-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .15), var(--shadow);
}
.dots { display: flex; gap: 16px; justify-content: center; margin: 0 0 24px; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--inactive); transition: all .1s; }
.dot.on { background: var(--primary); border-color: var(--primary); transform: scale(1.15); }
.login-btn { margin-top: 6px; }
.login-hint { margin-top: 26px; font-size: 13px; color: var(--muted); line-height: 1.8; }

/* ---------------- numpad / keys ---------------- */
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key {
  min-height: 60px; font-size: 24px; font-weight: 700; border: 0; border-radius: var(--radius);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow); cursor: pointer;
}
.key:active { transform: scale(.96); background: #f1f5f9; }
.key.confirm { background: var(--good); color: #fff; }

/* ---------------- role picker ---------------- */
.rolepicker { max-width: 360px; margin: 8vh auto 0; }
.rolepicker-greet { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.rolepicker-sub { color: var(--muted); margin-bottom: 18px; }
.role-btn {
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 68px; margin-bottom: 12px; padding: 12px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 19px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow);
  text-decoration: none; color: var(--ink);
}
.role-btn:active { transform: scale(.98); }
.role-icon { font-size: 26px; }

/* ---------------- section / card helpers ---------------- */
.section-title { font-size: 13px; font-weight: 700; letter-spacing: 1px; color: var(--muted); margin: 18px 2px 8px; text-transform: uppercase; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------------- progress bar ---------------- */
.progress-wrap { margin: 8px 0 4px; }
.progress-track { height: 18px; background: #e2e8f0; border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #2563eb, #16a34a); border-radius: 10px; transition: width .5s ease; }
.progress-label { display: flex; justify-content: space-between; font-size: 15px; margin-top: 6px; }
.progress-label b { font-size: 17px; }

/* ---------------- metric cards ---------------- */
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0; }
.metric { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; cursor: pointer; color: inherit; text-decoration: none; display: block; }
a:has(> .metric) { text-decoration: none; color: inherit; }
.metric:active { transform: scale(.98); }
.metric .m-icon { font-size: 24px; }
.metric .m-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 6px 0 2px; }
.metric .m-value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.metric .m-sub { font-size: 13px; color: var(--muted); }
.metric .m-status { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 700; margin-top: 8px; }
.mini-bar { height: 4px; background: var(--line); border-radius: 2px; margin: 6px 0 2px; overflow: hidden; }
.mini-fill { height: 100%; background: var(--primary); border-radius: 2px; transition: width .3s; }
.st-good { color: var(--good); } .st-warn { color: var(--warn); } .st-bad { color: var(--danger); } .st-inactive { color: var(--muted); } .st-progress { color: var(--primary); font-weight: 800; }

/* ---------------- dock grid ---------------- */
.dock-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.dock-cell { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 8px; text-align: center; cursor: pointer; border: 2px solid transparent; transition: all .15s ease; color: inherit; text-decoration: none; display: block; }
a:has(> .dock-cell) { text-decoration: none; color: inherit; }
.dock-cell:active { transform: scale(.97); }
.dock-cell.in-progress { border-color: var(--primary); background: #eff6ff; }
.dock-cell .dc-name { font-weight: 800; font-size: 15px; }
.dock-cell .dc-status { font-size: 20px; margin: 4px 0 2px; }
.dock-cell .dc-units { font-size: 16px; font-weight: 700; }
.dock-cell .dc-units.in-prog { color: var(--primary); font-size: 12px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-cell .dc-units.muted { color: var(--muted); font-weight: 500; }

/* ---------------- activity feed / lists ---------------- */
.feed { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.feed-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.feed-item:last-child { border-bottom: 0; }
.feed-item .fi-time { color: var(--muted); font-size: 13px; white-space: nowrap; padding-top: 1px; }
.feed-item .fi-main { font-size: 15px; }
.feed-item .fi-main b { font-weight: 700; }
.feed-item .fi-sub { font-size: 13px; color: var(--muted); }

.list-row { display: flex; align-items: center; gap: 12px; padding: 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.list-row:last-child { border-bottom: 0; }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title { font-weight: 700; font-size: 16px; }
.list-row .lr-sub { color: var(--muted); font-size: 13px; }
.icon-btn { border: 0; background: none; cursor: pointer; font-size: 18px; padding: 6px; border-radius: 8px; }
.icon-btn:active { background: #f1f5f9; }

/* ---------------- scan area ---------------- */
.scan-target {
  border: 2px dashed var(--inactive); border-radius: var(--radius);
  padding: 26px 16px; text-align: center; background: var(--surface);
}
.scan-target .scan-cam { font-size: 40px; }
.scan-target .scan-label { font-weight: 800; font-size: 17px; margin-top: 6px; letter-spacing: .5px; }
.scan-input {
  width: 100%; margin-top: 14px; padding: 16px; font-size: 20px; text-align: center;
  border: 2px solid var(--primary); border-radius: var(--radius); letter-spacing: 2px;
}
.scan-input:focus { outline: none; box-shadow: 0 0 0 4px rgba(29, 78, 216, .18); }
.num-input { width: 100%; padding: 14px; font-size: 30px; text-align: center; font-weight: 800; border: 2px solid var(--primary); border-radius: var(--radius); letter-spacing: 1px; }
.num-input::-webkit-outer-spin-button, .num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.num-input:focus { outline: none; box-shadow: 0 0 0 4px rgba(29, 78, 216, .18); }
.last-scan { color: var(--muted); font-size: 14px; margin-top: 16px; text-align: center; }
.last-scan b { color: var(--ink); }

/* ---------------- camera scan row ---------------- */
.scan-row { display: flex; align-items: stretch; gap: 0; margin-top: 14px; }
.scan-row .scan-input { flex: 1; min-width: 0; margin-top: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 0; }
.scan-cam-btn {
  width: 56px; flex-shrink: 0; border: 2px solid var(--primary); border-left: 0;
  border-radius: 0 var(--radius) var(--radius) 0; background: var(--primary); color: var(--primary-ink);
  font-size: 24px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: opacity .15s;
}
.scan-cam-btn:active { opacity: .8; }
.scan-cam-btn[disabled] { opacity: .35; pointer-events: none; }

/* ---------------- scanner overlay ---------------- */
.scanner-overlay {
  position: fixed; inset: 0; z-index: 2000; background: #000; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
}
.scanner-overlay .scanner-close {
  position: absolute; top: 16px; right: 16px; z-index: 2010;
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.18); color: #fff; font-size: 28px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.scanner-overlay .scanner-close:active { background: rgba(255,255,255,.3); }
.scanner-overlay .scanner-guide {
  color: rgba(255,255,255,.8); font-size: 15px; font-weight: 600;
  margin-top: 14px; letter-spacing: .5px; text-align: center;
}
.scanner-overlay .scanner-error {
  color: #fca5a5; font-size: 15px; font-weight: 600;
  margin-top: 10px; text-align: center; padding: 0 20px;
}
.scanner-overlay #scanner-reader {
  width: min(85vw, 400px); height: min(85vw, 400px);
}
.scanner-overlay #scanner-reader video { border-radius: 10px; }
/* hide html5-qrcode's built-in UI chrome */
.scanner-overlay #scanner-reader img[alt="Info icon"],
.scanner-overlay #scanner-reader span { display: none !important; }
.scanner-overlay #scanner-reader > div:last-child { display: none !important; }

/* ---------------- dock selector ---------------- */
.dock-select { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.dock-select button {
  min-height: 52px; font-size: 16px; font-weight: 700; border: 2px solid var(--line);
  background: var(--surface); border-radius: var(--radius); cursor: pointer;
}
.dock-select button.sel { border-color: var(--primary); background: var(--primary); color: #fff; }

/* ---------------- count screen ---------------- */
.count-display { text-align: center; font-size: 64px; font-weight: 800; line-height: 1; margin: 6px 0 16px; }
.steppers { display: flex; gap: 14px; margin-bottom: 16px; }
.stepper {
  flex: 1; min-height: 68px; font-size: 34px; font-weight: 800; border: 0; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); cursor: pointer;
}
.stepper:active { transform: scale(.96); }
.count-sub { text-align: center; font-size: 16px; color: var(--muted); margin: 14px 0; }
.count-sub b { color: var(--ink); font-size: 20px; }

/* ---------------- notice banner ---------------- */
.notice {
  background: var(--warn-bg); color: #7c2d12; border: 1px solid #fcd34d;
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; font-weight: 600; font-size: 15px;
  display: flex; align-items: center; gap: 10px;
}
.notice .nx { margin-left: auto; background: #7c2d12; color: #fff; border: 0; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 700; }

/* ---------------- flash overlay ---------------- */
.flash { position: fixed; inset: 0; z-index: 1000; pointer-events: none; opacity: 0; transition: opacity .12s; display: flex; align-items: center; justify-content: center; }
.flash.show { opacity: 1; }
.flash.good { background: rgba(21, 128, 61, .92); }
.flash.bad { background: rgba(185, 28, 28, .92); }
.flash-inner { text-align: center; color: #fff; }
.flash-sym { font-size: 96px; font-weight: 800; line-height: 1; }
.flash-code { font-size: 24px; font-weight: 800; letter-spacing: 2px; margin-top: 8px; }
.flash-msg { font-size: 20px; font-weight: 700; margin-top: 6px; }

/* ---------------- modal ---------------- */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card { background: var(--surface); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.modal-title { font-size: 19px; font-weight: 800; margin-bottom: 10px; }
.modal-body { color: var(--muted); font-size: 15px; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .btn { min-height: 46px; }
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.form-field input[type=text], .form-field input[type=password], .form-field input[type=number], .form-field textarea {
  width: 100%; padding: 12px; font-size: 16px; border: 2px solid var(--line); border-radius: 10px;
}
.form-field input:focus, .form-field textarea:focus { outline: none; border-color: var(--primary); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-toggle { padding: 10px 14px; border: 2px solid var(--line); border-radius: 20px; background: var(--surface); font-weight: 700; cursor: pointer; text-decoration: none; color: var(--ink); }
.chip-toggle.sel { border-color: var(--primary); background: var(--primary); color: #fff; }

/* ---------------- admin helpers ---------------- */
.admin-header { display: flex; align-items: center; gap: 10px; padding: 4px 2px 14px; }
.admin-header .brand { font-size: 18px; font-weight: 800; margin-right: auto; }
.admin-header .brand.page-title { margin-right: 0; margin-left: auto; text-align: right; }
.admin-add-btn { margin-bottom: 12px; }
.detail-strip { display: flex; gap: 12px; margin: 8px 0 16px; }
.detail-strip .ds { flex: 1; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; text-align: center; }
.detail-strip .ds .v { font-size: 22px; font-weight: 800; }
.detail-strip .ds .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bar-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.trip-lineage { margin: 10px 0; }
.pallet-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pallet-row:last-child { border-bottom: 0; }
.pallet-row .pr-code { font-weight: 700; }
.pallet-row .pr-units { margin-left: auto; font-weight: 700; }
.pallet-row .pr-expand { color: var(--muted); }
.pallet-detail { background: #f8fafc; font-size: 13px; color: var(--muted); padding: 8px 12px; }

/* ---------------- session card (reports) ---------------- */
.session-card { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; box-shadow: var(--shadow); }
.session-card.is-active { border-color: var(--primary); }
.session-card-header { background: var(--surface); padding: 12px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.session-card-header .sc-meta { flex: 1; font-size: 13px; color: var(--muted); }
.session-card-header .sc-pct { font-size: 13px; font-weight: 700; }
.session-card .detail-strip { margin: 0; border-radius: 0; border-bottom: 1px solid var(--line); }
.session-card .detail-strip .ds { border-radius: 0; box-shadow: none; border-right: 1px solid var(--line); }
.session-card .detail-strip .ds:last-child { border-right: 0; }
.session-card-docks { padding: 8px 16px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.session-card-docks span { margin-right: 12px; }

@media (max-width: 560px) {
  .metrics { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .metric .m-value { font-size: 20px; }
  .dock-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
}
