/*
 * The whole look of the interface, by hand, in one file.
 *
 * No Tailwind and no CSS build: the shop deploys with `docker compose up
 * --build` and nothing else, and a stylesheet that needs node to exist is a
 * stylesheet that breaks the deploy on the day the deploy has to work.
 *
 * Written mobile-first because that is where it gets used: the phone is on the
 * counter all day and the desktop only comes out at closing time. Every table
 * here turns into a stack of cards under 700px -- a shopkeeper scrolling a
 * table sideways with one thumb is a shopkeeper who stops using the screen.
 */

/* ---- tokens ------------------------------------------------------------ */

:root {
  color-scheme: light dark;

  /* Citrus, because that is what the shop sells. The orange is darkened from
     the fruit's own colour until it passes contrast on white -- a brand colour
     nobody can read is decoration, not identity. */
  --citrus: #d96a06;
  --citrus-soft: #fdf0e2;
  --citrus-line: #f2cfa6;
  --lime: #4f7a1f;
  --lime-soft: #eef5e4;

  --ink: #241c14;
  --ink-soft: #6b5c4d;
  --ink-faint: #9c8d7e;

  --paper: #fbf8f4;
  --surface: #ffffff;
  --surface-sunk: #f5f0e9;
  --line: #e8ded1;
  --line-strong: #d6c8b6;

  --danger: #b3261e;
  --danger-soft: #fceceb;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(36, 28, 20, .06), 0 4px 12px rgba(36, 28, 20, .05);
  --shadow-lift: 0 4px 8px rgba(36, 28, 20, .08), 0 12px 28px rgba(36, 28, 20, .10);

  --sidebar: 232px;
  --topbar: 56px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --citrus: #f59b4a;
    --citrus-soft: #3a2a17;
    --citrus-line: #5e4526;
    --lime: #9ccc65;
    --lime-soft: #253119;

    --ink: #f2ece4;
    --ink-soft: #b8ac9e;
    --ink-faint: #877b6e;

    --paper: #16120e;
    --surface: #1f1a15;
    --surface-sunk: #272119;
    --line: #352d24;
    --line-strong: #473d31;

    --danger: #f2857c;
    --danger-soft: #3a1c1a;
    --warn: #e0b060;
    --warn-soft: #362a13;

    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 12px rgba(0, 0, 0, .30);
    --shadow-lift: 0 4px 8px rgba(0, 0, 0, .40), 0 12px 28px rgba(0, 0, 0, .45);
  }
}

/* ---- reset ------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

/* `hidden` tem que esconder, sempre.
 *
 * O navegador esconde via `[hidden] { display: none }` na folha DELE, e
 * qualquer `display` que eu escreva aqui ganha dessa regra — folha de autor
 * vence folha do navegador. Foi o que aconteceu com `.line { display: grid }`:
 * a linha do pedido recebia `hidden` ao ser removida, era marcada para
 * exclusão, e continuava na tela. O ✕ parecia não fazer nada. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .6rem; }
p:last-child { margin-bottom: 0; }

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

img, svg { max-width: 100%; }

/* Focus is visible everywhere and never removed. Half the interface gets used
   with a keyboard at closing time, tabbing down a column of amounts. */
:focus-visible {
  outline: 2px solid var(--citrus);
  outline-offset: 2px;
  border-radius: 4px;
}

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

.shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: .5rem;
  height: var(--topbar);
  padding: 0 .75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
}
.topbar__brand:hover { text-decoration: none; }
.topbar__brand span { font-size: .95rem; }

.topbar__spacer { flex: 1; }

.topbar__who {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  color: var(--ink-soft);
}

.burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

/* ---- navigation -------------------------------------------------------- */

.nav {
  position: fixed;
  inset: var(--topbar) 0 0 0;
  z-index: 25;
  padding: .75rem;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  transform: translateX(-100%);
  transition: transform .18s ease;
}
.nav[data-open="true"] { transform: translateX(0); }

.nav__group { margin-bottom: 1rem; }
.nav__group:last-child { margin-bottom: 0; }

.nav__title {
  padding: 0 .6rem .35rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.nav__link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .6rem;
  margin-bottom: 1px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: .875rem;
  font-weight: 500;
}
.nav__link:hover { background: var(--surface-sunk); color: var(--ink); text-decoration: none; }
.nav__link[aria-current="page"] { background: var(--citrus-soft); color: var(--citrus); font-weight: 600; }
.nav__link em { font-style: normal; width: 1.15rem; text-align: center; }

