/* ========== Base ========== */
:root {
  --brand: #b4532a;
  --brand-ink: #fff;
  --bg: #f6f3ef;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --text: #24201c;
  --muted: #776e66;
  --line: #e6e0d9;
  --danger: #c2321f;
  --ok: #18804b;
  --warn: #b7791f;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 8px 24px rgba(40, 30, 20, .07);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.center { text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ========== Botones ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: var(--radius-sm); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: #d6cec5; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(0, 0, 0, .05); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.lg { padding: 14px 22px; font-size: 16px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.wa { background: #25d366; border-color: #25d366; color: #fff; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 6px; border-radius: 8px; color: var(--muted); font-size: 16px; line-height: 1; }
.icon-btn:hover { background: rgba(0, 0, 0, .06); color: var(--text); }

/* ========== Formularios ========== */
label.field { display: block; }
label.field > span, .field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
input[type=color] { padding: 2px; height: 38px; width: 52px; }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 3px; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.error-text { color: var(--danger); font-size: 14px; min-height: 1em; }

/* ========== Tarjetas, insignias ========== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; background: #888; white-space: nowrap; }
.badge.soft { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px;
  font: inherit; font-weight: 600; cursor: pointer; color: var(--text);
}
.chip:hover:not(:disabled) { border-color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip:disabled { opacity: .38; cursor: not-allowed; text-decoration: line-through; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* ========== Modal y avisos ========== */
.modal-back { position: fixed; inset: 0; background: rgba(25, 18, 12, .45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 14px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 16px; width: min(620px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); animation: pop .15s ease-out; }
.modal.wide { width: min(860px, 100%); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; }
.modal .body { padding: 18px 20px; }
.modal footer { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 16px 16px; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: #2b2420; color: #fff; padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 600; animation: pop .15s; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ========== Página pública de reservas ========== */
.public { min-height: 100vh; background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 14%, var(--bg)) 0, var(--bg) 340px); }
.public-wrap { max-width: 640px; margin: 0 auto; padding: 28px 16px 60px; }
.public-head { text-align: center; margin-bottom: 22px; }
.public-head img { max-height: 76px; max-width: 220px; margin-bottom: 10px; }
.public-head h1 { font-size: 28px; letter-spacing: -.01em; }
.public-head p { color: var(--muted); margin: 0; }
.step { padding: 18px 0; border-top: 1px solid var(--line); }
.step:first-child { border-top: 0; padding-top: 4px; }
.step h2 { font-size: 16px; display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.step h2 .n { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: inline-grid; place-items: center; font-size: 13px; flex: none; }
.party-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.party-grid .chip { min-width: 46px; }
.days { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x mandatory; }
.day {
  flex: none; width: 66px; padding: 9px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  text-align: center; cursor: pointer; scroll-snap-align: start; font: inherit; color: var(--text);
}
.day small { display: block; font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: .04em; }
.day b { display: block; font-size: 21px; }
.day.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.day.on small { color: inherit; opacity: .85; }
.day:disabled { opacity: .35; cursor: not-allowed; }
.times-shift + .times-shift { margin-top: 14px; }
.times-shift h4 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.times { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.times .chip { border-radius: 10px; padding: 9px 0; }
.notice { border-radius: 12px; padding: 14px; background: var(--surface-2); border: 1px dashed var(--line); }
.success-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 12px; font-size: 32px; color: #fff; background: var(--ok); }
.summary { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; text-align: left; background: var(--surface-2); border-radius: 12px; padding: 14px 16px; margin: 16px 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; }
.loading { opacity: .6; pointer-events: none; }

/* ========== Panel ========== */
.admin { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.topbar .brand { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 9px; }
.topbar .brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 15px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--muted); padding: 8px 13px; border-radius: 9px; cursor: pointer; position: relative; }
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button.active { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.tabs .count { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 6px; margin-left: 4px; }
.topbar .spacer { flex: 1; }
.user-menu { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 210px; padding: 6px; z-index: 30; }
.menu button, .menu a { display: block; width: 100%; text-align: left; border: 0; background: transparent; font: inherit; padding: 9px 12px; border-radius: 8px; cursor: pointer; color: var(--text); text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.page { padding: 18px; max-width: 1500px; margin: 0 auto; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=date], .toolbar input[type=time], .toolbar select { width: auto; }
.toolbar .search { width: 240px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi b { display: block; font-size: 24px; }
.kpi span { color: var(--muted); font-size: 13px; }

/* Lista de reservas */
.res-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.res-row { display: grid; grid-template-columns: 64px minmax(180px, 1.6fr) 50px minmax(110px, 1fr) 160px 100px 250px; gap: 12px; align-items: center; padding: 11px 14px; border-top: 1px solid var(--line); }
.res-row:first-child { border-top: 0; }
.res-row.head { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.res-row .time { font-weight: 800; font-size: 17px; }
.res-row .who b { display: block; }
.res-row .who small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-row .note { color: var(--warn); font-size: 12.5px; }
.res-row select { padding: 6px 8px; font-size: 13.5px; }
.res-row.dim { opacity: .55; }
.res-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 1000px) {
  .res-row { grid-template-columns: 56px 1fr 50px; }
  .res-row.head { display: none; }
  .res-row > :nth-child(n+4) { grid-column: 1 / -1; }
}
details.dropdown { position: relative; }
details.dropdown summary { list-style: none; }
details.dropdown summary::-webkit-details-marker { display: none; }
details.dropdown .menu { min-width: 190px; }

/* Solicitudes */
.req-card { display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.req-card + .req-card { margin-top: 12px; }
.req-card blockquote { margin: 8px 0 0; padding: 8px 12px; background: var(--surface-2); border-left: 3px solid var(--brand); border-radius: 6px; }

/* Mapa en el panel */
.map-layout { display: grid; grid-template-columns: 1fr 320px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .map-layout { grid-template-columns: 1fr; } }
.zone-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.zone-card + .zone-card { margin-top: 14px; }
.zone-card h3 { font-size: 15px; margin: 2px 4px 8px; }
.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.side-card + .side-card { margin-top: 12px; }
.side-card h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.arrival { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.arrival:first-of-type { border-top: 0; }
.arrival .t { font-weight: 800; width: 48px; }
.arrival .who { flex: 1; min-width: 0; }
.arrival .who small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Plano SVG */
.floor-svg { width: 100%; height: auto; display: block; border-radius: 10px; user-select: none; touch-action: none; }
.floor-bg { fill: var(--surface-2); }
.floor-grid { stroke: rgba(0, 0, 0, .05); }
.tbl { cursor: pointer; }
.tbl .body { stroke-width: 3; }
.tbl .chair { fill: #d8cfc5; }
.tbl text { font-family: var(--font); pointer-events: none; text-anchor: middle; dominant-baseline: central; }
.tbl .t-name { font-weight: 800; fill: #fff; }
.tbl .t-sub { fill: #fff; font-weight: 600; opacity: .95; }
.tbl.libre .t-name, .tbl.libre .t-sub { fill: var(--text); }
.tbl.selected .body { stroke: #111 !important; stroke-width: 5; stroke-dasharray: 8 5; }
.tbl.editing { cursor: grab; }
.tbl.editing.dragging { cursor: grabbing; opacity: .85; }
.combo-link { stroke-width: 10; stroke-linecap: round; opacity: .55; pointer-events: none; }

/* Editor del salón */
.editor { display: grid; grid-template-columns: 220px 1fr 300px; gap: 14px; align-items: start; }
@media (max-width: 1200px) { .editor { grid-template-columns: 1fr; } }
.zone-list button { display: flex; width: 100%; justify-content: space-between; align-items: center; border: 1px solid transparent; background: transparent; font: inherit; padding: 9px 11px; border-radius: 9px; cursor: pointer; text-align: left; color: var(--text); }
.zone-list button:hover { background: var(--surface-2); }
.zone-list button.on { background: color-mix(in srgb, var(--brand) 12%, transparent); border-color: color-mix(in srgb, var(--brand) 30%, transparent); font-weight: 700; }
.props h3 { font-size: 15px; }
.props .stack > * + * { margin-top: 10px; }
.combo-item { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.combo-item + .combo-item { margin-top: 8px; }

/* Configuración */
.settings { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .settings { grid-template-columns: 1fr; } }
.settings nav { position: sticky; top: 76px; }
.settings nav button { display: block; width: 100%; text-align: left; border: 0; background: transparent; font: inherit; padding: 9px 12px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; }
.settings nav button:hover { background: var(--surface); color: var(--text); }
.settings nav button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.settings .card h2 { font-size: 19px; }
.settings .card h3 { font-size: 15px; margin-top: 22px; }
.settings .section-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.day-row { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start; }
.shift { display: grid; grid-template-columns: 1fr 110px 110px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
@media (max-width: 640px) { .day-row { grid-template-columns: 1fr; } .shift { grid-template-columns: 1fr 1fr; } }
.var-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.var-chips code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 12px; cursor: pointer; }
.copy-box { display: flex; gap: 8px; }
.copy-box input { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.color-row { display: grid; grid-template-columns: 52px 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
table.simple { width: 100%; border-collapse: collapse; }
table.simple th, table.simple td { text-align: left; padding: 9px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
table.simple th { font-size: 12px; text-transform: uppercase; color: var(--muted); border-top: 0; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 18%, var(--bg)), var(--bg)); }
.login .card { width: min(380px, 100%); padding: 28px; }
.login h1 { font-size: 22px; }

/* Actividad */
.timeline { font-size: 13.5px; }
.timeline div { padding: 6px 0; border-top: 1px solid var(--line); }
.timeline div:first-child { border-top: 0; }
.timeline small { color: var(--muted); }
