/* Product Inbox: iOS-like look. Default palette: Tines gold and cream; another shop overrides
   the variables in public/brands/<dir>/brand.css. */
:root {
  --bg: #F7F3EC;
  --surface: #FFFFFF;
  --surface-2: #FBF8F3;
  --text: #1C1915;
  --muted: #685F55;           /* 5.7:1 on --bg (WCAG AA) */
  --separator: rgba(60, 45, 25, .13);
  --accent: #7A5418;          /* gold; 5.6:1 on --accent-soft, white on it 6.8:1 */
  --accent-text: #FFFFFF;
  --accent-soft: #F3E8D5;
  --accent-shadow: rgba(122, 84, 24, .35);
  --gold: #9A6F2A;            /* logo gold, darkened to 3.7:1 for borders */
  --danger: #C2372E;
  --danger-bg: rgba(194, 55, 46, .12);
  --warn: #8A5A00;
  --warn-bg: #FFF4D6;
  --ok: #2E7D4F;
  --ok-bg: #E7F3EA;
  --bar: rgba(251, 247, 240, .82);
  --radius: 14px;
  --tabbar-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1915;
    --surface: #2A2621;
    --surface-2: #322D27;
    --text: #F4EFE7;
    --muted: #A99F92;
    --separator: rgba(255, 240, 220, .12);
    --accent: #D9AE62;
    --accent-text: #1C1915;
    --accent-soft: #3A3126;
    --gold: #D9AE62;
    --danger: #FF7B6E;
    --danger-bg: rgba(255, 123, 110, .16);
    --warn: #F3C969;
    --warn-bg: #3A3020;
    --ok: #7FD39B;
    --ok-bg: #1F3A2A;
    --bar: rgba(28, 25, 21, .82);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.42 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  letter-spacing: -.01em;
}
body.has-tabs { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
main { max-width: 640px; margin: 0 auto; padding: 8px 16px 28px; }
h1 { font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -.025em; margin: 10px 4px 14px; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 26px 16px 8px; }
a { color: var(--accent); text-decoration: none; }
p { margin: 0 0 .6em; }

/* Navigation bar */
.navbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0;
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-bottom: .5px solid var(--separator);
}
.brand img { height: 46px; width: auto; display: block; }
.logout { position: absolute; right: 12px; bottom: 10px; margin: 0; }
.navlink { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; padding: 6px 4px; min-height: 44px; cursor: pointer; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around; align-items: flex-end;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 6px 8px env(safe-area-inset-bottom);
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-top: .5px solid var(--separator);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; padding-bottom: 6px; }
.tabbar a.active { color: var(--accent); }
.tab-icon { position: relative; display: inline-flex; }
.badge { position: absolute; top: -4px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #C2372E; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.tabbar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.tab-add .plus {
  display: grid; place-items: center; width: 56px; height: 56px; margin-top: -26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); box-shadow: 0 6px 18px var(--accent-shadow);
}
.tab-add .plus svg { width: 30px; height: 30px; stroke-width: 2.6; }
.tab-add { color: var(--accent) !important; }

/* Grouped lists and cards */
.group, .notes, .facts, details, fieldset.photos, fieldset.features, .proposal, .compare, .metrics, .cards li .card {
  background: var(--surface); border-radius: var(--radius);
}
.group { padding: 4px 16px; margin: 0 0 12px; }
.group > label { display: block; padding: 10px 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.group > label + input, .group > label + textarea, .group > label + select, .group > label + .money, .group > input, .group > select, .group > textarea { margin-bottom: 8px; }
.group > * + label { border-top: .5px solid var(--separator); }

.stack { display: flex; flex-direction: column; gap: 0; }
label { font-weight: 600; }
input, select, textarea, button, .button { font: inherit; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 0; border-radius: 10px; background: var(--surface-2); color: var(--text);
  appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea { resize: vertical; line-height: 1.4; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; padding: 8px 0; }
.check input { width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--accent); appearance: auto; -webkit-appearance: auto; }
.hint { color: var(--muted); font-weight: 400; font-size: 14px; }
.money { display: flex; align-items: center; gap: 8px; }
.money input { flex: 1; font-size: 20px; font-weight: 600; }
.money span { font-weight: 700; font-size: 20px; color: var(--muted); }
.password { display: flex; gap: 8px; }
.password input { flex: 1; }
.show-password { flex: none; }

/* Buttons */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 0;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: none;
}
.primary { background: var(--accent); color: var(--accent-text); }
.big { width: 100%; min-height: 54px; font-size: 18px; border-radius: 14px; margin-top: 8px; }
.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
button:disabled { opacity: .55; cursor: progress; }
button:active, .button:active { transform: scale(.98); }
.sticky-save {
  /* Clears the raised + button of the tab bar, which sticks out 26 px. */
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 22px); z-index: 5;
  margin: 0 -16px; padding: 10px 16px 10px; background: linear-gradient(to bottom, transparent, var(--bg) 22%);
}
.sticky-save .big { margin-top: 0; }
.sticky-save::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 48px; background: var(--bg); }

