:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --surface-3: #e8e9ed;
  --border: #e3e5ea;
  --border-strong: #d1d5db;
  --text: #16181d;
  --text-dim: #6b7280;
  --text-faint: #9ca3af;

  --accent: #16a34a;
  --accent-dark: #0f7d39;
  --accent-soft: #e7f7ee;

  --good: #16a34a;
  --good-soft: #e7f7ee;
  --bad: #dc2626;
  --bad-soft: #fdeceb;
  --warn: #d97706;
  --warn-soft: #fef3e2;
  --info: #2563eb;
  --info-soft: #eaf1fe;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 2px 10px rgba(16, 24, 40, 0.07), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 28px rgba(16, 24, 40, 0.12), 0 2px 6px rgba(16, 24, 40, 0.06);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.screen.with-nav { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }

.hidden { display: none !important; }

h1 { font-size: 24px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 17px; font-weight: 700; margin: 0 0 14px; letter-spacing: -0.01em; }
p.subtitle { color: var(--text-dim); margin: 0 0 24px; font-size: 14px; line-height: 1.5; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin-bottom: 12px;
}

input[type="text"], input[type="tel"], input[type="password"] {
  width: 100%;
  padding: 15px 16px;
  font-size: 17px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  margin-bottom: 12px;
  transition: border-color 0.15s, background 0.15s;
}
input[type="text"]:focus, input[type="tel"]:focus, input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

button {
  font-size: 16px;
  font-weight: 700;
  padding: 15px 18px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s, background 0.15s, opacity 0.15s;
  font-family: inherit;
}
button:active { transform: scale(0.97); }

.btn-primary {
  background: var(--text);
  color: #fff;
  width: 100%;
  box-shadow: var(--shadow-sm);
}
.btn-primary:disabled {
  opacity: 0.35;
  box-shadow: none;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  width: 100%;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.28);
}
.btn-accent:disabled {
  background: var(--surface-3);
  color: var(--text-faint);
  box-shadow: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border-strong);
  width: 100%;
}

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}

.shift-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.secondary-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}
.secondary-actions .btn-secondary { flex: 1; }

