* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f8;
    color: #1f2937;
}
.container {
    width: min(1100px, 92%);
    margin: 0 auto;
}
.topbar {
    background: #1f2937;
    color: white;
    padding: 16px 0;
    margin-bottom: 24px;
}
.topbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}
.topbar a {
    color: white;
    text-decoration: none;
}
.topbar nav {
    display: flex;
    gap: 14px;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}
.card, .table-wrapper {
    background: white;
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
.search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}
.search-form input {
    flex: 1;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 16px;
}
.form-grid .full {
    grid-column: 1 / -1;
}
label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
}
input, select, textarea, button {
    font: inherit;
}
input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: white;
}
textarea {
    resize: vertical;
}
.button, button {
    display: inline-block;
    border: none;
    background: #2563eb;
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
}
.button.secondary {
    background: #64748b;
}
.button.danger {
    background: #dc2626;
}
.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.actions form {
    margin: 0;
}
.actions-row {
    display: flex;
    gap: 10px;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid #e5e7eb;
}
th {
    background: #f8fafc;
}
.empty {
    text-align: center;
    color: #6b7280;
}
.flash {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}
.flash.ok {
    background: #dcfce7;
    color: #166534;
}
.flash.error {
    background: #fee2e2;
    color: #991b1b;
}
@media (max-width: 768px) {
    .topbar .container,
    .section-header,
    .search-form,
    .actions-row {
        flex-direction: column;
        align-items: stretch;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: normal;
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stat-card h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 18px;
}

.stat-number {
    font-size: 32px;
    font-weight: bold;
    margin: 0;
    color: #2563eb;
}

@media (max-width: 900px) {
    .dashboard-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
}

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

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

.text-danger {
    color: #dc2626 !important;
}

.card-alert {
    border: 2px solid #fca5a5;
    background: #fff7f7;
}

.alert-text {
    color: #b91c1c;
    font-weight: bold;
    margin-top: 0;
    margin-bottom: 14px;
}

.status-pending {
    color: #b45309;
    font-weight: bold;
}

.status-paid {
    color: #166534;
    font-weight: bold;
}

.login-body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f4f6f8;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: white;
    padding: 32px;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.10);
    text-align: center;
}

.login-logo img {
    width: 110px;
    height: 110px;
    object-fit: contain;
    margin-bottom: 14px;
}

.login-card h1 {
    margin: 0;
    font-size: 24px;
    color: #1f2937;
}

.login-card h2 {
    margin: 8px 0 24px;
    font-size: 16px;
    font-weight: normal;
    color: #64748b;
}

.login-card form {
    text-align: left;
}

.login-card form div {
    margin-bottom: 14px;
}

.login-button {
    width: 100%;
    margin-top: 8px;
}

/* =========================
   BRAND / HEADER
   ========================= */

.topbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand img {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 50%;
    background: white;
    padding: 4px;
}

.brand h1 {
    margin: 0;
    font-size: 24px;
    color: white;
}

.brand-subtitle {
    font-size: 13px;
    opacity: 0.85;
    color: white;
}

/* =========================
   MODO MÓVIL OPTIMIZADO
   ========================= */

@media (max-width: 768px) {

    body {
        font-size: 15px;
    }

    .container {
        width: 96%;
    }

    .topbar .container {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .topbar h1 {
        font-size: 20px;
        text-align: center;
        margin: 0;
    }

    .topbar nav {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .topbar nav a {
        background: rgba(255,255,255,0.12);
        padding: 10px;
        border-radius: 8px;
        text-align: center;
        font-size: 14px;
    }

    h2 {
        font-size: 22px;
    }

    h3 {
        font-size: 18px;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .section-header h2,
    .section-header h3 {
        margin-bottom: 0;
    }

    .dashboard-cards {
        grid-template-columns: 1fr !important;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-number {
        font-size: 26px;
    }

    .card {
        padding: 14px;
    }

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

    input,
    select,
    textarea,
    button,
    .button {
        width: 100%;
        min-height: 42px;
    }

    .actions,
    .actions-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .actions form {
        width: 100%;
    }

    .actions button,
    .actions .button,
    .actions-row button,
    .actions-row .button {
        width: 100%;
        text-align: center;
    }

    .search-form {
        flex-direction: column;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px;
    }

    table {
        min-width: 720px;
        font-size: 14px;
    }

    th,
    td {
        padding: 10px 8px;
        white-space: nowrap;
    }

    td.actions {
        min-width: 150px;
    }

    .login-card {
        width: 94%;
        padding: 24px 18px;
    }

    .login-logo img {
        width: 90px;
        height: 90px;
    }

    .login-card h1 {
        font-size: 22px;
    }

    .login-card h2 {
        font-size: 15px;
    }
}

.brand {
    justify-content: center;
    width: 100%;
}

.brand h1 {
    font-size: 20px;
}

.brand-subtitle {
    font-size: 12px;
}