/* Messages */
.alert, .field-error { color: var(--danger); font-weight: 600; }
.field-error { font-size: 14px; margin: -2px 0 8px; }
.alert { background: var(--surface); border-radius: var(--radius); padding: 12px 16px; border-left: 4px solid var(--danger); }
.notice { background: var(--ok-bg); color: var(--text); border-radius: var(--radius); padding: 12px 16px; }
.warn { color: var(--warn); font-weight: 600; }
.progress { text-align: center; font-weight: 600; color: var(--accent); margin: 8px 0 0; }

/* Photos */
fieldset { border: 0; margin: 0 0 12px; padding: 12px; min-width: 0; }
fieldset legend { float: left; width: 100%; padding: 0 4px 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
fieldset legend + * { clear: both; }
.photo-button {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; min-height: 120px;
  border-radius: 12px; border: 2px dashed var(--gold); background: var(--accent-soft); color: var(--accent);
  font-size: 18px; font-weight: 700; cursor: pointer; position: relative; text-align: center;
}
.thumbs:not(:empty) + .photo-button { min-height: 52px; flex-direction: row; font-size: 16px; }
.thumbs:not(:empty) + .photo-button small { display: none; }
legend .hint { text-transform: none; letter-spacing: 0; font-size: 13px; }
.photo-button small { font-size: 13px; font-weight: 500; color: var(--muted); }
.photo-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-button[hidden] { display: none; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.thumbs:empty { display: none; }
.thumb { position: relative; background: var(--surface-2); border-radius: 12px; overflow: hidden; }
.thumb.main { box-shadow: 0 0 0 3px var(--gold); }
.thumb img, .thumb .noimg { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.noimg { display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); background: var(--surface-2); overflow: hidden; word-break: break-all; padding: 4px; }
.thumb-bar { display: flex; }
.thumb-bar button { flex: 1; min-height: 44px; padding: 0; border-radius: 0; background: transparent; color: var(--text); font-size: 15px; }
.cover-badge { position: absolute; top: 6px; left: 6px; background: var(--accent); color: var(--accent-text); font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; pointer-events: none; z-index: 1; }
.cover-button { position: absolute; top: 5px; right: 5px; min-height: 0; width: 44px; height: 44px; padding: 0; border-radius: 50%; background: rgba(0, 0, 0, .5); color: #fff; font-size: 16px; }

/* Characteristics */
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.feature-grid label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }

/* Disclosure */
details { padding: 4px 16px; margin: 0 0 12px; }
details summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; color: var(--accent); list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: '›'; margin-left: auto; font-size: 22px; transition: transform .2s; color: var(--muted); }
details[open] summary::after { transform: rotate(90deg); }
details > label { display: block; font-size: 13px; color: var(--muted); margin-top: 6px; }
details > input { margin-bottom: 8px; }

/* Confirmation */
.done { text-align: center; padding-top: 18px; }
.done .brand-mark { width: 110px; height: auto; margin: 10px auto 4px; display: block; animation: hover 3s ease-in-out infinite; }
@keyframes hover { 50% { transform: translateY(-6px) rotate(-2deg); } }
@media (prefers-reduced-motion: reduce) { .done .brand-mark { animation: none; } }
.done h1 { margin-top: 4px; }
.done .card-summary { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin: 14px 0; text-align: left; }
.done .card-summary.card { display: flex; gap: 12px; align-items: center; }
.done .card-summary img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; }
.done-links { margin-top: 14px; }
.auto-status { color: var(--accent); font-weight: 600; margin: 0; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.auto-texts { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; text-align: left; margin-bottom: 12px; }

/* Icons (SF Symbols style): inherit the text colour. The sprite itself takes no space
   (inline style attributes are blocked by the CSP, so it is hidden here). */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }
#i-star path { fill: currentColor; stroke: none; }
.with-icon { display: inline-flex; align-items: center; gap: 6px; }
p.with-icon { display: flex; }
.photo-button .i { width: 26px; height: 26px; }
.thumb-bar .i { width: 18px; height: 18px; }
.cover-button .i { width: 17px; height: 17px; }

/* Personal greeting */
.hello { margin: 6px 4px 16px; }
.hello h1 { margin: 4px 0 6px; }
.greeting { font-size: 17px; line-height: 1.35; color: var(--accent); font-weight: 600; margin: 0; }