.sop-link {
  background: var(--info-soft);
  border: none;
  color: var(--info);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.shift-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  text-align: left;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.shift-btn:hover { box-shadow: var(--shadow-md); }

.shift-btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.shift-btn.status-completed .shift-btn-icon { background: var(--surface-3); color: var(--text-faint); }
.shift-btn.status-in_progress .shift-btn-icon { background: var(--warn-soft); color: var(--warn); }

.shift-btn .name { font-size: 16px; font-weight: 700; display: block; }
.shift-btn .desc { color: var(--text-dim); font-size: 13px; margin-top: 2px; }

.status-pill {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-pill.not_started { background: var(--surface-2); color: var(--text-dim); }
.status-pill.in_progress { background: var(--warn-soft); color: var(--warn); }
.status-pill.completed { background: var(--good-soft); color: var(--good); }

.error-text { color: var(--bad); font-size: 14px; margin: -4px 0 12px; font-weight: 600; }

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.top-bar .link {
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  background: none;
  border: none;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.top-bar .link:active { transform: scale(0.96); }

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 22px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #22c55e);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.task-list { display: flex; flex-direction: column; gap: 10px; }

.task-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.task-row.done { border-color: var(--good); background: var(--good-soft); }

.task-check {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: background 0.15s, border-color 0.15s;
}
.task-check .icon { width: 16px; height: 16px; stroke-width: 3; }
.task-row.done .task-check {
  background: var(--good);
  border-color: var(--good);
  color: white;
}

.task-title { font-weight: 700; font-size: 15px; }
.task-desc { color: var(--text-dim); font-size: 13px; margin-top: 2px; }

.task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.priority-badge, .due-badge, .est-badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.priority-badge.low { background: var(--surface-2); color: var(--text-dim); }
.priority-badge.normal { display: none; }
.priority-badge.high { background: var(--warn-soft); color: var(--warn); }
.priority-badge.critical { background: var(--bad-soft); color: var(--bad); }

.due-badge { background: var(--surface-2); color: var(--text-dim); }
.due-badge.overdue { background: var(--bad-soft); color: var(--bad); }

.est-badge { background: var(--surface-2); color: var(--text-dim); }

.task-row.before-only { border-color: var(--warn); background: var(--warn-soft); }
.task-row.before-only .task-check { background: var(--warn); border-color: var(--warn); color: white; }

.task-row.multi-group-header {
  box-shadow: none;
  border-color: transparent;
  background: none;
  padding: 4px 4px 0;
  margin-bottom: -2px;
}
.task-row.slot-row {
  margin-left: 16px;
  padding: 12px 14px;
  border-left: 2px solid var(--border-strong);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.task-row.slot-row .task-title { font-size: 14px; font-weight: 600; flex: 1; }
.task-row.slot-row.done { border-left-color: var(--good); }
.task-row.slot-row.before-only { border-left-color: var(--warn); }

.task-action {
  margin-left: auto;
  background: var(--text);
  border: none;
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.task-action .icon { width: 15px; height: 15px; stroke-width: 2.5; }
.task-action:disabled { background: var(--surface-3); color: var(--text-faint); }
.task-row.done .task-action { background: var(--good); }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  box-shadow: 0 -4px 16px rgba(16, 24, 40, 0.04);
}
.bottom-nav.hidden { display: none; }
.nav-item {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-sm);
}
.nav-item.active { color: var(--accent); }
.nav-item .icon { width: 22px; height: 22px; }

/* Camera modal */
.camera-modal {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  z-index: 50;
}
.camera-modal video, .camera-modal img.preview {
  flex: 1;
  width: 100%;
  object-fit: cover;
  background: black;
}
.camera-controls {
  display: flex;
  gap: 12px;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  background: #000;
}
.camera-controls button { flex: 1; }
.camera-controls .btn-secondary { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.25); }
.camera-status {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.done-banner {
  text-align: center;
  padding: 60px 0 20px;
}
.done-banner .check {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--good);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(22, 163, 74, 0.35);
  animation: pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.done-banner .check .icon { width: 40px; height: 40px; stroke-width: 3; }

@keyframes pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.screen:not(.hidden) { animation: fade-in 0.2s ease; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Restock sheet --- */

.rs-add { display: flex; gap: 10px; margin-bottom: 12px; }
.rs-search-wrap { position: relative; flex: 1; }
.rs-search-wrap input { width: 100%; margin: 0; font-size: 17px; padding: 14px; border-radius: var(--radius-md); }
.rs-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); overflow: hidden;
}
.rs-result {
  display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; background: none;
  border: none; border-bottom: 1px solid var(--border); padding: 13px 14px; font-size: 15px; font-weight: 600; color: var(--text);
}
.rs-result:last-child { border-bottom: none; }
.rs-result.muted { color: var(--text-dim); font-weight: 500; }
.rs-scan-btn {
  flex: 0 0 76px; border: none; border-radius: var(--radius-md); background: var(--text); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 700;
}
.rs-scan-btn .icon { width: 24px; height: 24px; }
.rs-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.rs-chip { border: 1.5px solid var(--border); background: var(--surface); color: var(--text-dim); border-radius: 999px; padding: 8px 12px; font-size: 13px; font-weight: 700; }
.rs-chip.on { background: var(--text); border-color: var(--text); color: #fff; }
.rs-list { display: flex; flex-direction: column; gap: 10px; }
.rs-empty { text-align: center; padding: 28px 10px; }
.rs-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 14px; box-shadow: var(--shadow-sm); }
.rs-row-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.rs-name { font-size: 16px; font-weight: 700; }
.rs-section { font-size: 12px; color: var(--text-dim); font-weight: 600; margin-top: 2px; }
.rs-remove { border: none; background: var(--bad-soft); color: var(--bad); border-radius: 10px; width: 36px; height: 36px; font-size: 20px; font-weight: 700; flex-shrink: 0; }
.rs-slots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.rs-slot {
  aspect-ratio: 1; border-radius: 10px; border: 2px solid var(--border-strong); background: var(--good-soft);
  color: var(--text-dim); font-size: 15px; font-weight: 800;
}
.rs-slot.empty { background: var(--warn); border-color: var(--warn); color: #fff; }
.rs-slot-note { font-size: 12px; color: var(--text-dim); font-weight: 600; margin-top: 6px; }
.rs-stepper { display: inline-flex; border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.rs-stepper button { width: 48px; height: 46px; border: none; background: var(--surface-2); font-size: 22px; font-weight: 700; color: var(--text); }
.rs-stepper input { width: 64px; margin: 0; border: none; border-radius: 0; text-align: center; font-size: 18px; font-weight: 800; }
.rs-bar {
  position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 10; margin-top: 14px;
  display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 10px 12px;
}
.rs-bar > div { flex: 1; font-size: 14px; }
.rs-bar .btn-accent { width: auto; flex: 1; }
.rs-bar .rs-clear { width: auto; padding: 12px 12px; }
.rs-group { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); margin: 16px 0 8px; }
.rs-pull {
  display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-md); padding: 10px 12px; margin-bottom: 8px;
}
.rs-pull.pulled { background: var(--good-soft); border-color: var(--good); }
.rs-pull.partial { background: var(--warn-soft); border-color: var(--warn); }
.rs-pull.not_found { background: var(--bad-soft); border-color: var(--bad); }
.rs-pull-qty { font-size: 22px; font-weight: 800; min-width: 34px; text-align: center; }
.rs-pull-main { flex: 1; min-width: 0; }
.rs-pull-btns { display: flex; gap: 6px; }
.rs-pull-btns button {
  min-width: 44px; height: 44px; border-radius: 10px; border: 1.5px solid var(--border-strong); background: var(--surface);
  font-size: 15px; font-weight: 800; color: var(--text-dim); padding: 0 8px;
}
.rs-pull-btns button[data-mark="pulled"].on { background: var(--good); border-color: var(--good); color: #fff; }
.rs-pull-btns button[data-mark="partial"].on { background: var(--warn); border-color: var(--warn); color: #fff; }
.rs-pull-btns button[data-mark="not_found"].on { background: var(--bad); border-color: var(--bad); color: #fff; }
#rs-notes { width: 100%; margin-top: 10px; font-size: 15px; padding: 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); font-family: inherit; }
.rs-scan-modal {
  position: fixed; inset: 0; z-index: 60; background: var(--bg); padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}
.rs-scan-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 17px; }
.rs-scan-view { width: 100%; border-radius: var(--radius-md); overflow: hidden; background: #000; min-height: 220px; }
.rs-scan-view video { width: 100% !important; display: block; }
.rs-manual { display: flex; gap: 8px; }
.rs-manual input { flex: 1; margin: 0; }
.rs-toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; z-index: 70; pointer-events: none; max-width: 90%;
}
.rs-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* The app's general button padding makes these too wide on a phone. */
.rs-slot, .rs-remove, .rs-stepper button, .rs-pull-btns button, .rs-chip, .rs-scan-btn, .rs-result { min-width: 0; }
.rs-slot { padding: 0; width: 100%; }
.rs-remove { padding: 0; display: flex; align-items: center; justify-content: center; }
.rs-stepper button { padding: 0; }
.rs-slots { width: 100%; }

/* --- Ask Elmo --- */
.ask-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.ask-title { font-weight: 800; font-size: 16px; }
.ask-sub { font-size: 13px; color: var(--text-dim); margin: 2px 0 10px; }
.ask-thread { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.ask-thread:empty { display: none; }
.ask-msg { padding: 10px 12px; border-radius: 14px; font-size: 15px; line-height: 1.45; max-width: 92%; }
.ask-msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.ask-msg.elmo { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.ask-typing { color: var(--text-dim); font-style: italic; }
.ask-sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ask-source { font-size: 12px; font-weight: 700; color: var(--info); background: var(--info-soft); padding: 5px 9px; border-radius: 999px; text-decoration: none; }
.ask-row { display: flex; gap: 8px; }
.ask-row input { flex: 1; margin: 0; font-size: 15px; padding: 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); min-width: 0; }
.ask-row .btn-accent { width: auto; padding: 12px 18px; }
