* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f3f4f6;
    color: #111827;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.login-box {
    width: 100%;
    max-width: 420px;
    background: #fff;
    padding: 32px;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,.08);
}

.brand {
    text-align: center;
    margin-bottom: 25px;
}

.brand h1 {
    margin: 0;
    font-size: 26px;
    color: #111827;
}

.brand p {
    margin: 8px 0 0;
    color: #6b7280;
    font-size: 14px;
}

label {
    display: block;
    font-weight: bold;
    margin-top: 16px;
    color: #374151;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px;
    margin-top: 6px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
}

button,
.btn {
    display: inline-block;
    margin-top: 24px;
    width: 100%;
    padding: 13px;
    background: #b91c1c;
    color: white;
    border: 0;
    border-radius: 8px;
    font-weight: bold;
    font-size: 15px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

button:hover,
.btn:hover {
    background: #991b1b;
}

button:disabled {
    opacity: .65;
    cursor: not-allowed;
}

.alert {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-info {
    background: #eaf4ff;
    border-color: #9ec5fe;
    color: #084298;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.footer {
    text-align: center;
    margin-top: 22px;
    font-size: 12px;
    color: #9ca3af;
}

.topbar {
    background: #111827;
    color: #fff;
    padding: 18px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

.topbar h1 {
    margin: 0;
    font-size: 22px;
}

.topbar p {
    margin: 4px 0 0;
    color: #d1d5db;
    font-size: 13px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logout,
.topbar-link {
    color: #fff;
    text-decoration: none;
    background: #b91c1c;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
}

.topbar-link {
    background: #374151;
}

.container {
    padding: 28px;
    max-width: 1200px;
    margin: auto;
}

.card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 5px 20px rgba(0,0,0,.05);
    margin-bottom: 20px;
}

.welcome-card h2 {
    margin-top: 0;
}

.muted {
    color: #6b7280;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
}

.option {
    background: #fff;
    border-radius: 12px;
    padding: 22px;
    box-shadow: 0 5px 20px rgba(0,0,0,.05);
    border-left: 5px solid #b91c1c;
}

.option-link {
    color: inherit;
    text-decoration: none;
    transition: transform .12s ease, box-shadow .12s ease;
}

.option-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 26px rgba(0,0,0,.08);
}

.option h3 {
    margin-top: 0;
    margin-bottom: 8px;
}

.option p {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.45;
}

.badge {
    display: inline-block;
    margin-top: 8px;
    font-size: 12px;
    font-weight: bold;
    background: #fee2e2;
    color: #991b1b;
    padding: 5px 8px;
    border-radius: 999px;
}

.muted-badge {
    background: #f3f4f6;
    color: #6b7280;
}

.calendar-container {
    max-width: 1400px;
}

.calendar-toolbar-card {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-end;
}

.calendar-toolbar-card h2 {
    margin-top: 0;
    margin-bottom: 8px;
}

.calendar-filters {
    min-width: 260px;
}

.calendar-filters label {
    margin-top: 0;
}

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    margin-bottom: 18px;
    font-size: 13px;
    color: #374151;
}

.legend-color {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 3px;
    margin-right: 5px;
    vertical-align: -1px;
}

.legend-pending {
    background: #b91c1c;
}

.legend-class {
    background: #7c3aed;
}

.legend-paid {
    background: #16a34a;
}

.legend-key {
    background: #2563eb;
}

.legend-returned {
    background: #166534;
}

.legend-block {
    background: #111827;
}

#calendar {
    --fc-border-color: #e5e7eb;
    --fc-today-bg-color: #fef2f2;
    --fc-button-bg-color: #111827;
    --fc-button-border-color: #111827;
    --fc-button-hover-bg-color: #374151;
    --fc-button-hover-border-color: #374151;
    --fc-button-active-bg-color: #b91c1c;
    --fc-button-active-border-color: #b91c1c;
}

.fc .fc-toolbar-title {
    font-size: 20px;
}

.fc-event {
    cursor: pointer;
    border-radius: 5px;
    padding: 2px 4px;
}

.fc-timegrid-event .fc-event-main {
    padding: 2px 4px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .62);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 9999;
}

.modal-backdrop.is-open {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 760px;
    max-height: 92vh;
    overflow: auto;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    padding: 24px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 12px;
}

.modal-header h3 {
    margin: 0;
    font-size: 22px;
}

.modal-close {
    margin: 0;
    width: auto;
    background: #f3f4f6;
    color: #111827;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 24px;
    line-height: 1;
}

.modal-close:hover {
    background: #e5e7eb;
}

.modal-message {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 14px;
}

.modal-error {
    background: #fee2e2;
    color: #991b1b;
}

.modal-success {
    background: #dcfce7;
    color: #166534;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 18px;
}

