:root {
    --navy-950: #071426;
    --navy-900: #0b1f3a;
    --navy-800: #173b63;
    --navy-700: #20517f;
    --blue-600: #2f6fed;
    --blue-500: #4b84f3;
    --cyan-500: #20a4c7;
    --surface: #ffffff;
    --surface-soft: #f4f7fb;
    --surface-muted: #eaf0f7;
    --text: #172033;
    --text-muted: #6b7688;
    --border: #dce4ee;
    --success: #15803d;
    --warning: #b7791f;
    --danger: #c2414b;
    --info: #087f9c;
    --sidebar-width: 280px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 4px 14px rgba(11, 31, 58, 0.06);
    --shadow-md: 0 12px 32px rgba(11, 31, 58, 0.1);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--surface-soft);
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a,
button,
input,
select,
textarea {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease,
        background-color 0.2s ease, transform 0.2s ease;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(47, 111, 237, 0.24);
    outline-offset: 2px;
}

.text-primary {
    color: var(--blue-600) !important;
}

.text-dark {
    color: var(--text) !important;
}

.text-secondary,
.text-muted {
    color: var(--text-muted) !important;
}

.bg-primary {
    background-color: var(--navy-800) !important;
}

.bg-dark {
    background-color: var(--navy-900) !important;
}

.bg-info {
    background-color: var(--info) !important;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar-col {
    position: sticky;
    top: 0;
    z-index: 1040;
    display: flex;
    flex: 0 0 var(--sidebar-width);
    flex-direction: column;
    width: var(--sidebar-width);
    height: 100vh;
    overflow: hidden;
    color: #d9e5f2;
    background: var(--navy-950);
    box-shadow: 10px 0 30px rgba(7, 20, 38, 0.12);
    transition: margin-left 0.28s ease, transform 0.28s ease;
}

.sidebar-collapsed .sidebar-col {
    margin-left: calc(var(--sidebar-width) * -1);
}

.logo-area {
    position: relative;
    display: flex;
    min-height: 112px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 22px 52px 18px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.sidebar-logo {
    display: block;
    max-width: 180px;
    max-height: 52px;
    object-fit: contain;
}

.brand-mark {
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 750;
    letter-spacing: -0.02em;
}

.brand-mark i {
    color: #78b5ff;
}

.sidebar-close {
    position: absolute;
    top: 16px;
    right: 14px;
    display: none;
    width: 36px;
    height: 36px;
    padding: 0;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
}

.sidebar-menu {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    padding: 18px 14px;
    overflow-y: auto;
    scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
    scrollbar-width: thin;
}

.sidebar-menu > a {
    display: flex;
    min-height: 46px;
    align-items: center;
    padding: 11px 14px;
    color: #b9c9dc;
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 10px;
}

.sidebar-menu > a i {
    width: 24px;
    color: #7f9bb9;
    text-align: center;
}

.sidebar-menu > a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(2px);
}

.sidebar-menu > a:hover i {
    color: #a8cdff;
}

.sidebar-menu > a.active {
    color: #ffffff;
    background: var(--navy-800);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 18px rgba(47, 111, 237, 0.28);
}

.sidebar-menu > a.active i {
    color: #ffffff;
}

.sidebar-section-label {
    display: block;
    margin: 13px 12px 4px;
    color: #647f9d;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 18px;
}

.sidebar-footer .btn {
    color: #ffd8dc;
    border-color: rgba(255, 166, 176, 0.35);
}

.sidebar-footer .btn:hover {
    color: #ffffff;
    background: var(--danger);
    border-color: var(--danger);
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1035;
    display: none;
    padding: 0;
    background: rgba(7, 20, 38, 0.56);
    border: 0;
    backdrop-filter: blur(2px);
}

.content-col {
    min-width: 0;
    flex: 1 1 auto;
    background: var(--surface-soft);
}

.top-navbar {
    position: sticky;
    top: 0;
    z-index: 1025;
    display: flex;
    min-height: 74px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 30px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid rgba(220, 228, 238, 0.9);
    box-shadow: 0 4px 20px rgba(11, 31, 58, 0.04);
    backdrop-filter: blur(12px);
}

.menu-toggle {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    padding: 0;
    color: var(--navy-800);
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 11px;
}

.menu-toggle:hover {
    color: #ffffff;
    background: var(--navy-800);
    border-color: var(--navy-800);
}

.topbar-title {
    margin: 0;
    color: var(--navy-900);
    font-size: 1rem;
    font-weight: 750;
}

.welcome-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 500;
}

