/*
 * Espresso & Cake — "the awning".
 * The venue's facade is black and white; each business brings its own color (businesses.color,
 * set on an element as --biz). The striped awning on top; each business's section drawn like the
 * venue's window (awning, black frame, white sill). Everything else is quiet.
 */

:root {
  --ink: #000000;
  --paper: #ffffff;
  --line: #e4e4e4;
  --soft: #f5f5f5;
  --muted: #6b6b6b;
  --alert: #d7263d;
  --ok: #1c7c54;
  --biz: #e4e4e4; /* overridden per business */
  --biz-text: var(--ink); /* a tint of --biz that reads on it (TextColor); only for text on --biz */
  --biz-shade: var(--ink); /* --biz's hue, way darker (TextColor.shade); for borders */

  --font-display: "Shrikhand", "Georgia", serif;
  --font-body: "Bricolage Grotesque", system-ui, sans-serif;

  --radius-pill: 999px;
  --radius-box: 14px;
  --page: 72rem;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--font-body);
  font-optical-sizing: auto;
}

main.page {
  max-width: var(--page);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ---------- Type ---------- */

h1, h2, h3 { font-weight: 400; line-height: 1.15; margin: 0 0 0.75rem; }
h1 { font: 400 2.6rem/1.1 var(--font-display); letter-spacing: 0.01em; margin-bottom: 1.25rem; }
h1:has(+ .lede) { margin-bottom: 0.4rem; }
.lede { color: var(--muted); font-size: 1.1rem; margin-bottom: 1.5rem; }
h2 { font: 700 1.35rem/1.2 var(--font-body); margin-top: 2rem; }
h3 { font: 700 1.05rem/1.3 var(--font-body); }
p { margin: 0 0 0.9rem; max-width: 70ch; }

a { color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--muted); }

