:root {
    --primary: #123b8f;
    --primary-dark: #0f2d6b;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --line: #dbe5f3;
    --text: #0f172a;
    --muted: #64748b;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    display: grid;
    grid-template-columns: 270px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--primary-dark);
    color: #fff;
    padding: 22px 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, .16);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #fff;
    color: var(--primary-dark);
    font-weight: 800;
}

.brand strong,
.brand span {
    display: block;
}

.brand span {
    color: #bfdbfe;
    font-size: 13px;
}

.nav {
    display: grid;
    gap: 5px;
    margin-top: 18px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 40px;
    padding: 9px 10px;
    border-radius: 8px;
    color: #dbeafe;
    font-weight: 700;
    font-size: 14px;
}

.nav-link:hover,
.nav-link.is-active {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.nav-icon {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: rgba(255, 255, 255, .12);
    font-size: 12px;
}

.nav-icon::before {
    content: attr(data-icon);
}

.main-content {
    padding: 26px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.topbar h1 {
    margin: 0;
    color: var(--primary-dark);
    font-size: 30px;
}

.topbar p {
    margin: 6px 0 0;
    color: var(--muted);
}

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

.btn,
button {
    border: 0;
    border-radius: 8px;
    padding: 11px 16px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-weight: 800;
}

.btn-light {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--primary-dark);
}

.btn-danger {
    background: var(--danger);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.stat-card,
.panel,
.login-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 12px 28px rgba(15, 45, 107, .06);
}

.stat-card {
    padding: 18px;
}

.stat-card span,
.stat-card small {
    display: block;
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin: 8px 0;
    color: var(--primary-dark);
    font-size: 30px;
}

.stat-card.warning strong {
    color: var(--warning);
}

.content-grid {
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 16px;
}

.panel {
    padding: 20px;
}

.panel h2 {
    margin: 0 0 14px;
    color: var(--primary-dark);
}

.flow {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.flow span,
.action-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8fafc;
    color: var(--primary-dark);
    padding: 16px;
    text-align: center;
    font-weight: 800;
}

.check-list {
    margin: 0;
    padding-left: 20px;
    color: #334155;
    line-height: 1.8;
}

.module-empty {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}

.module-empty-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: #e0ecff;
    color: var(--primary-dark);
    font-size: 28px;
    font-weight: 800;
}

.module-empty h2,
.module-empty p {
    margin: 0;
}

.module-empty p {
    margin-top: 6px;
    color: var(--muted);
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.action-card {
    cursor: default;
}

.mt {
    margin-top: 16px;
}

.muted-text {
    color: var(--muted);
    line-height: 1.6;
}

.toolbar {
    display: flex;
    align-items: end;
    gap: 12px;
    margin-bottom: 18px;
}

.toolbar label,
.form-grid label {
    display: grid;
    gap: 7px;
    color: #334155;
    font-size: 14px;
    font-weight: 800;
}

.search-box {
    flex: 1;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    padding: 11px 12px;
    font: inherit;
}

textarea {
    resize: vertical;
}

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

.span-2 {
    grid-column: span 2;
}

.span-3 {
    grid-column: span 3;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: var(--primary-dark);
    font-size: 13px;
    text-transform: uppercase;
}

.data-table tr:hover td {
    background: #f8fafc;
}

.empty-row {
    color: var(--muted);
    text-align: center !important;
}

.actions {
    white-space: nowrap;
}

.actions form {
    display: inline;
    margin-left: 10px;
}

.actions a + a {
    margin-left: 10px;
}

.actions a,
.link-button {
    border: 0;
    background: transparent;
    color: var(--primary);
    padding: 0;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 900;
}

.status.ok {
    background: #dcfce7;
    color: #166534;
}

.status.off {
    background: #fee2e2;
    color: #991b1b;
}

.status.pendiente {
    background: #fef3c7;
    color: #92400e;
}

.status.confirmada {
    background: #dbeafe;
    color: #1e40af;
}

.status.atendida {
    background: #dcfce7;
    color: #166534;
}

.status.cancelada {
    background: #fee2e2;
    color: #991b1b;
}

.status.en-espera {
    background: #fef3c7;
    color: #92400e;
}

.status.en-consulta {
    background: #dbeafe;
    color: #1e40af;
}

.status.pendiente-de-cobro {
    background: #ffedd5;
    color: #9a3412;
}

.status.cobrada,
.status.finalizada {
    background: #dcfce7;
    color: #166534;
}

.status.anulada {
    background: #fee2e2;
    color: #991b1b;
}

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

.detail-list.single {
    grid-template-columns: 1fr;
}

.detail-list div {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8fafc;
    padding: 12px;
}

.detail-list dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.detail-list dd {
    margin: 5px 0 0;
    color: var(--text);
    font-weight: 700;
}

.agenda-day {
    display: grid;
    gap: 12px;
}

.empty-agenda {
    display: grid;
    gap: 5px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: #f8fafc;
    color: var(--muted);
    padding: 24px;
    text-align: center;
}

.empty-agenda strong {
    color: var(--primary-dark);
}

.appointment-card {
    display: grid;
    grid-template-columns: 90px 1fr 190px;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--line);
    border-left: 6px solid var(--primary);
    border-radius: 12px;
    background: #fff;
    padding: 14px;
}