.user-avatar {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--surface-muted);
}

.user-menu {
    color: var(--navy-900) !important;
}

.page-content {
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    padding: 28px 30px 42px;
}

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

.page-heading h1,
.page-heading h2,
.page-heading h3,
.page-heading h4 {
    margin: 0;
    color: var(--navy-900);
    font-size: clamp(1.35rem, 2vw, 1.75rem);
    font-weight: 760;
    letter-spacing: -0.025em;
}

.page-heading p {
    margin: 5px 0 0;
    color: var(--text-muted);
}

.card {
    color: var(--text);
    background: var(--surface);
    border: 1px solid rgba(220, 228, 238, 0.9) !important;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm) !important;
}

.card-header {
    padding: 17px 20px;
    color: var(--navy-900);
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
}

.card-header h5,
.card-header h6 {
    color: inherit;
}

.card-body {
    padding: 20px;
}

.section-header,
.card-header.section-header {
    color: var(--navy-900) !important;
    background: var(--surface) !important;
    border-bottom: 1px solid var(--border);
}

.section-header .text-dark,
.section-header .text-primary,
.section-header .text-success,
.section-header .text-secondary {
    color: var(--navy-900) !important;
}

.section-header .btn-light,
.section-header .btn-light.text-dark,
.section-header .btn-light.text-primary,
.section-header .btn-light.text-success {
    color: #ffffff !important;
    background: var(--navy-800);
    border-color: var(--navy-800);
}

.section-header .btn-light:hover {
    color: #ffffff !important;
    background: var(--navy-900);
    border-color: var(--navy-900);
}

.stat-card {
    position: relative;
    min-height: 122px;
    overflow: hidden;
    color: #ffffff;
    border: 0 !important;
    background: var(--navy-800) !important;
    box-shadow: var(--shadow-md) !important;
}

