/* Built for a phone held in one hand in a shop, and for nothing else. Rows are
   thumb-sized, the count is the largest thing on the line, and the page follows
   whatever theme the phone is already in. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --sunk: #eef1f5;
  --ink: #101828;
  --ink-2: #475467;
  --muted: #98a2b3;
  --line: #e4e7ec;
  --accent: #0f766e;
  --bad: #b42318;
  --warn: #b54708;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #131c2b;
    --sunk: #1b2536;
    --ink: #e7edf5;
    --ink-2: #9fb0c6;
    --muted: #6b7c93;
    --line: #24314a;
    --accent: #2dd4bf;
    --bad: #f97066;
    --warn: #fdb022;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1 { font-size: 1.15rem; margin: 0; font-weight: 650; }
.muted { color: var(--ink-2); }
.small { font-size: 0.82rem; }
.empty { padding: 2rem 1rem; text-align: center; }

/* ---------------------------------- gate ---------------------------------- */

.gate { min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  width: 100%;
  max-width: 22rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.codeInput {
  font: 600 1.5rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.18em;
  text-align: center;
  padding: 0.85rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--sunk);
  color: var(--ink);
  width: 100%;
}
.codeInput:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.primary {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 0.85rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  /* A tap target that a thumb cannot miss. */
  min-height: 48px;
}
.primary:disabled { opacity: 0.6; }

.error { color: var(--bad); font-size: 0.9rem; margin: 0; }

/* ---------------------------------- app ----------------------------------- */

.head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1rem 0.6rem;
  position: sticky;
  top: 0;
  background: var(--bg);
}
.head > div { flex: 1; min-width: 0; }

.ghost {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  border-radius: 10px;
  width: 42px;
  height: 42px;
  font-size: 1.2rem;
  cursor: pointer;
}

.tabs { display: flex; gap: 0.4rem; padding: 0 1rem 0.75rem; }
.tab {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  border-radius: 10px;
  padding: 0.6rem;
  font: inherit;
  cursor: pointer;
  min-height: 42px;
}
.tab.active { background: var(--sunk); color: var(--ink); border-color: var(--muted); font-weight: 600; }

.list { list-style: none; margin: 0; padding: 0 1rem 1rem; display: flex; flex-direction: column; gap: 0.4rem; }

.row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.row .name { flex: 1; min-width: 0; }
.row .name b { font-weight: 600; display: block; overflow-wrap: anywhere; }

.amount { text-align: right; white-space: nowrap; }
.amount b { font-size: 1.05rem; font-weight: 700; display: block; }

.row.zero { border-color: var(--bad); }
.row.zero .amount b { color: var(--bad); }
.row.low .amount b { color: var(--warn); }

/* Block, like the count it stands in for on the stock rows — inline it ran
   straight into the balance beside it and read as one number. */
.delta { display: block; font-weight: 700; white-space: nowrap; }
.delta.plus { color: var(--accent); }
.delta.minus { color: var(--bad); }

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem 1.5rem;
  border-top: 1px solid var(--line);
  margin-top: 0.5rem;
}
.linky { background: none; border: 0; color: var(--ink-2); font: inherit; text-decoration: underline; cursor: pointer; }
