:root {
  --bg: #F3F4EF;
  --surface: #FFFFFF;
  --ink: #18212B;
  --muted: #5C6772;
  --line: #D9DED5;
  --accent: #2F6B4F;
  --accent-ink: #FFFFFF;
  --accent-soft: #E2EDE5;
  --warn: #8F5410;
  --warn-soft: #F5E9D8;
  --danger: #A33A2B;
  --danger-soft: #F6E1DD;
  --customer: #FFFFFF;
  --font: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171B;
    --surface: #1A2026;
    --ink: #E5E9E3;
    --muted: #9AA4AD;
    --line: #2C353D;
    --accent: #74B791;
    --accent-ink: #0D1912;
    --accent-soft: #1F3329;
    --warn: #E3A75C;
    --warn-soft: #3A2C1A;
    --danger: #E58373;
    --danger-soft: #3B221E;
    --customer: #222A31;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: inherit; }
h1, h2 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.75rem; }
p { margin: 0 0 0.5rem; }
code { font-size: 0.9em; background: var(--accent-soft); padding: 0 4px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.right { text-align: right; }
.actions { display: inline-flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.ok-text { color: var(--accent); font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* layout */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 1.25rem 0.9rem; display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 700; font-size: 1.05rem; text-decoration: none; padding: 0 0.5rem; }
.side a:not(.brand) { display: flex; align-items: center; gap: 0.55rem; padding: 0.4rem 0.5rem; border-radius: 6px; text-decoration: none; color: var(--muted); }
.side a:hover { color: var(--ink); }
.side a.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }
.side-nav { display: grid; gap: 2px; }
.side-group { display: grid; gap: 2px; }
.side-title { font-size: 0.8rem; color: var(--muted); padding: 0 0.5rem; margin-bottom: 0.25rem; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none; }
.dot.live { background: var(--accent); }
.side-foot { margin-top: auto; display: grid; gap: 0.25rem; padding: 0 0.5rem; }
.main { padding: 1.75rem clamp(1rem, 3vw, 2.5rem) 3rem; max-width: 1080px; width: 100%; }
.page-title { margin-bottom: 1.25rem; }

.t-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; }
.t-head > div { padding-bottom: 0.75rem; }
.tabs { display: flex; gap: 1.25rem; overflow-x: auto; }
.tabs a { text-decoration: none; color: var(--muted); padding: 0.5rem 0 0.7rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--accent); font-weight: 600; }

/* forms */
label { display: grid; gap: 0.3rem; font-size: 0.9rem; font-weight: 500; }
input, textarea, select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.55rem 0.7rem; width: 100%; }
textarea { resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
input[type=file] { padding: 0.4rem; }
label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.82rem; }
.stack { display: grid; gap: 1rem; }
.stack-tight { display: grid; gap: 0.4rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: 1rem; margin-bottom: 1.5rem; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 1rem; align-items: end; margin-bottom: 1.5rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; }
.panel + .panel { margin-top: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; font: inherit; font-weight: 600; font-size: 0.9rem; padding: 0.5rem 0.95rem; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: 0.85rem; text-align: left; cursor: pointer; text-decoration: underline; }