.stat-card::after {
    position: absolute;
    right: -32px;
    bottom: -54px;
    width: 150px;
    height: 150px;
    content: "";
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.stat-card.stat-card-accent {
    background: var(--blue-600) !important;
}

.stat-card.stat-card-success {
    background: var(--success) !important;
}

.stat-card.stat-card-info {
    background: var(--info) !important;
}

.stat-card .card-body {
    position: relative;
    z-index: 1;
}

.stat-card h1,
.stat-card h2,
.stat-card h3,
.stat-card h4,
.stat-card h5,
.stat-card h6,
.stat-card p,
.stat-card .text-dark,
.stat-card .text-primary,
.stat-card .text-secondary,
.stat-card .text-muted {
    color: #ffffff !important;
}

.stat-card .text-white-50,
.stat-card .opacity-75 {
    color: rgba(255, 255, 255, 0.72) !important;
}

.stat-card .stat-icon,
.stat-card > .card-body > i {
    color: rgba(255, 255, 255, 0.26);
}

.filter-card .card-body {
    padding: 16px 18px;
}

.form-label {
    margin-bottom: 7px;
    color: var(--navy-900);
    font-size: 0.86rem;
    font-weight: 650;
}

.form-control,
.form-select,
.input-group-text {
    min-height: 42px;
    color: var(--text);
    background-color: #ffffff;
    border-color: var(--border);
    border-radius: var(--radius-sm);
}

.form-control-sm,
.form-select-sm {
    min-height: 36px;
}

.input-group > .input-group-text {
    color: var(--navy-700);
    background: var(--surface-soft);
}

.form-control:focus,
.form-select:focus {
    background: #ffffff;
    border-color: var(--blue-600);
    box-shadow: 0 0 0 0.22rem rgba(47, 111, 237, 0.14);
}

.form-control::placeholder {
    color: #9aa6b5;
}

.btn {
    min-height: 40px;
    padding: 8px 15px;
    font-weight: 650;
    border-radius: var(--radius-sm);
}

.btn-sm {
    min-height: 34px;
    padding: 6px 11px;
}

.btn-primary,
.btn-dark {
    color: #ffffff;
    background: var(--navy-800);
    border-color: var(--navy-800);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-dark:hover,
.btn-dark:focus {
    color: #ffffff;
    background: var(--navy-900);
    border-color: var(--navy-900);
    transform: translateY(-1px);
}

.btn-outline-primary,
.btn-outline-dark {
    color: var(--navy-800);
    border-color: var(--navy-700);
}

.btn-outline-primary:hover,
.btn-outline-dark:hover {
    color: #ffffff;
    background: var(--navy-800);
    border-color: var(--navy-800);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}

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

.btn-warning {
    color: #ffffff;
    background: var(--warning);
    border-color: var(--warning);
}

.rounded-pill {
    padding-right: 20px;
    padding-left: 20px;
}

.table-responsive {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.table {
    margin-bottom: 0;
    color: var(--text);
    vertical-align: middle;
}

.table > :not(caption) > * > * {
    padding: 13px 14px;
    border-bottom-color: #e7edf4;
}

.table thead th {
    color: var(--navy-800);
    background: #eef3f8;
    font-size: 0.76rem;
    font-weight: 750;
    letter-spacing: 0.035em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table-hover > tbody > tr:hover > * {
    color: var(--text);
    background: #f4f8fc;
}

.table td .btn {
    margin: 2px 0;
}

.badge {
    padding: 0.48em 0.72em;
    font-weight: 700;
    border-radius: 7px;
}

.dropdown-menu {
    padding: 8px;
    border: 1px solid var(--border) !important;
    border-radius: 12px;
    box-shadow: var(--shadow-md) !important;
}

.dropdown-item {
    padding: 9px 11px;
    border-radius: 8px;
}

.dropdown-item:hover {
    color: var(--navy-900);
    background: var(--surface-muted);
}

.modal-content {
    overflow: hidden;
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 70px rgba(7, 20, 38, 0.24);
}

.modal-header {
    padding: 18px 22px;
    color: #ffffff;
    background: var(--navy-900) !important;
    border: 0;
}

.modal-header .modal-title,
.modal-header.text-dark .modal-title {
    color: #ffffff;
}

.modal-header .btn-close {
    filter: invert(1) grayscale(1) brightness(2);
}

.modal-body {
    padding: 22px;
}

.modal-footer {
    padding: 15px 22px;
    background: var(--surface-soft);
    border-top: 1px solid var(--border);
}

.nav-tabs {
    gap: 7px;
    padding: 5px;
    background: var(--surface-muted);
    border: 0;
    border-radius: 11px;
}

.nav-tabs .nav-link {
    color: var(--text-muted);
    font-weight: 650;
    border: 0;
    border-radius: 8px;
}

.nav-tabs .nav-link:hover {
    color: var(--navy-900);
}

.nav-tabs .nav-link.active {
    color: var(--navy-900);
    background: #ffffff;
    box-shadow: 0 3px 10px rgba(11, 31, 58, 0.08);
}

.alert {
    border: 0;
    border-radius: 10px;
}

.accordion {
    --bs-accordion-border-color: var(--border);
    --bs-accordion-btn-focus-box-shadow: 0 0 0 0.2rem rgba(47, 111, 237, 0.14);
    --bs-accordion-active-color: var(--navy-900);
    --bs-accordion-active-bg: var(--surface-muted);
}

.accordion-item {
    overflow: hidden;
    border-radius: 10px !important;
}

.dataTables_wrapper {
    padding: 18px 20px 20px;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 15px;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    min-height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.dataTables_wrapper .dt-buttons {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.page-link {
    color: var(--navy-800);
    border-color: var(--border);
}

.page-item.active .page-link {
    background: var(--navy-800);
    border-color: var(--navy-800);
}

.select2-container--bootstrap-5 .select2-selection {
    min-height: 42px;
    border-color: var(--border);
    border-radius: var(--radius-sm);
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--blue-600);
    box-shadow: 0 0 0 0.22rem rgba(47, 111, 237, 0.14);
}

.fc {
    color: var(--text);
}

#calendar {
    width: 100%;
    min-height: 610px;
    margin: 0 auto;
    padding: 20px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.fc .fc-toolbar-title {
    color: var(--navy-900);
    font-size: 1.3rem;
    font-weight: 750;
}

.fc .fc-button-primary {
    background: var(--navy-800);
    border-color: var(--navy-800);
}

.fc .fc-button-primary:hover,
.fc .fc-button-primary:not(:disabled).fc-button-active {
    background: var(--navy-900);
    border-color: var(--navy-900);
}

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

.timeline {
    position: relative;
    margin-left: 20px;
    padding-left: 30px;
    border-left: 3px solid var(--surface-muted);
}

.timeline-item {
    position: relative;
    margin-bottom: 32px;
}

.timeline-dot {
    position: absolute;
    top: 5px;
    left: -40px;
    width: 17px;
    height: 17px;
    background: var(--blue-600);
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--blue-600);
}

.timeline-date {
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.card-historia {
    border-left: 4px solid var(--blue-600) !important;
}

.card-historia:hover,
.file-card:hover {
    border-color: var(--blue-500) !important;
    box-shadow: var(--shadow-md) !important;
    transform: translateY(-3px);
}

.file-card {
    cursor: pointer;
}

.hover-card:hover {
    border-color: var(--blue-500) !important;
    box-shadow: var(--shadow-md) !important;
    transform: translateY(-3px);
}

.file-card a {
    display: block;
    width: 100%;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.meta-label {
    font-size: 0.7rem;
}

.file-date {
    font-size: 0.66rem;
}

.brand-preview {
    max-height: 100px;
    object-fit: contain;
}

.profile-avatar,
.profile-avatar-placeholder {
    width: 120px;
    height: 120px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
}

.profile-avatar {
    object-fit: cover;
}

.profile-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: var(--surface-muted);
    font-size: 3rem;
}

.avatar-upload {
    position: absolute;
    right: 0;
    bottom: 0;
    display: flex;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #ffffff;
    background: var(--navy-900);
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.chart-canvas {
    max-height: 240px;
}

.report-progress {
    width: 100%;
    height: 10px;
    overflow: hidden;
    appearance: none;
    background: var(--surface-muted);
    border: 0;
    border-radius: 999px;
}

.report-progress::-webkit-progress-bar {
    background: var(--surface-muted);
    border-radius: 999px;
}

.report-progress::-webkit-progress-value {
    background: var(--blue-600);
    border-radius: 999px;
}

.report-progress::-moz-progress-bar {
    background: var(--blue-600);
    border-radius: 999px;
}

.report-progress-column {
    width: 50%;
}

.print-logo-sm {
    max-height: 50px;
    margin-bottom: 10px;
    object-fit: contain;
}

.print-logo-md {
    max-height: 70px;
    margin-bottom: 10px;
    object-fit: contain;
}

.pre-line {
    white-space: pre-line;
}

.receta-container,
.certificado-container {
    padding: 40px;
    color: #000000;
    background: #ffffff;
    border: 2px solid #333333;
    font-family: "Times New Roman", serif;
}

.receta-header,
.certificado-header {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #333333;
}

.receta-body,
.certificado-body {
    min-height: 200px;
    font-size: 16px;
    line-height: 1.6;
}

.receta-footer,
.certificado-footer {
    margin-top: 50px;
    padding-top: 10px;
    border-top: 1px dashed #333333;
}

.ticket-container {
    padding: 20px;
    color: #000000;
    background: #ffffff;
    border: 1px solid #333333;
    font-family: "Courier New", Courier, monospace;
}

.auth-page {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 32px 18px;
    background: var(--navy-950);
}

.auth-page::before {
    position: fixed;
    inset: 0;
    pointer-events: none;
    content: "";
    opacity: 0.18;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, #000000, transparent 80%);
}

.card-login {
    z-index: 1;
    width: 100%;
    max-width: 430px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 22px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.32) !important;
}

.auth-page .card-header {
    padding: 38px 34px 18px;
    text-align: center;
    border: 0;
}

.auth-page .card-body {
    padding: 10px 34px 30px;
}

.auth-page .card-footer {
    padding: 16px 34px 22px;
    background: #ffffff;
    border: 0;
}

.auth-page .logo-img {
    max-width: 80%;
    max-height: 82px;
    object-fit: contain;
}

.auth-page .input-group-text {
    min-width: 46px;
    justify-content: center;
}

.auth-page .btn-primary {
    min-height: 48px;
    background: var(--navy-800);
    border: 0;
    box-shadow: 0 9px 20px rgba(47, 111, 237, 0.22);
}

.auth-page .btn-primary:hover {
    background: var(--navy-900);
}

.utility-page {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--surface-soft);
}

.utility-panel {
    width: min(100%, 680px);
    padding: 30px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.utility-status {
    margin: 16px 0;
    padding: 14px 16px;
    border-radius: 10px;
    font-weight: 700;
}

.utility-status-success {
    color: #0b5f2c;
    background: #e5f6eb;
}

.utility-status-warning {
    color: #78520d;
    background: #fff4d6;
}

.utility-status-danger {
    color: #922f39;
    background: #fdebed;
}

.eyebrow,
.modal-eyebrow {
    display: block;
    margin-bottom: 5px;
    color: var(--blue-600);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.modal-eyebrow {
    color: #a8cdff;
}

.panel {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.panel-toolbar {
    display: flex;
    min-height: 76px;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    padding: 16px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.panel-title {
    margin: 0;
    color: var(--navy-900);
    font-size: 1rem;
    font-weight: 780;
}

.panel-subtitle {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.panel-body {
    padding: 20px;
}

.panel-body-flush {
    padding: 0;
}

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

.metric-grid-compact .metric-card {
    min-height: 98px;
}

.metric-card {
    display: flex;
    min-width: 0;
    min-height: 112px;
    align-items: center;
    gap: 15px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 3px 12px rgba(11, 31, 58, 0.045);
}

.metric-icon {
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    place-items: center;
    color: var(--navy-800);
    background: #e8eef6;
    border-radius: 10px;
    font-size: 1rem;
}

.metric-icon-primary {
    color: #1d56bd;
    background: #e8f0ff;
}

.metric-icon-success {
    color: var(--success);
    background: #e7f5ec;
}

.metric-icon-warning {
    color: var(--warning);
    background: #fff4d9;
}

.metric-icon-danger {
    color: var(--danger);
    background: #fdebed;
}

.metric-label {
    display: block;
    margin-bottom: 3px;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric-value {
    display: block;
    color: var(--navy-900);
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.metric-meta {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.toolbar-controls {
    display: flex;
    align-items: end;
    gap: 10px;
}

.toolbar-field {
    min-width: 170px;
}

.toolbar-field label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-muted);
    font-size: 0.69rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.agenda-calendar-wrap {
    padding: 20px;
}

#agenda-calendar {
    min-height: 680px;
}

#agenda-calendar .fc-toolbar {
    gap: 12px;
    margin-bottom: 22px;
}

#agenda-calendar .fc-toolbar-title {
    color: var(--navy-900);
    font-size: 1.15rem;
    font-weight: 800;
    text-transform: capitalize;
}

#agenda-calendar .fc-button {
    min-height: 36px;
    padding: 6px 11px;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 7px;
    box-shadow: none;
}

#agenda-calendar .fc-button-primary {
    color: var(--navy-800);
    background: #ffffff;
    border-color: var(--border);
}

#agenda-calendar .fc-button-primary:hover,
#agenda-calendar .fc-button-primary:focus,
#agenda-calendar .fc-button-primary:not(:disabled).fc-button-active {
    color: #ffffff;
    background: var(--navy-800);
    border-color: var(--navy-800);
    box-shadow: none;
}

#agenda-calendar .fc-col-header-cell {
    background: #f0f4f8;
}

#agenda-calendar .fc-col-header-cell-cushion {
    padding: 10px 6px;
    color: var(--navy-800);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.035em;
    text-decoration: none;
    text-transform: uppercase;
}

#agenda-calendar .fc-timegrid-slot-label-cushion,
#agenda-calendar .fc-list-event-time {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 650;
}

#agenda-calendar .fc-theme-standard td,
#agenda-calendar .fc-theme-standard th,
#agenda-calendar .fc-theme-standard .fc-scrollgrid {
    border-color: #e5ebf2;
}

#agenda-calendar .fc-timegrid-now-indicator-line {
    border-color: var(--danger);
}

