:root {
    --clr-bg: #f6f7fb;
    --clr-surface: #ffffff;
    --clr-text: #111827;
    --clr-muted: #6b7280;
    --clr-border: #e5e7eb;
    --clr-accent: #760307;
    --dot-curso: #39567D;   /* azul */
    --dot-otro: #f59e0b;    /* amarillo */
    --dot-reserva: #BC5064;
    --dot-guardia: #79AA72;
    --radius: 14px;
}

* { box-sizing: border-box; }

.calendar {
    width: min(100%, 980px);
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    overflow: hidden;
}

.cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--clr-border);
    gap: 8px;
}
.cal-title h1 { font-size: 20px; margin: 0; letter-spacing: .3px; }
.cal-title .sub { color: var(--clr-muted); font-size: 13px; }
.btn {
    background: #fff;
    color: var(--clr-text);
    border: 1px solid var(--clr-border);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
}
.cal-nav {
    text-align: right;
}
.btn:hover { background: #f1f1f1; }

.legend { display:flex; align-items:center; gap:14px; color: var(--clr-muted); font-size: 13px; }
.legend .dot { width: 9px; height: 9px; border-radius: 999px; display:inline-block; }

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}
.cal-weekday {
    text-align: center;
    padding: 10px 6px;
    font-weight: 600;
    font-size: 12px;
    color: var(--clr-muted);
    border-bottom: 1px solid var(--clr-border);
}

.day {
    min-height: 70px;
    border-right: 1px solid var(--clr-border);
    border-bottom: 1px solid var(--clr-border);
    padding: 8px 10px 6px;
    position: relative;
    display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start;
    background: #fff;
}
.day:nth-child(7n) { border-right: none; }

.day .num {
    font-weight: 600;
    font-size: 14px;
    width: 28px; height: 28px;
    display:grid; place-items:center;
}
.day.today .num { outline: 2px solid var(--clr-accent); outline-offset: 2px; border-radius: 6px; }
.day.outside { color: var(--clr-muted); background: #fafafa; }

.dots { display:flex; gap:6px; margin-top: 6px; }
.dot { width: 8px; height: 8px; border-radius: 999px; }
.dot.curso { background: var(--dot-curso); }
.dot.reserva { background: var(--dot-reserva); }
.dot.guardia { background: var(--dot-guardia); }
.dot.otro { background: var(--dot-otro); }

.chips { display:flex; flex-wrap: wrap; gap:6px; margin-top: 8px; }
.chip { font-size: 11px; padding: 4px 6px; border-radius: 999px; border: 1px solid var(--clr-border); color: var(--clr-muted); }

.day button.full { position: absolute; inset: 0; border: 0; background: transparent; cursor: pointer; }
.day:hover { background: #f9f9f9; }

/* Fuerza la visibilidad del <dialog> cuando está abierto,
   aunque un framework ponga display:none en .modal o similares */
dialog.cal-modal[open] {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: 9999; /* por si acaso */
}

dialog.cal-modal {
    border: 1px solid var(--clr-border);
    border-radius: 16px;
    background: var(--clr-surface);
    color: var(--clr-text);
    width: min(92vw, 640px);
    padding: 0;
    box-shadow: 0 10px 40px rgba(0,0,0,.15);
}

/* backdrop del dialog */
dialog.cal-modal::backdrop {
    background: rgba(0,0,0,.3);
}
.modal-header { display:flex; justify-content: space-between; align-items:center; padding: 14px 16px; border-bottom: 1px solid var(--clr-border); }
.modal-body { padding: 12px 16px 18px; display: grid; gap: 12px; }
.close { all: unset; cursor:pointer; padding:6px 10px; border-radius: 8px; border: 1px solid var(--clr-border); }

.event-card {
    border: 1px solid var(--clr-border);
    background: #ffffff;
    border-radius: 12px;
    padding: 10px 12px;
    display: grid; gap: 6px;
}
.badge { color: var(--clr-text); font-size: 11px; padding: 4px 6px; border-radius: 999px; display:inline-flex; align-items:center; gap:6px; border: 1px solid var(--clr-border); background: #f9fafb; justify-self: start; /* tamaño al contenido, no full width */ }
.badge .dots { margin-top: 3px; }
.btn[disabled]{ opacity:.5; cursor:not-allowed; }