/* Inbox list */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters input[type=search] { flex: 1 1 100%; }
.filters select { flex: 1 1 auto; width: auto; }
.cards { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.card { display: flex; gap: 12px; align-items: center; padding: 10px; color: inherit; }
.card img, .card .noimg { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex: none; }
.card-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.card-body strong, .card-body span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.status-rejected, .status-needs_attention { background: var(--danger-bg); color: var(--danger); }
.status-imported { background: var(--ok-bg); color: var(--ok); }
/* Swipe left to delete (iOS Mail style). The red button sits behind the card; keyboard focus
   on the button (not a tap on the link) also slides the card, so it is reachable without the gesture. */
.cards li.swipe { position: relative; overflow: hidden; border-radius: var(--radius); }
.cards li.swipe .card { position: relative; z-index: 1; transition: transform .25s ease; touch-action: pan-y; }
.cards li.swipe.open .card, .cards li.swipe:has(.swipe-delete-button:focus-visible) .card { transform: translateX(-96px); }
.cards li.swipe.dragging .card { transition: none; }
.swipe-delete { position: absolute; top: 0; right: 0; bottom: 0; width: 96px; margin: 0; opacity: 0; transition: opacity .25s; }
/* Hidden while closed so the red does not show at the card's rounded corners; opacity keeps it focusable. */
.cards li.swipe.open .swipe-delete, .cards li.swipe.dragging .swipe-delete, .swipe-delete:has(.swipe-delete-button:focus-visible) { opacity: 1; }
.swipe-delete-button { width: 100%; height: 100%; border-radius: 0; background: #C2372E; color: #fff; display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; font-size: 13px; padding: 0; }
.swipe-delete-button .i { width: 22px; height: 22px; }
.swipe-hint { margin: -4px 4px 10px; }
.link-button { background: none; border: 0; padding: 0; min-height: 44px; color: var(--accent); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty img { width: 90px; opacity: .8; }

/* Detail */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; display: block; }
.gallery-item { position: relative; display: block; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0; padding: 4px 16px; margin: 14px 0 0; }
.facts dt, .facts dd { padding: 11px 0; border-bottom: .5px solid var(--separator); margin: 0; }
.facts dt { color: var(--muted); padding-right: 14px; }
.facts dd { overflow-wrap: anywhere; text-align: right; }
.facts dt:last-of-type, .facts dd:last-of-type { border-bottom: 0; }
.notes { padding: 14px 16px; overflow-wrap: anywhere; }
.proposal { padding: 14px 16px; }
.proposal .notes { background: var(--surface-2); margin-bottom: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions form { margin: 0; }
.inline-form { display: flex; gap: 8px; flex: 1 1 100%; }
.history { list-style: none; padding: 4px 16px; margin: 0; background: var(--surface); border-radius: var(--radius); color: var(--muted); font-size: 14px; }
.history li { padding: 9px 0; border-bottom: .5px solid var(--separator); }
.history li:last-child { border-bottom: 0; }
.history time { font-variant-numeric: tabular-nums; display: block; font-size: 12px; }
.edit-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 10px; }
.edit-thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; }
.edit-thumb label { font-weight: 400; font-size: 14px; }
.danger-zone summary { color: var(--danger); }

/* Tables */
.metrics, .compare { width: 100%; border-collapse: collapse; overflow: hidden; font-size: 15px; }
.metrics th, .metrics td, .compare th, .compare td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: .5px solid var(--separator); overflow-wrap: anywhere; }
.compare td p { margin: 0 0 .5em; }
.compare td:first-child { white-space: nowrap; color: var(--muted); font-weight: 600; }
@media (max-width: 600px) {
  /* Stacked rows on phones: field name on top, then the artisan's value and the shop's value. */
  .compare thead { display: none; }
  .compare, .compare tbody, .compare tr, .compare td { display: block; width: 100%; }
  .compare tr { padding: 10px 14px; border-bottom: .5px solid var(--separator); }
  .compare td { padding: 2px 0; border: 0; }
  .compare td:first-child { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
  .compare td:nth-child(2):not(:last-child)::before { content: 'Ficha · '; color: var(--muted); font-size: 13px; }
  .compare td:nth-child(3)::before { content: 'En la tienda · '; color: var(--muted); font-size: 13px; }
}
.metrics th, .compare th { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }

/* Login */
.login { max-width: 420px; margin: 0 auto; text-align: center; padding-top: 28px; }
.login .logo { width: 180px; height: auto; margin: 0 auto 6px; display: block; }
.login h1 { font-size: 26px; margin: 6px 0 4px; }
.login .group { text-align: left; }