#agenda-calendar .fc-timegrid-now-indicator-arrow {
    border-top-color: var(--danger);
    border-bottom-color: var(--danger);
}

#agenda-calendar .fc-event {
    padding: 2px 4px;
    border-width: 0 0 0 3px;
    border-radius: 5px;
    box-shadow: none;
}

#agenda-calendar .fc-event:hover {
    filter: brightness(0.96);
}

#agenda-calendar .fc-event-main {
    font-size: 0.72rem;
    font-weight: 700;
}

#agenda-calendar .fc-day-today {
    background: #f3f7fd !important;
}

.agenda-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 18px;
    padding-top: 15px;
    color: var(--text-muted);
    font-size: 0.74rem;
    border-top: 1px solid var(--border);
}

.agenda-legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-pending {
    background: var(--warning);
}

.status-confirmed {
    background: var(--blue-600);
}

.status-finished {
    background: var(--success);
}

.status-cancelled {
    background: var(--danger);
}

.appointment-drawer {
    width: min(100%, 430px) !important;
}

.appointment-drawer .offcanvas-header {
    padding: 22px;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--border);
}

.appointment-drawer .offcanvas-body {
    padding: 22px;
}

.appointment-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.appointment-status-row strong {
    color: var(--navy-900);
    font-size: 0.82rem;
    text-transform: capitalize;
}

