/* Portal de Agentes RY CANDY · DIBE */
:root {
  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #faf8f6;
  --text: #1d1b19;
  --muted: #6d675f;
  --line: #e7e2db;
  --brand: #c2185b;
  --brand-ink: #ffffff;
  --brand-soft: #fbe7ef;
  --ok: #1f7a4a;
  --ok-soft: #e3f3ea;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --info: #1d5fa8;
  --info-soft: #e5effa;
  --danger: #b3261e;
  --danger-soft: #fbe6e4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(29, 27, 25, .06), 0 2px 8px rgba(29, 27, 25, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412;
    --surface: #211e1b;
    --surface-2: #29251f;
    --text: #f1ede8;
    --muted: #a69f96;
    --line: #36312b;
    --brand: #f06292;
    --brand-ink: #1a0b11;
    --brand-soft: #3b1a27;
    --ok: #6fcf97; --ok-soft: #173326;
    --warn: #f2b35b; --warn-soft: #3a2a12;
    --info: #7fb2ee; --info-soft: #172a40;
    --danger: #f28b82; --danger-soft: #3d1a17;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font); min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.danger { color: var(--danger); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Aviso de ambiente de prácticas */
.env-banner { background: #ffb300; color: #1d1b19; text-align: center; font-weight: 700; font-size: .85rem; padding: .35rem 16px; letter-spacing: .02em; }

/* Barra superior */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: .7rem 16px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-block; width: 26px; height: 26px; border-radius: 50%; background:
  conic-gradient(var(--brand) 0 25%, #ffb300 0 50%, var(--brand) 0 75%, #ffb300 0); box-shadow: inset 0 0 0 5px var(--surface); border: 2px solid var(--brand); flex: none; }
.brand-mark.big { width: 56px; height: 56px; box-shadow: inset 0 0 0 10px var(--bg); border-width: 3px; }
.user-box { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.user-name { color: var(--muted); }
.link-btn { background: none; border: 0; color: var(--brand); font: inherit; cursor: pointer; padding: 0; }
.nav { max-width: 1120px; margin: 0 auto; padding: 0 12px; display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: .55rem .75rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); border-bottom-color: var(--brand); }
.nav a.nav-cta { margin-left: auto; color: var(--brand); }

.page { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 1.25rem 16px 6rem; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 16px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.crumbs { margin-bottom: .5rem; font-size: .9rem; }

/* Tarjetas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card .pad, .pad { padding: 1rem 1.1rem; }
.card h2.pad { padding-bottom: 0; margin-bottom: .5rem; }
.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Indicadores */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; display: flex; flex-direction: column; color: var(--text); box-shadow: var(--shadow); }
a.stat:hover { text-decoration: none; border-color: var(--brand); }
.stat-label { color: var(--muted); font-size: .82rem; }
.stat-value { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-alert { border-color: var(--danger); }
.stat-alert .stat-value { color: var(--danger); }
.summary { margin: .25rem 0 .75rem; }

/* Listas */
.list { list-style: none; padding: 0; margin: 0; }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .6rem 0; color: var(--text); }
.list a:hover { text-decoration: none; color: var(--brand); }
.list-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.list-side { flex: none; }

/* Tablas */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; text-align: left; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { border-bottom: 0; border-top: 1px solid var(--line); }
.table tfoot tr.total td { font-weight: 700; font-size: 1.05rem; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions form { display: inline; }
.row-off td { opacity: .55; }
tr[hidden] { display: none; }

/* Insignias */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* Avisos */
.alert { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 40px; }
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--brand); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-ghost { background: transparent; }
.btn-sm { padding: .3rem .65rem; min-height: 32px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }

/* Formularios */
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; margin-bottom: .85rem; }
label .muted { font-weight: 400; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; min-height: 42px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 1px; border-color: var(--brand); }
textarea { resize: vertical; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
.check { flex-direction: row; align-items: center; gap: .45rem; font-weight: 500; margin: 0; white-space: nowrap; }
.check input { width: auto; min-height: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: flex-end; margin-bottom: .85rem; }
.search { max-width: 320px; }
.tabs { display: flex; gap: .4rem; margin-bottom: .75rem; }
.tabs a { padding: .35rem .85rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); font-size: .9rem; }
.tabs a.active { background: var(--brand-soft); color: var(--brand); border-color: transparent; font-weight: 600; }
.tabs a:hover { text-decoration: none; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem 1.5rem; margin: 0; }
.facts .wide { grid-column: 1 / -1; }
.facts dt { color: var(--muted); font-size: .8rem; }
.facts dd { margin: 0; }
.card .facts:empty { display: none; }

/* Captura de pedido */
.line-entry { display: grid; grid-template-columns: 1fr 120px auto; gap: .75rem; align-items: end; padding-bottom: .25rem; }
.line-entry label { margin-bottom: .3rem; }
.picker { position: relative; }
.picker-list { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); max-height: 320px; overflow-y: auto; }
.picker-list li { padding: .5rem .6rem; border-radius: 8px; cursor: pointer; display: flex; gap: .5rem; align-items: baseline; }
.picker-list li.active, .picker-list li[role=option]:hover { background: var(--brand-soft); }
.picker-price { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.picker-empty { color: var(--muted); cursor: default; }
.entry-help { padding-top: 0; margin: 0; }
.line-entry .btn { min-height: 42px; }
.catalog-head { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.catalog-head h2 { margin: 0; margin-right: auto; }
.catalog .qty-col { width: 110px; }
.qty { width: 92px; text-align: right; min-height: 38px; padding: .35rem .5rem; }
.catalog tr.has-qty td { background: var(--brand-soft); }
.order-bar { position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1.1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; box-shadow: 0 -4px 16px rgba(0, 0, 0, .08); }
.order-total { font-size: 1.15rem; }

.big-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 1.8rem; font-weight: 700; margin: 0 auto .75rem; }
.big-icon.ok { background: var(--ok-soft); color: var(--ok); }
.big-icon.err { background: var(--danger-soft); color: var(--danger); }
.checks { list-style: none; padding: 0; margin: 0 0 1rem; }
.checks li::before { content: "● "; }
.checks li.ok { color: var(--ok); }
.checks li.err { color: var(--danger); }

/* Seguridad */
.code-input { font-size: 1.3rem; letter-spacing: .25em; text-align: center; max-width: 220px; font-variant-numeric: tabular-nums; }
.inline-form { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; margin: 1rem 0; }
.inline-form label { margin-bottom: 0; }
.inline-form .btn { min-height: 42px; }
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; list-style: none; padding: 0; margin: .5rem 0 0; }
.codes code { display: block; text-align: center; padding: .5rem; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 8px; font-size: 1rem; letter-spacing: .05em; }
.steps { padding-left: 1.2rem; margin: 0 0 1rem; }
.steps li { margin-bottom: .35rem; }
.qr-box { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; margin: .5rem 0 1rem; }
#qr svg { display: block; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
.secret { font-size: 1.05rem; letter-spacing: .08em; word-break: break-all; }
.checks-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .5rem 1rem; }
.checks-grid li { display: flex; gap: .5rem; align-items: flex-start; }
.checks-grid .dot { flex: none; width: 1.4rem; height: 1.4rem; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.checks-grid .ok .dot { background: var(--ok-soft); color: var(--ok); }
.checks-grid .bad .dot { background: var(--danger-soft); color: var(--danger); }

/* Acceso */
.auth-wrap { max-width: 400px; margin: 0 auto; padding: 3rem 16px; width: 100%; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand h1 { margin-top: .75rem; }
.auth-brand p { color: var(--muted); }
.auth-card h2 { margin-bottom: 1rem; }

.show-sm, .show-sm-inline { display: none; }

@media (max-width: 760px) {
  body { font-size: 15px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .show-sm { display: block; }
  .show-sm-inline { display: inline; }
  .catalog .qty-col { width: 84px; }
  .qty { width: 72px; }
  .search { max-width: none; width: 100%; }
  .user-name { display: none; }
  .table th, .table td { padding: .55rem .6rem; }
  .order-bar { flex-direction: column; align-items: stretch; border-radius: 12px 12px 0 0; margin: 0 -16px; }
  .order-bar .btn { width: 100%; }
  .stat-value { font-size: 1.1rem; }
  .line-entry { grid-template-columns: 1fr 90px; }
  .line-entry .btn { grid-column: 1 / -1; }
  .nav a.nav-cta { margin-left: 0; }
}

/* Punto de venta */
.page-wide { max-width: 1400px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kbd { font-size: .72rem; font-weight: 600; padding: .05rem .35rem; border-radius: 4px; border: 1px solid currentColor; opacity: .7; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.pos-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .5rem; }
.pos-head p { margin: 0; }
.pos-scan { margin-bottom: 1rem; }
.pos-code { font-size: 1.35rem; min-height: 56px; padding: .6rem .9rem; font-variant-numeric: tabular-nums; }
.pos-scan .hint { margin: .35rem 0 0; }
.pos-aviso { margin: .5rem 0 0; padding: .55rem .8rem; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.pos-cart .pos-name { font-weight: 600; line-height: 1.25; }
.pos-cart tr.pos-last td { background: var(--brand-soft); }
.pos-cart .qty { width: 56px; text-align: center; min-height: 32px; padding: .2rem; }
.stepper { display: inline-flex; gap: .25rem; align-items: center; }
.stepper .btn { min-width: 32px; padding: .2rem .4rem; }
.pos-side { position: sticky; top: 7.5rem; margin: 0; }
.pos-totals { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; margin: 0 0 .5rem; }
.pos-totals dt { color: var(--muted); }
.pos-totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.pos-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); padding: .6rem 0; margin-bottom: .5rem; }
.pos-total strong { font-size: 2.1rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.pos-pay { border: 0; padding: 0; margin: 0 0 .75rem; }
.pos-pay legend { font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin-bottom: .75rem; }
.seg label { flex-direction: row; align-items: center; justify-content: center; gap: .4rem; margin: 0; padding: .55rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 600; }
.seg label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.seg input { width: auto; min-height: auto; margin: 0; accent-color: var(--brand); }
.quick { display: flex; flex-wrap: wrap; gap: .35rem; margin: -.4rem 0 .6rem; }
.pos-change { display: flex; justify-content: space-between; align-items: baseline; }
.pos-change strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.pos-cobrar { min-height: 56px; font-size: 1.15rem; margin-bottom: .5rem; }
.pos-diff { padding: .55rem .8rem; border-radius: 10px; font-weight: 600; }
.pos-diff.ok { background: var(--ok-soft); color: var(--ok); }
.pos-diff.warn { background: var(--warn-soft); color: var(--warn); }
.pos-diff.bad { background: var(--danger-soft); color: var(--danger); }
.cancel-form { display: inline-flex !important; gap: .35rem; align-items: center; margin-left: .35rem; }
.cancel-form input { width: 150px; min-height: 32px; padding: .25rem .5rem; font-size: .85rem; }
.inline-select select { min-height: 34px; padding: .25rem .5rem; max-width: 260px; }
[hidden] { display: none !important; }

@media (max-width: 960px) {
  .pos { grid-template-columns: minmax(0, 1fr); }
  .pos-side { position: static; }
}
