:root {
  --bg: #f1f5f9; --panel: #ffffff; --line: #e2e8f0; --line-2: #cbd5e1;
  --text: #0f172a; --text-2: #475569; --text-3: #94a3b8;
  --accent: #2563eb; --accent-2: #1d4ed8; --accent-soft: #eff6ff;
  --ok: #047857; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7;
  --bad: #b91c1c; --bad-soft: #fee2e2; --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 Inter, system-ui, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
button, input, select, textarea { font: inherit; color: inherit; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: #0f172a; color: #cbd5e1; padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 700; font-size: 18px; padding: 0 10px 18px; }
.brand small { display: block; font-weight: 400; font-size: 11px; color: #64748b; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #cbd5e1; }
.nav:hover { background: #1e293b; text-decoration: none; }
.nav.on { background: #1e293b; color: #fff; }
.nav .badge { margin-left: auto; }
.sidebar .pie { margin-top: auto; font-size: 12px; color: #64748b; padding: 10px; }
.barra-top { display: none; }
.nav .corto { display: none; }
.nav .ico { width: 20px; text-align: center; }
.sidebar .pie button { background: none; border: 0; color: #94a3b8; padding: 0; cursor: pointer; display: block; margin-top: 4px; }
main { padding: 24px 28px 60px; max-width: 1200px; width: 100%; min-width: 0; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.head .sub { color: var(--text-2); }
.head .acciones { margin-left: auto; display: flex; gap: 8px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.kpi .l { color: var(--text-2); font-size: 12px; }
.dos { grid-template-columns: 1fr 1fr; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: #fff; border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.pri:hover { background: var(--accent-2); }
.btn.peligro { color: var(--bad); }
.btn.chico { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--line); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.azul { background: var(--accent-soft); color: var(--accent); }
.badge.rojo { background: #ef4444; color: #fff; }

.lista { display: flex; flex-direction: column; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item.noleida { position: relative; }
.item.noleida::before { content: ''; position: absolute; left: -12px; top: 20px; width: 6px; height: 6px; border-radius: 99px; background: var(--accent); }
.item .t { font-weight: 600; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .m { color: var(--text-2); font-size: 13px; }
.item .der { text-align: right; font-size: 13px; }
.item .monto { font-weight: 600; font-variant-numeric: tabular-nums; }
.estrella { background: none; border: 0; cursor: pointer; font-size: 22px; line-height: 1; color: var(--text-3); padding: 0 0 4px; float: right; margin-left: 8px; }
.estrella:hover { color: #f59e0b; }
.estrella.on { color: #f59e0b; }
.btn.seguir-on { color: #b45309; border-color: #fcd34d; background: var(--warn-soft); }
textarea { font: inherit; border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; width: 100%; resize: vertical; }
.item .motivo { font-size: 12px; color: var(--text-3); grid-column: 1 / -1; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 3px; }
.vacio { color: var(--text-3); padding: 24px 0; text-align: center; }

.campo { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.campo label { font-weight: 600; font-size: 13px; }
.campo .ayuda { font-size: 12px; color: var(--text-3); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
.fila { display: flex; gap: 12px; }
.fila > * { flex: 1; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.check input { margin-top: 3px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; border: 1px solid var(--line-2); border-radius: 8px; padding: 6px; background: #fff; position: relative; }
.chips:focus-within { outline: 2px solid #bfdbfe; border-color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent-2); border-radius: 6px; padding: 2px 4px 2px 8px; font-size: 13px; }
.chip.rojo { background: var(--bad-soft); color: var(--bad); }
.chip button { border: 0; background: none; cursor: pointer; color: inherit; padding: 0 4px; font-size: 15px; line-height: 1; }
.chips input { border: 0 !important; outline: 0 !important; flex: 1; min-width: 140px; padding: 3px 4px !important; }
.sugerencias { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--line-2); border-radius: 8px; margin-top: 4px; box-shadow: 0 8px 24px rgba(15,23,42,.12); z-index: 10; max-height: 280px; overflow: auto; }
.sugerencias div { padding: 8px 10px; cursor: pointer; }
.sugerencias div:hover, .sugerencias div.on { background: var(--accent-soft); }
.sugerencias small { color: var(--text-3); display: block; }

.grid.precios { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.grid.precios td:nth-child(2) { min-width: 220px; }
.editor { display: grid; grid-template-columns: 420px 1fr; gap: 16px; align-items: start; }
.aviso-regla { background: var(--warn-soft); border: 1px solid #fcd34d; border-radius: 8px; padding: 12px; margin-bottom: 14px; font-size: 13px; color: #78350f; }
.aviso-regla p { margin: 6px 0 10px; }
.aviso-regla .ayuda { margin: 10px 0 0; color: #92400e; }
.editor .preview { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }

.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filtros input[type=search] { max-width: 320px; }
.filtros select { width: auto; }

.barras { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.barras .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.barras .b span { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.barras .b small { font-size: 10px; color: var(--text-3); }
.barras .b em { font-style: normal; font-size: 11px; color: var(--text-2); }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 7px 6px; border-top: 1px solid var(--line); font-size: 13px; vertical-align: top; }
th { color: var(--text-2); font-weight: 600; border-top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
dl.datos { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0; }
dl.datos dt { color: var(--text-2); }
dl.datos dd { margin: 0; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth .brand { color: var(--text); padding: 0 0 20px; font-size: 22px; }
.error { color: var(--bad); font-size: 13px; margin-bottom: 10px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; }
.cargando { color: var(--text-3); padding: 40px; text-align: center; }

@media (max-width: 900px) {
  /* En el celular: encabezado compacto arriba y barra de pestañas abajo, como una app */
  .layout { grid-template-columns: 1fr; align-content: start; }
  .barra-top { display: flex; position: sticky; top: 0; z-index: 20; align-items: center; gap: 6px;
    background: #0f172a; color: #fff; padding: 10px 12px 10px 16px; }
  .barra-top .brand { padding: 0; font-size: 16px; margin-right: auto; }
  .barra-top .brand small { display: inline; margin-left: 8px; }
  .icono-top { background: none; border: 0; color: #cbd5e1; font-size: 20px; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
  .icono-top.on, .icono-top:hover { background: #1e293b; text-decoration: none; }
  .icono-top.salir-top { font-size: 13px; }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 20;
    flex-direction: row; gap: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid #1e293b; }
  .sidebar .brand, .sidebar .pie { display: none; }
  .sidebar .nav { flex: 1; flex-direction: column; gap: 1px; padding: 6px 2px; position: relative; font-size: 11px; min-width: 0; }
  .sidebar .nav .ico { font-size: 20px; line-height: 1.2; }
  .sidebar .nav .txt { display: none; }
  .sidebar .nav .corto { display: block; }
  .sidebar .nav .badge { position: absolute; top: 2px; left: 52%; margin: 0; font-size: 10px; padding: 0 5px; }
  .sidebar .nav[href="#/dispositivo"], .sidebar .nav[href="#/precios"] { display: none; }
  main { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .v { font-size: 22px; }
  .dos, .editor, .grid.precios { grid-template-columns: 1fr; }
  .editor .preview { position: static; max-height: none; }
  dl.datos { grid-template-columns: 1fr; gap: 2px; }
  dl.datos dd { margin-bottom: 8px; }
  .item { grid-template-columns: 1fr; }
  .item .der { text-align: left; display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
  .item .der .estrella { order: 9; margin-left: auto; }
  .head .acciones { margin-left: 0; }
  .toast { bottom: calc(90px + env(safe-area-inset-bottom)); }
}

/* App nativa: respetar la muesca y la barra de estado del celular */
.nativa .barra-top { padding-top: calc(10px + env(safe-area-inset-top)); }
.nativa .auth { padding-top: calc(16px + env(safe-area-inset-top)); }

/* Recorrido de bienvenida */
#recorrido { position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .72); display: grid; place-items: center;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); animation: recorrido-entra .2s ease-out; }
@keyframes recorrido-entra { from { opacity: 0; } to { opacity: 1; } }
.recorrido-tarjeta { position: relative; background: var(--panel); border-radius: 16px; width: 100%; max-width: 440px;
  max-height: 100%; overflow: auto; padding: 28px 24px 20px; box-shadow: 0 24px 64px rgba(0, 0, 0, .35); }
.recorrido-saltar { position: absolute; top: 12px; right: 12px; background: none; border: 0; color: var(--text-3); cursor: pointer; font-size: 14px; padding: 6px; }
.recorrido-icono { font-size: 48px; line-height: 1; margin-bottom: 12px; }
.recorrido-tarjeta h2 { font-size: 22px; margin: 0 0 8px; }
.recorrido-donde { display: inline-block; font-size: 12px; color: var(--accent-2); background: var(--accent-soft); border-radius: 99px; padding: 3px 10px; margin-bottom: 12px; }
.recorrido-tarjeta p { color: var(--text); margin: 0 0 10px; font-size: 15px; }
.recorrido-tarjeta ul { margin: 0 0 16px; padding-left: 20px; color: var(--text-2); font-size: 14px; }
.recorrido-tarjeta li { margin-bottom: 6px; }
.recorrido-final { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.recorrido-final .btn { justify-content: center; padding: 10px 12px; }
.recorrido-pie { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.recorrido-puntos { display: flex; gap: 6px; }
.recorrido-puntos button { width: 8px; height: 8px; border-radius: 99px; border: 0; padding: 0; background: var(--line-2); cursor: pointer; }
.recorrido-puntos button.on { background: var(--accent); width: 20px; }
