:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f9fbff;
    --border: #d9e2f1;
    --text: #1c2430;
    --muted: #5f6b7a;
    --primary: #10327d;
    --primary-soft: #eaf1ff;
    --success: #0f766e;
    --warning: #b45309;
    --danger: #b91c1c;
    --shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #eff4fb 0%, #f7f9fc 100%);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.app-shell {
    width: min(1280px, calc(100% - 24px));
    margin: 24px auto 48px;
}

.hero {
    background: linear-gradient(135deg, #04206e, #1344b0 55%, #3b82f6);
    color: white;
    border-radius: 28px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.hero h1 {
    margin: 0 0 8px;
    font-size: clamp(1.5rem, 2.5vw, 2.2rem);
}

.hero p {
    margin: 0;
    color: rgba(255, 255, 255, 0.88);
    line-height: 1.55;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.search-card {
    margin-top: 18px;
    padding: 18px;
}

.search-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: end;
}

.field-group {
    display: grid;
    gap: 8px;
}

.field-label {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--muted);
}

.input,
.button {
    width: 100%;
    min-height: 48px;
    border-radius: 14px;
    border: 1px solid var(--border);
    font: inherit;
}

.input {
    padding: 0 14px;
    background: white;
    color: var(--text);
    outline: none;
}

.input:focus {
    border-color: #8fb1ff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.button {
    cursor: pointer;
    padding: 0 18px;
    font-weight: 700;
    background: var(--primary);
    color: white;
    border: none;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.toolbar {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.hint {
    color: var(--muted);
    font-size: 0.92rem;
}

.status {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 14px;
    font-weight: 600;
    display: none;
}

.status.visible {
    display: block;
}

.status.info {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.status.warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.status.error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

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

.section-card {
    padding: 18px;
}

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.section-title {
    margin: 0;
    font-size: 1.15rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.95rem;
}

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

.info-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    min-height: 90px;
}

.info-box .label {
    display: block;
    color: var(--muted);
    font-size: 0.84rem;
    margin-bottom: 6px;
    font-weight: 600;
}

.info-box .value {
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.45;
    word-break: break-word;
}

.tabs-wrap {
    display: grid;
    gap: 14px;
}

.tabs-header {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tab-btn {
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    border-radius: 999px;
    padding: 10px 14px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tab-panel {
    border: 1px solid var(--border);
    border-radius: 20px;
    background: white;
    padding: 16px;
}

.prescription-topbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}

.prescription-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid var(--border);
    font-size: 0.92rem;
    font-weight: 700;
}

.pill.muted {
    color: var(--muted);
}

.table-section+.table-section {
    margin-top: 18px;
}

.table-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.table-title {
    margin: 0;
    font-size: 1rem;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
    background: white;
}

th,
td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #e9eef7;
    font-size: 0.93rem;
    vertical-align: top;
}

th {
    background: #f8fbff;
    color: var(--muted);
    font-size: 0.83rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tbody tr:hover {
    background: #fafcff;
}

.empty-cell {
    color: var(--muted);
    font-weight: 600;
}

.table-note {
    color: var(--muted);
    font-size: 0.88rem;
}

.footer-note {
    margin-top: 14px;
    color: var(--muted);
    font-size: 0.88rem;
}

.hidden {
    display: none !important;
}

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

@media (max-width: 768px) {
    .app-shell {
        width: min(100% - 16px, 1280px);
        margin-top: 16px;
    }

    .hero,
    .search-card,
    .section-card {
        padding: 16px;
    }

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

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

    .section-title-row,
    .table-section-header,
    .prescription-topbar,
    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .tabs-header {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }

    .tab-btn {
        white-space: nowrap;
    }
}