/* ---------------------------------------------------------------------------
   Vault
   A single stylesheet, no framework. Tokens first, then layout, then
   components, so overrides stay unnecessary.
   --------------------------------------------------------------------------- */

:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #e7ebf0;
  --border: #dfe3e8;
  --border-strong: #c4cad2;

  --text: #16191d;
  --text-muted: #5f6873;
  --text-faint: #8b939d;

  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #eaf0ff;

  /* What goes on top of a filled accent or status colour. White works on the
     deep light-mode colours and fails badly on the light dark-mode ones —
     white on #6a93ff measures 2.9:1, well under the 4.5:1 floor — so the ink
     flips with the scheme rather than the fill being darkened. */
  --accent-ink: #ffffff;
  --status-ink: #ffffff;

  --success: #15803d;
  --success-soft: #e8f6ed;
  --warning: #b45309;
  --warning-soft: #fdf3e3;
  --danger: #b91c1c;
  --danger-soft: #fdeaea;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, 0.12);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Literal codes only — a recovery code, an invitation token. Amounts and
     dates use tabular figures in the text face instead. */
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; /* taste-skill-ignore */

  /* The notch, the home indicator, the Android gesture bar. Zero in a browser
     window, non-zero once installed as an app, so every edge reads from these
     rather than assuming a rectangle. */
  --inset-top: env(safe-area-inset-top, 0px);
  --inset-right: env(safe-area-inset-right, 0px);
  --inset-bottom: env(safe-area-inset-bottom, 0px);
  --inset-left: env(safe-area-inset-left, 0px);

  --tabbar-height: 58px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1c2024;
    --surface-2: #23282d;
    --border: #2f353b;
    --border-strong: #3d444b;

    --text: #e8eaed;
    --text-muted: #a3acb6;
    --text-faint: #7c848d;

    --accent: #6a93ff;
    --accent-hover: #86a7ff;
    --accent-soft: #1e2739;

    --accent-ink: #0b1222;
    --status-ink: #13161a;

    --success: #4ade80;
    --success-soft: #16261c;
    --warning: #fbbf24;
    --warning-soft: #2a2213;
    --danger: #f87171;
    --danger-soft: #2c1a1a;

    --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  /* Keeps the installed app from rubber-banding the whole page under the
     status bar when a list is scrolled past its end. */
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  /* A WebView is not a browser: the grey flash on every tap and the
     text-selection lasso on chrome both read as a bug in an app. */
  -webkit-tap-highlight-color: transparent;
}

body.centred {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: calc(24px + var(--inset-top)) calc(16px + var(--inset-right))
           calc(24px + var(--inset-bottom)) calc(16px + var(--inset-left));
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 27px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0 0 12px; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 14px; }
.tiny  { font-size: 13px; }
.mono  { font-family: var(--mono); } /* taste-skill-ignore: literal codes */
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px calc(16px + var(--inset-right)) 72px calc(16px + var(--inset-left));
}

/* Room for the tab bar, which floats over the page on a phone. */
body.has-tabbar .shell { padding-bottom: calc(72px + var(--tabbar-height) + var(--inset-bottom)); }
@media (min-width: 801px) {
  body.has-tabbar .shell { padding-bottom: 72px; }
}

.card-shell {
  width: 100%;
  max-width: 480px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-head .subtitle { color: var(--text-muted); margin: 0; max-width: 72ch; }

.row { display: flex; gap: 12px; align-items: center; }
.row-wrap { flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 24px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.topbar {
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: var(--inset-top);
  -webkit-user-select: none;
  user-select: none;
}

.topbar-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 calc(16px + var(--inset-right)) 0 calc(16px + var(--inset-left));
  height: 58px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 21px; height: 21px; color: var(--accent); }

.nav-links { display: flex; gap: 2px; margin-left: 8px; }
.nav-links a {
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 15px;
  position: relative;
}
.nav-links a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-links a.active { background: var(--accent-soft); color: var(--accent); }

.nav-badge {
  display: inline-block;
  min-width: 17px;
  padding: 0 5px;
  margin-left: 5px;
  border-radius: 9px;
  background: var(--warning);
  color: var(--status-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.vault-state { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-muted); }
.vault-state .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.vault-state.unlocked .dot { background: var(--success); }
.vault-state.unlocked .label { color: var(--success); }

.avatar { width: 30px; height: 30px; border-radius: 50%; display: block; object-fit: cover; }
.avatar-text {
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 650;
}

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border); /* taste-skill-ignore: an overlay needs an edge against any content */
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg); /* taste-skill-ignore: a menu that floats */
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.menu-head { padding: 8px 10px 10px; margin-bottom: 6px; display: flex; flex-direction: column; }
.menu-panel a,
.menu-panel button {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-align: left;
  color: var(--text);
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  width: 100%;
}
.menu-panel a:hover,
.menu-panel button:hover { background: var(--surface-2); text-decoration: none; }
.menu-panel form { margin: 0; }

