:root {
  --red: #D7261E;
  --red-dark: #B01E17;
  --blue: #2C6BB3;
  --blue-dark: #1F4E86;
  --blue-soft: #EAF1FA;
  --ink: #1d2433;
  --muted: #667085;
  --line: #e3e7ee;
  --bg: #f5f7fb;
  --card: #ffffff;
  --green: #1f8a4c;
  --amber: #b26b00;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; color: var(--blue-dark); }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small, small { font-size: .85rem; }
.center { text-align: center; }
.text-red { color: var(--red); font-weight: 600; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; word-break: break-all; }

/* Barra superior */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: .5rem 1.25rem; background: #fff; border-bottom: 3px solid var(--blue); box-shadow: var(--shadow); }
.brand img { height: 44px; display: block; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; margin-left: auto; }
.nav a, .nav .link { padding: .5rem .75rem; border-radius: 8px; color: var(--ink); font-weight: 500; }
.nav a:hover { background: var(--blue-soft); text-decoration: none; }
.nav a.active { background: var(--blue); color: #fff; }
.menu-toggle { display: none; margin-left: auto; font-size: 1.5rem; background: none; border: 0; padding: .25rem .5rem; cursor: pointer; }
.inline { display: inline; margin: 0; }
.link { background: none; border: 0; font: inherit; cursor: pointer; color: var(--red); }

.container { max-width: 1180px; margin: 0 auto; padding: 1.25rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin: .25rem 0 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + section { margin-top: 1rem; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1.1rem; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-family: inherit; font-size: .95rem; font-weight: 600; line-height: 1.2; cursor: pointer; text-decoration: none !important; }
.btn:hover { border-color: #c8d0dc; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-light { background: var(--blue-soft); border-color: #d3e1f3; color: var(--blue-dark); }
.btn-danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn-whatsapp { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn-block { width: 100%; }
.btn-lg { min-height: 54px; font-size: 1.1rem; padding: .75rem 1.6rem; }
.btn-sm { min-height: 34px; padding: .3rem .7rem; font-size: .85rem; }
.btn-row, .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.actions { justify-content: flex-end; margin-top: .5rem; }
.actions-card { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.inline-form { display: inline-flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.inline-form input { width: 230px; }

/* Formularios */
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .92rem; }
input, select, textarea { width: 100%; min-height: 44px; padding: .55rem .7rem; border: 1px solid #cfd6e0; border-radius: 9px; font-family: inherit; font-size: 1rem; font-weight: 400; color: var(--ink); background: #fff; }
textarea { min-height: 60px; resize: vertical; }
select[size] { min-height: 150px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(44, 107, 179, .25); border-color: var(--blue); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.1rem; }
.form-grid h2 { margin: .75rem 0 0; padding-top: .75rem; border-top: 1px solid var(--line); }
.form-grid h2:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.form-grid .sub { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: .9rem; background: #fafbfd; border: 1px dashed var(--line); border-radius: var(--radius); margin-top: .5rem; }
.full { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.check { flex-direction: row; align-items: flex-start; gap: .6rem; font-weight: 500; }
.check input { width: 22px; min-height: 22px; height: 22px; margin-top: 1px; flex: none; }
.check.big { font-size: 1rem; padding: .75rem; background: var(--blue-soft); border-radius: 10px; }
.consent { background: #fffbea; border: 1px solid #f3e3a0; padding: .75rem; border-radius: 10px; }
.checks { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin-bottom: .75rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; }
legend { font-weight: 700; padding: 0 .3rem; }
.hint { font-weight: 400; color: var(--muted); }
.hint.warn { color: var(--amber); }
details summary { cursor: pointer; font-weight: 700; color: var(--blue-dark); padding: .4rem 0; }
.searchbar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.searchbar select { max-width: 220px; }
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.radio-card { flex-direction: row; gap: .6rem; align-items: flex-start; padding: .9rem; border: 2px solid var(--line); border-radius: var(--radius); cursor: pointer; font-weight: 400; }
.radio-card input { width: 20px; min-height: 20px; height: 20px; flex: none; }
.radio-card:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.total-box { padding: .8rem 1rem; background: var(--blue-soft); border-radius: 10px; }
.total-box .total { font-size: 1.1rem; color: var(--red); }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }
.secret { font-size: 1.15rem; padding: .6rem; background: var(--blue-soft); border-radius: 8px; margin: .5rem 0; letter-spacing: .05em; }
.narrow { max-width: 560px; }

/* Subidas de fotos */
.upload { display: flex; flex-direction: column; gap: .5rem; padding: .75rem; border: 1px dashed #cfd6e0; border-radius: var(--radius); background: #fafbfd; }
.upload-label { font-weight: 600; font-size: .92rem; }
.file-btn { position: relative; overflow: hidden; align-self: flex-start; flex-direction: row; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }
.thumb { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.previews { display: flex; flex-wrap: wrap; gap: .4rem; }
.previews img { width: 92px; height: 70px; object-fit: cover; border-radius: 6px; border: 2px solid var(--green); }

/* Tablas y listas */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .7rem .9rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfd; }
.table.compact td { padding: .45rem .7rem; font-size: .9rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .6rem 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: baseline; }
.list li small { color: var(--muted); width: 100%; }
.list.compact li { padding: .35rem 0; }
.dl { display: grid; grid-template-columns: 160px 1fr; gap: .45rem .9rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .9rem; }
.dl dd { margin: 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.gallery figure { margin: 0; }
.gallery img, .gallery .placeholder { width: 100%; height: 105px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.gallery .placeholder { display: flex; align-items: center; justify-content: center; color: var(--muted); background: #f0f2f6; font-size: .85rem; }
.gallery figcaption { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.gallery.small { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .4rem; }
.gallery.small img { height: 72px; }

/* Indicadores */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; color: var(--muted); box-shadow: var(--shadow); }
.stat span { display: block; font-size: 1.9rem; font-weight: 800; color: var(--blue-dark); }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #eef0f4; color: #475467; vertical-align: middle; }
.badge-activo, .badge-rentado { background: #e6f0ff; color: var(--blue-dark); }
.badge-borrador, .badge-mantenimiento { background: #fff4de; color: var(--amber); }
.badge-cerrado, .badge-disponible { background: #e3f6ea; color: var(--green); }
.badge-anulado, .badge-inactivo, .badge-red { background: #fde8e7; color: var(--red-dark); }
.steps { display: flex; list-style: none; padding: 0; margin: 0 0 1rem; gap: .5rem; counter-reset: s; flex-wrap: wrap; }
.steps li { flex: 1; min-width: 140px; padding: .6rem .8rem; border-radius: 10px; background: #fff; border: 1px solid var(--line); color: var(--muted); font-weight: 600; counter-increment: s; }
.steps li::before { content: counter(s) ". "; }
.steps li.done { background: #e3f6ea; border-color: #b9e5c9; color: var(--green); }
.steps li.done::before { content: "✓ "; }

/* Alertas */
.alert { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; }
.alert ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.alert-success { background: #e9f8ef; border-color: #b9e5c9; color: #14572f; }
.alert-error { background: #fdecea; border-color: #f5c2bd; color: #7d1c15; }
.alert-warning { background: #fff7e3; border-color: #f3dc9b; color: #6b4a00; }
.danger-zone summary { color: var(--red); }

/* Firma */
.sigpad { border: 2px solid var(--blue); border-radius: var(--radius); background: #fff; overflow: hidden; }
.sigpad-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .5rem .75rem; background: var(--blue-soft); }
.sigpad canvas { display: block; width: 100%; height: 220px; touch-action: none; cursor: crosshair; background: repeating-linear-gradient(#fff 0 179px, #c5d3e6 179px 181px, #fff 181px 220px); }
.sig-preview { max-width: 260px; max-height: 100px; border: 1px solid var(--line); border-radius: 8px; padding: .3rem; margin-bottom: .75rem; }
.sign-summary .summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem; }
.summary-grid div { display: flex; flex-direction: column; padding: .7rem; background: #fafbfd; border: 1px solid var(--line); border-radius: 10px; }
.summary-grid small { color: var(--muted); }

/* Pantalla de acceso */
body.guest { display: flex; min-height: 100vh; align-items: center; justify-content: center; background: linear-gradient(160deg, #fff 0%, var(--blue-soft) 100%); }
.guest-box { width: 100%; max-width: 420px; margin: 1rem; padding: 2rem; background: #fff; border-radius: 16px; box-shadow: 0 10px 30px rgba(16, 24, 40, .12); }
.guest-logo { display: block; width: 100%; max-width: 300px; margin: 0 auto 1.25rem; }
.guest-box h1 { margin-bottom: 1rem; }

@media (max-width: 900px) {
  .grid-2, .radio-cards { grid-template-columns: 1fr; }
  .stats, .sign-summary .summary-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .menu-toggle { display: block; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; }
  .nav.open { display: flex; }
  .topbar { flex-wrap: wrap; }
  .form-grid, .form-grid .sub { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; }
  .dl dt { margin-top: .4rem; }
  .container { padding: .9rem; }
  .searchbar { flex-wrap: wrap; }
  .searchbar select { max-width: none; }
}