.appointment-card.pendiente {
    border-left-color: #f59e0b;
}

.appointment-card.confirmada {
    border-left-color: #2563eb;
}

.appointment-card.atendida {
    border-left-color: #16a34a;
}

.appointment-card.cancelada {
    border-left-color: #dc2626;
}

.appointment-time {
    display: grid;
    gap: 4px;
    color: var(--primary-dark);
}

.appointment-time strong {
    font-size: 24px;
}

.appointment-time span,
.appointment-body small {
    color: var(--muted);
}

.appointment-body h3,
.appointment-body p {
    margin: 0;
}

.appointment-body p {
    margin-top: 5px;
    color: #334155;
}

.appointment-side {
    display: grid;
    justify-items: end;
    gap: 12px;
}

.status-form {
    display: grid;
    gap: 12px;
}

.notice {
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    background: #eff6ff;
    color: #1e3a8a;
    margin-bottom: 16px;
    padding: 12px 14px;
    font-weight: 800;
}

.single-column {
    grid-template-columns: 1fr;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    background: rgba(15, 23, 42, .45);
    padding: 24px;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    width: min(920px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
    padding: 20px;
}

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

.modal-header h2,
.modal-header p {
    margin: 0;
}

.modal-header h2 {
    color: var(--primary-dark);
}

.modal-header p {
    color: var(--muted);
    margin-top: 4px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.calendar-head {
    margin-bottom: 8px;
}

.calendar-head span {
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 900;
    text-align: center;
}

.calendar-cell {
    display: grid;
    gap: 5px;
    min-height: 92px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8fafc;
    color: var(--text);
    padding: 10px;
}

.calendar-cell:hover,
.calendar-cell.selected {
    border-color: var(--primary);
    background: #eff6ff;
}

.calendar-cell.muted {
    border-style: dashed;
    background: transparent;
}

.calendar-cell strong {
    color: var(--primary-dark);
    font-size: 18px;
}

.calendar-cell span {
    color: #334155;
    font-size: 13px;
    font-weight: 800;
}

.calendar-cell small {
    color: var(--muted);
    font-size: 11px;
}

.receipt {
    max-width: 860px;
}

.receipt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
    padding-bottom: 16px;
}

.receipt-header h2,
.receipt-header p {
    margin: 0;
}

.receipt-header h2 {
    color: var(--primary-dark);
}

.receipt-header p {
    color: var(--muted);
    margin-top: 4px;
}

.receipt-header strong {
    color: var(--primary-dark);
    font-size: 28px;
}

.totals-box {
    display: grid;
    gap: 8px;
    width: min(360px, 100%);
    margin-left: auto;
    margin-top: 18px;
}

.totals-box div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    padding: 8px 0;
}

.totals-box span {
    color: var(--muted);
}

.grand-total {
    color: var(--primary-dark);
    font-size: 22px;
    font-weight: 900;
}

@media print {
    .sidebar,
    .topbar .topbar-actions,
    .nav,
    .btn {
        display: none !important;
    }

    .app-shell {
        display: block;
    }

    .main-content {
        padding: 0;
    }

    .panel {
        border: 0;
        box-shadow: none;
    }
}

.login-body {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(420px, 100%);
    padding: 32px;
}

.login-brand {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: var(--primary-dark);
    color: #fff;
    font-size: 22px;
    font-weight: 900;
}

.login-card h1,
.login-card p {
    text-align: center;
}

.login-card h1 {
    margin: 0;
    color: var(--primary-dark);
}

.login-card p {
    margin: 8px 0 24px;
    color: var(--muted);
}

.login-card label {
    display: grid;
    gap: 7px;
    margin-bottom: 14px;
    color: #334155;
    font-weight: 700;
}

.login-card input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    font: inherit;
}

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

.login-card small {
    display: block;
    margin-top: 14px;
    color: var(--muted);
    text-align: center;
}

.alert {
    margin-bottom: 14px;
    border-radius: 8px;
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 12px;
}

@media (max-width: 980px) {
    .app-shell,
    .content-grid,
    .stats-grid,
    .action-grid,
    .form-grid,
    .detail-list {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

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

    .appointment-card {
        grid-template-columns: 1fr;
    }

    .appointment-side {
        justify-items: start;
    }

    .calendar-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .calendar-head {
        display: none;
    }

    .span-2,
    .span-3 {
        grid-column: auto;
    }

    .toolbar,
    .topbar,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }
}