/* --------------------------------------------------------------------------
   Cards, panels
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

.panel {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 14px 16px;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); /* taste-skill-ignore: a control, not a container */
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--status-ink); }
.btn-danger:hover { opacity: 0.88; background: var(--danger); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 6px 11px; font-size: 14px; }
.btn-lg { padding: 12px 22px; font-size: 16px; }
.btn-block { width: 100%; }

.btn-google { background: var(--surface); border-color: var(--border-strong); font-weight: 550; }
.btn-google svg { width: 17px; height: 17px; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; color: var(--text); }

input[type="text"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], input[type="email"],
select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong); /* taste-skill-ignore: a form field */
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); /* taste-skill-ignore: focus ring */
}
textarea { resize: vertical; min-height: 72px; }

.field { margin-bottom: 14px; }
.field-hint { font-size: 13px; color: var(--text-muted); margin-top: 5px; font-weight: 400; max-width: 72ch; }
.field-error { font-size: 13px; color: var(--danger); margin-top: 5px; }

.inline-fields { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-fields > * { flex: 1 1 140px; }

/*
 * A row of controls that share one line: a search box, a filter or two and a
 * button. Every child is a control, so they line up on their own — any hint or
 * error text belongs under the row rather than under one control, which would
 * make that column taller and leave the rest floating against its middle.
 */
.filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.filter-row > input[type="search"] { flex: 3 1 240px; width: auto; }
.filter-row > select { flex: 1 1 150px; width: auto; }
.filter-row > .btn { flex: 0 0 auto; }

/* --------------------------------------------------------------------------
   Flash and callouts
   -------------------------------------------------------------------------- */

.flash, .callout {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent; /* taste-skill-ignore: carries the state colour */
  margin-bottom: 16px;
  font-size: 15px;
}
.flash-success, .callout-success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.flash-error,   .callout-error   { background: var(--danger-soft);  border-color: var(--danger);  color: var(--danger); }
.flash-info,    .callout-info    { background: var(--accent-soft);  border-color: var(--accent);  color: var(--accent); }
.callout-warning { background: var(--warning-soft); border-color: var(--warning); color: var(--warning); }

.callout strong { display: block; margin-bottom: 3px; }

/* --------------------------------------------------------------------------
   Receipt grid
   -------------------------------------------------------------------------- */

.receipt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 14px;
}

.receipt-card {
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background 0.12s, border-color 0.12s;
  position: relative;
}
.receipt-card:hover { background: var(--surface-2); }
.receipt-card.selected { border-color: var(--accent); }

.receipt-thumb {
  aspect-ratio: 3 / 4;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}
.receipt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.receipt-thumb .placeholder { width: 30px; height: 30px; color: var(--text-faint); }

.receipt-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.receipt-merchant { font-weight: 600; font-size: 15px; line-height: 1.3; word-break: break-word; }
.receipt-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
/* The total never wraps: a figure broken across two lines stops being a
   figure. The date gives way instead. */
.receipt-total { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.receipt-meta .muted { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }

.select-box {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Badges and chips
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.7;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border); /* taste-skill-ignore: a chip-sized control */
  white-space: nowrap;
}
.badge .swatch { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.badge-review { background: var(--warning-soft); color: var(--warning); border-color: var(--warning); }
.badge-auto { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-manual { background: var(--success-soft); color: var(--success); border-color: transparent; }

.chip-row { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong); /* taste-skill-ignore: a control, not a container */
  background: var(--surface);
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
  font-weight: 500;
}
.chip:hover { background: var(--surface-2); text-decoration: none; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { font-size: 13px; color: var(--text-muted); font-weight: 650; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 650; border-top: 2px solid var(--border-strong); border-bottom: 0; }

/* --------------------------------------------------------------------------
   Progress and meters
   -------------------------------------------------------------------------- */

.meter { height: 7px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s; }
.meter-fill.warn { background: var(--warning); }
.meter-fill.full { background: var(--danger); }

.storage-line { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }

/* --------------------------------------------------------------------------
   Upload
   -------------------------------------------------------------------------- */

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 44px 24px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .icon { width: 34px; height: 34px; display: block; margin: 0 auto 10px; color: var(--text-muted); }
.dropzone:hover .icon, .dropzone.dragover .icon { color: var(--accent); }

.queue { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }

.queue-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--radius);
}
.queue-thumb { width: 44px; height: 56px; object-fit: cover; border-radius: 4px; background: var(--surface-2); flex: none; }
.queue-info { flex: 1; min-width: 0; }
.queue-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-status { font-size: 14px; color: var(--text-muted); }
.queue-item.is-error .queue-status { color: var(--danger); }
.queue-item.is-done  .queue-status { color: var(--success); }

