/* Plataforma de socios — mismo lenguaje visual que la Cuponera Virtual de la intranet. */
:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --text: #1f2b3d;
  --muted: #64748b;
  --line: #dde5ef;
  --brand: #2563a9;
  --brand-dark: #1b4a80;
  --brand-soft: #e8f1fa;
  --accent: #3498db;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --success: #0f7a45;
  --success-soft: #e6f6ee;
  --warning: #b7791f;
  --warning-soft: #fdf3e2;
  --wa: #1f9d55;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(24, 41, 66, .08);
  --shadow-sm: 0 2px 8px rgba(24, 41, 66, .06);
  --ring: 0 0 0 3px rgba(37, 99, 169, .18);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161f; --surface: #1b2130; --surface-soft: #222a3b; --text: #e9eef7; --muted: #9caabf;
    --line: #303a4d; --brand: #4b9be0; --brand-dark: #2f7fc4; --brand-soft: #1e304a; --accent: #5dade2;
    --danger: #f07167; --danger-soft: #3a2223; --success: #4ec38a; --success-soft: #1c3329;
    --warning: #e0a458; --warning-soft: #33291a; --shadow: 0 12px 30px rgba(0,0,0,.28);
    --shadow-sm: 0 2px 8px rgba(0,0,0,.22); --ring: 0 0 0 3px rgba(75,155,224,.22);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161f; --surface: #1b2130; --surface-soft: #222a3b; --text: #e9eef7; --muted: #9caabf;
  --line: #303a4d; --brand: #4b9be0; --brand-dark: #2f7fc4; --brand-soft: #1e304a; --accent: #5dade2;
  --danger: #f07167; --danger-soft: #3a2223; --success: #4ec38a; --success-soft: #1c3329;
  --warning: #e0a458; --warning-soft: #33291a; --shadow: 0 12px 30px rgba(0,0,0,.28);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.22); --ring: 0 0 0 3px rgba(75,155,224,.22);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", Roboto, Arial, sans-serif; font-size: 14px; line-height: 1.45;
}
a { color: var(--brand); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Barra superior con la marca del socio ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; background: var(--surface);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.topbar-inner {
  max-width: 1320px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 16px; letter-spacing: .02em;
  color: #fff; background: linear-gradient(135deg, var(--brand), var(--accent));
  box-shadow: 0 6px 14px rgba(37, 99, 169, .25);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.brand-text span { font-size: 12px; color: var(--muted); white-space: nowrap; }

.nav { display: flex; gap: 4px; flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 13px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 700; white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}
.nav a:hover { background: var(--surface-soft); color: var(--text); }
.nav a.is-active { background: var(--brand-soft); color: var(--brand-dark); }
:root[data-theme="dark"] .nav a.is-active { color: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nav a.is-active { color: var(--accent); } }

.user-menu { display: flex; align-items: center; gap: 10px; flex: none; }
.user-chip { display: flex; flex-direction: column; text-align: right; }
.user-chip strong { font-size: 13px; }
.user-chip span { font-size: 11.5px; color: var(--muted); }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer;
  font-size: 16px; text-decoration: none; transition: border-color .15s ease, color .15s ease;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.icon-btn.is-danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- Estructura ---------- */
.shell { max-width: 1320px; margin: 0 auto; padding: 28px 24px 64px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
.eyebrow { display: block; margin-bottom: 6px; color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.hero h1 { margin: 0; font-size: clamp(24px, 3.4vw, 34px); font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.hero p { margin: 6px 0 0; color: var(--muted); }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.panel { margin-bottom: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { display: flex; align-items: center; gap: 9px; margin: 0 0 3px; font-size: 17px; font-weight: 700; }
.panel-head h2 i { color: var(--brand); }
.panel-head p { margin: 0; color: var(--muted); font-size: 13px; }
.panel-body { padding: 22px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm); font: inherit; font-size: 14px; font-weight: 700;
  line-height: 1.2; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; pointer-events: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 6px 14px rgba(37,99,169,.22); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; box-shadow: 0 6px 14px rgba(31,157,85,.25); }
.btn-wa:hover { filter: brightness(.95); }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-block { width: 100%; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { color: var(--muted); font-size: 11.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.field > label .req { color: var(--danger); }
.input, .select, textarea.input {
  width: 100%; min-height: 46px; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-soft); color: var(--text); font: inherit; font-size: 15px; outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
textarea.input { min-height: 80px; resize: vertical; }
.select { cursor: pointer; }
.input:focus, .select:focus { border-color: var(--brand); box-shadow: var(--ring); }
.input.is-invalid, .select.is-invalid { border-color: var(--danger); background: var(--danger-soft); }
.input.is-valid { border-color: var(--success); }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon > .input { padding-left: 40px; }
.input-prefix { display: flex; }
.input-prefix span { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--surface); color: var(--muted); font-weight: 700; }
.input-prefix .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.hint { font-size: 12.5px; color: var(--muted); }
.error { font-size: 12.5px; color: var(--danger); font-weight: 600; display: flex; gap: 5px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

/* Selector de tipo de cupón en tarjetas */
.tipo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.tipo-card { position: relative; cursor: pointer; }
.tipo-card input { position: absolute; opacity: 0; }
.tipo-card span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 92px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--surface-soft);
  transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.tipo-card span strong { font-size: 26px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.tipo-card span small { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.tipo-card:hover span { transform: translateY(-2px); border-color: var(--accent); }
.tipo-card input:checked + span { border-color: var(--brand); background: var(--brand-soft); box-shadow: var(--ring); }
.tipo-card input:checked + span strong { color: var(--brand); }
.tipo-card input:focus-visible + span { box-shadow: var(--ring); }

/* ---------- Indicadores ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.stat .label { display: flex; align-items: center; gap: 7px; }
.stat strong { display: block; margin-top: 8px; font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.stat.is-brand { background: linear-gradient(135deg, var(--brand), var(--accent)); border-color: transparent; color: #fff; }
.stat.is-brand .label { color: rgba(255,255,255,.85); }
.quota { margin-top: 10px; height: 6px; border-radius: 999px; background: rgba(255,255,255,.3); overflow: hidden; }
.quota > i { display: block; height: 100%; background: #fff; border-radius: inherit; }

.quota-pill { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); font-weight: 600; }
.quota-pill i { color: var(--brand); }
.quota-pill.is-full { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.quota-pill.is-full i { color: var(--danger); }

/* ---------- Tabla ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { position: sticky; top: 0; padding: 12px 16px; background: var(--surface-soft); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; text-align: left; white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.mono { font-family: Consolas, "Courier New", monospace; font-weight: 700; letter-spacing: .03em; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty i { display: block; font-size: 36px; margin-bottom: 10px; color: var(--line); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 800; white-space: nowrap; }
.pill-brand { background: var(--brand-soft); color: var(--brand); }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-muted { background: var(--surface-soft); color: var(--muted); border: 1px solid var(--line); }

.filters { display: grid; grid-template-columns: 2fr repeat(4, minmax(0, 1fr)) auto; gap: 12px; align-items: end; padding: 18px 22px; border-bottom: 1px solid var(--line); }

/* ---------- Paginación ---------- */
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 22px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.pagination .pages { display: flex; gap: 6px; }

/* ---------- Avisos ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 13px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 600; }
.alert i { font-size: 18px; line-height: 1.2; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--brand-soft); color: var(--brand-dark); }

/* ---------- Cupón emitido ---------- */
.cupon-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .9fr); gap: 20px; align-items: start; }
.cupon-preview { position: relative; padding: 18px; background: repeating-linear-gradient(45deg, var(--surface-soft), var(--surface-soft) 10px, var(--surface) 10px, var(--surface) 20px); }
.cupon-preview canvas { display: block; width: 100%; height: auto; border-radius: 12px; box-shadow: 0 18px 40px rgba(15, 40, 70, .22); }
.cupon-preview .loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-weight: 600; }
.cupon-preview .loading.is-hidden { display: none; }
.send-actions { display: grid; gap: 10px; }
.detail-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); min-width: 0; }
.detail span { display: block; font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .07em; text-transform: uppercase; }
.detail p { margin: 4px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.detail.wide { grid-column: 1 / -1; }

.success-banner { display: flex; align-items: center; gap: 14px; padding: 16px 20px; margin-bottom: 20px; border-radius: var(--radius); background: linear-gradient(135deg, #0f7a45, #1fa463); color: #fff; box-shadow: 0 10px 24px rgba(15, 122, 69, .25); }
.success-banner i { font-size: 28px; }
.success-banner strong { display: block; font-size: 16px; }

/* ---------- Usuarios ---------- */
.user-card { display: grid; grid-template-columns: minmax(200px, 1.1fr) 2.4fr auto; gap: 18px; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.user-card:last-child { border-bottom: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 800; flex: none; }
.user-id { display: flex; gap: 12px; align-items: center; min-width: 0; }
.user-id strong { display: block; }
.user-id span { color: var(--muted); font-size: 12.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; }
.chip span { display: inline-flex; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-soft); font-weight: 700; font-size: 13px; cursor: pointer; color: var(--muted); }
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip input:focus-visible + span { box-shadow: var(--ring); }
.switches { display: flex; flex-wrap: wrap; gap: 14px; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-side {
  position: relative; overflow: hidden; padding: 48px; color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  /* Foto de la planta CEDDIVE con degradado de la marca: oscuro a la izquierda (texto), se aclara hacia la foto. */
  background:
    linear-gradient(to top, rgba(12, 34, 62, .78) 0%, rgba(12, 34, 62, 0) 32%),
    linear-gradient(100deg, rgba(20, 56, 100, .96) 0%, rgba(27, 74, 128, .9) 30%, rgba(37, 99, 169, .55) 58%, rgba(52, 152, 219, .12) 100%),
    url('../img/login-ceddive.jpg') 72% center / cover no-repeat,
    #1b4a80;
}
.login-side::after { content: ""; position: absolute; left: -140px; top: -140px; width: 420px; height: 420px; border-radius: 50%; border: 70px solid rgba(255,255,255,.06); pointer-events: none; }
.login-side > * { position: relative; z-index: 1; }
.login-side h1 { text-shadow: 0 2px 18px rgba(8, 24, 48, .35); }
.login-side h1 { font-size: clamp(30px, 4vw, 44px); line-height: 1.08; letter-spacing: -.03em; margin: 0 0 14px; }
.login-side p { max-width: 440px; color: rgba(255,255,255,.85); font-size: 15.5px; }
.login-side ul { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; }
.login-side li { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.login-side li i { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: rgba(255,255,255,.16); }
.login-logo { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; letter-spacing: .02em; }
.login-logo img { width: 46px; height: 46px; padding: 6px; border-radius: 12px; background: #fff; }
.login-main { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.login-card { width: 100%; max-width: 400px; }
.login-card h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.02em; }
.login-card > p { margin: 0 0 26px; color: var(--muted); }
.pass-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; font-size: 17px; }
.footer-note { margin-top: 26px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ---------- Modales (dialog nativo) ---------- */
.modal {
  width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); padding: 0;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text);
  box-shadow: 0 30px 80px rgba(10, 25, 45, .35); overflow: hidden;
}
.modal[open] { display: flex; flex-direction: column; animation: modal-in .18s ease-out; }
.modal > form, .modal-paso { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.modal-paso[hidden] { display: none; }
.modal::backdrop { background: rgba(12, 20, 34, .55); backdrop-filter: blur(3px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex: none; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.modal-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.modal-head .modal-x { margin-left: auto; }
.modal-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-size: 19px; }
.modal-head.is-success .modal-icon { background: var(--success); color: #fff; }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1 1 auto; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-soft); flex: none; flex-wrap: wrap; }
.modal-foot-btns { display: flex; gap: 8px; margin-left: auto; }
.form-compacta { display: flex; flex-direction: column; gap: 14px; }
.form-compacta .grid-2 { gap: 14px; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

/* Tipos de cupón compactos */
.tipo-grid.is-compacta { grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; }
.tipo-grid.is-compacta .tipo-card span { padding: 10px 8px; gap: 0; }
.tipo-grid.is-compacta .tipo-card span strong { font-size: 20px; }
.tipo-grid.is-compacta .tipo-card span small { font-size: 10.5px; }

.nota-toggle summary { cursor: pointer; color: var(--brand); font-weight: 700; font-size: 13px; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
.nota-toggle summary::-webkit-details-marker { display: none; }
.nota-toggle summary small { color: var(--muted); font-weight: 600; }
.nota-toggle textarea { margin-top: 8px; width: 100%; resize: vertical; }

/* Paso "cupón emitido" */
.cupon-preview.is-mini { padding: 10px; border-radius: 14px; }
.cupon-preview.is-mini canvas { border-radius: 8px; box-shadow: 0 10px 24px rgba(15, 40, 70, .18); }
.enviar-a { margin: 12px 0; color: var(--muted); font-weight: 600; text-align: center; }
.envio-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.envio-grid .btn-wa { grid-column: 1 / -1; }

/* Interruptores de permisos */
.toggle-list { display: grid; gap: 8px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); cursor: pointer; }
.toggle-row strong { display: block; font-size: 14px; }
.toggle-row small { color: var(--muted); font-size: 12.5px; }
.switch { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 42px; height: 24px; margin: 0; border-radius: 999px; background: var(--line); cursor: pointer; transition: background .18s ease; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s ease; }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: none; box-shadow: var(--ring); }
.perm-icons { display: inline-flex; gap: 6px; }
.perm-icons i { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface-soft); color: var(--line); border: 1px solid var(--line); }
.perm-icons i.on { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

/* Tabla pequeña del detalle de actividad */
.table-mini { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 13px; }
.table-mini th, .table-mini td { padding: 8px 12px; }
.table-mini .is-antes { color: var(--danger); text-decoration: line-through; text-decoration-color: rgba(192,57,43,.4); }
.table-mini .is-despues { color: var(--success); font-weight: 700; }

/* Paginación numerada */
.pagination .pages { align-items: center; gap: 14px; flex-wrap: wrap; }
.per-page { display: flex; align-items: center; gap: 8px; }
.per-page label { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.per-page .select { width: auto; padding: 6px 28px 6px 10px; }
.page-nums { display: flex; gap: 4px; align-items: center; }
.page-btn { min-width: 34px; height: 34px; padding: 0 8px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); font-weight: 700; text-decoration: none; }
a.page-btn:hover { border-color: var(--brand); color: var(--brand); }
.page-btn.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.page-btn.is-disabled { opacity: .4; }
.page-gap { padding: 0 2px; color: var(--muted); }

/* Avisos */
.toast { position: fixed; top: 18px; right: 18px; z-index: 50; display: flex; align-items: center; gap: 9px; max-width: calc(100vw - 36px); padding: 11px 16px; border-radius: 12px; background: var(--text); color: var(--surface); font-weight: 600; box-shadow: 0 12px 30px rgba(0,0,0,.25); opacity: 0; transform: translateY(-8px); transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: none; }
.toast-success i { color: #4ec38a; }
.toast-error i { color: #f07167; }
.toast-info i { color: #5dade2; }

@media (max-width: 600px) {
  /* En el celular el modal sale desde abajo (hoja inferior). */
  .modal { width: 100vw; max-width: 100vw; max-height: 94dvh; margin: auto 0 0; border-radius: 20px 20px 0 0; border-bottom: 0; }
  .modal[open] { animation-name: sheet-in; }
  .modal-foot-btns { width: 100%; }
  .modal-foot-btns .btn { flex: 1 1 0; }
  .envio-grid { grid-template-columns: 1fr 1fr; }
  .envio-grid [data-cupon="copiar"] { grid-column: 1 / -1; }
  .form-compacta .grid-2 { grid-template-columns: 1fr 1fr; }
  .pagination { justify-content: center; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }

/* ---------- Página del cupón (compacta, sin scroll en escritorio) ---------- */
.cupon-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.cupon-top-t { min-width: 0; }
.cupon-top-t .eyebrow { margin-bottom: 2px; }
.cupon-top h1 { margin: 0; font-size: clamp(20px, 2.6vw, 26px); font-weight: 700; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cupon-top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.cupon-top-actions form { margin: 0; }
.cupon-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); margin: 0; overflow: clip; } /* clip: permite la barra sticky */
.cupon-card-img { position: relative; display: grid; place-items: center; padding: 18px; border-right: 1px solid var(--line); background: repeating-linear-gradient(45deg, var(--surface-soft), var(--surface-soft) 10px, var(--surface) 10px, var(--surface) 20px); }
.cupon-card-img canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: min(560px, calc(100dvh - 280px)); border-radius: 10px; box-shadow: 0 14px 34px rgba(15, 40, 70, .2); }
.cupon-card-img .loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-weight: 600; }
.cupon-card-img .loading.is-hidden { display: none; }
.cupon-card-info { display: flex; flex-direction: column; gap: 16px; padding: 18px 20px; min-width: 0; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; margin: 0; }
.kv > div { padding: 8px 0; border-bottom: 1px dashed var(--line); min-width: 0; }
.kv .kv-wide { grid-column: 1 / -1; }
.kv dt { font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.kv dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.envio-bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: auto; }
.envio-bar .btn-wa { grid-column: 1 / -1; padding: 12px 18px; font-size: 15px; }
.envio-hint { margin: -6px 0 0; font-size: 12px; }

@media (max-width: 900px) {
  .cupon-card { grid-template-columns: 1fr; }
  .cupon-card-img { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px; }
  .cupon-card-img canvas { max-height: none; width: 100%; }
}
@media (max-width: 760px) {
  .hide-sm { display: none; }
  .cupon-top { gap: 10px; margin-bottom: 12px; }
  .cupon-top .pill { display: none; }
  .cupon-card-info { padding: 12px 16px 0; gap: 0; }
  .envio-hint { display: none; }
  /* Barra de envío fija abajo: WhatsApp grande + íconos. */
  .envio-bar {
    position: sticky; bottom: 0; z-index: 5; grid-template-columns: 1fr auto auto auto;
    margin: 12px -16px 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -8px 20px rgba(15, 30, 50, .08);
  }
  .envio-bar .btn-wa { grid-column: auto; padding: 11px 12px; font-size: 14px; }
  .envio-bar .btn-ghost { width: 44px; padding: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters .field:first-child { grid-column: 1 / -1; }
  .user-card { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .cupon-layout { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-page { grid-template-columns: 1fr; }
  .login-side { padding: 28px 24px; min-height: 230px; background-position: 0 0, 0 0, 60% 35%, 0 0; }
  .login-side ul, .login-side p.lead { display: none; }
  .login-side::after { display: none; }
}
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .nav { order: 3; flex-basis: 100%; }
  .user-chip { display: none; }
  .brand { flex: 1 1 auto; }
  .shell { padding: 20px 16px 48px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; padding: 16px; }
  .panel-head, .panel-body { padding: 16px; }
  .detail-list { grid-template-columns: 1fr; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1 1 auto; }
  /* Tabla como tarjetas en móvil */
  .table.responsive thead { display: none; }
  .table.responsive tr { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table.responsive td { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border: 0; }
  .table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
  .table.responsive td.cell-actions { justify-content: flex-end; }
  .table.responsive td.cell-actions::before { content: none; }
}
