/* Tornami: estilos base compartidos por los paneles */
:root {
    --brand: #E4572E;
    --brand-ink: #ffffff;
    --bg: #f6f5f2;
    --surface: #ffffff;
    --ink: #1d1d1f;
    --muted: #6b6b70;
    --line: #e4e2dc;
    --ok: #1f7a4d;
    --ok-bg: #e5f4e4;
    --warn: #9a4b00;
    --warn-bg: #f9eeda;
    --danger: #b42318;
    --danger-bg: #fbebeb;
    --radius: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141416;
        --surface: #1d1d20;
        --ink: #f2f2f3;
        --muted: #a0a0a8;
        --line: #2e2e33;
        --ok: #6fd39b;
        --ok-bg: #16301f;
        --warn: #f3b25f;
        --warn-bg: #33260f;
        --danger: #ff8a7a;
        --danger-bg: #3a1714;
    }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: var(--brand); }
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; padding-block: 12px; gap: 16px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; margin: 0; }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; }
.tag { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.btn { display: inline-block; border: 0; border-radius: 8px; padding: 10px 16px; font: inherit; font-weight: 600; background: var(--brand); color: var(--brand-ink); cursor: pointer; text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .9rem; }
.field input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.alert { padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); margin-bottom: 14px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.status { font-size: .8rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.status-active { background: var(--ok-bg); color: var(--ok); }
.status-suspended { background: var(--warn-bg); color: var(--warn); }
code { font-size: .85em; background: var(--bg); padding: 1px 5px; border-radius: 4px; }

.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }

/* --- Panel --- */
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a { color: var(--muted); text-decoration: none; font-weight: 600; padding: 6px 12px; border-radius: 8px; }
.mainnav a:hover { color: var(--ink); background: var(--bg); }
.mainnav a.is-active { color: var(--ink); background: var(--bg); }
.usernav { display: flex; align-items: center; gap: 10px; }
.btn-sm { padding: 6px 12px; font-size: .9rem; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; }
.btn-link.danger { color: var(--danger); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.breadcrumb { font-size: .9rem; margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); }
.strong-link { font-weight: 700; color: var(--ink); text-decoration: none; }
.strong-link:hover { color: var(--brand); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; text-decoration: none; color: var(--ink); }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-warn .stat-value { color: var(--warn); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select, .inline-form input { font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.filters input[type=search] { flex: 1; min-width: 220px; }

.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-warning, .flash-danger { background: var(--warn-bg); color: var(--warn); }
.flash-danger { background: var(--danger-bg); color: var(--danger); }

.status-pending { background: var(--warn-bg); color: var(--warn); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.stack > * + * { margin-top: 16px; }
.card h2 { font-size: 1.1rem; margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
dl.props dt { color: var(--muted); font-size: .9rem; }
dl.props dd { margin: 0; word-break: break-word; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { display: inline; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.inline-form input { flex: 1; min-width: 200px; }

/* --- Formularios --- */
.form-card { max-width: 720px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 16px; }
.form-section { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.field select, .field textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.field .help { color: var(--muted); font-size: .85rem; }
.field .errors { list-style: none; margin: 0; padding: 0; color: var(--danger); font-size: .9rem; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.field-check label { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.optional { font-weight: 400; font-size: .85em; }
.input-affix { display: flex; align-items: stretch; }
.input-affix input { flex: 1; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-affix span { border: 1px solid var(--line); border-left: 0; border-radius: 0 8px 8px 0; padding: 10px 12px; background: var(--surface); color: var(--muted); }
form > ul.errors, .form-errors { list-style: none; padding: 12px 14px; margin: 0 0 16px; border-radius: 8px; background: var(--danger-bg); color: var(--danger); }

.secret { font-family: ui-monospace, Consolas, monospace; font-size: 1.3rem; letter-spacing: .05em; padding: 12px 16px; border-radius: 8px; background: var(--bg); border: 1px dashed var(--line); display: inline-block; user-select: all; }

/* --- Panel del cliente --- */
.support-banner { background: var(--warn-bg); color: var(--warn); padding: 8px 16px; text-align: center; font-size: .9rem; }
.panel-footer { font-size: .8rem; padding-top: 0; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li + li { margin-top: 10px; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.checklist li { display: flex; align-items: center; gap: 10px; }
.checklist .check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .8rem; flex: none; }
.checklist li.is-done { color: var(--muted); }
.checklist li.is-done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.stat-value small { font-size: .9rem; font-weight: 500; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tile h2 { font-size: 1.05rem; margin: 12px 0 4px; }
.tile p { margin: 0 0 10px; }
.tile-link { text-decoration: none; color: var(--ink); transition: border-color .15s; }
.tile-link:hover { border-color: var(--brand); }
.tile-brand { height: 96px; border-radius: 8px; display: grid; place-items: center; border: 1px solid var(--line); }
.tile-brand img { max-height: 72px; max-width: 80%; border-radius: 50%; }
.tile-initial { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.4rem; }
.swatches span { display: inline-block; width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line); margin-right: 4px; }
.type-tile.is-disabled { opacity: .6; }
.logo-current { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; vertical-align: middle; border: 1px solid var(--line); }
.danger-zone { margin-top: 20px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .9rem; }

.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.preview-pane { position: sticky; top: 16px; }
@media (max-width: 900px) { .editor-grid { grid-template-columns: 1fr; } .preview-pane { position: static; } }
.fields-table td, .fields-table th { padding: 6px 8px; }
.field input[type=color] { padding: 2px; height: 42px; width: 100%; cursor: pointer; }
.field .choices-list, .field > div:has(> input[type=checkbox]) { display: grid; gap: 6px; }

/* --- Tarjeta (vista previa del Wallet) --- */
.wallet-card { --card-primary: #1F6FEB; --card-on-primary: #fff; --card-bg: #fff; --card-on-bg: #111;
    background: var(--card-bg); color: var(--card-on-bg); border-radius: 18px; overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,.12); border: 1px solid rgba(0,0,0,.06); max-width: 340px; font-size: .95rem; }
.wallet-card-head { background: var(--card-primary); color: var(--card-on-primary); display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.wallet-card-logo { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #fff; flex: none; }
.wallet-card-logo-empty { display: grid; place-items: center; color: var(--card-primary); font-weight: 800; }
.wallet-card-business { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wallet-card-body { padding: 14px 16px 6px; }
.wallet-card-title { font-weight: 700; font-size: 1.1rem; margin: 0; }
.wallet-card-desc { margin: 2px 0 10px; opacity: .8; font-size: .85rem; min-height: 1em; }
.stamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 10px 0; }
.stamp { aspect-ratio: 1; border-radius: 50%; border: 2px dashed currentColor; opacity: .45; }
.stamp.is-filled { background: var(--card-primary); border: 2px solid var(--card-primary); opacity: 1; box-shadow: inset 0 0 0 3px var(--card-bg); }
.wallet-card-reward { margin: 6px 0 0; font-size: .85rem; }
.wallet-card-qr { display: grid; place-items: center; padding: 12px 0 16px; }
.wallet-card-qr span { width: 84px; height: 84px; border-radius: 6px; background:
    repeating-conic-gradient(var(--card-on-bg) 0 25%, transparent 0 50%) 0 0 / 14px 14px; opacity: .85; border: 6px solid #fff; outline: 1px solid rgba(0,0,0,.1); }

/* --- Panel: QR de alta --- */
.qr-list { display: grid; gap: 14px; }
.qr-item { display: flex; gap: 14px; align-items: flex-start; }
.qr-item img { border: 1px solid var(--line); border-radius: 6px; background: #fff; flex: none; }
.qr-item .actions { margin-top: 4px; font-size: .9rem; }
code.copyable { user-select: all; word-break: break-all; }
.inline-form select { font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }

/* --- Web pública del club (socios) --- */
body.club { background: var(--club-bg, var(--bg)); }
.club-wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.club-header { background: var(--brand); color: var(--brand-ink); }
.club-header .club-wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.club-brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.club-brand img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #fff; }
.club-account { color: inherit; font-weight: 600; text-decoration: none; opacity: .9; }
.club-main { padding-top: 24px; padding-bottom: 32px; }
.club-footer { font-size: .8rem; color: var(--muted); padding-bottom: 24px; }
.club-hero { text-align: center; margin: 8px 0 24px; color: var(--club-on-bg, var(--ink)); }
.club-hero h1 { font-size: 1.8rem; }
.club-programs { display: grid; gap: 16px; }
.club-program { display: grid; grid-template-columns: minmax(0, 340px) 1fr; gap: 20px; align-items: center; }
@media (max-width: 700px) { .club-program { grid-template-columns: 1fr; } }
.club-note { text-align: center; color: var(--club-on-bg, var(--muted)); opacity: .8; font-size: .9rem; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-lg { padding: 14px 20px; font-size: 1.05rem; }
.club-join { display: grid; grid-template-columns: 1fr minmax(0, 420px); gap: 24px; align-items: start; }
@media (max-width: 800px) { .club-join { grid-template-columns: 1fr; } }
.club-join-intro { color: var(--club-on-bg, var(--ink)); }
.club-join-intro .lead { font-size: 1.1rem; }
.club-join-intro .wallet-card { margin: 16px 0; }
.club-benefits { padding-left: 18px; }
.club-benefits li + li { margin-top: 4px; }
.consents { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.consents .field label { font-weight: 500; font-size: .92rem; align-items: flex-start; }
.consents .field input[type=checkbox] { margin-top: 3px; flex: none; }
.terms { font-size: .85rem; margin: -6px 0 12px 26px; }
.legal { font-size: .78rem; color: var(--muted); margin: 14px 0 0; }
.hp-field { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }
.club-message { max-width: 520px; margin: 0 auto; }
.club-message h1 { font-size: 1.4rem; }
.dev-note { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 8px; font-size: .9rem; }
.card-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.danger-link { color: var(--danger); }
.club-card-page { max-width: 420px; margin: 0 auto; display: grid; gap: 16px; }
.wallet-card-live { max-width: none; }
.wallet-card-qrcode { background: #fff; color: #111; text-align: center; padding: 16px 16px 12px; border-top: 1px dashed rgba(0,0,0,.15); }
.qr-box svg { width: 220px; height: 220px; max-width: 100%; }
.qr-code-text { font-family: ui-monospace, Consolas, monospace; letter-spacing: .15em; margin: 4px 0 0; font-size: .9rem; color: #555; }
.reward-ready { background: rgba(255,255,255,.6); color: #111; border-radius: 8px; padding: 8px 10px; font-weight: 600; font-size: .9rem; }
.btn-gwallet { display: flex; align-items: center; justify-content: center; gap: 10px; background: #000; color: #fff; border-radius: 999px; padding: 12px 18px; font-weight: 600; text-decoration: none; margin: 0 0 12px; }
.btn-gwallet.is-disabled { background: #6b6b70; cursor: default; }
.howto summary { cursor: pointer; font-weight: 600; }
.howto ol { padding-left: 18px; }
.history li { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; }

/* --- Escáner (móvil del empleado) --- */
body.scanner-body { background: #111; color: #f2f2f3; }
.scanner { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; gap: 12px; padding: 0 0 24px; }
.scanner.is-busy { cursor: progress; }
.scanner.is-busy button { opacity: .6; pointer-events: none; }
.scanner-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--brand); color: var(--brand-ink); }
.scanner-head strong { display: block; }
.scanner-user { font-size: .85rem; opacity: .85; }
.scanner-head-actions { display: flex; gap: 14px; }
.scanner-head-actions a { color: inherit; font-weight: 600; text-decoration: none; }
.scanner-store { display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.scanner-store label { color: #a0a0a8; font-size: .9rem; }
.scanner-store select { flex: 1; font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid #333; background: #1d1d20; color: #f2f2f3; }
.scanner-camera, .scanner-result, .scanner-empty { padding: 0 16px; display: grid; gap: 12px; }
.scanner-reader { width: 100%; min-height: 0; border-radius: 14px; overflow: hidden; background: #000; }
.scanner-reader video { width: 100% !important; border-radius: 14px; }
.scanner-hint { text-align: center; color: #a0a0a8; margin: 0; }
.scanner-manual { display: flex; gap: 8px; }
.scanner-manual input { flex: 1; font: inherit; font-family: ui-monospace, Consolas, monospace; letter-spacing: .1em; text-transform: uppercase; padding: 12px; border-radius: 8px; border: 1px solid #333; background: #1d1d20; color: #f2f2f3; }
.scanner .btn-ghost { color: #f2f2f3; border-color: #444; }
.scanner-card { --card-primary: var(--brand); background: #fff; color: #111; border-radius: 16px; padding: 16px; border-top: 8px solid var(--card-primary); }
.scanner-member { font-size: 1.6rem; font-weight: 800; margin: 0; }
.scanner-program { margin: 2px 0 8px; color: #555; font-size: .9rem; }
.scanner-stamps { --card-bg: #fff; color: #111; }
.scanner-balance { font-weight: 600; margin: 4px 0; }
.scanner-reward { background: #fff4d6; color: #7a4b00; border-radius: 8px; padding: 8px 10px; font-weight: 700; margin: 8px 0 0; }
.scanner-meta { color: #666; font-size: .85rem; margin: 8px 0 0; }
.btn-xl { padding: 20px; font-size: 1.3rem; border-radius: 14px; }
.btn[disabled] { background: #3a3a3f; color: #c8c8cc; cursor: not-allowed; font-size: 1rem; }
.btn-reward { background: #f2b705; color: #111; }
.scanner-secondary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.scanner-secondary .btn[hidden] + .btn { grid-column: span 2; }
.scanner-message { border-radius: 12px; padding: 14px; font-weight: 700; text-align: center; font-size: 1.1rem; }
.scanner-message.is-ok { background: #16301f; color: #6fd39b; }
.scanner-message.is-celebrate { background: #f2b705; color: #111; font-size: 1.25rem; }
.scanner-error { margin: 0 16px; background: #3a1714; color: #ff8a7a; border-radius: 12px; padding: 14px; font-weight: 600; }
.scanner-empty { text-align: center; padding-top: 40px; }

/* Campañas: novedades en la tarjeta web */
.club-news h2 { margin-top: 0; }
.news-item { display: grid; gap: 4px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.news-item:last-child { border-bottom: 0; padding-bottom: 0; }
.news-kind { justify-self: start; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.news-kind-promotion, .news-kind-event { color: var(--brand); }
.news-title { font-size: 1.05rem; }
.news-body { margin: 0; white-space: pre-line; }
.news-date { font-size: .8rem; }

/* Campañas: panel */
.campaign-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
@media (max-width: 860px) { .campaign-layout { grid-template-columns: 1fr; } }
.phone-preview { background: #1d1d20; color: #f2f2f3; border-radius: 22px; padding: 16px; display: grid; gap: 10px; }
.phone-preview-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: #a0a0a8; margin: 0; }
.phone-notification { background: rgba(255,255,255,.12); border-radius: 14px; padding: 10px 12px; display: grid; gap: 2px; font-size: .9rem; }
.phone-notification strong { font-size: .95rem; }
.phone-notification span { color: #c8c8cc; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.audience-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 12px 0; }
.audience-grid .stat { background: var(--bg); border-radius: 8px; padding: 10px 12px; }
.audience-grid .stat strong { display: block; font-size: 1.5rem; }
.audience-grid .stat span { font-size: .85rem; color: var(--muted); }
.campaign-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.campaign-actions form { display: flex; gap: 8px; align-items: end; margin: 0; }
.campaign-actions input[type="datetime-local"] { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.kind-help { margin: 4px 0 0; font-size: .85rem; color: var(--muted); }
.notice-box { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 12px; font-size: .9rem; }