.progress-track { height: 4px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.25s; }

/* --------------------------------------------------------------------------
   Recovery code
   -------------------------------------------------------------------------- */

.recovery-code {
  font-family: var(--mono); /* taste-skill-ignore: a literal recovery code */
  font-size: 19px;
  letter-spacing: 0.06em;
  background: var(--surface-2);
  border: 1px solid var(--border-strong); /* taste-skill-ignore: a literal code block */
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  word-spacing: 0.3em;
  user-select: all;
  margin: 14px 0;
}

.strength { height: 5px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 7px; }
.strength-bar { height: 100%; width: 0; transition: width 0.25s, background 0.25s; }
.strength-bar.weak   { background: var(--danger); }
.strength-bar.fair   { background: var(--warning); }
.strength-bar.good   { background: var(--accent); }
.strength-bar.strong { background: var(--success); }

/* --------------------------------------------------------------------------
   Page marks

   One drawn mark at the head of a single-card page: signing in, opening the
   vault, a new account. Emoji used to sit here, which meant a page opened with
   somebody
   else's artwork, redrawn by every platform this now ships on.
   -------------------------------------------------------------------------- */

.page-mark { width: 40px; height: 40px; display: block; margin: 0 auto; color: var(--accent); }

/* An error page leads with its status, at a size that makes the number the
   picture. */
.error-status {
  font-size: 60px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text-faint);
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 13, 17, 0.55);
  display: grid;
  place-items: center;
  z-index: 80;
  padding: calc(16px + var(--inset-top)) calc(16px + var(--inset-right))
           calc(16px + var(--inset-bottom)) calc(16px + var(--inset-left));
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg); /* taste-skill-ignore: a dialog that floats */
  width: 100%;
  max-width: 520px;
  max-height: 85dvh;
  overflow: auto;
  padding: 22px;
}
.modal-lg { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

.lightbox-img { width: 100%; height: auto; border-radius: var(--radius-sm); background: var(--surface-2); }

/* One allowance in the relief tracker. Space between them, not a rule. */
.relief-row { padding: 18px 0; }
.relief-row:last-child { padding-bottom: 0; }
.relief-row:first-child { padding-top: 0; }

/* A column of radio choices, each with its own explanation underneath. */
.field-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.choice { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; line-height: 1.45; }
.choice input { margin-top: 3px; flex-shrink: 0; }
.choice span span { display: block; }

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast-host {
  position: fixed;
  bottom: calc(20px + var(--inset-bottom));
  right: calc(20px + var(--inset-right));
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); /* taste-skill-ignore: a toast that floats */
  font-size: 15px;
  max-width: 360px;
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}
.toast.error { background: var(--danger); color: var(--status-ink); }
.toast.success { background: var(--success); color: var(--status-ink); }

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

/* --------------------------------------------------------------------------
   Empty state, loading
   -------------------------------------------------------------------------- */

.empty { text-align: center; padding: 64px 20px; color: var(--text-muted); }
.empty h3 { font-size: 21px; color: var(--text); margin-bottom: 6px; }
.empty p { max-width: 42ch; margin: 0 auto; }

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: var(--surface-2);
  animation: pulse 1.3s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes pulse { 50% { opacity: 0.45; } }

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */

.pager { display: flex; gap: 7px; justify-content: center; align-items: center; margin-top: 26px; }
.pager .page-info { color: var(--text-muted); font-size: 14px; padding: 0 10px; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 800px) {
  .nav-links { display: none; }
  .topbar-inner { gap: 10px; }
  .vault-state .label { display: none; }
  .receipt-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .shell { padding-left: calc(12px + var(--inset-left)); padding-right: calc(12px + var(--inset-right)); padding-top: 16px; }
  .card { padding: 16px; }
  h1 { font-size: 24px; }
}