.status-chip {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    padding: 4px 9px;
    color: var(--navy-800);
    background: var(--surface-muted);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
}

.status-chip-pending {
    color: #76520f;
    background: #fff2cf;
}

.status-chip-confirmed {
    color: #1c50a7;
    background: #e5eeff;
}

.status-chip-finished {
    color: #0d622f;
    background: #e3f4e9;
}

.status-chip-cancelled {
    color: #922f39;
    background: #fde7ea;
}

.detail-list {
    margin: 0;
}

.detail-list > div {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 15px;
    padding: 12px 0;
    border-bottom: 1px solid #e8edf3;
}

.detail-list dt {
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 700;
}

.detail-list dd {
    margin: 0;
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.drawer-actions {
    display: grid;
    gap: 9px;
    margin-top: 24px;
}

.drawer-actions .btn {
    justify-content: center;
}

.context-note {
    margin: 0 0 18px;
    padding: 12px 14px;
    color: var(--navy-800);
    background: var(--surface-muted);
    border-left: 3px solid var(--blue-600);
    border-radius: 7px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.75fr);
    gap: 18px;
    margin-top: 18px;
}

.dashboard-stack {
    display: grid;
    align-content: start;
    gap: 18px;
}

.chart-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
    gap: 18px;
    margin-top: 18px;
}