.status-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-top: 16px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: normal;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 9px 12px;
    border-radius: 8px;
}

.checkbox-label input {
    width: auto;
    margin: 0;
}

.readonly-info,
.amount-box {
    margin-top: 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    color: #374151;
    padding: 12px;
    border-radius: 8px;
    line-height: 1.45;
}

.amount-box {
    background: #fff7ed;
    border-color: #fed7aa;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}

.modal-actions button {
    margin-top: 0;
}

.secondary-btn {
    background: #374151;
}

.secondary-btn:hover {
    background: #1f2937;
}

.danger-btn {
    background: #991b1b;
}

.danger-btn:hover {
    background: #7f1d1d;
}

.customer-search-wrap {
    position: relative;
}

.field-help {
    display: block;
    margin-top: 6px;
    color: #6b7280;
    font-size: 12px;
}

.suggestions {
    position: absolute;
    z-index: 10000;
    left: 0;
    right: 0;
    top: 82px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    box-shadow: 0 14px 34px rgba(0,0,0,.16);
    overflow: hidden;
}

.suggestion-item {
    display: block;
    width: 100%;
    margin: 0;
    border: 0;
    background: #fff;
    color: #111827;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    border-radius: 0;
    font-size: 14px;
}

.suggestion-item:hover {
    background: #fef2f2;
    color: #111827;
}

.suggestion-item strong {
    display: block;
}

.suggestion-item span {
    display: block;
    margin-top: 3px;
    color: #6b7280;
    font-size: 12px;
}

.suggestion-empty {
    padding: 11px 12px;
    color: #6b7280;
    font-size: 13px;
    background: #f9fafb;
}

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
    }

    .logout,
    .topbar-link {
        flex: 1;
        text-align: center;
    }

    .container {
        padding: 18px;
    }

    .login-box {
        padding: 24px;
    }

    .calendar-toolbar-card {
        align-items: stretch;
        flex-direction: column;
    }

    .calendar-filters {
        min-width: 0;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .modal-actions {
        grid-template-columns: 1fr;
    }

    .fc .fc-toolbar {
        flex-direction: column;
        gap: 10px;
    }

    .fc .fc-toolbar-title {
        font-size: 18px;
    }
}


.payment-key-box {
    margin-top: 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px;
}

.payment-key-box h4 {
    margin: 0 0 10px;
}

.price-preview-box {
    margin-top: 18px;
    background: #fff7ed;
    border-color: #fed7aa;
}

.price-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.price-grid div {
    background: rgba(255,255,255,.6);
    border: 1px solid #fed7aa;
    border-radius: 8px;
    padding: 10px;
}

.price-grid span {
    display: block;
    color: #9a3412;
    font-size: 12px;
    margin-bottom: 5px;
}

.price-grid strong {
    display: block;
    font-size: 18px;
    color: #111827;
}

.price-total {
    background: #ffedd5 !important;
}

.key-select-wrap {
    margin-top: 12px;
}

@media (max-width: 760px) {
    .price-grid {
        grid-template-columns: 1fr 1fr;
    }
}


.price-preview-box {
    margin-top: 18px;
    background: #fff7ed;
    border-color: #fed7aa;
}

.price-preview-title {
    font-weight: bold;
    color: #9a3412;
    margin-bottom: 10px;
    font-size: 16px;
}

.price-state {
    background: rgba(255,255,255,.65);
    border: 1px solid #fed7aa;
    color: #9a3412;
    border-radius: 8px;
    padding: 10px;
}

.price-note {
    margin-bottom: 10px;
}

.price-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.price-grid div {
    background: rgba(255,255,255,.72);
    border: 1px solid #fed7aa;
    border-radius: 8px;
    padding: 10px;
}

.price-grid span {
    display: block;
    color: #9a3412;
    font-size: 12px;
    margin-bottom: 5px;
}

.price-grid strong {
    display: block;
    font-size: 18px;
    color: #111827;
}

.price-total {
    background: #ffedd5 !important;
    border-color: #fb923c !important;
}

.price-total strong {
    font-size: 22px;
}

.payment-key-box {
    margin-top: 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px;
}

.payment-key-box h4 {
    margin: 0 0 10px;
}

.key-select-wrap {
    margin-top: 12px;
}

@media (max-width: 760px) {
    .price-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* V1.33 - llaves asociadas a varias pistas */
.key-courts-fieldset {
    border: 1px solid #d9dee7;
    border-radius: 10px;
    padding: 12px;
    margin: 0 0 14px;
}
.key-courts-fieldset.compact { margin-top: 10px; }
.key-courts-fieldset legend { font-weight: 700; padding: 0 6px; }
.key-courts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 8px;
    margin-top: 8px;
}
.key-court-summary { margin: 6px 0; }