/* Only a phone-sized window hides the top links, so the menu only needs to
   stand in for them there. */
@media (min-width: 801px) {
  .menu-phone-only { display: none; }
}

@media print {
  .topbar, .tabbar, .btn, .pager, .toast-host, .chip-row { display: none !important; }
  body { background: #fff; }
  .card { border: 0; box-shadow: none; padding: 0; } /* taste-skill-ignore: removing one */
}

/* --------------------------------------------------------------------------
   Admin
   -------------------------------------------------------------------------- */

.admin-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 20px;
  background: var(--surface);
  border-radius: var(--radius);
}

.admin-badge {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 650;
}

.admin-links { display: flex; gap: 2px; flex-wrap: wrap; }
.admin-links a {
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
}
.admin-links a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.admin-links a.active { background: var(--accent-soft); color: var(--accent); }
.admin-bar > a:last-child { margin-left: auto; }

.invite-link {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border-strong); /* taste-skill-ignore: a literal code block */
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 12px 0;
}
.invite-link input {
  border: 0;
  background: transparent;
  font-family: var(--mono); /* taste-skill-ignore: a literal invitation URL */
  font-size: 13px;
  padding: 0;
  flex: 1;
  min-width: 0;
}
.invite-link input:focus { box-shadow: none; } /* taste-skill-ignore: removing one */

.row-actions { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: wrap; }

@media (max-width: 800px) {
  .admin-bar > a:last-child { margin-left: 0; }
}


/* --------------------------------------------------------------------------
   The app shell on a phone

   Installed — from the browser, the Play Store or sideloaded — this is an app,
   and an app puts its navigation under the thumb. Above 800px the top bar
   carries the links and this bar is not rendered at all.
   -------------------------------------------------------------------------- */

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: none;
  background: var(--surface);
  padding: 0 var(--inset-right) var(--inset-bottom) var(--inset-left);
  -webkit-user-select: none;
  user-select: none;
  /* It floats over the content, so it is one of the few things that may cast
     a shadow. */
  box-shadow: 0 -2px 14px rgba(16, 24, 40, 0.08); /* taste-skill-ignore: a bar that floats */
}

@media (max-width: 800px) {
  .tabbar { display: flex; }
}

.tab {
  flex: 1;
  min-width: 0;
  height: var(--tabbar-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  position: relative;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 550;
  text-decoration: none;
  touch-action: manipulation;
}
.tab:hover { text-decoration: none; }
.tab:active { background: var(--surface-2); }
.tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.tab.active { color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }

.tab-icon { width: 23px; height: 23px; flex: none; }

/* Adding a receipt is the one thing the app is for, so it is the one thing
   wearing the accent. */
.tab-action { color: var(--text-muted); }
.tab-action-mark {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
}
.tab-action .tab-icon { width: 20px; height: 20px; }
.tab-action:active .tab-action-mark { background: var(--accent-hover); }

.tab-badge {
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: 4px;
  min-width: 16px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--warning);
  color: var(--status-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  .tabbar { box-shadow: 0 -2px 14px rgba(0, 0, 0, 0.4); } /* taste-skill-ignore: a bar that floats */
}

/* --------------------------------------------------------------------------
   Touch

   Pointer-coarse rather than a width: a tablet is a touch device at any size,
   and iOS zooms the whole page when a field smaller than 16px takes focus.
   -------------------------------------------------------------------------- */

/* Press feedback. On a touch screen there is no hover to tell you a tap
   landed, and the gap before the next page paints is long enough to tap
   twice. Transform and opacity only, so nothing reflows. */
.btn:active:not(:disabled),
.chip:active,
.receipt-card .receipt-thumb:active { transform: scale(0.985); }
.btn, .chip, .receipt-thumb { transition: background 0.12s, border-color 0.12s, opacity 0.12s, transform 0.08s; }

@media (pointer: coarse) {
  input[type="text"], input[type="password"], input[type="number"],
  input[type="date"], input[type="search"], input[type="email"],
  select, textarea {
    font-size: 16px;
  }

  .btn { min-height: 40px; touch-action: manipulation; }
  .btn-sm { min-height: 34px; }
  .menu-panel a, .menu-panel button { padding: 11px 10px; }
  .chip { padding: 8px 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
