:root {
    --azul-1: #0b3d84;
    --azul-2: #0a4f9d;
    --azul-3: #124b8d;
    --azul-4: #0c3b72;
    --azul-texto: #17395e;
    --dorado-1: #e4ad34;
    --dorado-2: #cf8d14;
    --naranja-1: #f0a01d;
    --naranja-2: #de8300;
    --fondo-panel: rgba(188, 207, 228, 0.88);
    --fondo-claro: rgba(255, 255, 255, 0.92);
    --borde: #b8cadf;
    --texto-secundario: #5a708c;
    --sombra: 0 4px 14px rgba(0, 0, 0, 0.14);
    --radio: 8px;
    --radio-sm: 6px;
    --alto-touch: 46px;
    --transicion: 0.18s ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--azul-texto);
    background: #CED3E5;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed;
}

/* =========================
   CONTENEDOR GENERAL
========================= */
.page {
    width: min(96%, 1360px);
    margin: 14px auto 24px;
}

/* =========================
   BUSCADOR
========================= */
.search-bar {
    background: rgba(242, 245, 250, 0.96);
    border: 1px solid #c9d4e1;
    border-radius: var(--radio);
    padding: 14px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.07);
    margin-bottom: 12px;
}

.search-form {
    display: grid;
    grid-template-columns: 1fr 210px;
    gap: 12px;
    align-items: center;
}

.search-field {
    position: relative;
}

.search-field input[type="text"] {
    width: 100%;
    height: var(--alto-touch);
    padding: 0 16px;
    border: 1px solid #c5cfdb;
    border-radius: var(--radio-sm);
    background: #ffffff;
    color: #23486f;
    font-size: 16px;
    outline: none;
    transition: border-color var(--transicion), box-shadow var(--transicion);
}

.search-field input[type="text"]::placeholder {
    color: #637d9d;
    font-weight: 600;
}

.search-field input[type="text"]:focus {
    border-color: #d8931e;
    box-shadow: 0 0 0 4px rgba(216, 147, 30, 0.12);
}

.btn-search {
    height: var(--alto-touch);
    border: none;
    border-radius: var(--radio-sm);
    background: linear-gradient(180deg, var(--naranja-1) 0%, var(--naranja-2) 100%);
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition: filter var(--transicion), transform var(--transicion);
}

.btn-search:hover {
    filter: brightness(1.03);
}

.btn-search:active {
    transform: translateY(1px);
}

/* =========================
   PANEL PRINCIPAL
========================= */
.content-panel {
    background: var(--fondo-panel);
    border: 1px solid rgba(123, 157, 194, 0.72);
    border-radius: var(--radio);
    overflow: hidden;
    backdrop-filter: blur(2px);
}

/* =========================
   TABS
========================= */
.panel-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    background: linear-gradient(180deg, rgba(165, 191, 219, 0.62) 0%, rgba(145, 177, 210, 0.40) 100%);
    border-bottom: 1px solid rgba(122, 157, 194, 0.45);
}

.panel-tab {
    min-height: 50px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    border-right: 1px solid rgba(255, 255, 255, 0.18);
}

.panel-tab:last-child {
    border-right: none;
}

.panel-tab--link {
    text-decoration: none;
    cursor: pointer;
    transition: filter var(--transicion), transform var(--transicion), background var(--transicion), color var(--transicion);
}

.panel-tab--link:hover {
    filter: brightness(1.03);
}

.panel-tab--inactive {
    background: linear-gradient(180deg, rgba(226, 235, 246, 0.98) 0%, rgba(199, 215, 234, 0.96) 100%);
    color: #254d7b;
}

.panel-tab--active {
    color: #ffffff;
}

.panel-tab--blue.panel-tab--active {
    background: linear-gradient(180deg, var(--azul-3) 0%, var(--azul-4) 100%);
}

.panel-tab--gold.panel-tab--active {
    background: linear-gradient(180deg, var(--dorado-1) 0%, var(--dorado-2) 100%);
}

/* =========================
   TABLA
========================= */
.table-scroll-wrap {
    position: relative;
    width: 100%;
}

.table-scroll-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
    padding: 10px 12px;
    border-radius: var(--radio);
    background: linear-gradient(180deg, rgba(11, 61, 132, 0.96) 0%, rgba(10, 79, 157, 0.96) 100%);
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

