/* ── TOKENS ──────────────────────────────────────────────────────────── */
:root {
  --bg:           #080808;
  --surface:      #111111;
  --surface-2:    #191919;
  --border:       #1e1e1e;
  --border-hi:    #2c2c2c;
  --text:         #e2e2e2;
  --text-muted:   #555555;
  --text-dim:     #888888;
  --accent:       #e8a020;
  --accent-dim:   rgba(232,160,32,.14);
  --accent-border:rgba(232,160,32,.28);
  --success:      #22c55e;
  --success-dim:  rgba(34,197,94,.14);
  --success-bdr:  rgba(34,197,94,.3);
  --danger:       #ef4444;
  --danger-dim:   rgba(239,68,68,.14);
  --danger-bdr:   rgba(239,68,68,.3);
  --warning:      #f59e0b;
  --warning-dim:  rgba(245,158,11,.14);
  --blue:         #3b82f6;
  --blue-dim:     rgba(59,130,246,.14);
  --r:            6px;
  --r-sm:         4px;
  --nav-h:        60px;
  --hdr-h:        52px;
  --font-mono:    'IBM Plex Mono', monospace;
  --font-sans:    'IBM Plex Sans', sans-serif;
}

/* ── RESET ───────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── APP SHELL ───────────────────────────────────────────────────────── */
#app { height: 100%; position: relative; }

#main-app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ── LOCK SCREEN ─────────────────────────────────────────────────────── */
.lock-screen {
  position: fixed; inset: 0; z-index: 100;
  background-image: url('https://vrpvwreazoxjkbspgejz.supabase.co/storage/v1/object/public/images/breaking_bad2.gif');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 40px 32px;
}

.lock-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.35em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.lock-mark {
  font-size: 52px;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}

.lock-title {
  font-family: var(--font-mono);
  font-size: 24px;
  color: var(--text);
  letter-spacing: 0.25em;
  margin-bottom: 12px;
}

.lock-form {
  display: flex; flex-direction: column;
  gap: 10px; width: 100%; max-width: 260px;
}

.lock-form input[type="password"] {
  background: var(--surface);
  border: 1px solid var(--border-hi);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 18px;
  padding: 14px 16px;
  border-radius: var(--r);
  width: 100%; outline: none;
  letter-spacing: 0.3em;
  text-align: center;
  transition: border-color .15s;
}

.lock-form input[type="password"]:focus {
  border-color: var(--accent);
}

.lock-error {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--danger);
  text-align: center;
  letter-spacing: 0.08em;
  min-height: 18px;
}

/* ── HEADER ──────────────────────────────────────────────────────────── */
#app-header {
  height: var(--hdr-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px; gap: 10px;
  flex-shrink: 0;
}

.header-title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--text);
  flex: 1;
}

.header-operator {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  padding: 3px 8px;
  border-radius: 3px;
  letter-spacing: 0.08em;
}

/* ── BOTTOM NAV ──────────────────────────────────────────────────────── */
#bottom-nav {
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  cursor: pointer;
  padding: 6px 2px 4px;
  color: var(--text-muted);
  transition: color .15s;
  position: relative;
  min-width: 0;
}

.nav-item:active { opacity: .65; }

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

.nav-item.active::after {
  content: '';
  position: absolute; top: 0; left: 18%; right: 18%;
  height: 2px; background: var(--accent);
  border-radius: 0 0 2px 2px;
}

.nav-item svg {
  width: 20px; height: 20px;
  stroke-width: 1.75;
  flex-shrink: 0;
}

.nav-item span {
  font-size: 9px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
}

/* ── CONTENT ─────────────────────────────────────────────────────────── */
#content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ── BUTTONS ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px;
  border-radius: var(--r);
  font-family: var(--font-sans);
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: none;
  transition: opacity .15s;
  white-space: nowrap; user-select: none;
}

.btn:active { opacity: .7; }
.btn:disabled { opacity: .38; cursor: not-allowed; }

.btn-primary  { background: var(--accent); color: #000; }
.btn-secondary{ background: var(--surface-2); color: var(--text); border: 1px solid var(--border-hi); }
.btn-danger   { background: var(--danger-dim); color: var(--danger); border: 1px solid var(--danger-bdr); }
.btn-success  { background: var(--success-dim); color: var(--success); border: 1px solid var(--success-bdr); }
.btn-ghost    { background: transparent; color: var(--text-dim); }
.btn-sm       { padding: 7px 12px; font-size: 12px; }
.btn-block    { width: 100%; }
.btn-icon     { padding: 8px; }

/* ── PAGE ────────────────────────────────────────────────────────────── */
.page {
  padding: 14px 16px 24px;
  display: flex; flex-direction: column; gap: 14px;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
}

.page-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── CARD ────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.card-header {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.card-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.card-body { padding: 16px; }

/* ── METRICS GRID ────────────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 24px;
  color: var(--text);
  line-height: 1;
}

.metric-value.accent { color: var(--accent); }

/* ── LIST ITEMS ──────────────────────────────────────────────────────── */
.list-item {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px;
  cursor: pointer;
  transition: background .1s;
  -webkit-user-select: none; user-select: none;
}

.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--surface-2); }