.nav__count {
  margin-left: auto;
  padding: .05rem .4rem;
  border-radius: 99px;
  background: var(--surface-sunk);
  font-size: .7rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.nav__link[aria-current="page"] .nav__count { background: var(--surface); }
.nav__count[data-tone="alert"] { background: var(--danger); color: #fff; }

.scrim {
  position: fixed;
  inset: var(--topbar) 0 0 0;
  z-index: 24;
  background: rgba(36, 28, 20, .45);
}

.main { padding: 1rem .75rem 3rem; }

@media (min-width: 900px) {
  .burger, .scrim { display: none; }
  .nav {
    position: fixed;
    width: var(--sidebar);
    inset: var(--topbar) auto 0 0;
    transform: none;
  }
  .main { margin-left: var(--sidebar); padding: 1.5rem 1.5rem 4rem; }
  .topbar { padding-left: 1rem; }
}

/* ---- page header ------------------------------------------------------- */

.page {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: 1rem;
}
.page__titles { flex: 1 1 14rem; min-width: 0; }
.page__sub { margin: .15rem 0 0; font-size: .85rem; color: var(--ink-soft); }
.page__actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---- cards ------------------------------------------------------------- */

.card {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin: -1rem -1rem 1rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--line);
}
.card__head h2 { flex: 1 1 auto; }
.card__foot {
  margin: 1rem -1rem -1rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface-sunk);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: .85rem;
  color: var(--ink-soft);
}

.grid { display: grid; gap: 1rem; }
@media (min-width: 700px) {
  .grid--2 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1100px) {
  .grid--4 { grid-template-columns: repeat(4, 1fr); }
  .grid--3-1 { grid-template-columns: 2fr 1fr; }
}

/* ---- stat tiles -------------------------------------------------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}

.tile {
  padding: .8rem .9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tile__label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.tile__value {
  margin-top: .2rem;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.tile__note { font-size: .78rem; color: var(--ink-soft); }
.tile--accent { border-color: var(--citrus-line); background: var(--citrus-soft); }
.tile--accent .tile__value { color: var(--citrus); }
.tile--alert { border-color: var(--danger); }
.tile--alert .tile__value { color: var(--danger); }

/* ---- tables ------------------------------------------------------------ */

.table-wrap { overflow-x: auto; margin: 0 -1rem; padding: 0 1rem; }

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.table th {
  padding: .5rem .6rem;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: .6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-sunk); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .shrink { width: 1%; white-space: nowrap; }
.table tfoot td {
  padding: .6rem;
  border-top: 2px solid var(--line-strong);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Under 700px every row becomes a card, and each cell carries its own header
   through data-label. Two columns of numbers on a phone is a scroll bar
   nobody finds. */
@media (max-width: 699px) {
  .table--stack, .table--stack thead, .table--stack tbody, .table--stack tfoot,
  .table--stack tr, .table--stack th, .table--stack td { display: block; }
  .table--stack thead { display: none; }
  .table--stack tr {
    margin-bottom: .6rem;
    padding: .6rem .75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
  }
  .table--stack td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .2rem 0;
    border: 0;
    text-align: right;
  }
  .table--stack td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-faint);
    text-align: left;
  }
  .table--stack td[data-label=""]::before { content: none; }
  .table--stack .num { text-align: right; }
  .table-wrap { margin: 0; padding: 0; }
}

/* ---- bars --------------------------------------------------------------- */

/* The one piece of chart in the whole interface, and it is a bar inside a
   table cell. A column of numbers already says how much; the bar says which
   Friday was the big one without anyone reading twelve of them. */
.bar {
  min-width: 80px;
  height: 8px;
  border-radius: 99px;
  background: var(--surface-sunk);
  overflow: hidden;
}
.bar span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--citrus);
}
@media (max-width: 699px) { .bar { display: none; } }

/* ---- badges ------------------------------------------------------------ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .1rem .45rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-sunk);
  color: var(--ink-soft);
}
.badge--ok { background: var(--lime-soft); color: var(--lime); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--alert { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--citrus-soft); color: var(--citrus); }
.badge--mute { text-decoration: line-through; }

/* ---- buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem .85rem;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-sunk); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary {
  background: var(--citrus);
  border-color: var(--citrus);
  color: #fff;
}
.btn--primary:hover { background: #c25e05; border-color: #c25e05; }
@media (prefers-color-scheme: dark) {
  .btn--primary { color: #241c14; }
  .btn--primary:hover { background: #ffb066; border-color: #ffb066; }
}

.btn--danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn--danger:hover { background: var(--danger-soft); }

.btn--ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn--ghost:hover { background: var(--surface-sunk); color: var(--ink); }

.btn--sm { min-height: 32px; padding: .25rem .6rem; font-size: .8rem; }
.btn--block { width: 100%; }

.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---- forms ------------------------------------------------------------- */

.field { margin-bottom: .9rem; }
.field:last-child { margin-bottom: 0; }

