:root {
  --bg: #f6f1ea; --card: #fffdf9; --ink: #2a1a1f; --muted: #7a6a6e; --line: #e6dccf;
  --wine: #6d1a36; --wine-dark: #531228; --gold: #a8843c; --ok: #2f6f4f; --bad: #a3312b;
  --bad-bg: #fbeceb; --ok-bg: #e9f3ed; --chip: #efe6da;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171113; --card: #211a1c; --ink: #f1e8e4; --muted: #a89a9c; --line: #382c2f;
    --wine: #c9567a; --wine-dark: #b3446a; --gold: #cfa95c; --ok: #6cc198; --bad: #ee8a83;
    --bad-bg: #3a1d1c; --ok-bg: #1b3327; --chip: #2e2427;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { display: flex; align-items: center; gap: 10px; font: 600 1.15rem var(--serif);
  color: var(--ink); text-decoration: none; }
.brand small { font: 400 .8rem var(--sans); color: var(--muted); }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--wine); color: #fff; font: 600 1rem var(--serif); }
.demo { font-size: .7rem; letter-spacing: .12em; font-weight: 700; color: var(--gold);
  border: 1px solid var(--gold); border-radius: 4px; padding: 2px 8px; }
.wrap { max-width: 860px; margin: 0 auto; padding: 28px 16px 40px; }
.wrap.wide { max-width: 1280px; }
.wrap.full { max-width: none; }  /* panel lists: the table takes the whole window */
.wrap.full .lead, .wrap.full .hint { max-width: 120ch; }
.eyebrow { margin: 0; color: var(--gold); font-size: .78rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; }
h1 { font: 600 2rem/1.15 var(--serif); margin: 4px 0 8px; text-wrap: balance; }
h2 { font: 600 1.25rem var(--serif); margin: 28px 0 10px; }
.lead { color: var(--muted); margin: 0 0 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .82rem;
  color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ref { display: block; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.qty { width: 76px; text-align: right; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--wine); outline-offset: 2px; }
.field { display: block; margin-top: 16px; font-weight: 600; font-size: .9rem; }
.field input, .field textarea, .field select { display: block; width: 100%; margin-top: 6px; font-weight: 400; }
.opt, .hint { color: var(--muted); font-weight: 400; font-size: .85rem; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 24px; justify-content: end;
  margin: 16px 0 0; max-width: 320px; margin-left: auto; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--muted); } .totals dd { margin: 0; text-align: right; }