.list-item-main { flex: 1; min-width: 0; }

.list-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.list-item-sub {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 5px;
  flex-shrink: 0;
}

/* ── BADGES ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
}

.badge-success { background: var(--success-dim); color: var(--success); }
.badge-danger  { background: var(--danger-dim);  color: var(--danger);  }
.badge-warning { background: var(--warning-dim); color: var(--warning); }
.badge-blue    { background: var(--blue-dim);    color: var(--blue);    }
.badge-accent  { background: var(--accent-dim);  color: var(--accent);  }
.badge-muted   { background: var(--surface-2);   color: var(--text-muted); border: 1px solid var(--border); }

/* ── FORMS ───────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-control {
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  outline: none; width: 100%;
  -webkit-appearance: none;
  transition: border-color .15s;
}

.form-control:focus { border-color: var(--accent); }

.form-mono { font-family: var(--font-mono); font-size: 13px; }

textarea.form-control { resize: vertical; min-height: 72px; }
select.form-control option { background: var(--surface-2); color: var(--text); }

/* ── TOGGLE ──────────────────────────────────────────────────────────── */
.toggle { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border-hi);
  border-radius: 12px; cursor: pointer;
  transition: background .2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform .2s, background .2s;
}

.toggle input:checked + .toggle-slider { background: var(--accent-dim); border: 1px solid var(--accent-border); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); background: var(--accent); }

/* ── MODAL / BOTTOM SHEET ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.72);
  display: flex; flex-direction: column; justify-content: flex-end;
}

.modal-sheet {
  background: var(--bg);
  border-top: 1px solid var(--border-hi);
  border-radius: 16px 16px 0 0;
  max-height: 92vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.modal-handle {
  width: 36px; height: 4px;
  background: var(--border-hi);
  border-radius: 2px;
  margin: 10px auto 6px;
  flex-shrink: 0;
}

.modal-header {
  padding: 6px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}

.modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px;
  flex-shrink: 0;
}

/* ── DETAIL ROWS ─────────────────────────────────────────────────────── */
.detail-row {
  display: flex; flex-direction: column; gap: 3px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child { border-bottom: none; }

.detail-key {
  font-family: var(--font-mono);
  font-size: 9px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-muted);
}

.detail-value {
  font-size: 13px; color: var(--text);
  word-break: break-word;
}

/* ── DIVIDER LABEL ───────────────────────────────────────────────────── */
.divider-label {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 9px; letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 2px 0;
}

.divider-label::before, .divider-label::after {
  content: ''; flex: 1; height: 1px;
  background: var(--border);
}

/* ── STATES ──────────────────────────────────────────────────────────── */
.loading-state {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 12px;
  padding: 56px 16px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.14em;
}

.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border-hi);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-state {
  margin: 16px;
  padding: 16px;
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 12px; text-align: center;
  background: var(--danger-dim);
  border: 1px solid var(--danger-bdr);
  border-radius: var(--r);
}

.empty-state {
  padding: 48px 16px; text-align: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.1em;
}

/* ── PRODUCT THUMB ───────────────────────────────────────────────────── */
.product-thumb {
  width: 44px; height: 44px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  object-fit: cover; flex-shrink: 0;
}

.product-thumb-empty {
  width: 44px; height: 44px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 18px;
}

/* ── TOAST ───────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px));
  left: 50%; transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column-reverse; gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 320px;
}

.toast {
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--r);
  font-family: var(--font-mono);
  font-size: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  animation: t-in .2s ease, t-out .2s ease 2.5s forwards;
}

.toast-success { border-left: 3px solid var(--success); color: var(--success); }
.toast-error   { border-left: 3px solid var(--danger);  color: var(--danger);  }
.toast-info    { border-left: 3px solid var(--accent);  color: var(--accent);  }

@keyframes t-in  { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@keyframes t-out { from { opacity:1; } to { opacity:0; } }

/* ── LABEL RESULT CARD ───────────────────────────────────────────────── */
.label-result {
  background: var(--success-dim);
  border: 1px solid var(--success-bdr);
  border-radius: var(--r);
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
}

.label-result-eyebrow {
  font-family: var(--font-mono);
  font-size: 9px; letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--success);
}

.label-result-tracking {
  font-family: var(--font-mono);
  font-size: 13px; color: var(--text);
}

/* ── MISC ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

.row-between {
  display: flex; align-items: center; justify-content: space-between;
}

.row-gap { display: flex; align-items: center; gap: 10px; }

.mono { font-family: var(--font-mono); }

.text-accent { color: var(--accent); }
.text-dim    { color: var(--text-dim); }
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