.chart-frame {
    position: relative;
    width: 100%;
    min-height: 290px;
    padding: 12px 4px 2px;
}

.chart-frame-compact {
    min-height: 250px;
}

.chart-frame canvas {
    max-height: 290px;
}

.schedule-list,
.stock-list,
.activity-list,
.quick-action-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.schedule-item,
.stock-item,
.activity-item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 14px 18px;
    border-bottom: 1px solid #e7edf4;
}

.schedule-item:last-child,
.stock-item:last-child,
.activity-item:last-child {
    border-bottom: 0;
}

.schedule-time {
    display: flex;
    width: 54px;
    height: 48px;
    flex: 0 0 54px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--navy-800);
    background: var(--surface-muted);
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 800;
}

.schedule-time small {
    margin-top: 1px;
    font-size: 0.62rem;
    font-weight: 700;
}

.schedule-content,
.stock-content,
.activity-content {
    min-width: 0;
    flex: 1;
}

.schedule-content strong,
.stock-content strong,
.activity-content strong {
    display: block;
    overflow: hidden;
    color: var(--navy-900);
    font-size: 0.83rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-content span,
.stock-content span,
.activity-content span {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stock-value {
    min-width: 36px;
    padding: 5px 8px;
    color: #922f39;
    background: #fdebed;
    border-radius: 7px;
    font-size: 0.72rem;
    font-weight: 800;
    text-align: center;
}

.activity-icon {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    color: var(--navy-700);
    background: var(--surface-muted);
    border-radius: 8px;
    font-size: 0.75rem;
}

.quick-action-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 16px;
}

.quick-action {
    display: flex;
    min-height: 78px;
    align-items: center;
    gap: 11px;
    padding: 13px;
    color: var(--navy-900);
    text-decoration: none;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 9px;
}

.quick-action:hover {
    color: var(--navy-900);
    background: var(--surface-muted);
    border-color: #b8c8db;
}

.quick-action i {
    color: var(--blue-600);
}

.quick-action strong {
    display: block;
    font-size: 0.8rem;
}

.quick-action small {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.67rem;
}

.empty-state {
    display: grid;
    min-height: 180px;
    place-items: center;
    padding: 28px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state i {
    display: block;
    margin-bottom: 12px;
    color: #a2b0c1;
    font-size: 2rem;
}

.empty-state strong {
    display: block;
    margin-bottom: 4px;
    color: var(--navy-900);
}

.empty-state p {
    max-width: 320px;
    margin: 0;
    font-size: 0.8rem;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

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

    .dashboard-grid,
    .chart-grid {
        grid-template-columns: 1fr;
    }

    .page-content {
        padding-right: 22px;
        padding-left: 22px;
    }
}

@media (max-width: 991.98px) {
    body.nav-open {
        overflow: hidden;
    }

    .sidebar-col,
    .sidebar-collapsed .sidebar-col {
        position: fixed;
        left: 0;
        margin-left: 0;
        transform: translateX(-105%);
    }

    .sidebar-col.is-open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: inline-grid;
        place-items: center;
    }

    .sidebar-backdrop.is-visible {
        display: block;
    }

    .top-navbar {
        padding-right: 20px;
        padding-left: 20px;
    }
}

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

    .metric-card {
        min-height: 88px;
    }

    .panel-toolbar,
    .agenda-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

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

    .toolbar-field {
        width: 100%;
        min-width: 0;
    }

    .quick-action-list {
        grid-template-columns: 1fr;
    }

    .agenda-calendar-wrap {
        padding: 13px;
    }

    #agenda-calendar {
        min-height: 540px;
    }

    #agenda-calendar .fc-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    #agenda-calendar .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
    }

    .detail-list > div {
        grid-template-columns: 88px minmax(0, 1fr);
    }

    .top-navbar {
        min-height: 66px;
        padding: 10px 15px;
    }

    .page-content {
        padding: 20px 14px 32px;
    }

    .page-heading,
    .card-header.d-flex {
        align-items: stretch !important;
        flex-direction: column;
    }

    .page-heading .btn,
    .card-header.d-flex > .btn {
        width: 100%;
    }

    .filter-card form > [class*="col-"] {
        width: 100%;
        flex: 0 0 100%;
    }

    .filter-card form .form-control,
    .filter-card form .form-select,
    .filter-card form .btn {
        width: 100%;
    }

    .card-header form.d-flex,
    .card-header > .d-flex {
        width: 100%;
        flex-wrap: wrap;
    }

    .card-header form.d-flex .form-control,
    .card-header > .d-flex .form-control {
        min-width: 150px;
        flex: 1 1 150px;
    }

    .card-body > .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 12px;
    }

    .card-body {
        padding: 17px;
    }

    .row.mb-4 > [class*="col-md-"] + [class*="col-md-"] {
        margin-top: 12px;
    }

    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
    }

    .modal-dialog {
        margin: 10px;
    }

    .modal-body {
        padding: 18px;
    }

    .dataTables_wrapper {
        padding: 14px;
    }

    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        float: none;
        text-align: left;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: calc(100% - 70px);
    }

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

    .fc .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
    }

    #calendar {
        min-height: 520px;
        padding: 12px;
    }

    .receta-container,
    .certificado-container {
        padding: 22px;
    }

    .report-progress-column {
        width: auto;
        min-width: 170px;
    }
}

