/* Estilos compartidos por todas las apps. Se carga antes del app.css de cada una, que tiene sus colores (tokens) y
   lo propio de sus pantallas. Va embebido en Negocios.Comun y se sirve en /comun/comun.css. */

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; color: var(--muted); font-weight: 600; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.right { text-align: right; }
.error { color: var(--bad); font-size: 14px; min-height: 1.2em; margin: 0; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.strike { text-decoration: line-through; color: var(--faint); }

/* ---------- Controles ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 16px; /* 16px: iOS no hace zoom */
  color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--accent); }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
textarea { resize: vertical; min-height: 70px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
  min-height: 44px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.lg { min-height: 52px; font-size: 17px; }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; flex: none; }
.icon-btn { min-width: 44px; padding: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
  padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.plain::before { display: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.spacer { flex: 1; }
.narrow { max-width: 480px; }
.mt { margin-top: 16px; }
.my { margin: 16px 0; }
.markup { width: 80px; }
.list a.item { color: var(--text); text-decoration: none; font-weight: 600; min-height: 48px; }
.list a.item svg { width: 22px; height: 22px; color: var(--muted); }

/* ---------- Login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; padding: 24px; box-shadow: var(--shadow); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; }
.brand.big { font-size: 26px; margin-bottom: 6px; }
.login-card .center, .center { text-align: center; }
.login-card h2 { margin-bottom: 4px; }
.auth-tabs { margin-bottom: 14px; }
.auth-tabs button { flex: 1; }
#auth { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar .brand { min-width: 0; flex: 0 1 auto; }
.topbar .brand img { flex: none; }
#brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .brand.switch { cursor: pointer; }
.topbar .brand.switch::after { content: "▾"; color: var(--muted); font-size: 14px; margin-left: -2px; }
.biz-item { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--text); font: inherit; padding: 12px 4px; }
.biz-item.current strong { color: var(--accent); }
.access-row { flex-wrap: wrap; }
.access-row .seg button { min-height: 34px; padding: 2px 10px; font-size: 13px; }
.topbar .chip { flex: none; }
.account { margin-left: auto; font-weight: 600; max-width: 30vw; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.view { padding: 16px; padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 1200px; margin: 0 auto; }

.nav-top { display: none; }
.nav-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
}
.nav-bottom a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; position: relative;
}
.nav-bottom a svg { width: 24px; height: 24px; }
.nav-bottom a.active { color: var(--accent); }
.nav-bottom a.secondary { display: none; }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff;
  font-size: 11px; font-weight: 700; display: inline-grid; place-items: center;
}
.nav-bottom .badge { position: absolute; top: 6px; left: calc(50% + 6px); }

@media (min-width: 900px) {
  .nav-bottom { display: none; }
  .nav-top { display: flex; gap: 2px; margin-left: 8px; }
  .nav-top a {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px;
    color: var(--muted); text-decoration: none; font-weight: 600; font-size: 15px;
  }
  .nav-top a:hover { background: var(--surface-2); }
  .nav-top a.active { color: var(--accent); background: var(--accent-soft); }
  .nav-top a.mobile-only { display: none; }
  .view { padding: 24px; padding-bottom: 40px; }
}

.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin-right: auto; }

/* ---------- Medios de pago / montos ---------- */
.methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.methods button {
  min-height: 52px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.methods button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button { min-height: 38px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.bigline { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); }
.bigline strong { font-size: 26px; }
.bigline.accent { background: var(--accent-soft); }
.bigline.good { background: var(--good-soft); }
.bigline.bad { background: var(--bad-soft); }
.bigline.warn { background: var(--warn-soft); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 800; margin-top: 2px; }
.kpi .hint { font-size: 13px; color: var(--faint); }
.kpi.hero { background: var(--accent-soft); border-color: transparent; }
.kpi.hero .value { font-size: 32px; color: var(--accent); }
.list { display: flex; flex-direction: column; }
.list .item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.list .item.click { cursor: pointer; }
.list .item.click:hover { background: var(--surface-2); }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv.total { font-weight: 800; font-size: 17px; border-bottom: 0; border-top: 2px solid var(--line); padding-top: 10px; }
.cols { display: grid; gap: 16px; }
@media (min-width: 900px) { .cols { grid-template-columns: 1fr 1fr; align-items: start; } }

/* ---------- Tablas (en el teléfono se ven como tarjetas) ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tr.inactive td { color: var(--faint); }
td .sub { display: block; font-size: 13px; color: var(--muted); }
@media (max-width: 699px) {
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.cards tr:last-child { border-bottom: 0; }
  table.cards td { border: 0; padding: 3px 0; display: flex; justify-content: flex-end; align-items: baseline; gap: 6px; text-align: right; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; margin-right: auto; }
  table.cards td .sub { display: inline; }
  table.cards td.main { display: block; text-align: left; font-weight: 600; font-size: 16px; padding-bottom: 6px; }
  table.cards td.main::before { display: none; }
  table.cards td.actions::before { display: none; }
  table.cards td.actions { justify-content: flex-end; padding-top: 8px; }
}

/* ---------- Filtros ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  min-height: 38px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.seg button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.filters input[type="date"] { width: auto; min-height: 38px; padding: 6px 10px; }
.filters .grow { flex: 1; min-width: 180px; }
.filters select { width: auto; }
.banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px;
  background: var(--warn-soft); color: var(--warn); font-weight: 600; margin-bottom: 14px; cursor: pointer; border: 0; width: 100%; font: inherit; text-align: left;
}
.banner svg { width: 20px; height: 20px; flex: none; }

/* ---------- Gráfico ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--series-1); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .bar.on { opacity: .8; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; transform: translate(-50%, -100%);
  background: var(--text); color: var(--bg); padding: 6px 10px; border-radius: 8px; font-size: 13px; white-space: nowrap;
  box-shadow: var(--shadow);
}
.tooltip strong { display: block; font-size: 14px; }
details.table-toggle summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-top: 8px; }

/* ---------- Modal ---------- */
.modal {
  border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--text);
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgb(0 0 0 / .45); }
#modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-head { display: flex; align-items: center; gap: 10px; }
.modal-head h2 { margin-right: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.modal-foot .btn { flex: 1 1 140px; }
@media (max-width: 599px) {
  .modal { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  #modal-body { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
/* ---------- Avisos ---------- */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 100;
  top: calc(var(--top-h) + 8px + env(safe-area-inset-top));
  display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px));
}
.toast {
  padding: 12px 16px; border-radius: 10px; background: var(--text); color: var(--bg); font-weight: 600;
  box-shadow: var(--shadow); font-size: 15px;
}
.toast.err { background: var(--bad); color: #fff; }
.toast.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); }
.toast.ok { background: var(--good); color: #fff; }

.print-area { display: none; }
@media print {
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block; color: #000; font-size: 12px; width: 72mm; }
  .print-area .kv { border-bottom: 1px dashed #999; }
}

/* Código de 6 números del mail */
.otp { font-size: 28px; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }

/* Importar productos */
.imp-errors { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; margin: 8px 0; }
input[type="file"] { padding: 8px; }

/* Primeros pasos */
.onboarding { margin-bottom: 16px; border-color: var(--accent); }
.onboarding ol { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.onboarding li.done { color: var(--faint); text-decoration: line-through; }

.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--faint); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -1px; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }


/* Suscripción */
.sub-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--line); }
.sub-banner.warn { background: var(--warn-soft); color: var(--warn); }
.sub-banner.info { background: var(--accent-soft); color: var(--accent); }
.sub-banner span { flex: 1; min-width: 200px; }
.pre { white-space: pre-line; }

.chip.lock { font-size: 11px; padding: 1px 7px; margin-left: 4px; }
.chip.lock::before { content: "🔒"; width: auto; height: auto; background: none; }

/* ---------- Planes ---------- */
.plans { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin: 8px 0; }
.plan-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); }
.plan-card.featured { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.plan-card h3 { margin: 0; font-size: 1.15rem; }
.plan-card p { margin: 0; }
.plan-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.plan-price strong { font-size: 1.5rem; }
.plan-card ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; font-size: .92rem; }
.plan-card li { padding-left: 22px; position: relative; }
.plan-card li::before { content: "•"; position: absolute; left: 6px; color: var(--muted); }
.plan-card li.yes::before { content: "✓"; left: 4px; color: var(--good); font-weight: 700; }
.plan-card li.no { color: var(--faint); text-decoration: line-through; }
.plan-card li.no::before { content: "–"; left: 5px; color: var(--faint); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#reg-plans { margin-top: 4px; }
