:root {
  --azul: #0a1f5c;
  --azul-claro: #eaf1fb;
  --rojo: #c62828;
  --verde: #2e7d32;
  --gris: #666;
  --borde: #ddd;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: #1a1a1a; background: #f4f6fa; font-size: 14px;
}
button { font: inherit; cursor: pointer; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: white; padding: 48px 56px; border-radius: 12px; text-align: center;
  box-shadow: 0 4px 24px rgba(10,31,92,0.12);
}
.login-card h1 { margin: 0 0 4px; color: var(--azul); font-size: 26px; }
.login-card h1 span, .brand span { color: #b98e2f; }
.login-sub { color: var(--gris); margin: 0 0 28px; }
#botonGoogle { display: flex; justify-content: center; }
.login-error { color: var(--rojo); margin-top: 16px; max-width: 320px; }

/* ── Shell ── */
header {
  display: flex; align-items: center; gap: 24px; background: var(--azul);
  color: white; padding: 0 20px; height: 52px; position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: bold; font-size: 16px; white-space: nowrap; }
nav { display: flex; gap: 4px; flex: 1; }
.tab {
  background: none; border: none; color: rgba(255,255,255,0.75);
  padding: 16px 14px; border-bottom: 3px solid transparent;
}
.tab:hover { color: white; }
.tab.activa { color: white; border-bottom-color: #b98e2f; font-weight: 600; }
.usuario { display: flex; align-items: center; gap: 10px; font-size: 12px; color: rgba(255,255,255,0.85); }
.link { background: none; border: none; color: inherit; text-decoration: underline; padding: 4px; }

main { padding: 18px 20px; max-width: 1280px; margin: 0 auto; }

/* ── Toolbar y tabla ── */
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
#buscador {
  flex: 0 1 420px; padding: 9px 14px; border: 1px solid var(--borde);
  border-radius: 8px; font-size: 14px; background: white;
}
#buscador:focus { outline: 2px solid var(--azul); border-color: transparent; }
.contador { color: var(--gris); font-size: 13px; flex: 1; }
.secundario {
  background: white; border: 1px solid var(--borde); border-radius: 6px; padding: 8px 14px;
}
.secundario:hover { border-color: var(--azul); }

.tabla-wrap { background: white; border-radius: 8px; border: 1px solid var(--borde); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--gris); padding: 10px 12px; border-bottom: 2px solid var(--borde);
  position: sticky; top: 0; background: white;
}
th.num, td.num { text-align: right; }
td { padding: 7px 12px; border-bottom: 1px solid #eee; vertical-align: middle; }
tr:hover td { background: #f8faff; }

.nombre-link { color: var(--azul); font-weight: 600; cursor: pointer; text-decoration: none; }
.nombre-link:hover { text-decoration: underline; }

td select {
  font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid transparent;
  border-radius: 4px; background: transparent; max-width: 160px;
}
td select:hover, td select:focus { border-color: var(--borde); background: white; }

.editable { cursor: text; border-radius: 4px; padding: 4px 6px; display: block; min-height: 1.4em; }
.editable:hover { background: var(--azul-claro); }
.editable.vacio { color: #bbb; font-style: italic; }
td input.edit-input {
  font: inherit; font-size: 13px; width: 100%; padding: 4px 6px;
  border: 1px solid var(--azul); border-radius: 4px;
}
.guardando { opacity: 0.5; }

.estado-badge { font-size: 12px; }
.tabla-aviso { padding: 14px; color: var(--gris); text-align: center; }

/* ── Paneles (SMS / Mails) ── */
.panel {
  background: white; border: 1px solid var(--borde); border-radius: 8px;
  padding: 24px; max-width: 720px;
}
.panel h2 { margin: 0 0 16px; font-size: 18px; color: var(--azul); }
.panel h3 { margin: 22px 0 10px; font-size: 14px; color: var(--azul); }
.modo-row { display: flex; gap: 20px; margin-bottom: 12px; }
.modo-row label { display: flex; align-items: center; gap: 6px; }
.nota { color: var(--gris); font-size: 13px; margin: 8px 0; }
.nota.ok { color: var(--verde); }
.nota.err { color: var(--rojo); }
textarea {
  width: 100%; font: inherit; padding: 10px; border: 1px solid var(--borde);
  border-radius: 6px; resize: vertical; margin-top: 8px;
}
.fila-config { display: flex; align-items: center; gap: 16px; margin: 12px 0; flex-wrap: wrap; }
.fila-config label { display: flex; align-items: center; gap: 6px; }
.fila-config select, .fila-config input[type=number] {
  font: inherit; padding: 5px 8px; border: 1px solid var(--borde); border-radius: 4px;
}
.test-check { color: var(--verde); font-weight: 600; }
.primario {
  background: var(--azul); color: white; border: none; border-radius: 6px; padding: 10px 22px;
}
.primario:disabled, .secundario:disabled { opacity: 0.5; cursor: default; }
.resultado { margin-top: 14px; font-size: 13px; white-space: pre-line; }
.resultado.ok { color: var(--verde); }
.resultado.err { color: var(--rojo); }

/* ── Drawer ficha ── */
.drawer-fondo { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 94vw);
  background: white; z-index: 21; box-shadow: -4px 0 24px rgba(0,0,0,0.2);
  display: flex; flex-direction: column; padding: 20px 24px; overflow-y: auto;
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-head h2 { margin: 0; color: var(--azul); font-size: 18px; }
.ficha-total {
  background: var(--azul-claro); border-radius: 8px; padding: 12px 16px;
  margin: 14px 0; font-weight: 600; color: var(--azul);
}
.ficha-total b { color: var(--rojo); font-size: 16px; }
.ficha-body table { font-size: 13px; }
.ficha-body th { position: static; }
.op-card { border: 1px solid var(--borde); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.op-card .op-tit { font-weight: 600; color: var(--azul); margin-bottom: 6px; }
.op-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 14px; font-size: 13px; }
.op-grid .k { color: var(--gris); font-size: 11px; text-transform: uppercase; }

/* ── Cuota mensual ── */
.cuota-box {
  background: var(--azul-claro); border-radius: 8px; padding: 12px 16px;
  font-size: 13px; margin: 10px 0; line-height: 1.6;
}
.cuota-box .barra {
  height: 8px; background: #d5e2f5; border-radius: 4px; overflow: hidden; margin-top: 6px;
}
.cuota-box .barra > div { height: 100%; background: var(--azul); border-radius: 4px; }
.cuota-box.alerta .barra > div { background: var(--rojo); }

/* ── Días de la semana (chips) ── */
.dias-chips { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.dias-chips label { cursor: pointer; }
.dias-chips input { display: none; }
.dias-chips span {
  display: inline-block; padding: 8px 14px; border: 1px solid var(--borde);
  border-radius: 20px; background: white; font-size: 13px; user-select: none;
}
.dias-chips input:checked + span {
  background: var(--azul); color: white; border-color: var(--azul); font-weight: 600;
}

/* ── Editor del mail ── */
.editor-mail { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.editor-campos { flex: 1 1 340px; display: flex; flex-direction: column; gap: 10px; }
.editor-campos > label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--gris); font-weight: 600; }
.editor-campos input[type=text], .editor-campos textarea {
  font: inherit; font-size: 13px; font-weight: normal; color: #1a1a1a;
  padding: 7px 10px; border: 1px solid var(--borde); border-radius: 6px; resize: vertical;
  margin-top: 0; width: 100%;
}
.editor-preview { flex: 1 1 420px; min-width: 0; }
#mailPreviewFrame {
  width: 100%; height: 720px; border: 1px solid var(--borde); border-radius: 8px;
  background: #eeeeee;
}

/* ── Reportes ── */
.periodo-botones { display: flex; gap: 8px; }
.periodo.activa { background: var(--azul); color: white; border-color: var(--azul); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 10px; }
.card {
  background: white; border: 1px solid var(--borde); border-radius: 8px;
  padding: 14px 16px; text-align: center;
}
.card.destacada { background: var(--azul); border-color: var(--azul); color: white; }
.card-num { font-size: 26px; font-weight: bold; }
.card.destacada .card-num { color: white; }
.card-tit { font-size: 12px; color: var(--gris); margin-top: 2px; }
.card.destacada .card-tit { color: rgba(255,255,255,0.85); }
.card-sub { font-size: 12px; margin-top: 4px; color: rgba(255,255,255,0.9); }
.delta-pos { color: var(--verde); font-weight: 600; }
.delta-neg { color: var(--rojo); font-weight: 600; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #1a1a1a; color: white; padding: 10px 20px; border-radius: 8px;
  font-size: 13px; z-index: 30; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.toast.err { background: var(--rojo); }
