:root {
  --brand: #E8743B;
  --brand-dark: #C95E29;
  --brand-soft: #FDF1EA;
  --ink: #1F2328;
  --ink-2: #57606A;
  --ink-3: #8C959F;
  --line: #E6E8EB;
  --bg: #F6F7F9;
  --card: #FFFFFF;
  --ok: #2E8B57;
  --bad: #C2410C;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; }
a { color: var(--brand-dark); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--ink-3); }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, var(--brand-soft), var(--bg) 55%); }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(16,24,40,.08); padding: 32px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: .3px; }
.logo-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 800; }
.auth-card h1 { font-size: 20px; margin: 24px 0 4px; }
.auth-card p.sub { color: var(--ink-2); margin: 0 0 20px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 13px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; background: #fff; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px;
  padding: 8px 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: #F3F4F6; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; justify-content: center; padding: 11px; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }
.error { background: #FEF2F2; color: #B42318; border-radius: 8px; padding: 9px 12px; margin-bottom: 14px; font-size: 13px; }
.notice { background: var(--brand-soft); color: var(--brand-dark); border-radius: 8px; padding: 9px 12px; margin-bottom: 14px; font-size: 13px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.side .logo { padding: 0 8px 18px; }
.side .biz { font-size: 12px; color: var(--ink-3); padding: 0 8px 14px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-3); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: #F3F4F6; }
.nav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }
.main { padding: 24px 32px 48px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { font-size: 22px; margin: 0; }
.menu-btn { display: none; }

/* ---------- Cards / KPIs ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card h2 { font-size: 15px; margin: 0 0 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi .k { font-size: 12px; color: var(--ink-2); }
.kpi .v { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 12px; margin-top: 2px; }
.up { color: var(--ok); } .down { color: var(--bad); }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }

/* ---------- Range picker ---------- */
.range { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.range .chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 13px; color: var(--ink-2); }
.range .chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.range input[type=date] { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }

/* ---------- Tables ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type=search], .toolbar select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; min-width: 220px; background: #fff; }
.spacer { flex: 1; }
.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); white-space: nowrap; }
th { font-size: 12px; color: var(--ink-2); font-weight: 600; background: #FAFBFC; position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #FAFBFC; }
tr.click { cursor: pointer; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.empty { text-align: center; color: var(--ink-3); padding: 36px 12px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #EEF0F3; color: var(--ink-2); }
.badge.ok { background: #E7F5EE; color: var(--ok); }
.badge.warn { background: #FFF4E5; color: #B54708; }
.badge.brand { background: var(--brand-soft); color: var(--brand-dark); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a.on { color: var(--brand-dark); border-color: var(--brand); font-weight: 600; }

/* ---------- Chart ---------- */
.chart { width: 100%; height: 240px; }
.chart .bar { fill: var(--brand); opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart text { font-size: 11px; fill: var(--ink-3); }
.chart .grid { stroke: var(--line); }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 50px rgba(16,24,40,.25); }
.modal.wide { max-width: 760px; }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; font-size: 17px; }
.modal .body { padding: 18px 20px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.x { border: 0; background: none; font-size: 22px; color: var(--ink-3); line-height: 1; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 8px; z-index: 60; box-shadow: var(--shadow); }
.muted { color: var(--ink-3); }
.receipt-lines td { padding: 6px 4px; border: 0; }
.mt { margin-top: 12px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; width: 250px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .main { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .toolbar input[type=search] { min-width: 0; flex: 1; }
}

/* ---------- Complementos / suscripciones ---------- */
.gate { max-width: 560px; margin: 24px auto; text-align: center; padding: 36px 28px; }
.gate h2 { font-size: 22px; margin: 14px 0 6px; }
.gate-ic { width: 64px; height: 64px; border-radius: 18px; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; margin: 0 auto; }
.gate-ic svg { width: 32px; height: 32px; }
.gate-ic.sm { width: 48px; height: 48px; border-radius: 14px; margin: 0; }
.gate-ic.sm svg { width: 24px; height: 24px; }
.gate-list { list-style: none; padding: 0; margin: 18px auto; text-align: left; display: inline-block; }
.gate-list li { padding: 5px 0 5px 26px; position: relative; }
.gate-list li::before { content: "✓"; position: absolute; left: 0; color: var(--brand); font-weight: 800; }
.gate-price { font-size: 28px; font-weight: 800; margin: 8px 0 16px; }
.gate-price .muted { font-size: 14px; font-weight: 500; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 18px 0; }
.plan h2 { margin-top: 12px; }
.plan .gate-price { margin: 10px 0 0; }

/* ---------- Cuenta ---------- */
.acct { max-width: 760px; }
.acct-head { display: flex; gap: 16px; align-items: center; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 24px; font-weight: 800; flex: none; }
.acct-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.acct-row:last-of-type { border-bottom: 0; }
.pw { position: relative; display: flex; }
.pw input { flex: 1; padding-right: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 40px 9px 11px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; opacity: .6; }
.danger-zone { border: 1px solid #F5C2B0; }
.danger-zone h2 { color: var(--bad); }
input:disabled { background: #F6F7F9; color: var(--ink-2); }

/* ---------- Menú lateral y barra superior (v2) ---------- */
.shell { grid-template-columns: 272px 1fr; }
.side { padding: 0; display: flex; flex-direction: column; }
.side-user { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.side-user-t { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.side-user-t strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-t span { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.caret { color: var(--ink-3); }
.avatar.sm { width: 38px; height: 38px; font-size: 16px; }
.user-menu { border-bottom: 1px solid var(--line); padding: 6px 0; }
.user-menu a { display: block; padding: 9px 20px 9px 66px; color: var(--ink-2); }
.user-menu a:hover { background: #F3F4F6; }
.side .nav { flex: 1; overflow-y: auto; padding: 6px 0; }
.grp-h { display: flex; align-items: center; gap: 14px; padding: 13px 18px; color: var(--ink); font-weight: 600; border-left: 4px solid transparent; }
.grp-h svg { width: 22px; height: 22px; color: var(--brand); flex: none; }
.grp-h span:not(.chev) { flex: 1; }
.grp-h:hover { background: #F7F7F8; }
.grp-h.active { background: var(--brand-soft); border-left-color: var(--brand); }
.chev { color: var(--ink-3); transition: transform .2s; font-size: 18px; line-height: 1; }
.grp.open .chev { transform: rotate(180deg); }
.grp-c { display: none; padding: 2px 0 8px; }
.grp.open .grp-c { display: block; animation: drop .18s ease-out; }
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } }
.grp-c a { display: block; padding: 9px 18px 9px 58px; color: var(--ink-2); font-weight: 500; }
.grp-c a:hover { background: #F7F7F8; color: var(--ink); }
.grp-c a.on { color: var(--brand-dark); font-weight: 700; }
.side-brand { padding: 14px 18px; border-top: 1px solid var(--line); }
.main { padding: 0; }
.appbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 14px 28px; background: linear-gradient(90deg, var(--brand), #F08A55); color: #fff; box-shadow: 0 2px 8px rgba(232,116,59,.25); }
.appbar h1 { font-size: 20px; margin: 0; flex: 1; font-weight: 700; }
.appbar .btn.primary { background: #fff; color: var(--brand-dark); border-color: #fff; }
.appbar .btn.primary:hover { background: var(--brand-soft); }
.appbar-act { display: flex; gap: 8px; }
.menu-btn { display: none; background: none; border: 0; color: #fff; font-size: 24px; padding: 0 4px; }
.page { padding: 22px 28px 48px; }
.scrim { display: none; }
.topbar { display: none; }

/* ---------- Funciones (interruptores) ---------- */
.feat { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.feat:last-of-type { border-bottom: 0; }
.feat-ic svg { width: 26px; height: 26px; color: var(--ink-2); }
.feat-t { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #D0D5DD; border-radius: 999px; transition: background .2s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(20px); }
.perm-box { border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px 10px; margin-bottom: 14px; }
.token-box { background: #F6F7F9; border: 1px dashed var(--line); border-radius: 8px; padding: 12px; word-break: break-all; }
.store-badges { display: flex; justify-content: center; margin: 18px 0; }
.store-badge { background: #111; color: #fff; border-radius: 10px; padding: 12px 18px; font-weight: 700; display: inline-flex; flex-direction: column; align-items: center; }
.store-badge small { font-weight: 400; opacity: .7; font-size: 11px; }
.ticket-prev { max-width: 280px; margin: 0 auto; font-family: ui-monospace, Menlo, monospace; font-size: 13px; text-align: center; background: #FFFDF9; border: 1px solid var(--line); padding: 16px; border-radius: 6px; }
.tp-row { display: flex; justify-content: space-between; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 300px; max-width: 86vw; height: 100vh; z-index: 45; transform: translateX(-105%); transition: transform .25s ease; }
  .side.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 44; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .scrim.on { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-flex; }
  .appbar { padding: 12px 14px; }
  .appbar h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .appbar .btn { padding: 7px 10px; font-size: 13px; }
  .page { padding: 14px; }
  .row { flex-direction: column; gap: 0; }
}

/* ---------- Etiquetas ---------- */
.tabs { flex-wrap: nowrap; }
.labels { display: grid; grid-template-columns: repeat(auto-fill, 200px); gap: 8px; margin-top: 14px; }
.label { border: 1px dashed var(--line); border-radius: 6px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; background: #fff; font-size: 12px; text-align: center; }
.label .bc { width: 180px; height: 40px; }
@media print {
  .side, .appbar, .no-print, .tabs, .toast { display: none !important; }
  .shell { display: block; } .page { padding: 0; } body { background: #fff; }
  .labels { grid-template-columns: repeat(3, 1fr); }
}