.flash { padding: 0.7rem 0.9rem; border-radius: 6px; margin-bottom: 1rem; background: var(--accent-soft); }
.flash.error { background: var(--danger-soft); color: var(--danger); }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tr:last-child td { border-bottom: 0; }
.grid th { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td a { text-decoration: none; }
.badge { display: inline-block; min-width: 1.8rem; text-align: center; padding: 0.1rem 0.5rem; border-radius: 999px; font-weight: 700; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.empty { padding: 2rem; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; list-style: none; }
.empty .btn { margin-top: 0.5rem; }

/* knowledge */
.search { margin-bottom: 0.75rem; max-width: 420px; }
.kb-list { display: grid; gap: 0.5rem; }
.kb-item { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.kb-item.off { opacity: 0.65; }
.kb-item summary { cursor: pointer; padding: 0.75rem 1rem; display: flex; gap: 0.75rem; align-items: baseline; list-style: none; }
.kb-item summary::-webkit-details-marker { display: none; }
.kb-item[open] summary { border-bottom: 1px solid var(--line); }
.kb-item form { padding: 1rem; }
.kb-cat { font-size: 0.8rem; color: var(--accent); font-weight: 600; flex: none; min-width: 6rem; }
.kb-q { font-weight: 500; }

/* conversations */
.filters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters a { text-decoration: none; padding: 0.3rem 0.75rem; border-radius: 999px; color: var(--muted); font-size: 0.9rem; border: 1px solid transparent; }
.filters a.on { border-color: var(--line); background: var(--surface); color: var(--ink); font-weight: 600; }
.inbox { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.inbox li + li { border-top: 1px solid var(--line); }
.inbox .empty { border: 0; }
.inbox-row { display: grid; grid-template-columns: 1fr auto; gap: 0.15rem 1rem; padding: 0.8rem 1rem; text-decoration: none; border-left: 3px solid transparent; }
.inbox-row:hover { background: var(--bg); }
.inbox-row.human { border-left-color: var(--warn); }
.inbox-row .who { font-weight: 600; }
.inbox-row .preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-row .state { text-align: right; color: var(--muted); }
.inbox-row.human .state { color: var(--warn); font-weight: 600; }

.conv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.conv-head h2 { margin-bottom: 0.2rem; }

/* the transcript: who said what must be readable at a glance */
.thread { display: flex; flex-direction: column; gap: 0.6rem; padding: 1.25rem; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; max-height: 62vh; overflow-y: auto; margin-bottom: 1rem; }
.bubble { max-width: min(560px, 85%); padding: 0.6rem 0.85rem 0.45rem; border-radius: 12px; }
.bubble p { margin: 0 0 0.2rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .meta { font-size: 0.75rem; color: var(--muted); }
.bubble .meta + .meta { display: block; margin-top: 0.15rem; }
.bubble.customer { align-self: flex-start; background: var(--customer); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.bubble.bot { align-self: flex-end; background: var(--accent-soft); border-bottom-right-radius: 3px; }
.bubble.agent { align-self: flex-end; background: var(--warn-soft); border-bottom-right-radius: 3px; }
.note { align-self: center; font-size: 0.8rem; color: var(--muted); text-align: center; margin: 0.25rem 0; }

.composer { display: grid; grid-template-columns: 1fr auto; gap: 0.75rem; align-items: start; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.report-card { display: block; text-decoration: none; color: inherit; }
.report-card:hover { border-color: var(--accent); }
.report-card h2 { margin: 0; }
.filters select { width: auto; }

.qr-box { display: grid; justify-items: start; gap: 0.5rem; }
.qr-box img { width: 280px; height: 280px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 8px; image-rendering: pixelated; }

/* página pública de prueba */
.demo { width: min(760px, 100%); margin: 0 auto; padding: 2rem 1rem; }
.demo-head { margin-bottom: 1rem; }
.demo-head h1 { margin: 0 0 0.25rem; }
.login-box { width: min(380px, 100%); display: grid; gap: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 2rem; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; padding: 0.75rem 1rem; }
  .side-nav, .side-group { display: flex; flex-wrap: wrap; gap: 0.25rem; }
  .side-title { display: none; }
  .side-foot { margin: 0 0 0 auto; padding: 0; }
  .two, .two-col, .inline-form { grid-template-columns: 1fr; }
  .composer { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* numbers */
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.row-between p { margin: 0; max-width: 60ch; }
.number-row { display: grid; grid-template-columns: 1fr auto; gap: 0.2rem 1rem; padding: 0.85rem 1rem; text-decoration: none; }
.number-row:hover { background: var(--bg); }
.number-row .detail { grid-column: 1 / -1; }
.number-row .pill, .number-row .right { justify-self: end; }
.danger-text { color: var(--danger); font-weight: 600; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.pill { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 0.1rem 0.6rem; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); vertical-align: middle; }
.pill.connected { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.pending { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.method-choice { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.method-choice legend { font-weight: 600; margin-bottom: 0.5rem; }
.choice { display: flex; gap: 0.75rem; align-items: flex-start; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 400; }
.choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice input { margin-top: 0.2rem; flex: none; }
.callout { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0.8rem 1rem; }
.callout p:last-child { margin-bottom: 0; }
.callout code { word-break: break-all; }
[hidden] { display: none !important; }
@media (max-width: 820px) { .method-choice { grid-template-columns: 1fr; } }

/* Store: publicaciones */
.bar { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 1rem; }
.bar .page-title, .bar .filters { margin-bottom: 0; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain legend { font-weight: 600; margin-bottom: 0.4rem; }
.btn.small { font-size: 0.8rem; padding: 0.3rem 0.6rem; }
.thumb-cell { width: 64px; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; display: block; }
.gallery { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; }
.gallery li { position: relative; display: flex; flex-direction: column; gap: 0.4rem; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.gallery .badge { position: absolute; top: 0.4rem; left: 0.4rem; background: var(--accent); color: var(--accent-ink); font-size: 0.75rem; }
.gallery .actions { justify-content: flex-start; }
.bar .badge { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.upload-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.upload-form label { flex: 1 1 260px; }
.actions.start { justify-content: flex-start; align-items: center; }

/* Store: back office de órdenes */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0.5rem 0 0; }
.facts dt { color: var(--muted); font-size: 0.88rem; }
.facts dd { margin: 0; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
.timeline li { border-left: 2px solid var(--line); padding-left: 0.75rem; }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.flash a { color: inherit; font-weight: 600; }
.sandbox-bar { background: var(--warn-soft); color: var(--warn); text-align: center; font-weight: 600; font-size: 0.88rem; padding: 0.35rem 16px; }

/* Store: tienda pública */
.shop-wrap { width: min(1120px, 100%); margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.shop-head { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.shop-head-row { display: flex; align-items: center; gap: 1rem; padding-top: 0.7rem; padding-bottom: 0.7rem; }
.shop-head .brand { padding: 0; white-space: nowrap; }
.shop-search { flex: 1; max-width: 480px; }
.shop-search input { border-radius: 999px; padding: 0.45rem 0.9rem; background: var(--bg); }
.shop-user { display: flex; align-items: center; gap: 0.9rem; margin-left: auto; white-space: nowrap; }
.shop-user a:not(.btn) { text-decoration: none; font-weight: 500; }
.shop-main { padding-top: 1.5rem; padding-bottom: 3rem; min-height: 70vh; }
.shop-foot { padding-top: 1.5rem; padding-bottom: 2rem; border-top: 1px solid var(--line); }
.shop .bar h1 { margin: 0; }
.filters-sep { width: 1px; background: var(--line); margin: 0.2rem 0.25rem; }

.cards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.card { display: flex; flex-direction: column; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; text-decoration: none; transition: border-color 0.15s; }
.card:hover { border-color: var(--accent); }
.card img, .card-img-empty { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--bg); }
.card-body { display: grid; gap: 0.2rem; padding: 0.75rem 0.9rem 0.9rem; position: relative; }
.card-title { font-weight: 500; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-price { font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.tag { justify-self: start; font-size: 0.75rem; font-weight: 600; color: var(--warn); background: var(--warn-soft); padding: 0.05rem 0.5rem; border-radius: 999px; margin-top: 0.25rem; }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1.5rem; }

.product { display: grid; grid-template-columns: 1.1fr 1fr; gap: 2rem; align-items: start; }
.product-photo { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; display: block; }
.product-thumbs { list-style: none; padding: 0; margin: 0.6rem 0 0; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.product-thumbs button { padding: 0; border: 2px solid transparent; border-radius: 8px; background: none; cursor: pointer; }
.product-thumbs button.on { border-color: var(--accent); }
.product-thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; display: block; }
.product-info h1 { margin-bottom: 0.3rem; }
.price { font-size: 1.8rem; font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; }
.auction-head { display: flex; justify-content: space-between; gap: 1rem; }
.auction-head p { margin: 0; }
.countdown { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.prose { white-space: pre-line; overflow-wrap: anywhere; }
details summary { cursor: pointer; color: var(--muted); }
details .timeline { margin-top: 0.75rem; }
a.btn.wide { text-align: center; }

.auth { display: grid; place-items: center; padding: 1rem 0 2rem; }
.auth .login-box h1 { margin: 0; }
.account-block { margin-bottom: 2rem; }
.order-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.5rem; align-items: start; }
.order-item { display: flex; gap: 0.75rem; align-items: center; text-decoration: none; }

@media (max-width: 820px) {
  .product, .order-layout { grid-template-columns: 1fr; }
  .shop-head-row { flex-wrap: wrap; }
  .shop-search { order: 3; flex-basis: 100%; max-width: none; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; }
}
