:root {
  --brand: #9f1239;
  --brand-dark: #4c0519;
  --brand-soft: #fdf2f5;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.25rem; margin: 0 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
p { margin: .25rem 0; }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .9rem; }
.mono.big { font-size: 1.4rem; letter-spacing: .04em; padding: .5rem; background: var(--brand-soft); border-radius: 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 700; }
.center { text-align: center; }
.ok { color: var(--ok); }
.bad { color: var(--danger); }
.hidden { display: none !important; }

/* ------------------------------- layout */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 248px;
  background: var(--brand-dark); color: #fff;
  display: flex; flex-direction: column; padding: 16px 14px; gap: 14px;
  overflow-y: auto; z-index: 30;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand-mark {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%;
  background: var(--brand); display: grid; place-items: center;
  font-weight: 800; letter-spacing: .5px;
}
.brand-logo { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: .95rem; }
.brand-text span { font-size: .75rem; color: #f3c6d3; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: #f7e7ec; padding: 9px 10px; border-radius: 8px; font-size: .95rem;
}
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-sep {
  margin: 12px 0 4px; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .08em; color: #e2a9bb;
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; font-size: .85rem; }
.who { display: flex; flex-direction: column; }
.who span { color: #f3c6d3; font-size: .78rem; }
.link-small { color: #f7e7ec; font-size: .82rem; }

.content { margin-left: 248px; padding: 18px 22px 40px; display: flex; flex-direction: column; gap: 14px; }
.topbar {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 4px 2px; min-height: 40px;
}
.crumbs { font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* ------------------------------- componentes */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
  display: flex; flex-direction: column; gap: 12px;
}
.card.narrow { max-width: 620px; }
.card-highlight { border-color: var(--brand); background: var(--brand-soft); }
.head-card { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 2px;
}
.kpi span { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi strong { font-size: 1.5rem; }
.kpi small { color: var(--muted); font-size: .82rem; }
.kpi-alert { border-left: 4px solid var(--danger); }
.kpi-inline { padding: 8px 12px; }
.kpi-inline strong { font-size: 1.2rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  background: #f3f4f6; color: #374151; font-size: .78rem; font-weight: 600;
}
.chip-link { background: var(--brand-soft); color: var(--brand); }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-cycle { background: var(--brand-soft); color: var(--brand); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 9px; border: 1px solid transparent;
  font-size: .92rem; font-weight: 600; cursor: pointer; text-decoration: none !important;
  background: #eef0f3; color: #1f2937; font-family: inherit;
}
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-sm { padding: 6px 10px; font-size: .85rem; }
.btn-xs { padding: 3px 7px; font-size: .78rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.flash { padding: 10px 14px; border-radius: 9px; font-size: .92rem; font-weight: 600; }
.flash-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #a7f3d0; }
.flash-err { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.flash-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid #fde68a; }
.empty { color: var(--muted); padding: 18px; text-align: center; }

/* ------------------------------- formularios */
label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; font-weight: 600; color: #374151; }
input, select, textarea {
  font-family: inherit; font-size: 1rem; padding: 8px 10px; border-radius: 8px;
  border: 1px solid #d1d5db; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(159,18,57,.25); border-color: var(--brand);
}
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-tight { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; }
.filters, .inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.filters input, .filters select { width: auto; min-width: 160px; }
.inline-form input, .inline-form select { width: auto; }
.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.subblock { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.cell-input { width: 96px; text-align: right; padding: 5px 7px; font-size: .9rem; }

/* ------------------------------- tablas */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table thead th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); background: #fafafa;
}
.table tbody tr:hover { background: #fcfcfd; }
.table .num { text-align: right; white-space: nowrap; }
.table .center { text-align: center; }
.table .total-row td { font-weight: 700; background: var(--brand-soft); border-top: 2px solid var(--brand); }
.row-muted td { color: var(--muted); background: #fafafa; }
.table-scroll { overflow-x: auto; }
.actions-cell { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.totals-json { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow: auto; max-height: 260px; font-size: .8rem; }
.mini summary { cursor: pointer; font-size: .8rem; color: var(--brand); }
details.help { border-top: 1px solid var(--line); padding-top: 10px; }
details.help summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.data { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.data dt { font-weight: 600; color: var(--muted); font-size: .85rem; }
.data dd { margin: 0; }

/* ------------------------------- login */
.no-shell { background: #0b1220; }
/* Sin sidebar: el contenido ocupa todo el ancho (si no, el login queda corrido). */
body.no-shell .content {
  margin-left: 0;
  padding: 0;
  min-height: 100vh;
  display: block;
}
body.no-shell .topbar,
body.no-shell .flash { display: none; }
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}
.login-card { width: 100%; max-width: 400px; gap: 16px; }
.login-brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.login-brand h1 { font-size: 1.3rem; margin: 6px 0 0; }
.login-brand .brand-mark { width: 60px; height: 60px; flex: 0 0 60px; font-size: 1.2rem; }
.login-brand .brand-logo { width: 60px; height: 60px; flex: 0 0 60px; }

/* ------------------------------- cobro */
.billing-block { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.block-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.block-head h3 { margin: 0; }
.charge-block {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  display: flex; flex-direction: column; gap: 10px; background: #fcfcfd;
}
.charge-block .block-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.charge-block select { max-width: 340px; }
.charge-list { display: flex; flex-direction: column; gap: 6px; }
.charge-row {
  display: grid; grid-template-columns: 24px 1fr 140px; gap: 8px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
.charge-row input[type=checkbox] { width: 18px; height: 18px; }
.charge-row .meta { display: flex; flex-direction: column; gap: 1px; }
.charge-row .meta small { color: var(--muted); font-size: .78rem; }
.charge-row input[type=text] { text-align: right; }
.methods-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; }
.method-row {
  display: grid; grid-template-columns: 1fr 110px; align-items: center; gap: 8px;
  background: #fcfcfd; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  font-weight: 500;
}
.method-row input { text-align: right; }
.totals {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px;
  background: var(--brand-soft); border: 1px solid #f3c6d3; border-radius: 10px; padding: 12px;
}
.totals div { display: flex; flex-direction: column; }
.totals span { font-size: .76rem; text-transform: uppercase; color: var(--muted); }
.totals strong { font-size: 1.2rem; }
.totals .bad-total { color: var(--danger); }
.totals .ok-total { color: var(--ok); }

/* ------------------------------- asistencia */
.attendance-table td { vertical-align: middle; }
.mark { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font-weight: 700; }
.mark input { width: 20px; height: 20px; accent-color: var(--brand); }
.mark-present span { color: var(--ok); }
.mark-absent span { color: var(--danger); }
.mark-excused span { color: var(--warn); }

.logo-preview { max-width: 160px; max-height: 160px; border-radius: 10px; border: 1px solid var(--line); }

.only-mobile { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .content { margin-left: 0; padding: 14px; }
  .only-mobile { display: inline-flex; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .charge-row { grid-template-columns: 24px 1fr 100px; }
}