@media (max-width: 575.98px) {
    .sidebar-col {
        width: min(88vw, var(--sidebar-width));
    }

    .auth-page {
        padding: 18px 12px;
    }

    .auth-page .card-header {
        padding: 30px 24px 14px;
    }

    .auth-page .card-body {
        padding: 8px 24px 24px;
    }

    .top-navbar .dropdown-toggle::after {
        display: none;
    }

    .table > :not(caption) > * > * {
        padding: 11px 10px;
    }
}

@media print {
    @page {
        margin: 12mm;
    }

    body,
    .content-col,
    .page-content {
        color: #000000 !important;
        background: #ffffff !important;
    }

    .sidebar-col,
    .sidebar-backdrop,
    .top-navbar,
    .no-print,
    .dt-buttons,
    .dataTables_filter,
    .dataTables_length,
    .dataTables_paginate,
    .nav-tabs,
    body.printing-modal form {
        display: none !important;
    }

    .page-content {
        max-width: none;
        padding: 0 !important;
    }

    .card {
        border: 1px solid #cccccc !important;
        box-shadow: none !important;
        break-inside: avoid;
    }

    .table {
        font-size: 10pt;
    }

    .timeline {
        border-left: 1px solid #000000;
    }

    body.printing-modal * {
        visibility: hidden;
    }

    body.printing-modal .modal.show,
    body.printing-modal .modal.show * {
        visibility: visible;
    }

    body.printing-modal .modal.show {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: auto;
        margin: 0;
        padding: 0;
    }

    body.printing-modal .modal-content {
        border: 0;
        box-shadow: none;
    }

    body.printing-modal .modal-header,
    body.printing-modal .modal-footer,
    body.printing-modal .btn-close {
        display: none !important;
    }

    body.printing-modal .modal-body {
        padding: 0;
    }
}
