* { box-sizing: border-box; }
body {
    font-family: Segoe UI, Arial, sans-serif;
    margin: 0;
    background: #f4f6f8;
    color: #222;
}
.topbar {
    background: #1f3a5f;
    color: white;
    padding: 16px 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
.topbar-brand { display: flex; align-items: center; justify-content: center; gap: 20px; flex-wrap: wrap; width: 100%; }
.logo { height: 64px; width: 64px; object-fit: contain; border-radius: 50%; background: white; padding: 4px; }
.topbar-title { margin: 0; text-align: center; line-height: 1.3; }
.topbar-title a { color: white; text-decoration: none; font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }
.topbar-title span { display: block; font-size: 15px; font-weight: 400; opacity: 0.9; }

.nav-buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.nav-btn {
    text-decoration: none; font-weight: 600; padding: 10px 20px; border-radius: 6px;
    font-size: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.25); border: 0; cursor: pointer; font-family: inherit;
}
.btn-rojo { background: #c0392b; color: white; }
.btn-rojo:hover { background: #a5311f; }
.btn-verde { background: #27ae60; color: white; }
.btn-verde:hover { background: #219150; }
.btn-negro { background: #111111; color: white; }
.btn-negro:hover { background: #333333; }
.btn-gris { background: #5d6d7e; color: white; }
.btn-gris:hover { background: #4a5866; }

.container { max-width: 1200px; margin: 24px auto; padding: 0 16px; }
.intro { max-width: 70ch; margin-top: 0; }
h2 { margin: 0 0 12px; }

.flashes { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 4px; margin-bottom: 8px; }
.flash-success { background: #d4edda; color: #155724; }
.flash-error { background: #f8d7da; color: #721c24; }

.registro { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; align-items: start; }
@media (max-width: 820px) { .registro { grid-template-columns: minmax(0, 1fr); } }

.formulario, .calendario {
    background: white; padding: 24px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.formulario.angosto { max-width: 500px; }
.formulario h2, .calendario h2 { margin: 0; font-size: 20px; }
.formulario label { display: flex; flex-direction: column; font-size: 14px; color: #444; gap: 4px; }
.formulario input[type=text], .formulario input[type=tel], .formulario input[type=password], .formulario select,
.filtro select {
    padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 15px; font-family: inherit; width: 100%;
}
.fila-dos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .fila-dos { grid-template-columns: 1fr; } }

fieldset.misas { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
fieldset.misas legend { font-size: 14px; color: #444; padding: 0; margin-bottom: 4px; }
.misa-op { position: relative; }
.formulario .misa-op { flex-direction: row; }
.misa-op input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.misa-op span {
    display: block; width: 100%; text-align: center; padding: 12px 6px; border: 1px solid #ccc; border-radius: 6px;
    font-weight: 700; cursor: pointer; background: #fafbfc; color: #222;
}
.misa-op input:checked + span { background: #1f3a5f; border-color: #1f3a5f; color: white; }
.misa-op input:focus-visible + span { outline: 3px solid #c0392b; outline-offset: 2px; }

.btn-enviar {
    background: #1f3a5f; color: white; border: none; padding: 12px; border-radius: 4px;
    cursor: pointer; font-size: 16px; font-weight: 600; font-family: inherit;
}
.btn-enviar:hover { background: #17304f; }
.boton-secundario { text-align: center; color: #555; text-decoration: none; padding: 8px; }
.ayuda { font-size: 13px; color: #777; margin: 0; }

.meses-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.mes-tab {
    font: inherit; font-weight: 600; text-transform: capitalize; border: 1px solid #ccc; background: #fafbfc;
    padding: 7px 14px; border-radius: 999px; cursor: pointer;
}
.mes-tab.activo { background: #1f3a5f; border-color: #1f3a5f; color: white; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dow { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #777; text-align: center; font-weight: 700; padding-bottom: 4px; }
.dow.dom { color: #c0392b; }
.dia { min-height: 54px; border-radius: 6px; padding: 5px 7px; font-size: 13px; display: flex; flex-direction: column; justify-content: space-between; }
.dia.otro { color: #aaa; }
.dia.vacio { background: transparent; }
.dia.domingo { position: relative; border: 1.5px solid #27ae60; background: #e6f6ec; cursor: pointer; color: #222; }
.dia.domingo input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.dia.domingo .n { font-weight: 700; font-size: 15px; }
.dia.domingo .c { font-size: 11px; font-weight: 600; color: #4b5b57; font-variant-numeric: tabular-nums; }
.dia.domingo:has(input:checked) { background: #c0392b; border-color: #c0392b; color: white; }
.dia.domingo:has(input:checked) .c { color: white; }
.dia.domingo:has(input:focus-visible) { outline: 3px solid #1f3a5f; outline-offset: 2px; }
.dia.domingo.lleno { background: #eceff1; border-color: #cfd8dc; color: #78909c; cursor: not-allowed; }
.dia.domingo.lleno input { cursor: not-allowed; }
.dia.domingo.lleno:has(input:checked) { background: #c0392b; color: white; }

.leyenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: #555; }
.leyenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.lg-disp { background: #e6f6ec; border: 1.5px solid #27ae60; }
.lg-sel { background: #c0392b; }
.lg-lleno { background: #eceff1; border: 1.5px solid #cfd8dc; }
@media (max-width: 480px) { .dia { min-height: 46px; padding: 3px 4px; } .dia.domingo .c { font-size: 10px; } .formulario, .calendario { padding: 16px; } }

.domingo-card { background: white; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 16px; overflow: hidden; }
.domingo-card h3 { margin: 0; padding: 12px 16px; background: #eef2f6; text-transform: capitalize; font-size: 17px; }
.slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.slot { padding: 12px 16px; border-right: 1px solid #e5e5e5; min-width: 0; }
.slot:last-child { border-right: 0; }
@media (max-width: 720px) {
    .slots { grid-template-columns: minmax(0, 1fr); }
    .slot { border-right: 0; border-bottom: 1px solid #e5e5e5; }
    .slot:last-child { border-bottom: 0; }
}
.slot h4 { margin: 0 0 6px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cnt { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #d1fae5; color: #065f46; font-variant-numeric: tabular-nums; }
.cnt.lleno { background: #f8d7da; color: #721c24; }
.slot ul { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.slot li { padding: 3px 0; overflow-wrap: anywhere; }
.vacio-txt { color: #888; font-size: 13px; margin: 0; }

.admin-barra { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.admin-acciones { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.admin-acciones form { margin: 0; }
.filtro { margin-bottom: 16px; max-width: 420px; }
.filtro label { display: flex; flex-direction: column; font-size: 14px; color: #444; gap: 4px; }
.tabla-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 24px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e5e5e5; font-size: 14px; }
th { background: #eef2f6; }
.acciones { display: flex; gap: 8px; align-items: center; }
.acciones form { display: inline; margin: 0; }
.acciones button { background: #c0392b; color: white; border: none; padding: 4px 10px; border-radius: 4px; cursor: pointer; font: inherit; }
.acciones a { background: #2980b9; color: white; padding: 4px 10px; border-radius: 4px; text-decoration: none; }

@media (max-width: 640px) {
    table, thead, tbody, th, td, tr { display: block; }
    thead { display: none; }
    tr { margin-bottom: 12px; border: 1px solid #e5e5e5; border-radius: 6px; padding: 8px; }
    td { border: none; padding: 4px 6px; }
    td::before { content: attr(data-label); font-weight: 600; display: inline-block; min-width: 90px; color: #555; }
}

/* Misas especiales */
fieldset.especiales { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
fieldset.especiales legend { font-size: 14px; color: #444; padding: 0; margin-bottom: 6px; }
.formulario .esp-op { flex-direction: row; align-items: center; gap: 10px; position: relative; border: 1.5px solid #d4a017; background: #fff8e1; border-radius: 6px; padding: 10px 12px; cursor: pointer; color: #222; }
.esp-op input { width: 20px; height: 20px; flex: none; margin: 0; }
.esp-txt { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.esp-txt b { text-transform: capitalize; }
.esp-cnt { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; color: #7a5b00; }
.esp-op:has(input:checked) { background: #c0392b; border-color: #c0392b; color: white; }
.esp-op:has(input:checked) .esp-cnt { color: white; }
.esp-op.lleno { background: #eceff1; border-color: #cfd8dc; color: #78909c; cursor: not-allowed; }
.esp-op:has(input:focus-visible) { outline: 3px solid #1f3a5f; outline-offset: 2px; }
.estrella { color: #d4a017; font-size: 13px; }
.dia.domingo:has(input:checked) .estrella { color: white; }
.dia.con-especial { border: 1.5px dashed #d4a017; background: #fff8e1; flex-direction: row; justify-content: space-between; color: #444; }
.slot-especial { background: #fffdf3; }
.fila-pasada { opacity: .55; }
.slots { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
@media (max-width: 720px) { .slots { grid-template-columns: minmax(0, 1fr); } }

/* Clave de registro, aviso y pie legal */
.intro strong { color: #c0392b; }
dialog#dlg-clave { border: 0; border-radius: 10px; padding: 22px; width: min(92vw, 380px); box-shadow: 0 10px 40px rgba(0,0,0,.35); }
dialog#dlg-clave::backdrop { background: rgba(15, 25, 40, .55); }
dialog#dlg-clave h3 { margin: 0 0 6px; }
dialog#dlg-clave input { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; margin: 10px 0 14px; }
.dlg-botones { display: flex; gap: 10px; align-items: center; }
.dlg-botones .btn-enviar { flex: 1; }
.clave-actual { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.btn-peligro { background: transparent; color: #c0392b; border: 1px solid #c0392b; padding: 10px; border-radius: 4px; cursor: pointer; font-size: 15px; font-family: inherit; }
.legal { max-width: 1200px; margin: 40px auto 24px; padding: 0 16px; font-size: 10px; line-height: 1.5; color: #b3bac1; text-align: center; }
.legal strong { font-weight: 600; }