.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.negative { color: var(--alert); font-weight: 700; }
.positive { color: var(--ok); font-weight: 700; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

/* ---------- Header: the black bar and the awning ---------- */

.topbar {
  background: var(--ink);
  color: var(--paper);
}

.topbar-inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.brand {
  font: 400 1.6rem/1 var(--font-display);
  color: var(--paper);
  text-decoration: none;
  white-space: nowrap;
}

.nav { display: flex; gap: 0.35rem; align-items: center; flex: 1; flex-wrap: wrap; }
.nav a {
  color: var(--paper);
  text-decoration: none;
  font-weight: 600;
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-pill);
}
.nav a:hover { background: #2a2a2a; }
.nav a[aria-current="page"] { background: var(--paper); color: var(--ink); }

.user { display: flex; gap: 0.75rem; align-items: center; color: #bdbdbd; white-space: nowrap; }
.user-name { color: #bdbdbd; text-decoration: none; }
.user-name:hover { color: var(--paper); text-decoration: underline; }
.user form { margin: 0; }
.user button {
  background: transparent;
  color: var(--paper);
  border: 2px solid #555;
  padding: 0.25rem 0.8rem;
  margin: 0;
  font-size: 0.9rem;
}
.user button:hover { border-color: var(--paper); }

/* Stripes with a scalloped bottom edge, like the facade's awning. The wrapper's shadow draws
   the black edge under the white scallops (a filter on the masked element itself would be cut off). */
.awning-edge { filter: drop-shadow(0 3px 0 var(--ink)); }
.awning {
  height: 46px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 44px, var(--paper) 44px 88px);
  -webkit-mask: radial-gradient(22px at 22px 24px, #000 98%, transparent) 0 0 / 44px 100% repeat-x,
                linear-gradient(#000 0 0) top / 100% 24px no-repeat;
          mask: radial-gradient(22px at 22px 24px, #000 98%, transparent) 0 0 / 44px 100% repeat-x,
                linear-gradient(#000 0 0) top / 100% 24px no-repeat;
}

/* ---------- Flash ---------- */

.flash {
  max-width: var(--page);
  margin: 1rem auto 0;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-box);
  border: 2px solid var(--ink);
  font-weight: 600;
}
.flash.notice { background: var(--paper); }
.flash.notice::before { content: "☕ "; }
.flash.success { background: #e3f4ea; border-color: var(--ok); color: #0f4a31; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.flash.success > div::before { content: "☕ "; }
.flash-link { color: inherit; font-weight: 800; white-space: nowrap; }
.flash-highlight { display: block; margin-top: 0.3rem; font: 400 1.9rem/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.flash.alert { background: #fff0f2; border-color: var(--alert); color: #8a1324; }
.flash-wrap { padding: 0 1.5rem; }

.errors {
  background: #fff0f2;
  border: 2px solid var(--alert);
  color: #8a1324;
  border-radius: var(--radius-box);
  padding: 0.75rem 1.1rem;
  margin-bottom: 1.25rem;
}
.errors p { margin: 0 0 0.35rem; font-weight: 700; }
.errors ul { margin: 0; padding-left: 1.2rem; }

/* ---------- Buttons & links that act ---------- */

button, input[type="submit"], .button {
  font: 600 1rem/1.2 var(--font-body);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-pill);
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  margin: 0;
}
button:hover, .button:hover { background: var(--soft); }
button:disabled { opacity: 0.35; cursor: default; }

input[type="submit"], .button.primary {
  background: var(--ink);
  color: var(--paper);
}
input[type="submit"]:hover, .button.primary:hover { background: #333; }

.actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin: 0 0 1.5rem; }
.actions form { margin: 0; }
.form + .actions { margin-top: 1rem; }

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

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  margin: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px var(--soft); }
input:disabled { background: var(--soft); color: #aaa; border-color: #cfcfcf; }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--ink); vertical-align: -0.15rem; }

input[type="text"], input[type="password"], input[type="email"], input[type="date"],
input[type="datetime-local"], textarea, select { width: 100%; }

.form { max-width: 40rem; }
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 700; margin-bottom: 0.3rem; }
.field input[type="checkbox"] + label { display: inline; font-weight: 600; margin-left: 0.35rem; }

fieldset {
  border: 2px solid var(--line);
  border-radius: var(--radius-box);
  padding: 1rem 1.2rem 1.2rem;
  margin: 0 0 1.25rem;
}
legend { font-weight: 800; padding: 0 0.4rem; }

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

table { width: 100%; border-collapse: collapse; margin-bottom: 1.25rem; }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { font-size: 0.9rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--ink); }
tfoot th { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 800; }
tbody tr:hover { background: #fafafa; }
.table-scroll { overflow-x: auto; }

/* Tables of the same kind line up from one business section to the next. */
.business table { table-layout: fixed; }
.col-money { width: 9rem; }
.col-count { width: 8rem; }
.col-status { width: 8rem; }
.col-plus { width: 4rem; }
.col-edit { width: 6rem; }

/* ---------- The books: a business and its color ---------- */

/* Each business's section is drawn like the venue's window ("la ventanilla"): a solid black
   awning with its name in spaced capitals, a thick black frame, and a white sill underneath.
   The awning is in the business color. */
.business {
  --frame: 7px;
  --overhang: 12px;
  position: relative;
  margin: 2.75rem 0 2.5rem;
  border: var(--frame) solid var(--ink);
  border-top: 0;
  background: var(--paper);
}
.business > table { margin-bottom: 0; }
.business > p { margin: 0; padding: 1rem 1.2rem; }

/* The awning, in the business color: slightly wider than the window, its face sloping outward.
   Two clipped layers draw it: black underneath, the color 2px inside, so the black shows as an
   outline (a white business still shows on the white page). */
.business-tag {
  position: relative;
  isolation: isolate;
  margin: 0 calc(-1 * (var(--frame) + var(--overhang)));
  padding: 0.9rem 4rem;
  color: var(--biz-text);
  font: 700 1rem/1.2 var(--font-body);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-align: center;
}
.business-tag::before,
.business-tag::after {
  content: "";
  position: absolute;
  z-index: -1;
  clip-path: polygon(var(--overhang) 0, calc(100% - var(--overhang)) 0, 100% 100%, 0 100%);
}
.business-tag::before { inset: 0; background: var(--ink); }
.business-tag::after { inset: 2px; background: var(--biz); }

/* The sill: a white ledge outlined in black, wider than the frame. */
.business::after {
  content: "";
  position: absolute;
  left: calc(-1 * (var(--frame) + var(--overhang)));
  right: calc(-1 * (var(--frame) + var(--overhang)));
  bottom: calc(-1 * var(--frame) - 14px);
  height: 14px;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}

/* A strip of the business color on the left of each of its rows, between the window frame and a
   thin black line, so a white business shows as white, not as nothing. */
.business tbody tr td:first-child:not(.grip) {
  box-shadow: inset 5px 0 0 var(--biz), inset 6.5px 0 0 var(--ink);
  padding-left: 1.2rem;
}

/* In lists that can be reordered (products, supplies), the strip is a wider column of its own:
   the grip. Where the viewer may reorder, it's the handle: dotted in the business's text color,
   move cursor, focusable (arrow keys move the row). */
.grip-col { width: 1.5rem; }
.business tbody td.grip { width: 1.5rem; padding: 0; background-color: var(--biz); box-shadow: inset -1.5px 0 0 var(--ink); }
.business tbody td.grip.handle {
  cursor: move;
  touch-action: none;
  background-image: radial-gradient(circle, var(--biz-text) 1.4px, transparent 1.9px);
  background-size: 7px 7px;
  background-position: center;
}
.business tbody td.grip.handle:hover, .business tbody td.grip.handle:focus-visible { background-size: 6px 6px; }
.business tbody td.grip.handle:focus-visible { outline-offset: -3px; }

/* The businesses themselves are dragged by their awning (products page, for who may arrange them).
   While dragging, every section folds down to its awning, a see-through copy of the awning follows
   the pointer, and an awning-size slot in the dragged business's colors shows where it lands. */
.business-tag.handle { cursor: move; touch-action: none; user-select: none; -webkit-user-select: none; }
.business-tag.handle:focus-visible { outline-offset: 4px; }
.business-list.sorting { cursor: move; user-select: none; -webkit-user-select: none; }
.business-list.sorting .business { margin-bottom: 1.25rem; }
.business-list.sorting .business > :not(.business-tag) { display: none; }
.business-ghost { --frame: 7px; --overhang: 12px; position: fixed; top: 0; left: 0; z-index: 50; opacity: 0.7; pointer-events: none; filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.25)); }
.business-ghost .business-tag { margin-bottom: 0; }
.business-slot { margin: 2.75rem calc(-7px - 12px) 1.25rem; }
.business-slot .drop-slot-box { height: 3.2rem; }
tbody[data-controller~="sortable"].dragging { cursor: move; user-select: none; -webkit-user-select: none; }

/* While dragging: a see-through copy of the row under the pointer… */
.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  margin: 0;
  table-layout: fixed;
  opacity: 0.7;
  pointer-events: none;
  background: var(--paper);
  outline: 2px solid var(--ink);
  border-radius: 6px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.22), 0 3px 0 var(--ink);
}
.drag-ghost td { border-bottom: 0; }
/* …and a dashed slot where it will land. */
.business tbody tr.drop-slot td:first-child { padding: 4px 6px; box-shadow: none; }
tr.drop-slot:hover { background: none; }
.drop-slot-box {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--ink);
  border-radius: 10px;
  background: repeating-linear-gradient(-45deg, var(--biz) 0 8px, var(--biz-text) 8px 16px);
  opacity: 0.45; /* a hint of where it lands, quieter than the row being dragged */
}
/* The label sits on a patch of the business color, so it reads over the stripes. */
.drop-slot-box span {
  background: var(--biz);
  color: var(--biz-text);
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.9rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.85rem;
}

/* A small dot of color next to a business name. */
.swatch {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--biz);
  border: 2px solid var(--ink);
  vertical-align: -0.05rem;
  margin-right: 0.4rem;
}

