:root {
    --ink: #172033;
    --muted: #667085;
    --line: #d0d7e2;
    --paper: #ffffff;
    --soft: #f6f8fb;
    --bg: #eef3f8;
    --green: #198754;
    --green-dark: #146c43;
    --blue: #0d6efd;
    --blue-dark: #0a58ca;
    --amber: #f59f00;
    --amber-dark: #d18400;
    --slate: #344054;
    --danger: #dc3545;
    --shadow: 0 16px 38px rgba(23, 32, 51, .10);
    --shadow-lg: 0 24px 54px rgba(23, 32, 51, .16);
}

* { box-sizing: border-box; }
body {
    position: relative;
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(248,251,255,.70) 0%, rgba(237,244,247,.66) 48%, rgba(246,247,251,.78) 100%),
        linear-gradient(115deg, rgba(7, 96, 73, .11) 0 18%, transparent 18% 100%),
        linear-gradient(245deg, rgba(13, 110, 253, .12) 0 22%, transparent 22% 100%),
        url("../img/rs-juanda-bg.jpg") center / cover fixed no-repeat;
    overflow-x: hidden;
}
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background:
        linear-gradient(180deg, rgba(255,255,255,.26), rgba(255,255,255,.62)),
        linear-gradient(90deg, rgba(23, 32, 51, .045) 1px, transparent 1px),
        linear-gradient(180deg, rgba(23, 32, 51, .035) 1px, transparent 1px),
        linear-gradient(135deg, transparent 0 62%, rgba(245, 159, 0, .10) 62% 76%, transparent 76% 100%);
    background-size: 42px 42px, 42px 42px, 100% 100%;
    mask-image: linear-gradient(180deg, rgba(0,0,0,.72), rgba(0,0,0,.18));
}
a { color: inherit; text-decoration: none; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: min(1220px, calc(100% - 32px));
    margin: 18px auto 0;
    padding: 16px 18px;
    border: 1px solid rgba(255, 255, 255, .82);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(255, 255, 255, .78));
    box-shadow: 0 18px 42px rgba(23, 32, 51, .10);
    backdrop-filter: blur(14px);
}
.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.brand img {
    width: 54px;
    height: 54px;
    object-fit: contain;
    padding: 7px;
    border: 1px solid rgba(13, 110, 253, .18);
    border-radius: 8px;
    background: linear-gradient(180deg, #fff, #f4f8ff);
    box-shadow: 0 10px 22px rgba(13, 110, 253, .10);
}
.brand strong, .brand small, .clock strong, .clock small { display: block; }
.brand strong { font-size: 22px; letter-spacing: .1px; }
.brand small, .clock small { color: var(--muted); }
.clock { text-align: right; }
.clock strong { font-size: 26px; font-weight: 800; color: #0b5f49; }

.page {
    width: min(1220px, calc(100% - 32px));
    margin: 22px auto 32px;
}
.home-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 18px;
    padding: 22px 24px;
    border: 1px solid rgba(255, 255, 255, .86);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(255,255,255,.94), rgba(238,244,255,.78)),
        repeating-linear-gradient(135deg, rgba(13,110,253,.07) 0 1px, transparent 1px 16px);
    box-shadow: 0 18px 42px rgba(23, 32, 51, .10);
    backdrop-filter: blur(12px);
}
.home-head span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 8px;
    color: #0b5f49;
    background: #e9f7ef;
    font-size: 13px;
    font-weight: 800;
}
.home-head h1 {
    max-width: 760px;
    margin: 10px 0 0;
    font-size: 32px;
    line-height: 1.12;
}
.home-head small {
    max-width: 320px;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.5;
}
.home-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.menu-tile {
    position: relative;
    min-height: 238px;
    padding: 28px;
    border-radius: 8px;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 22px 48px rgba(23, 32, 51, .16);
    overflow: hidden;
    isolation: isolate;
    transition: transform .22s ease, box-shadow .22s ease, filter .22s ease, border-color .22s ease;
    border: 1px solid rgba(255,255,255,.28);
}
.menu-tile::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: .94;
}
.menu-tile::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 46%;
    background:
        linear-gradient(180deg, transparent, rgba(255,255,255,.12)),
        repeating-linear-gradient(135deg, rgba(255,255,255,.13) 0 1px, transparent 1px 12px);
    z-index: -1;
    opacity: .72;
    transition: height .22s ease, opacity .22s ease;
}
.menu-tile.green::before { background: linear-gradient(135deg, #0e9f6e 0%, #146c43 64%, #0b3d31 100%); }
.menu-tile.blue::before { background: linear-gradient(135deg, #0d6efd 0%, #314fcb 55%, #102a7a 100%); }
.menu-tile.amber::before { background: linear-gradient(135deg, #f59f00 0%, #d9480f 58%, #7c2d12 100%); }
.menu-tile.slate::before { background: linear-gradient(135deg, #475467 0%, #1f2a44 54%, #0f172a 100%); }
.menu-tile:hover {
    transform: translateY(-6px);
    box-shadow: 0 28px 62px rgba(23, 32, 51, .22);
    filter: saturate(1.03);
    border-color: rgba(255,255,255,.48);
}
.menu-tile:hover::after { height: 56%; opacity: .92; }
.menu-tile img, .tile-icon {
    width: 66px;
    height: 66px;
    object-fit: contain;
}
.tile-icon {
    display: inline-grid;
    place-items: center;
    color: #fff;
    border: 1px solid rgba(255,255,255,.48);
    border-radius: 8px;
    background: rgba(255,255,255,.12);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.20),
        0 12px 26px rgba(0,0,0,.10);
    backdrop-filter: blur(8px);
    transition: transform .22s ease, background .22s ease, border-color .22s ease;
}
.menu-tile:hover .tile-icon {
    transform: scale(1.04);
    background: rgba(255,255,255,.18);
    border-color: rgba(255,255,255,.70);
}
.menu-tile strong {
    font-size: 34px;
    line-height: 1.08;
    max-width: 82%;
    text-shadow: 0 2px 16px rgba(0,0,0,.16);
}
.menu-tile small {
    font-size: 17px;
    color: rgba(255,255,255,.90);
    max-width: 88%;
}
.summary-strip {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.summary-strip div {
    position: relative;
    overflow: hidden;
    padding: 22px 24px;
    background:
        linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,251,255,.90));
    border: 1px solid rgba(255, 255, 255, .82);
    border-radius: 8px;
    box-shadow: 0 16px 34px rgba(23, 32, 51, .09);
    transition: transform .2s ease, box-shadow .2s ease;
}
.summary-strip div::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    width: 10px;
    height: 100%;
    background: linear-gradient(180deg, #0d6efd, #198754);
}
.summary-strip div:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(23, 32, 51, .10);
}
.summary-strip b {
    display: block;
    font-size: 32px;
    color: var(--green);
}
.summary-strip span { color: var(--muted); }

.work-surface {
    background:
        linear-gradient(180deg, rgba(255,255,255,.93), rgba(255,255,255,.84));
    border: 1px solid rgba(255,255,255,.72);
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 26px 70px rgba(23, 32, 51, .16);
    backdrop-filter: blur(14px);
}
.work-surface.wide { padding-bottom: 34px; }
.surface-head { margin-bottom: 22px; }
.surface-head h1 {
    margin: 12px 0 8px;
    font-size: 34px;
}
.surface-head p {
    margin: 0;
    color: var(--muted);
    font-size: 18px;
}
.back {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 46px;
    padding: 0 15px 0 13px;
    border: 1px solid rgba(13, 110, 253, .20);
    border-radius: 8px;
    color: #0a58ca;
    background:
        linear-gradient(180deg, rgba(255,255,255,.96), rgba(238,244,255,.88));
    font-weight: 700;
    box-shadow: 0 10px 22px rgba(13, 110, 253, .09);
    transition: background .18s ease, transform .18s ease, border-color .18s ease, box-shadow .18s ease, color .18s ease;
}
.back .ui-icon {
    width: 20px;
    height: 20px;
    padding: 3px;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    box-shadow: 0 8px 18px rgba(13, 110, 253, .24);
}
.back:hover {
    color: #084298;
    background:
        linear-gradient(180deg, #fff, #eaf1ff);
    border-color: rgba(13, 110, 253, .42);
    transform: translateX(-3px);
    box-shadow: 0 16px 30px rgba(13, 110, 253, .16);
}
.search-row {
    display: grid;
    grid-template-columns: 1fr 180px;
    gap: 12px;
}
.search-row.double {
    grid-template-columns: 1fr 1fr 180px;
}
input, select, button {
    font: inherit;
}
input, select {
    width: 100%;
    min-height: 62px;
    border: 1px solid rgba(160, 174, 192, .48);
    border-radius: 8px;
    padding: 0 18px;
    font-size: 20px;
    background:
        linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,251,255,.90));
    color: var(--ink);
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.80), 0 8px 20px rgba(23,32,51,.045);
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease, transform .18s ease;
}
input:focus, select:focus {
    border-color: rgba(13, 110, 253, .74);
    box-shadow:
        0 0 0 4px rgba(13, 110, 253, .14),
        0 14px 28px rgba(13, 110, 253, .08);
    background: #fff;
    transform: translateY(-1px);
}
button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    border-radius: 8px;
    min-height: 62px;
    padding: 0 22px;
    color: #fff;
    background:
        linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,0)),
        linear-gradient(135deg, #18a96f 0%, #16885a 48%, #0b6b49 100%);
    font-weight: 700;
    cursor: pointer;
    box-shadow:
        0 16px 32px rgba(25, 135, 84, .25),
        inset 0 1px 0 rgba(255,255,255,.28);
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease, background .18s ease;
}
button::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(110deg, transparent 0 34%, rgba(255,255,255,.22) 46%, transparent 58% 100%);
    transform: translateX(-120%);
    transition: transform .45s ease;
}
.ui-icon {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.tile-svg {
    width: 38px;
    height: 38px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-button span {
    min-width: 0;
}
button:hover {
    transform: translateY(-2px);
    box-shadow:
        0 22px 42px rgba(25, 135, 84, .32),
        inset 0 1px 0 rgba(255,255,255,.34);
    filter: brightness(1.02);
}
button:hover::after { transform: translateX(120%); }
button:active {
    transform: translateY(0);
}
.search-row button {
    min-width: 160px;
    letter-spacing: .1px;
}
.search-row button .ui-icon {
    width: 24px;
    height: 24px;
    padding: 4px;
    border-radius: 8px;
    background: rgba(255,255,255,.16);
}
.result-panel {
    margin-top: 22px;
    border-top: 1px solid rgba(13, 110, 253, .13);
    padding-top: 24px;
}
.frista-panel {
    margin-top: 18px;
    padding: 20px;
    border: 1px solid rgba(13, 110, 253, .22);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(255,255,255,.86), rgba(238,244,255,.96)),
        #eef4ff;
    box-shadow: 0 14px 32px rgba(13, 110, 253, .10);
}
.frista-panel h2 {
    margin: 0 0 6px;
    font-size: 25px;
}
.frista-panel p {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 16px;
}
.frista-actions {
    display: grid;
    grid-template-columns: minmax(240px, .9fr) minmax(280px, 1.1fr);
    gap: 12px;
}
.secondary-action {
    color: var(--blue-dark);
    background: #fff;
    border: 1px solid rgba(13, 110, 253, .32);
    box-shadow: 0 10px 22px rgba(13, 110, 253, .08);
}
.secondary-action:hover {
    border-color: rgba(13, 110, 253, .58);
    box-shadow: 0 16px 30px rgba(13, 110, 253, .16);
}
.secondary-action.is-loading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #fff;
    background: var(--blue-dark);
    border-color: var(--blue-dark);
    cursor: wait;
    opacity: .9;
}
.btn-spinner {
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    flex: 0 0 auto;
    animation: spin .75s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.hidden { display: none !important; }
.patient-title {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
    padding: 2px 2px 0;
}
.patient-title strong {
    font-size: 30px;
    letter-spacing: .2px;
}
.patient-title span {
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid rgba(13, 110, 253, .14);
    border-radius: 8px;
    color: #0a58ca;
    background: rgba(238, 244, 255, .82);
    font-size: 18px;
    font-weight: 700;
}
.info-grid, .form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.info-grid div {
    position: relative;
    min-height: 88px;
    padding: 16px;
    border: 1px solid rgba(160, 174, 192, .42);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(255,255,255,.90), rgba(247,250,255,.82));
    box-shadow:
        0 10px 24px rgba(23, 32, 51, .055),
        inset 0 1px 0 rgba(255,255,255,.80);
    overflow: hidden;
    transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.info-grid div::before {
    content: "";
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 4px;
    border-radius: 0 8px 8px 0;
    background: linear-gradient(180deg, #0d6efd, #198754);
    opacity: .72;
}
.info-grid div:hover {
    transform: translateY(-2px);
    border-color: rgba(13, 110, 253, .30);
    background:
        linear-gradient(180deg, rgba(255,255,255,.98), rgba(247,250,255,.94));
    box-shadow:
        0 16px 32px rgba(23, 32, 51, .10),
        inset 0 1px 0 rgba(255,255,255,.90);
}
.info-grid small, label {
    display: block;
    color: var(--muted);
}
.info-grid b {
    display: block;
    margin-top: 8px;
    font-size: 18px;
    word-break: break-word;
}
label {
    font-weight: 700;
}
label select { margin-top: 8px; }
.primary-wide {
    width: 100%;
    margin-top: 18px;
    font-size: 20px;
    min-height: 64px;
    background:
        linear-gradient(180deg, rgba(255,255,255,.15), rgba(255,255,255,0)),
        linear-gradient(135deg, #149968 0%, #0f7d53 50%, #075b40 100%);
    box-shadow:
        0 18px 36px rgba(25, 135, 84, .28),
        inset 0 1px 0 rgba(255,255,255,.26);
}
.schedule-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.doctor-card {
    display: flex;
    gap: 14px;
    padding: 14px;
    border: 1px solid rgba(208, 215, 226, .84);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 22px rgba(23, 32, 51, .06);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.doctor-card:hover {
    transform: translateY(-4px);
    border-color: #b8c3d2;
    box-shadow: 0 18px 36px rgba(23, 32, 51, .12);
}
.doctor-card img {
    width: 86px;
    height: 108px;
    object-fit: cover;
    object-position: center top;
    border-radius: 8px;
    background: #e2e8f0;
}
.doctor-card strong, .doctor-card span, .doctor-card small {
    display: block;
}
.doctor-card strong { font-size: 18px; line-height: 1.25; }
.doctor-card span {
    width: fit-content;
    color: var(--green-dark);
    margin: 8px 0;
    padding: 5px 9px;
    border-radius: 999px;
    background: #e9f7ef;
    font-size: 13px;
    font-weight: 800;
}
.doctor-card small {
    width: fit-content;
    color: var(--slate);
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef4ff;
    font-weight: 700;
}
.empty-state {
    grid-column: 1 / -1;
    padding: 28px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 8px;
}
.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    min-width: 320px;
    max-width: 720px;
    padding: 16px 20px;
    border-radius: 8px;
    color: #fff;
    background: var(--slate);
    text-align: center;
    font-weight: 700;
    display: none;
    z-index: 50;
    box-shadow: var(--shadow-lg);
}
.toast.show { display: block; }
.toast.error { background: var(--danger); }
.busy {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.72);
    display: none;
    place-items: center;
    z-index: 40;
}
.busy b {
    margin-top: 82px;
    color: var(--slate);
}
.busy span {
    position: absolute;
    width: 56px;
    height: 56px;
    border: 6px solid #cbd5e1;
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.busy.show { display: grid; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
    .topbar, .patient-title, .home-head { flex-direction: column; align-items: flex-start; }
    .clock { text-align: left; }
    .home-grid, .summary-strip, .search-row, .info-grid, .form-grid, .schedule-grid {
        grid-template-columns: 1fr;
    }
    .frista-actions {
        grid-template-columns: 1fr;
    }
    .search-row.double {
        grid-template-columns: 1fr;
    }
    .menu-tile { min-height: 190px; }
    .menu-tile strong { font-size: 28px; }
    .home-head h1 { font-size: 26px; }
    .topbar, .page {
        width: min(100% - 24px, 1220px);
    }
}