.field > label, .label {
  display: block;
  margin-bottom: .25rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.input, .select, .textarea {
  width: 100%;
  padding: .55rem .65rem;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* iOS zooms into anything smaller on focus. */
}
.textarea { min-height: 76px; resize: vertical; }
.select {
  appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b5c4d' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .7rem center;
}
.input:disabled, .select:disabled { background: var(--surface-sunk); color: var(--ink-faint); }

.input--money, .input--num { text-align: right; font-variant-numeric: tabular-nums; }

.field__hint { margin-top: .25rem; font-size: .78rem; color: var(--ink-faint); }
.field__error { margin-top: .25rem; font-size: .78rem; color: var(--danger); font-weight: 500; }
.field--invalid .input, .field--invalid .select, .field--invalid .textarea { border-color: var(--danger); }

.check {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem 0;
  font-size: .9rem;
  cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--citrus); flex: 0 0 auto; }

.form-row { display: grid; gap: .9rem; }
@media (min-width: 600px) {
  .form-row--2 { grid-template-columns: repeat(2, 1fr); }
  .form-row--3 { grid-template-columns: repeat(3, 1fr); }
}

fieldset { margin: 0 0 1rem; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: .5rem; font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); }

/* ---- repeating lines (order items, recipe inputs, purchase items) ------- */

.line {
  display: grid;
  grid-template-columns: 1fr 5.5rem 7rem auto;
  gap: .5rem;
  align-items: end;
  padding: .5rem 0;
  border-bottom: 1px solid var(--line);
}
.line:last-child { border-bottom: 0; }
.line .field { margin: 0; min-width: 0; }
.line__drop { align-self: center; color: var(--ink-faint); }
.line__drop:hover { color: var(--danger); }

/* On a phone the product gets the full width and the numbers sit under it.
   A 4-column grid squeezed into 360px makes the product name unreadable,
   which is the one field that has to be read. */
@media (max-width: 599px) {
  .line {
    grid-template-columns: 1fr 1fr auto;
    grid-template-areas: "main main drop" "qty price .";
    padding: .75rem 0;
  }
  .line__main { grid-area: main; }
  .line__qty { grid-area: qty; }
  .line__price { grid-area: price; }
  .line__drop { grid-area: drop; align-self: start; }
}

/* ---- filter bar -------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .6rem;
  margin-bottom: 1rem;
  padding: .75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.filters .field { margin: 0; flex: 1 1 9rem; min-width: 0; }
.filters .btn { flex: 0 0 auto; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chip {
  padding: .3rem .7rem;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--surface);
}
.chip:hover { text-decoration: none; background: var(--surface-sunk); }
.chip[aria-current="true"] { background: var(--citrus); border-color: var(--citrus); color: #fff; }
@media (prefers-color-scheme: dark) { .chip[aria-current="true"] { color: #241c14; } }

/* ---- flash and callouts ------------------------------------------------ */

.flash {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .7rem .85rem;
  margin-bottom: 1rem;
  border: 1px solid var(--lime);
  border-radius: var(--radius-sm);
  background: var(--lime-soft);
  color: var(--lime);
  font-size: .875rem;
  font-weight: 500;
}
.flash--alert { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.flash--warn { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.flash pre { margin: 0; font-family: inherit; white-space: pre-wrap; }

.callout {
  padding: .7rem .85rem;
  border-left: 3px solid var(--citrus);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--citrus-soft);
  font-size: .85rem;
}

.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ink-soft);
}
.empty strong { display: block; margin-bottom: .25rem; color: var(--ink); }

/* ---- chat --------------------------------------------------------------- */

/* It looks like WhatsApp because it IS the WhatsApp conversation, on the same
   number and in the same thread. Making it look like a form would hide that. */
.chat {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-height: 60vh;
  overflow-y: auto;
  padding: .25rem;
}

.chat__line { display: flex; }
.chat__line--user { justify-content: flex-end; }

.chat__bubble {
  max-width: min(88%, 40rem);
  padding: .5rem .7rem;
  border-radius: var(--radius);
  background: var(--surface-sunk);
  font-size: .9rem;
}
.chat__line--user .chat__bubble {
  background: var(--citrus-soft);
  border: 1px solid var(--citrus-line);
}
.chat__bubble pre {
  margin: 0;
  font-family: inherit;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat__when { margin-top: .2rem; font-size: .7rem; color: var(--ink-faint); }

/* ---- misc -------------------------------------------------------------- */

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: .8rem; }
.num-cell { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: .5rem; }
.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.ref { font-family: var(--mono); font-size: .8rem; color: var(--ink-faint); }
.negative { color: var(--danger); }
.positive { color: var(--lime); }

.divider { height: 1px; margin: 1rem 0; background: var(--line); border: 0; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- login ------------------------------------------------------------- */

.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: var(--paper);
}
.login__box { width: 100%; max-width: 360px; }
.login__brand { text-align: center; margin-bottom: 1.25rem; }
.login__brand h1 { font-size: 1.2rem; }
.login__brand p { margin-top: .2rem; font-size: .85rem; color: var(--ink-soft); }
.login__mark { font-size: 2rem; line-height: 1; }
