:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --card: #0f3460;
  --accent: #e94560;
  --success: #2ecc71;
  --warning: #f39c12;
  --text: #eee;
  --text-dim: #8892b0;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ── Header ──────────────────────────────── */
.header {
  background: var(--surface);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
}

.header-back {
  color: var(--accent);
  text-decoration: none;
  font-size: 24px;
  padding: 4px 8px;
}

.wh-badge {
  background: var(--accent);
  color: #fff;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* ── Main ────────────────────────────────── */
.container {
  flex: 1;
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* ── Home grid ───────────────────────────── */
.module-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}

.module-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.1s, box-shadow 0.1s;
  border: 2px solid transparent;
}

.module-card:active {
  transform: scale(0.96);
  border-color: var(--accent);
}

.module-card .icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.module-card .label {
  font-size: 16px;
  font-weight: 600;
}

.module-card .count {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

.module-card.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ── Tabs ────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--card);
}

.tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface);
  text-decoration: none;
  transition: background 0.1s;
}

.tab.active {
  background: var(--card);
  color: var(--text);
}

.tab:active { opacity: 0.8; }

/* ── Scanner bar ─────────────────────────── */
.scan-bar {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.scan-bar input {
  flex: 1;
  background: var(--bg);
  border: 2px solid var(--card);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.scan-bar input:focus {
  border-color: var(--accent);
}

.scan-bar button {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

/* ── List items ──────────────────────────── */
.list-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  border: 2px solid transparent;
  transition: border-color 0.1s;
}

.list-item:active {
  border-color: var(--accent);
}

.list-item .main {
  flex: 1;
}

.list-item .title {
  font-weight: 600;
  font-size: 15px;
}

.list-item .sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.list-item .arrow {
  color: var(--text-dim);
  font-size: 20px;
}

.list-item .badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-ready { background: var(--success); color: #000; }
.badge-waiting { background: var(--warning); color: #000; }
.badge-in-progress { background: var(--accent); color: #fff; }

/* ── Receipt meta ───────────────────────── */
.receipt-meta {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 12px;
}

.doc-stats {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ── Work timer ─────────────────────────── */
.work-timer {
  font-size: 13px;
  font-weight: 700;
  color: var(--warning);
  font-variant-numeric: tabular-nums;
  margin-right: 8px;
  min-width: 36px;
}

/* ── Progress bar ───────────────────────── */
.progress-wrap {
  position: relative;
  width: 90px;
  height: 24px;
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--card);
}

.progress-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--success);
  border-radius: 12px;
  transition: width 0.3s ease;
  opacity: 0.5;
}

.progress-bar.complete {
  opacity: 0.8;
  animation: pulse-green 1s ease-in-out 2;
}

@keyframes pulse-green {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

.progress-text {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

/* ── Overcount warning ──────────────────── */
.line-card.overcount {
  border-color: var(--warning) !important;
}

.line-card.overcount .qty-done {
  color: var(--warning);
}

/* ── Filter toggle ──────────────────────── */
.filter-toggle {
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  float: right;
  padding: 2px 0;
}

.filter-toggle:active { opacity: 0.6; }

/* ── Toast undo ─────────────────────────── */
.toast-undo {
  margin-left: 12px;
  text-decoration: underline;
  cursor: pointer;
  font-weight: 400;
  opacity: 0.85;
}

.toast-undo:active { opacity: 0.5; }

/* ── Receipt detail ──────────────────────── */
.line-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  border: 2px solid transparent;
}

.line-card.scanned {
  border-color: var(--accent);
  background: #1c2a4a;
}

.line-card.done {
  border-color: var(--success);
  opacity: 0.65;
}

.line-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.line-info { flex: 1; min-width: 0; }

.line-ref {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.3px;
}

.line-barcode {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.line-name {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.line-dest {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ── Quantity display + buttons ──────────── */
.qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 8px;
}

.qty-display {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.qty-done {
  font-size: 28px;
  font-weight: 700;
}

.qty-sep {
  font-size: 20px;
  color: var(--text-dim);
  margin: 0 2px;
}

.qty-expected {
  font-size: 20px;
  color: var(--text-dim);
}

.qty-unit {
  font-size: 12px;
  color: var(--text-dim);
  margin-left: 4px;
}

.qty-buttons {
  display: flex;
  gap: 4px;
}

.btn-qty {
  background: var(--bg);
  border: 1px solid var(--card);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-width: 40px;
}

.btn-qty:active {
  background: var(--card);
}

.btn-qty-max {
  background: var(--success);
  color: #000;
  border-color: var(--success);
}

.btn-qty-max:active {
  opacity: 0.8;
}

/* ── Clickable line ─────────────────────── */
.line-link {
  text-decoration: none;
  color: inherit;
}
.line-link:active { opacity: 0.7; }

/* ── Line detail page ───────────────────── */
.line-detail-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
}

.line-detail-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.line-detail-img {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.line-detail-qty {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 24px;
  justify-content: center;
}

.qty-big {
  font-size: 56px;
  font-weight: 700;
}

.qty-unit-big {
  font-size: 20px;
  color: var(--text-dim);
}

.qty-grid { margin-top: 20px; }

.qty-grid-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
}

.btn-qty-lg {
  background: var(--bg);
  border: 2px solid var(--card);
  border-radius: 8px;
  color: var(--text);
  padding: 16px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.btn-qty-lg:active { background: var(--card); }

.btn-qty-lg.btn-qty-max {
  background: var(--success);
  color: #000;
  border-color: var(--success);
}

.qty-grid form { width: 100%; }

.qty-manual-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.qty-manual-row .btn { flex-shrink: 0; }

.input-qty-manual {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 2px solid var(--card);
  border-radius: 8px;
  padding: 14px;
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}

.input-qty-manual::-webkit-inner-spin-button,
.input-qty-manual::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.input-qty-manual:focus { border-color: var(--accent); }

.line-detail-actions { margin-top: 20px; }

.barcode-update-form {
  display: flex;
  gap: 8px;
}

.input-barcode {
  flex: 1;
  background: var(--bg);
  border: 2px solid var(--card);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.input-barcode:focus { border-color: var(--accent); }

/* ── Toast variants ─────────────────────── */
.toast-success { background: var(--success); color: #000; }
.toast-error { background: var(--accent); color: #fff; }

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.1s;
}

.btn:active { opacity: 0.8; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: var(--success); color: #000; }
.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}

.btn-warning {
  background: var(--warning);
  color: #000;
  border: 2px solid var(--warning);
}
.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

.btn-confirm {
  background: var(--success);
  color: #000;
  padding: 8px 16px;
  font-size: 14px;
}

/* ── Validate bar ────────────────────────── */
.validate-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 2px solid var(--accent);
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  z-index: 100;
}

.validate-bar .btn { flex: 1; }

/* ── Warehouse selector ──────────────────── */
.wh-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.wh-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid var(--card);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.wh-btn.active {
  border-color: var(--accent);
  background: var(--card);
}

/* ── Error page ──────────────────────────── */
.error-box {
  background: #3d1525;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 40px;
  text-align: center;
}

.error-box h2 { color: var(--accent); margin-bottom: 12px; }

/* ── Empty state ─────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.empty-state .icon { font-size: 64px; margin-bottom: 16px; }

/* ── Lock warning ──────────────────────────── */
.lock-warning {
  background: #3d2515;
  border: 2px solid var(--warning);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--warning);
  text-align: center;
}

/* ── Action row (photo, etc.) ─────────────── */
.action-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.photo-upload-btn {
  cursor: pointer;
  font-size: 13px;
}

/* ── Bottom spacing for validate bar ─────── */
.has-validate-bar { padding-bottom: 80px; }

/* ── Print section ───────────────────────── */
.print-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--card);
  overflow: hidden;
}

.print-header {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  color: var(--accent);
}

.print-header:active { opacity: 0.7; }

.print-options {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.print-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.print-select {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--card);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  -webkit-appearance: none;
}

.print-select:focus { border-color: var(--accent); }

.print-qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.print-qty-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.print-qty-controls .btn-qty {
  width: 40px;
  height: 40px;
  font-size: 18px;
  text-align: center;
}

#print-qty-display {
  font-size: 20px;
  font-weight: 700;
  min-width: 30px;
  text-align: center;
}

/* ── Putaway ─────────────────────────────── */
.putaway-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 12px;
}

.putaway-qty {
  font-size: 22px;
  font-weight: 700;
  white-space: nowrap;
}

.putaway-route {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.putaway-from {
  color: var(--text-dim);
}

.putaway-arrow {
  color: var(--accent);
  font-size: 16px;
}

.putaway-dest {
  font-weight: 600;
  color: var(--warning);
}

.putaway-hint {
  background: var(--card);
  border: 2px solid var(--warning);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--warning);
  text-align: center;
}

/* ── Qty modal overlay ────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.modal-box {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 24px 20px;
  width: 90%;
  max-width: 340px;
  text-align: center;
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}
.modal-subtitle {
  font-size: 14px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 20px;
}
.modal-qty-btns {
  margin-bottom: 16px;
}
.modal-btn-all {
  width: 100%;
  padding: 16px;
  font-size: 20px;
  font-weight: 700;
  background: var(--success);
  color: #000;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 12px;
}
.modal-btn-all:active { opacity: 0.8; }
.modal-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.modal-btn-qty {
  min-width: 56px;
  padding: 14px 18px;
  font-size: 20px;
  font-weight: 700;
  background: var(--bg);
  border: 2px solid var(--card);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}
.modal-btn-qty:active {
  border-color: var(--accent);
  background: var(--card);
}
.modal-cancel {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  background: transparent;
  border: 2px solid var(--text-dim);
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
}
.modal-cancel:active { opacity: 0.6; }

/* ── Putaway edit button ──────────────── */
.putaway-edit-btn {
  color: var(--accent);
  font-size: 22px;
  padding: 4px 8px;
  text-decoration: none;
  flex-shrink: 0;
}
.putaway-edit-btn:active { opacity: 0.6; }

/* ── Toast notification ──────────────────── */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: #000;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  z-index: 200;
  animation: fadeInOut 2s ease-in-out forwards;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* ── User selection ─────────────────────── */
.user-select-card {
  display: block;
  padding: 16px 20px;
  margin-bottom: 8px;
  background: var(--card);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  border: 2px solid transparent;
}
.user-select-card:active {
  border-color: var(--accent);
  background: var(--surface);
}
.user-select-card.user-admin {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  margin-bottom: 16px;
}
.user-indicator {
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-dim);
}
.user-indicator a {
  color: var(--accent);
  text-decoration: none;
  margin-left: 8px;
}

/* ── Pick location headers ────────────── */
/* ── Delivery meta ─────────────────────── */
.delivery-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 16px;
  margin-bottom: 8px;
}
.delivery-carrier {
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
}
.delivery-pallet {
  background: var(--warning);
  color: #000;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}
.delivery-batch {
  color: var(--text-dim);
  font-size: 13px;
}

.pick-location-header {
  padding: 8px 16px;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  background: var(--surface);
  border-radius: var(--radius);
  letter-spacing: 0.5px;
}

/* ── DPD Pickup Counter ──────────────────── */
.dpd-counter-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-top: 12px;
}

.dpd-status {
  width: 100%;
  text-align: center;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  background: var(--surface);
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dpd-status-active {
  background: #1a3a2a;
  color: var(--success);
  border: 2px solid var(--success);
  animation: pulse-border 2s ease-in-out infinite;
}

.dpd-status-stopped {
  background: #3d2515;
  color: var(--warning);
  border: 2px solid var(--warning);
}

@keyframes pulse-border {
  0%, 100% { border-color: var(--success); }
  50% { border-color: transparent; }
}

.dpd-elapsed {
  font-variant-numeric: tabular-nums;
}

.dpd-counter-display {
  text-align: center;
  padding: 24px 0;
}

.dpd-count {
  font-size: 120px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.dpd-count-label {
  font-size: 18px;
  color: var(--text-dim);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.dpd-breakdown {
  display: flex;
  gap: 16px;
  width: 100%;
}

.dpd-breakdown-item {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.dpd-breakdown-label {
  font-size: 13px;
  color: var(--text-dim);
  display: block;
}

.dpd-breakdown-value {
  font-size: 32px;
  font-weight: 700;
  display: block;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.dpd-time-info {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-dim);
}

.dpd-time-info strong {
  color: var(--text);
}

.dpd-summary-box {
  width: 100%;
  background: #1a3a2a;
  border: 2px solid var(--success);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  color: var(--success);
}

.dpd-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dpd-btn {
  padding: 18px 20px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}