.table-scroll-hint__icon {
    font-size: 20px;
    font-weight: 700;
    display: inline-block;
    animation: moverHorizontal 1.4s infinite ease-in-out;
}

.table-scroll-hint__text {
    display: inline-block;
}

.table-responsive {
    position: relative;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: var(--radio-sm);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    touch-action: pan-x;
    background: rgba(255, 255, 255, 0.20);
}

.table-scroll-wrap::before,
.table-scroll-wrap::after {
    content: "";
    position: absolute;
    top: 54px;
    bottom: 0;
    width: 26px;
    z-index: 3;
    pointer-events: none;
}

.table-scroll-wrap::before {
    left: 0;
    background: linear-gradient(to right, rgba(11, 61, 132, 0.18), rgba(11, 61, 132, 0));
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}

.table-scroll-wrap::after {
    right: 0;
    background: linear-gradient(to left, rgba(11, 61, 132, 0.18), rgba(11, 61, 132, 0));
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
}

.patient-table {
    width: 100%;
    min-width: 1220px;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.9);
    margin-bottom: 4px;
}

.patient-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px 8px;
    background: linear-gradient(180deg, #134d94 0%, #0d3f7b 100%);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    border: 1px solid #8aa8c8;
    white-space: nowrap;
}

.patient-table tbody td {
    padding: 12px 8px;
    text-align: center;
    font-size: 14px;
    color: #26486f;
    border: 1px solid var(--borde);
    background: rgba(255, 255, 255, 0.78);
    vertical-align: middle;
}

.patient-table tbody tr:nth-child(even) td {
    background: rgba(219, 229, 240, 0.92);
}

.patient-table tbody tr:hover td {
    background: rgba(210, 223, 239, 0.96);
}

.patient-table tbody td:first-child {
    font-weight: 700;
    color: #20467a;
    font-size: 15px;
    white-space: nowrap;
}

.patient-table tbody td:nth-child(2) {
    min-width: 240px;
    text-align: left;
    padding-left: 12px;
}

.patient-table tbody td:nth-child(3),
.patient-table tbody td:nth-child(6) {
    white-space: nowrap;
}

.pending-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 84px;
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(228, 173, 52, 0.18);
    color: #8f6500;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.no-results {
    font-weight: 700;
    color: var(--texto-secundario);
    padding: 22px !important;
}

.table-responsive::-webkit-scrollbar {
    height: 14px;
}

.table-responsive::-webkit-scrollbar-track {
    background: rgba(198, 211, 227, 0.95);
    border-radius: 20px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #d89c17 0%, #b67b0a 100%);
    border-radius: 20px;
    border: 2px solid rgba(198, 211, 227, 0.95);
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #e3a51d 0%, #c88607 100%);
}

/* =========================
   BOTONES DE ACCIÓN
========================= */
.action-form {
    margin: 0;
}

.btn-action {
    border: none;
    cursor: pointer;
    transition: filter var(--transicion), transform var(--transicion), box-shadow var(--transicion);
}

.btn-action:hover {
    filter: brightness(1.03);
}

.btn-action:active {
    transform: translateY(1px);
}

.btn-action--primary {
    min-width: 118px;
    height: 40px;
    padding: 0 14px;
    border-radius: var(--radio-sm);
    background: linear-gradient(180deg, #1e5ea8 0%, #124988 100%);
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
}

.btn-action--icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radio-sm);
    background: linear-gradient(180deg, #ebb43c 0%, #d89c17 100%);
    color: #ffffff;
    font-size: 17px;
    font-weight: 700;
}

/* =========================
   PIE DE TABLA
========================= */
.table-footer {
    margin-top: 14px;
    display: flex;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
}

.table-footer__info {
    color: #143a69;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
}

.table-footer__links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.table-footer__links a {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #0d3d76;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--borde);
    border-radius: var(--radio-sm);
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 700;
    transition: background var(--transicion), color var(--transicion);
}

.table-footer__links a:hover {
    background: #0d3d76;
    color: #ffffff;
}