.totals .grand { color: var(--ink); font: 600 1.25rem var(--serif); padding-top: 6px;
  border-top: 1px solid var(--line); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.btn { font: 600 1rem var(--sans); border-radius: 8px; padding: 11px 20px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; }
.btn.primary { background: var(--wine); border-color: var(--wine); color: #fff; }
.btn.primary:hover { background: var(--wine-dark); }
.btn.ghost { color: var(--muted); } .btn.ghost:hover { color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.alert, .notice { border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.alert { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); }
.notice { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok); }
.alert p, .notice p { margin: 2px 0; }
.paybox { margin-top: 20px; padding: 14px 16px; border: 1px dashed var(--gold); border-radius: 10px; }
.paybox p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.result { text-align: center; padding: 36px 20px; }
.result table, .result .totals { text-align: left; max-width: 520px; margin-left: auto; margin-right: auto; }
.seal { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: grid;
  place-items: center; font-size: 1.8rem; color: #fff; background: var(--ok); }
.seal-off { background: var(--muted); }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 16px 28px; }

/* admin panel: a sidebar on a computer, a menu button on a phone */
body.panel { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  gap: 4px; padding: 16px 12px; background: var(--card); border-right: 1px solid var(--line); }
.side .brand { padding: 0 6px 10px; font-size: 1.05rem; }
.side .brand small { display: block; font-size: .75rem; }
.side nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.side-sec { display: flex; flex-direction: column; gap: 1px; }
.side-sec:not([open]) > :not(summary) { display: none; }
.side-group { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 0;
  padding: 6px 8px; border-radius: 6px; color: var(--muted); font-size: .85rem; font-weight: 600;
  cursor: pointer; list-style: none; user-select: none; }
.side-group::-webkit-details-marker { display: none; }
.side-group::after { content: "›"; font-size: 1rem; letter-spacing: 0; transition: transform .15s; }
.side-sec[open] > .side-group::after { transform: rotate(90deg); }
.side-group:hover { color: var(--ink); background: var(--bg); }
.side nav a { display: block; margin-top: 1px; padding: 6px 10px; border-radius: 7px; color: var(--ink); text-decoration: none; font-size: .93rem; }
.side nav a:hover { background: var(--bg); }
.side nav a.on { background: var(--chip); font-weight: 600; }
.side nav a.sub { margin-left: 14px; font-size: .88rem; color: var(--muted); }
.side nav a.sub.on { color: var(--ink); }
.company-switch select { width: 100%; padding: 6px 8px; font-size: .9rem; }
.side-foot { padding-top: 12px; }
.mobile-top, .scrim { display: none; }
body.panel .wrap { margin: 0; padding: 24px 28px 40px; }
@media (max-width: 860px) {
  body.panel { display: block; }
  .mobile-top { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20;
    padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
  .mobile-top .brand { font-size: 1rem; }
  .side { position: fixed; z-index: 40; left: 0; top: 0; width: min(280px, 85vw); transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 0 24px rgba(0,0,0,.25); }
  body.menu-open .side { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.35); }
  body.panel .wrap { padding: 16px 12px 32px; }
}
/* a settings page: one card per section, its title inside */
.section { margin-bottom: 18px; }
.section > h2:first-child { margin-top: 0; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.section h3 { font: 600 1rem var(--sans); margin: 18px 0 4px; }
.section .hint { margin: 6px 0 0; }
.section-index { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.section-index a { padding: 3px 12px; border-radius: 999px; background: var(--chip); color: var(--ink);
  text-decoration: none; font-size: .85rem; font-weight: 600; }
.savebar { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px; align-items: center;
  padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.inline { display: inline; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--chip);
  font-size: .8rem; font-weight: 600; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.warn { background: var(--chip); color: var(--gold); font-weight: 600; }
/* Order status: Pendiente is what the office acts on, so it is the one that stands out. */
.chip.pending { background: color-mix(in srgb, var(--gold) 24%, transparent); color: var(--gold); font-weight: 700; }
.chip.review { background: color-mix(in srgb, var(--wine) 20%, transparent); color: var(--wine); font-weight: 700; }
.chip.off { background: none; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; white-space: nowrap; }
.check input { width: 16px; height: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.row .field { margin-top: 0; flex: 1 1 180px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 20px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 4px 20px; }
.copy { display: block; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; font: .9rem ui-monospace, monospace; overflow-wrap: anywhere; user-select: all; }
.mono { font: .85rem ui-monospace, monospace; }
.muted { color: var(--muted); }
.login { max-width: 380px; margin: 8vh auto 0; }
td form { margin: 0; }
td select { padding: 5px 8px; }
.grid2 .field, .grid3 .field { display: flex; flex-direction: column; justify-content: space-between; margin-top: 14px; }
.toc { display: flex; flex-wrap: wrap; gap: 6px 8px; padding: 14px 16px; }
.toc a { padding: 4px 12px; border-radius: 999px; background: var(--chip); color: var(--ink);
  text-decoration: none; font-size: .88rem; font-weight: 600; }
.toc a:hover { color: var(--wine); }
.doc { scroll-margin-top: 16px; max-width: 920px; }
.doc h3 { font: 600 1rem var(--sans); margin: 20px 0 6px; }
.doc p, .doc li { max-width: 75ch; }
.doc li { margin: 5px 0; }
.doc ul, .doc ol { padding-left: 22px; }
.doc a { color: var(--wine); }
.doc .table-scroll { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 4px 12px; margin: 12px 0; }
.doc tr:last-child td { border-bottom: 0; }
.doc td { vertical-align: top; }
fieldset.customer { border: 1px solid var(--line); border-radius: 10px; margin: 24px 0 0; padding: 4px 16px 16px; }
fieldset.customer legend { font: 600 1.1rem var(--serif); padding: 0 8px; }
fieldset.customer .hint { margin: 0; }
.save-customer { margin-top: 14px; }
.stat { display: flex; align-items: center; gap: 18px; margin-bottom: 16px; }
.stat strong { font: 600 2rem var(--serif); color: var(--wine); white-space: nowrap; }
.stat span { color: var(--muted); max-width: 70ch; }
.sample { margin-bottom: 14px; }
.sample-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.sample audio { height: 36px; max-width: 100%; }
.stat .plain { font: 600 1rem var(--sans); color: var(--bad); }
.eyebrow a { color: var(--gold); text-decoration: none; }
h1 .chip { vertical-align: middle; font-family: var(--sans); }
.row-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row-form input[type=search] { flex: 1 1 260px; min-width: 0; }
.row-form select { width: auto; }
.pager { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: var(--muted); }
.stockline { margin-bottom: 18px; }
.qr { display: inline-block; background: #fff; padding: 8px; border-radius: 8px; line-height: 0; }
.qr svg { max-width: 100%; height: auto; }
.brand-logo { height: 34px; width: auto; background: #fff; padding: 3px 8px; border-radius: 6px; }
.brand-logo.on-dark { background: #111; }
.companies { padding: 8px 20px; border-bottom: 1px solid var(--line); font-size: .9rem; }
.companies a { color: var(--wine); } .companies .hint { margin-left: 10px; }

/* users page */
td input.name { width: 100%; min-width: 190px; padding: 5px 8px; font: inherit; color: var(--ink);
  background: transparent; border: 1px solid transparent; border-radius: 6px; font-weight: 600; }
td input.name:hover, td input.name:focus { border-color: var(--line); background: var(--card); }
th a.sort { color: inherit; text-decoration: none; white-space: nowrap; }
th a.sort:hover { text-decoration: underline; }
.nowrap { white-space: nowrap; }
form.inline { display: inline; }
form.search { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
form.search input[type=search] { flex: 1 1 260px; max-width: 420px; padding: 7px 10px; font: inherit;
  color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }

/* lists: the name gets the room; on a phone or a narrow window each row becomes a card */
table.products td.main { min-width: 17rem; width: 42%; }
table.products td.detail { min-width: 8.5rem; }
th abbr { text-decoration: none; cursor: help; }
@media (max-width: 760px) {
  .top { flex-wrap: wrap; padding: 10px 12px; }
  .top .brand small { display: none; }
  .row-form select { flex: 1 1 140px; min-width: 0; }
  .wrap { padding: 18px 10px 32px; }
  .card { padding: 14px; }
  h1 { font-size: 1.6rem; }
}
@media (max-width: 1100px) {
  table.stack, table.stack tbody { display: block; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.stack tr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px; padding: 14px 0;
    border-bottom: 1px solid var(--line); }
  table.stack tr:first-child { padding-top: 0; }
  table.stack tr:last-child { padding-bottom: 0; border-bottom: 0; }
  table.stack td { display: block; min-width: 0; padding: 0; border: 0; text-align: left; }
  table.stack td.main, table.stack td.detail { grid-column: 1 / -1; min-width: 0; width: auto; }
  table.stack td.main strong { font-size: 1.05rem; line-height: 1.3; }
  table.stack td.detail { margin-top: -4px; color: var(--muted); font-size: .9rem; }
  table.stack td.detail .ref { display: inline; font-size: inherit; }
  table.stack td.detail .ref::before { content: " · "; }
  table.stack td[data-label]::before { content: attr(data-label); display: block; color: var(--muted);
    font-size: .75rem; font-weight: 600; }
  table.stack td[data-label]:empty::after { content: "—"; color: var(--muted); }
  table.stack td.action { align-self: end; text-align: right; }
  table.stack td.full { grid-column: 1 / -1; }
  table.stack td.span2 { grid-column: span 2; }
  table.stack td.first { order: -1; }
  table.stack td.last { order: 1; }
  table.stack td.full .check { margin-right: 14px; }
  table.stack td input.name { min-width: 0; border-color: var(--line); background: var(--bg); }
}

/* what the AI read, step by step */
.reading { margin-bottom: 14px; }
.reading-head { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 0 0 10px; }
.reading-steps { display: grid; grid-template-columns: 8.5rem 1fr; gap: 8px 16px; margin: 0; }
.reading-steps dt { color: var(--muted); font-size: .74rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; padding-top: 3px; }
.reading-steps dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.reading-steps ul { margin: 4px 0 0; padding-left: 18px; }
.reading-steps audio { height: 34px; max-width: 100%; margin-top: 6px; }
.reading summary { cursor: pointer; color: var(--wine); }
.hint a, .lead a, .reading a { color: var(--wine); }
pre.reply { margin: 8px 0 0; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; font: .85rem/1.45 var(--sans); white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 640px) { .reading-steps { grid-template-columns: 1fr; gap: 2px 0; } .reading-steps dd { margin-bottom: 8px; } }

/* telling the bot which product a name it could not place was */
form.teach { margin: 6px 0 4px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .9rem; }
form.teach label { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); }
form.teach input[type=text] { width: 16rem; max-width: 100%; padding: 6px 10px; }


/* search boxes that show their results while typing */
.live-slot { display: contents; }
form.searching input[type=search] { border-color: var(--gold); }

/* products offered while typing in an order's "add a product" box */
.suggest { position: fixed; z-index: 50; width: 34rem; max-width: calc(100vw - 16px);
  scrollbar-color: var(--muted) var(--card); scrollbar-width: thin; border: 1px solid var(--line); overflow-y: auto; border-radius: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.25);
  background: var(--card); }
.suggest .hint { margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.picked:not(:empty) { display: block; margin-top: 4px; }
.suggest-item { display: block; width: 100%; padding: 8px 10px; margin: 0; text-align: left; cursor: pointer;
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-top-width: 0; }
.suggest-item:first-child { border-top-width: 1px; border-radius: 8px 8px 0 0; }
.suggest-item:last-child { border-radius: 0 0 8px 8px; }
.suggest-item:only-child { border-radius: 8px; }
.suggest-item:hover, .suggest-item:focus-visible { background: var(--chip); outline: none; }
.suggest-item:disabled { color: var(--muted); cursor: default; background: var(--bg); }
table.lines td.main input[name=add_ref] { width: 100%; max-width: 34rem; }

/* order lines on a phone: the name on its own line, the figures in one row under it */
@media (max-width: 640px) {
  table.cards, table.cards tbody { display: block; }
  table.cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.cards tr { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: 8px 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  table.cards tr:first-child { padding-top: 0; }
  table.cards td { display: block; padding: 0; border: 0; text-align: left; }
  table.cards td:empty { display: none; }
  table.cards td.main { flex: 1 0 100%; }
  table.cards td.main strong { font-size: 1.05rem; line-height: 1.3; }
  table.cards td.main input { width: 100%; }
  table.cards td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px;
    color: var(--muted); font-size: .75rem; font-weight: 600; }
  table.cards td[data-label] { flex: 1 1 0; }
  table.cards td[data-label]:has(.qty) { flex: 0 0 auto; }
  table.cards td[data-label]:last-child { text-align: right; }
  table.cards .qty { width: 84px; padding: 9px 10px; }
  table.cards tr.add td.main { flex: 1 1 0; }
  table.cards td.line-total { text-align: right; }
  /* ✕ at the top right, beside the name; the figures go on the row below */
  table.cards tr:has(td.remove) td { order: 2; }
  table.cards tr:has(td.remove) td.main { order: 0; flex: 1 1 calc(100% - 60px); }
  table.cards tr:has(td.remove) td.remove { order: 1; flex: 0 0 auto; width: auto; align-self: flex-start; }
}

/* Text kept with its own line breaks (a notice as it was sent). */
td.pre { white-space: pre-line; }

/* Order review page: remove a line (✕, asked to confirm) and the line just added. */
td.remove { width: 1%; text-align: right; }
button.remove { min-width: 40px; min-height: 40px; padding: 0 10px; font-size: 1rem; line-height: 1; }
button.remove:hover, button.remove:focus-visible { color: var(--bad); border-color: currentColor; }
tr.just-added td { background: var(--ok-bg); }
/* The form's first button, pressed by Enter in any box: out of sight but still a real button. */
.default-button { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
a.bot-card { display: block; color: var(--ink); text-decoration: none; }
a.bot-card:hover { border-color: var(--wine); }
.section ul { margin: 6px 0 0; padding-left: 20px; }

/* dense lists (products): one line per row, details on hover */
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin-right: auto; }
.lead.compact { margin-bottom: 12px; font-size: .92rem; }
abbr.help { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: var(--chip); color: var(--muted); font-size: .75rem; text-decoration: none; cursor: help; }
.row-form.filters { margin-bottom: 12px; }
.row-form.filters select, .row-form.filters input { padding: 6px 8px; font-size: .9rem; }
.card.flush { padding: 0; }
table.dense { font-size: .95rem; }
table.dense th { padding: 8px 10px; position: sticky; top: 0; background: var(--card); }
table.dense td { padding: 6px 10px; line-height: 1.35; }
table.dense tbody tr:hover td { background: var(--bg); }
table.dense a { color: var(--ink); text-decoration: none; }
table.dense td.name a { font-weight: 600; }
table.dense a:hover { color: var(--wine); text-decoration: underline; }
table.dense td.name { max-width: 36rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.dense td.clip { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.dense .chip { padding: 1px 8px; font-size: .8rem; }
details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; z-index: 10; margin-top: 4px; min-width: 180px; padding: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.menu-list a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.menu-list a:hover { background: var(--bg); }
@media (max-width: 760px) {
  table.products thead th:nth-child(n+3):not(:nth-child(9)):not(:nth-child(10)) { display: none; }
  table.products td:nth-child(n+3):not(:nth-child(9)):not(:nth-child(10)) { display: none; }
  table.dense td.name { max-width: 52vw; }
}
@media (max-width: 1250px) and (min-width: 761px) {  /* Productos only: other tables have their own */
  table.products :is(th, td):is(:nth-child(4), :nth-child(5), :nth-child(7)) { display: none; }
  table.dense td.name { max-width: 20rem; }
}
@media (max-width: 1100px) and (min-width: 761px) {
  table.products :is(th, td):nth-child(3) { display: none; }
}
.audience fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0; padding: 8px 14px 12px; }
.audience legend { padding: 0 6px; font-weight: 600; font-size: .9rem; }
.audience .check { display: flex; margin-top: 6px; }
/* two levels in the sidebar: bright section headers, pages indented on a guide line */
.side-group { color: var(--ink); font-size: .88rem; margin-top: 10px; }
.side-sec > a { margin-left: 14px; padding: 5px 10px; border-left: 2px solid var(--line); border-radius: 0 7px 7px 0;
  color: var(--muted); font-size: .9rem; }
.side-sec > a:hover { color: var(--ink); }
.side-sec > a.on { color: var(--ink); background: var(--chip); border-left-color: var(--wine); font-weight: 600; }
.side-sec > a.sub { margin-left: 30px; font-size: .85rem; }
.side-sec > a.parent { color: var(--ink); font-weight: 600; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.photo { margin: 0; padding: 10px; }
.photo img { display: block; width: 100%; height: 220px; object-fit: cover; border-radius: 8px; background: var(--bg); }
.photo figcaption { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }

/* Clothes: models with their photo, colours and sizes */
table.dense td.thumb { width: 44px; padding: 2px 4px; }
table.dense td.thumb img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.card.model { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.model-photo { width: 180px; max-width: 100%; border-radius: 10px; object-fit: cover; }
.card.model > div { flex: 1; min-width: 240px; }
table.sizes th { text-align: left; white-space: nowrap; position: static; padding-right: 12px; }
table.sizes td { display: flex; flex-wrap: wrap; gap: 4px; }
table.sizes .chip { text-decoration: none; }
table.sizes .chip.here { outline: 2px solid var(--wine); }
.pre { white-space: pre-line; }

/* Datos: one scheduled download per kind, folded until it is needed */
details.pull { border-top: 1px solid var(--line); padding: 10px 0; }
details.pull > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; list-style: none; }
details.pull > summary::-webkit-details-marker { display: none; }
details.pull > summary::before { content: "▸"; color: var(--muted); }
details.pull[open] > summary::before { content: "▾"; }
details.pull .pull-src { font-size: .85em; overflow-wrap: anywhere; }
details.pull form { margin-top: 10px; }
.alert-text { color: var(--bad, #a33); margin: 8px 0 0; }

/* Columns: drag the edge of a heading to resize (panel.js); the widths are then fixed. */
table[data-cols] th { position: relative; }
table.dense[data-cols] th { position: sticky; }
.col-grip { position: absolute; top: 0; right: 0; width: 8px; height: 100%; cursor: col-resize; touch-action: none; }
.col-grip::after { content: ""; position: absolute; top: 25%; bottom: 25%; right: 2px; width: 2px; border-radius: 1px;
  background: var(--line); opacity: 0; }
thead:hover .col-grip::after { opacity: 1; }
.col-grip:hover::after, table.resizing .col-grip::after { opacity: 1; background: var(--muted); }
table.resizing { user-select: none; cursor: col-resize; }
table.resized { table-layout: fixed; }
table.resized th, table.resized td { overflow: hidden; text-overflow: ellipsis; }
table.resized td.name, table.resized td.clip { max-width: none; }
@media (max-width: 1100px) { .col-grip { display: none; } }
table.dense th a.sort { color: inherit; }
th[data-sortable] { cursor: pointer; user-select: none; }
th[data-sortable]:hover { color: var(--ink); }
th[data-sortable][aria-sort=ascending]::after { content: " ▲"; }
th[data-sortable][aria-sort=descending]::after { content: " ▼"; }

/* Pedidos: one line per order; the row opens to the whole order. */
table.orders { font-size: 1rem; }
table.orders td.clip { max-width: 16rem; }
table.orders .ref { font-size: .86rem; }
table.orders td.lines { width: 100%; min-width: 12rem; max-width: 0; overflow: hidden; }
table.orders .first-line { display: flex; min-width: 0; }
table.orders .first-line .item { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.orders .first-line .more-items { flex: none; margin-left: .4em; color: var(--muted); white-space: nowrap; }
table.orders tr.order-row.cancelled td:not(.action), table.orders tr.order-row.cancelled strong { color: var(--muted); }
table.orders .toggle { width: 1%; padding-right: 0; }
table.orders tr.order-row { cursor: pointer; }
table.orders .more { display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0;
  border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
table.orders .more::before { content: ""; width: 7px; height: 7px; margin-left: -3px; border: solid currentColor;
  border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform .15s; }
table.orders .more[aria-expanded=true]::before { margin: -4px 0 0; transform: rotate(45deg); }
table.orders .more:hover, table.orders .more:focus-visible { background: var(--chip); color: var(--ink); }
table.orders .more[aria-expanded=true] { color: var(--ink); }
@media (prefers-reduced-motion: reduce) { table.orders .more::before { transition: none; } }
/* The open order's row stands apart from its details below it. */
table.orders tr.open td, table.orders tr.open:hover td { background: color-mix(in srgb, var(--wine) 14%, var(--card)); color: var(--ink); }
table.orders tr.order-more td, table.orders tr.order-more:hover td { background: var(--bg); border-bottom: 0;
  padding-top: 3px; padding-bottom: 3px; vertical-align: top; }
table.orders tr.order-more.first td { padding-top: 12px; }
table.orders tr.order-more.wide:not(.fill) { height: 1px; }  /* the spare height goes to the fill row */
table.orders tr.order-more.sum td { padding-bottom: 4px; }
table.orders tr.order-more.fill td { padding: 0 0 10px; border-bottom: 1px solid var(--line); }
table.orders tr.order-more td.span { border-bottom: 1px solid var(--line); padding-bottom: 14px; }
table.orders tr.order-more.sum td.detail-line, table.orders tr.order-more.sum td.num { font-weight: 600; padding-top: 8px;
  border-top: 1px solid color-mix(in srgb, var(--muted) 50%, transparent); }
table.orders .detail-line .line { display: grid; grid-template-columns: 2.4rem minmax(0, 1fr); }
table.orders .detail-line .x { color: var(--muted); }
table.orders .detail-customer p { margin: 0 0 6px; }
table.orders tr.order-more.narrow { display: none; }
.status-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.status-filter a { padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--ink); font-size: .9rem; text-decoration: none; }
.status-filter a b { margin-left: 4px; font-variant-numeric: tabular-nums; }
.status-filter a:hover { border-color: var(--muted); }
.status-filter a.here { background: var(--wine-dark); border-color: var(--wine-dark); color: #fff; }
.status-filter a.none:not(.here) { color: var(--muted); }
.detail-lines { list-style: none; margin: 0 0 6px; padding: 0; }
.detail-lines li { display: grid; grid-template-columns: 3rem minmax(0, 1fr) auto; gap: 10px; padding: 3px 0;
  border-bottom: 1px solid var(--line); }
.detail-lines li.sum { font-weight: 600; border-bottom: 0; }
/* Pedidos by window width. From 1401 px every column. Narrower, Usuario and Creado go (both are in the
   open order); from 1100 px "Editar" moves into the open order too. The open order keeps to the columns
   shown (panel.js fits its spans) until phones, where it is stacked. */
table.orders .edit-here { display: none; }
@media (max-width: 1400px) {
  table.orders th:is(:nth-child(4), :nth-child(8)),
  table.orders tr.order-row td:is(:nth-child(4), :nth-child(8)) { display: none; }
}
@media (max-width: 1100px) {
  table.orders th:nth-child(9), table.orders tr.order-row td:nth-child(9) { display: none; }
  table.orders td.lines { min-width: 8rem; }
  table.orders td.clip { max-width: 10rem; }  /* the customer's name gives way to the lines */
  table.orders .edit-here { display: block; margin-top: 10px; }
}
@media (max-width: 760px) {
  table.orders th:is(:nth-child(4), :nth-child(6), :nth-child(8), :nth-child(9)),
  table.orders tr.order-row td:is(:nth-child(4), :nth-child(6), :nth-child(8), :nth-child(9)) { display: none; }
  table.orders td.clip { max-width: 26vw; }
  table.orders th, table.orders tr.order-row td { padding-left: 6px; padding-right: 6px; }
  table.orders tr.order-more.wide { display: none; }
  table.orders tr.order-more.narrow:not([hidden]) { display: table-row; }
  table.orders tr.order-more.narrow td { padding: 8px 10px 14px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
  table.orders tr.order-more.narrow p { margin: 0 0 6px; }
  table.orders .narrow-box { max-width: calc(100vw - 88px); }  /* never wider than the phone */
}
@media (max-width: 420px) {  /* the smallest phones: a narrower arrow; it stays, a keyboard needs it */
  table.orders th:first-child, table.orders tr.order-row td:first-child { padding-left: 2px; padding-right: 0; }
  table.orders .more { width: 22px; }
  table.orders .narrow-box { max-width: calc(100vw - 70px); }
}
/* Productos: the name takes the room the other columns leave, so the table fits its box at any width. */
table.products td.name { width: 100%; min-width: 9rem; max-width: 0; }
@media (max-width: 760px) { table.products td.name { min-width: 6rem; } }
/* Unsaved changes: a bar while a form differs from what the page loaded with (panel.js). */
.unsaved { position: fixed; left: 50%; bottom: 16px; z-index: 60; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center; max-width: calc(100vw - 32px); padding: 10px 12px 10px 16px;
  background: var(--card); border: 1px solid var(--gold); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.unsaved-note { font-weight: 600; }
.savebar.dirty { box-shadow: inset 0 2px 0 var(--gold); }
.savebar .unsaved-note { margin-right: auto; }
.unsaved[hidden], .unsaved [hidden], .savebar [hidden] { display: none; }