/* A sold item in its business color: "2× Latte". */
.chip {
  display: inline-block;
  background: var(--biz);
  color: var(--biz-text);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-pill);
  padding: 0.1rem 0.65rem;
  margin: 0.1rem 0.15rem 0.1rem 0;
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Small pieces ---------- */

.move-col { width: 6rem; white-space: nowrap; }

.thumb-col { width: 4.5rem; }
.thumb { width: 3.5rem; height: 3.5rem; object-fit: cover; border-radius: 10px; display: block; }

.status { font-size: 0.88rem; font-weight: 700; padding: 0.15rem 0.65rem; border-radius: var(--radius-pill); border: 1.5px solid var(--ink); }
.status.hidden { border-style: dashed; color: var(--muted); border-color: var(--muted); }

.note { display: block; font-size: 0.85rem; color: var(--muted); }
.available { display: block; font-size: 0.85rem; color: var(--muted); }
.available.none { color: var(--alert); font-weight: 700; }
tr.sold-out td { color: #a5a5a5; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.5rem; }
dl.facts dt { font-weight: 700; }
dl.facts dd { margin: 0; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.gallery img { width: 100%; height: auto; border-radius: var(--radius-box); display: block; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: 0.75rem; }
.photo-grid figure { margin: 0; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; }
.photo-grid figcaption { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.35rem; font-size: 0.9rem; }
.photo-grid button { width: 100%; justify-content: center; padding: 0.35rem; }

.qty { width: 5.5rem; text-align: right; }

/* The sale form's quantity: the number (typed by hand too), + (solid, the business's color) and
   − (solid red), both signs in the business's text tint, bordered in its shade. − hides at zero but keeps its place. */
.stepper { display: inline-flex; align-items: center; gap: 0.4rem; }
.stepper .qty { width: 4rem; text-align: right; padding-inline: 0.5rem; -moz-appearance: textfield; appearance: textfield; }
.stepper .qty::-webkit-outer-spin-button, .stepper .qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .step {
  width: 2.5rem; height: 2.5rem; padding: 0; justify-content: center;
  border-radius: 10px; font-size: 1.4rem; font-weight: 800; line-height: 1; touch-action: manipulation;
}
.stepper .more { background: var(--biz); border-color: var(--biz-shade); color: var(--biz-text); }
.stepper .more:hover { background: var(--biz); filter: brightness(0.92); }
.stepper .less { background: var(--alert); border-color: var(--biz-shade); color: var(--biz-text); }
.stepper .less:hover { background: #b51f33; }
.stepper[data-empty] .less { visibility: hidden; }

/* ---------- Product form: supplies it uses ---------- */

.supply-use-row { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.6rem; }
.supply-use-row { flex-wrap: wrap; }
.supply-use-row select, .supply-use-row input[type="text"] { flex: 1 1 auto; min-width: 0; }
/* "Nuevo insumo", the last option of a row's select. */
.new-supply-option { font-weight: 800; }
/* A new supply's first count, on its own line under its name. */
.new-supply-count { flex-basis: 100%; display: flex; align-items: center; gap: 0.5rem; padding-left: 0.25rem; font-size: 0.92rem; color: var(--muted); }
.supply-use-row select, .supply-use-row input[type="text"] { flex: 1; width: auto; min-width: 0; }
.supply-use-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.new-tag { font-size: 0.8rem; font-weight: 700; padding: 0.1rem 0.6rem; border: 1.5px dashed var(--ink); border-radius: var(--radius-pill); }
.own-supply { background: var(--soft); border-radius: 10px; padding: 0.8rem 1rem; }
.own-supply p { margin: 0.35rem 0 0.6rem; }

/* ---------- Sales: period tabs and date nav ---------- */

.period-tabs { display: inline-flex; gap: 0; border: 2px solid var(--ink); border-radius: var(--radius-pill); overflow: hidden; margin-bottom: 1rem; }
.period-tabs a { padding: 0.45rem 1.1rem; text-decoration: none; font-weight: 600; }
.period-tabs a + a { border-left: 2px solid var(--ink); }
.period-tabs a.current { background: var(--ink); color: var(--paper); }

.date-nav { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem; }
.date-nav > a { font-size: 1.3rem; text-decoration: none; padding: 0.1rem 0.6rem; border-radius: var(--radius-pill); border: 2px solid var(--ink); }
.date-nav form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.date-nav input[type="date"] { width: auto; }
.period-label { font: 400 1.5rem/1.2 var(--font-display); margin: 0.5rem 0 1.5rem; }

/* Gross sales per business: one colored tile each, the books side by side. */
.totals { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.total-tile {
  background: var(--biz);
  color: var(--biz-text);
  border: 2px solid var(--ink);
  border-radius: var(--radius-box);
  padding: 0.9rem 1.2rem;
  min-width: 13rem;
}
.total-tile .label { font-weight: 700; }
.total-tile .amount { font: 400 2rem/1.1 var(--font-display); display: block; margin-top: 0.25rem; font-variant-numeric: tabular-nums; }
/* The all-businesses tile stays plain, so it never looks like one business's tile. */
.total-tile.all { background: var(--paper); color: var(--ink); border-style: double; border-width: 6px; }

.breakdown th.biz-col { background: var(--biz); color: var(--biz-text); text-align: right; border: 1.5px solid var(--ink); border-bottom-width: 2px; }
.breakdown tr.empty td { color: #b0b0b0; }

/* ---------- Sale form: products left, the ticket right ---------- */

.sale-layout { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 2.5rem; align-items: start; }
.ticket {
  position: sticky;
  top: 1rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius-box);
  padding: 1.2rem 1.3rem;
  background: var(--paper);
}
.ticket h2 { margin-top: 0; font: 400 1.5rem/1.2 var(--font-display); }
.ticket-total { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px dashed var(--ink); padding-bottom: 0.75rem; margin-bottom: 1rem; }
.ticket-total strong { font: 400 2.2rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
/* Payments on 5 columns: the label takes 3, the amount 2. */
.payment-field { display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; gap: 0.45rem; margin-bottom: 0.6rem; }
.payment-field label { grid-column: span 3; }
.payment-field input { grid-column: span 2; width: 100%; min-width: 0; padding-inline: 0.5rem; text-align: right; }
.payment-field label { font-weight: 700; }
.ticket input[type="submit"] { width: 100%; justify-content: center; font-size: 1.1rem; padding: 0.8rem; margin-top: 0.5rem; }
.ticket fieldset { border: 0; padding: 0; margin: 0 0 0.75rem; }
.ticket legend { padding: 0; margin-bottom: 0.5rem; }
.remaining { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; margin: -0.25rem 0 1.25rem; }
.remaining strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.remaining.due strong { color: var(--alert); }
.remaining.change strong { color: var(--ok); }

/* Quick cash, under "Efectivo": coins (cover what's left) and little greenback-style bills. */
.cash-quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; margin: -0.15rem 0 0.9rem; }
.cash-quick button {
  position: relative; height: 2.6rem; padding: 0; justify-content: center; border-radius: 6px;
  touch-action: manipulation; transition: transform 0.1s;
}
.cash-quick button:hover { transform: translateY(-1px) rotate(-1deg); }
.cash-quick button:active { transform: scale(0.96); }
.bill {
  --bill-ink: #2f6b3a;
  border: 2px solid var(--bill-ink);
  color: var(--bill-ink);
  background:
    repeating-linear-gradient(45deg, transparent 0 4px, rgb(47 107 58 / 0.06) 4px 5px),
    linear-gradient(135deg, #d9efd0, #b9dfaa);
  box-shadow: inset 0 0 0 2px #eef8e9, inset 0 0 0 3px rgb(47 107 58 / 0.55);
}
.bill:hover { background:
    repeating-linear-gradient(45deg, transparent 0 4px, rgb(47 107 58 / 0.06) 4px 5px),
    linear-gradient(135deg, #cfe9c4, #addb9c); }
/* The value in the corners, like a real bill; the center oval is the "portrait". */
.bill::before, .bill::after { content: attr(data-value); position: absolute; font-size: 0.55rem; font-weight: 800; line-height: 1; }
.bill::before { top: 4px; left: 5px; }
.bill::after { bottom: 4px; right: 5px; }
.bill span {
  font: 400 0.95rem/1 var(--font-display);
  padding: 0.2rem 0.5rem; border-radius: 50%;
  background: radial-gradient(ellipse at center, #f2faee 55%, #cfe9c4 100%);
  border: 1px solid rgb(47 107 58 / 0.5);
}
.coins { border: 2px solid #8a6a10; background: linear-gradient(135deg, #fff7dc, #fbe8a6); }
.coins:hover { background: linear-gradient(135deg, #fff2c8, #f8df8a); }
.coins svg { width: 2.4rem; height: auto; }
.coins svg ellipse, .coins svg circle { fill: #f4c542; stroke: #8a6a10; stroke-width: 1.4; }
.coins svg .rim { fill: none; stroke-width: 1; }
.hint { font-size: 0.88rem; }

.sale-total { font-size: 1.15rem; }

/* Lists shown a page at a time (application/_pager), swapped in place. */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin: -0.25rem 0 1.5rem; }
.pager .button { padding: 0.4rem 1rem; }
.pager .button.disabled { opacity: 0.3; cursor: default; }
.pager .button.disabled:hover { background: var(--paper); }
.pager-where { color: var(--muted); font-variant-numeric: tabular-nums; }
turbo-frame.paged { display: block; }
turbo-frame.paged[aria-busy="true"] { opacity: 0.5; transition: opacity 0.15s; }

/* ---------- Dashboard ---------- */

.hello { font-size: 3.2rem; margin-bottom: 0.4rem; }
.hello + p { font-size: 1.15rem; color: var(--muted); margin-bottom: 1.75rem; }
.big-action { font-size: 1.2rem; padding: 0.9rem 1.6rem; }

/* ---------- Login ---------- */

.login { max-width: 24rem; margin: 3rem auto; }
.login h1 { text-align: center; font-size: 3rem; }
.login input[type="submit"] { width: 100%; justify-content: center; }

@media (max-width: 860px) {
  .sale-layout { grid-template-columns: minmax(0, 1fr); }
  .ticket { position: static; }
  .topbar-inner { flex-wrap: wrap; gap: 0.75rem; }
  h1 { font-size: 2.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

.add-stock { display: inline-flex; padding: 0.05rem 0.6rem; border: 1.5px solid var(--ink); border-radius: var(--radius-pill); text-decoration: none; font-weight: 800; }
.add-stock:hover { background: var(--biz); color: var(--biz-text); }
.qty-col { width: 11rem; white-space: nowrap; }

.field-hint { display: block; margin-top: 0.35rem; }
input[type="file"] { width: 100%; border-style: dashed; }

/* ---------- Product form: details left; on sale and photos right ---------- */

.product-form { max-width: none; display: grid; grid-template-columns: minmax(0, 40rem) minmax(0, 1fr); gap: 1rem 3rem; align-items: start; }
.product-form > .errors { grid-column: 1 / -1; }
.product-form-side { position: sticky; top: 1rem; }

/* On sale or hidden, as one big switch. */
.on-sale-toggle { width: 100%; justify-content: center; padding: 0.85rem 1.2rem; font-size: 1.15rem; border-style: dashed; color: var(--muted); border-color: var(--muted); }
.on-sale-toggle::before { content: ""; width: 0.75rem; height: 0.75rem; border-radius: 50%; border: 2px solid currentColor; }
.on-sale-toggle[aria-pressed="true"] { background: var(--ink); color: var(--paper); border: 2px solid var(--ink); }
.on-sale-toggle[aria-pressed="true"]::before { background: var(--ok); border-color: var(--paper); }
.on-sale-toggle[aria-pressed="true"]:hover { background: #333; }
.on-sale-field .field-hint { margin-top: 0.4rem; }

@media (max-width: 860px) {
  .product-form { grid-template-columns: 1fr; }
  .product-form-side { position: static; }
}

/* ---------- Adding photos, one at a time, previewed (photos/_upload_field) ---------- */

.field-label { font-weight: 700; margin: 0 0 0.3rem; }
/* Saved photos and new picks in one grid, in order; the first (the cover) takes four cells. */
.photo-picks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-flow: dense; gap: 0.6rem; margin-bottom: 0.75rem; }
.photo-picks:empty { display: none; }
/* The four-arrows "move" cursor says it can be dragged; the buttons keep the normal pointer. */
.photo-pick { position: relative; margin: 0; cursor: move; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 12px; }
.photo-pick:first-child { grid-column: span 2; grid-row: span 2; }
.photo-pick img { width: 100%; height: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 2px solid var(--ink); display: block; -webkit-user-drag: none; }
.photo-picks.dragging { cursor: move; } /* the grid holds the pointer while dragging */
/* While dragging: a see-through copy of the photo under the pointer, and a slot where it lands
   (striped in the business colors, like the lists' "Suelta aquí"). */
.photo-pick.photo-ghost { position: fixed; top: 0; left: 0; z-index: 50; opacity: 0.7; pointer-events: none; box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25); }
.photo-pick.photo-ghost .cover-tag { display: none; }
.photo-slot { cursor: move; }
.photo-slot .drop-slot-box { aspect-ratio: 1; height: 100%; padding: 0.4rem; text-align: center; }
.photo-slot:not(:first-child) .drop-slot-box span { font-size: 0.62rem; letter-spacing: 0.06em; padding: 0.1rem 0.45rem; border-width: 1.5px; }
.photo-pick figcaption { position: absolute; left: 0.35rem; right: 0.35rem; bottom: 0.35rem; display: flex; justify-content: space-between; align-items: center; gap: 0.3rem; }
.photo-pick figcaption .new-tag { background: var(--paper); }
.photo-pick button { margin-left: auto; padding: 0.1rem 0.55rem; font-size: 0.8rem; }
.photo-pick .cover-tag { display: none; position: absolute; top: 0.45rem; left: 0.45rem; background: var(--ink); color: var(--paper); font-size: 0.8rem; font-weight: 700; padding: 0.1rem 0.6rem; border-radius: var(--radius-pill); }
.photo-pick:first-child .cover-tag { display: inline-block; }
.field label.button { display: inline-flex; margin-bottom: 0; }
.field label.button[hidden] { display: none; }
label.button:focus-within { outline: 3px solid var(--ink); outline-offset: 2px; }
.photo-error { color: var(--alert); font-weight: 700; margin: 0.5rem 0 0; }
.photo-picker .field-hint { margin-top: 0.5rem; }

/* Hidden from sight, still reachable by keyboard and screen readers. */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Phones: wide tables scroll inside themselves instead of widening the page. */
@media (max-width: 640px) {
  main.page { padding: 1.5rem 1rem 3rem; }
  table { display: block; overflow-x: auto; }
  .business table { table-layout: auto; }
  .period-tabs { display: flex; flex-wrap: wrap; border-radius: var(--radius-box); }
  .total-tile { min-width: 0; flex: 1 1 9rem; }
}

/* ---------- Phones ---------- */

@media (max-width: 640px) {
  /* Top bar: the brand and "Cerrar sesión" on one row; the sections below, as even tabs. */
  .topbar-inner { display: grid; grid-template-columns: 1fr auto; gap: 0.6rem; padding: 0.7rem 1rem 0.6rem; }
  .brand { font-size: 1.35rem; align-self: center; }
  .brand { font-size: 1.2rem; }
  .user { gap: 0.5rem; }
  .user-name { font-size: 0.9rem; }
  .user button { padding: 0.2rem 0.7rem; font-size: 0.85rem; }
  .nav { grid-column: 1 / -1; order: 3; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.25rem; }
  .nav a { text-align: center; padding: 0.4rem 0.2rem; font-size: 0.92rem; }

  /* The sale form: each product is a card row: photo | name, what's left and price | quantity. */
  .business { --overhang: 6px; --frame: 5px; }
  .business-tag { padding: 0.7rem 1rem; }
  .sale-products table, .sale-products tbody { display: block; overflow: visible; }
  .sale-products tr {
    display: grid; grid-template-columns: 3rem minmax(0, 1fr) auto;
    grid-template-areas: "thumb name qty" "thumb price qty";
    align-items: center; column-gap: 0.6rem; row-gap: 0.1rem;
    padding: 0.6rem 0.7rem 0.6rem 1.1rem; border-bottom: 1px solid var(--line);
    box-shadow: inset 5px 0 0 var(--biz), inset 6.5px 0 0 var(--ink); /* the business strip, on the row */
  }
  .sale-products tr:last-child { border-bottom: 0; }
  .sale-products td, .sale-products .business tbody tr td:first-child:not(.grip) { padding: 0; border: 0; width: auto; box-shadow: none; }
  .sale-products .thumb-col { grid-area: thumb; }
  .sale-products .name-col { grid-area: name; align-self: end; }
  .sale-products .price-col { grid-area: price; align-self: start; text-align: left; font-weight: 700; }
  .sale-products .qty-col { grid-area: qty; }
  .sale-products .thumb { width: 3rem; height: 3rem; }
  .stepper { gap: 0.3rem; }
  .stepper .qty { width: 2.9rem; }

  .ticket { padding: 1rem; }

  /* Tables: tighter cells; times and links that shouldn't break stay on one line. */
  th, td { padding: 0.5rem 0.5rem; }
  table.sales td:first-child, table.movements td:first-child, table.movements a { white-space: nowrap; }
  table.movements td:first-child { font-size: 0.88rem; }

  /* Period tabs: all five on one row. */
  .period-tabs { display: flex; flex-wrap: nowrap; border-radius: var(--radius-pill); }
  .period-tabs a { flex: 1 1 auto; text-align: center; padding: 0.45rem 0.4rem; font-size: 0.82rem; }

  /* Pager: where we are on top, the two buttons side by side under it. */
  .pager { display: grid; grid-template-columns: 1fr 1fr; }
  .pager-where { grid-column: 1 / -1; grid-row: 1; text-align: center; }
  .pager .button { justify-content: center; }

  /* A sale's items: name and subtotal, then business, quantity × price. */
  table.sale-items, table.sale-items tbody { display: block; }
  table.sale-items thead { display: none; }
  table.sale-items tr {
    display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "name name name subtotal" "business quantity price .";
    align-items: center; gap: 0.3rem 0.4rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line);
  }
  table.sale-items td { padding: 0; border: 0; }
  table.sale-items .item-name { grid-area: name; font-weight: 700; }
  table.sale-items .item-subtotal { grid-area: subtotal; font-weight: 700; }
  table.sale-items .item-business { grid-area: business; }
  table.sale-items .item-quantity { grid-area: quantity; color: var(--muted); }
  table.sale-items .item-price { grid-area: price; text-align: left; color: var(--muted); }
  table.sale-items .item-price::before { content: "× "; }

  /* The products list: grip | photo | name, then price and status | how many can be made. */
  table.products-list, table.products-list tbody { display: block; overflow: visible; }
  table.products-list thead { display: none; }
  table.products-list tr {
    display: grid; grid-template-columns: 1.5rem 3rem auto minmax(0, 1fr) auto;
    grid-template-areas: "grip thumb name name available" "grip thumb price status available";
    align-items: center; column-gap: 0.6rem; border-bottom: 1px solid var(--line);
  }
  table.products-list td, .business table.products-list tbody tr td:first-child:not(.grip) { padding: 0; border: 0; width: auto; box-shadow: none; }
  table.products-list td.grip { grid-area: grip; align-self: stretch; }
  table.products-list .thumb-col { grid-area: thumb; padding: 0.55rem 0; }
  table.products-list .thumb { width: 3rem; height: 3rem; }
  table.products-list .name-col { grid-area: name; align-self: end; padding-top: 0.55rem; }
  table.products-list .price-col { grid-area: price; align-self: start; text-align: left; padding-bottom: 0.55rem; }
  table.products-list .status-col { grid-area: status; align-self: start; padding-bottom: 0.55rem; }
  table.products-list .status { font-size: 0.75rem; padding: 0.05rem 0.5rem; }
  table.products-list .available-col { grid-area: available; padding-right: 0.7rem; font-weight: 700; }
  table.products-list .available-col::before { content: attr(data-label); display: block; font-size: 0.7rem; font-weight: 600; color: var(--muted); }
  table.products-list tr.drop-slot td { grid-column: 1 / -1; }

  /* Product form: one column, and "save" last (after on sale and photos). */
  .product-form { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
  .product-form-main { display: contents; }
  .product-form > *, .product-form-main > * { min-width: 0; }
  .product-form-side { order: 1; }
  .product-form input[type="submit"] { order: 2; align-self: flex-start; margin-top: 0.5rem; }
  .supply-use-row .qty { width: 3.5rem; }
  .supply-use-row button { padding: 0.45rem 0.8rem; }
}