/* =========================
   PAGINACIÓN
========================= */
.pagination {
    margin-top: 16px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.pagination__item {
    min-width: 44px;
    min-height: 44px;
    padding: 10px 14px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #b4c7dc;
    border-radius: var(--radio-sm);
    color: #144072;
    font-size: 14px;
    font-weight: 700;
    transition: background var(--transicion), color var(--transicion), transform var(--transicion);
}

.pagination__item:hover {
    background: #e8eef5;
}

.pagination__item:active {
    transform: translateY(1px);
}

.pagination__item.is-active {
    background: linear-gradient(180deg, var(--azul-3) 0%, var(--azul-4) 100%);
    border-color: var(--azul-4);
    color: #ffffff;
}

/* =========================
   ANIMACIÓN
========================= */
@keyframes moverHorizontal {
    0% {
        transform: translateX(0);
        opacity: 0.75;
    }
    25% {
        transform: translateX(-4px);
        opacity: 1;
    }
    50% {
        transform: translateX(0);
        opacity: 0.75;
    }
    75% {
        transform: translateX(4px);
        opacity: 1;
    }
    100% {
        transform: translateX(0);
        opacity: 0.75;
    }
}

/* =========================
   TABLET GRANDE / HORIZONTAL
========================= */
@media (max-width: 1180px) {
    .topbar__inner {
        grid-template-columns: 160px 1fr 96px;
    }

    .topbar__title h1 {
        font-size: 1.65rem;
    }

    .page {
        width: min(97%, 1360px);
    }

    .patient-table {
        min-width: 1140px;
    }
}

/* =========================
   TABLET
========================= */
@media (max-width: 900px) {
    .topbar__inner {
        grid-template-columns: 130px 1fr 78px;
        min-height: 78px;
        padding: 10px 14px;
    }

    .topbar__logo--left img {
        max-height: 42px;
    }

    .topbar__logo--right img {
        max-height: 52px;
    }

    .topbar__title h1 {
        font-size: 1.35rem;
    }

    .page {
        width: min(98%, 1360px);
        margin-top: 10px;
    }

    .search-bar {
        padding: 12px;
    }

    .search-form {
        grid-template-columns: 1fr 180px;
        gap: 10px;
    }

    .search-field input[type="text"] {
        font-size: 15px;
    }

    .btn-search {
        font-size: 14px;
    }

    .panel-tab {
        min-height: 48px;
        padding: 10px 12px;
        font-size: 14px;
    }

    .table-scroll-hint {
        font-size: 14px;
        padding: 11px 12px;
    }

    .table-scroll-hint__icon {
        font-size: 21px;
    }

    .table-scroll-wrap::before,
    .table-scroll-wrap::after {
        width: 22px;
    }

    .patient-table thead th,
    .patient-table tbody td {
        padding: 11px 7px;
    }

    .btn-action--primary {
        min-width: 110px;
        height: 38px;
        font-size: 13px;
    }

    .btn-action--icon {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .table-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .table-footer__links {
        width: 100%;
        justify-content: flex-start;
    }
}

/* =========================
   TABLET PEQUEÑA / MÓVIL GRANDE
========================= */
@media (max-width: 680px) {
    .topbar__inner {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
        gap: 8px;
        padding: 12px;
    }

    .topbar__logo--left,
    .topbar__logo--right {
        justify-content: center;
    }

    .topbar__logo--left img {
        max-height: 40px;
    }

    .topbar__logo--right img {
        max-height: 46px;
    }

    .topbar__title h1 {
        font-size: 1.2rem;
    }

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

    .btn-search {
        width: 100%;
    }

    .panel-tabs {
        grid-template-columns: 1fr;
    }

    .panel-tab {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    }

    .panel-tab:last-child {
        border-bottom: none;
    }

    .table-scroll-hint {
        flex-direction: column;
        gap: 6px;
        font-size: 13px;
        padding: 10px;
    }

    .table-scroll-hint__icon {
        font-size: 22px;
    }

    .table-scroll-wrap::before,
    .table-scroll-wrap::after {
        top: 68px;
        width: 18px;
    }

    .table-responsive::-webkit-scrollbar {
        height: 12px;
    }

    .table-footer__links {
        flex-direction: column;
        width: 100%;
    }

    .table-footer__links a {
        width: 100%;
    }

    .pagination {
        justify-content: flex-start;
    }
}

.table-scroll-hint--tablet {
    display: none;
}

@media (min-width: 581px) and (max-width: 1050px) {
    .table-scroll-hint--tablet {
        display: flex;
    }
}