:root {
    --brand: #4b6b9a;
    --brand-dark: #3b567d;
    --muted: #6b7280;
    --card: #f8fafc;
    --background: #eef1f5;
    --border: #e5e7eb;
    --text: #374151;
}

html {
    font-size: 16px;
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--background);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.45;
}

.portal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    background: var(--brand);
    color: #fff;
}

.portal-title {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
}

    .portal-title:hover {
        color: #fff;
    }

.portal-nav,
.row-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.portal-logout {
    display: inline;
    margin: 0;
}

.portal-button {
    display: inline-block;
    padding: 8px 12px;
    border: 0;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 500;
    line-height: 1.45;
    text-decoration: none;
}

    .portal-button:hover,
    .portal-button:focus {
        background: var(--brand-dark);
        color: #fff;
    }

    .portal-button.disabled-link {
        cursor: default;
        opacity: .72;
    }

.portal-container {
    max-width: 1150px;
    margin: 0 auto;
    padding: 16px;
}

.portal-card {
    margin-bottom: 14px;
    padding: 14px;
    border-radius: 10px;
    background: var(--card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}

    .portal-card h2,
    .portal-card h3,
    .portal-card h4 {
        margin-top: 0;
    }

.home-toolbar,
.portal-flex,
.quick-patient-grid {
    display: flex;
    gap: 12px;
}

.home-search {
    flex: 1;
}

.home-actions {
    width: 360px;
}

.portal-half {
    flex: 1;
    min-width: 0;
}

.portal-field {
    width: 100%;
    box-sizing: border-box;
    margin: 6px 0 8px;
    padding: 9px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #f9fafb;
    color: var(--text);
}

    .portal-field:focus {
        outline: 2px solid rgba(75, 107, 154, .22);
        border-color: var(--brand);
    }

.muted {
    color: var(--muted);
    font-size: .9rem;
}

.patients-table-wrap {
    overflow-x: auto;
    max-width: 100%;
}

.portal-table {
    width: 100%;
    border-collapse: collapse;
}

    .portal-table th,
    .portal-table td {
        padding: 8px;
        border-bottom: 1px solid var(--border);
        text-align: left;
        vertical-align: top;
        font-size: .95rem;
    }

    .portal-table th {
        background: #f1f5f9;
        color: var(--text);
        font-weight: 600;
    }

.patient-name {
    color: var(--brand-dark);
    font-weight: 650;
    text-decoration: none;
}

    .patient-name:hover {
        text-decoration: underline;
    }

.patient-open-link {
    display: none;
}

.status-pill {
    display: inline-block;
    padding: 3px 8px;
    border: 1px solid #86efac;
    border-radius: 999px;
    background: #dcfce7;
    color: #166534;
    font-size: .82rem;
    font-weight: 650;
}

.empty-message {
    padding: 12px 8px;
    color: var(--muted);
}

.validation-summary-errors {
    margin-bottom: 12px;
    color: #991b1b;
}

/* Identity login */
.login-page {
    display: grid;
    min-height: calc(100vh - 72px);
    place-items: center;
    padding: 40px 16px;
}

.login-card {
    width: min(100%, 480px);
    padding: 32px;
    border: 1px solid rgba(75, 107, 154, .14);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 16px 42px rgba(31, 41, 55, .12);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.login-mark {
    display: grid;
    width: 58px;
    height: 58px;
    flex: 0 0 58px;
    place-items: center;
    border-radius: 14px;
    background: var(--brand);
    box-shadow: 0 7px 18px rgba(75, 107, 154, .25);
    color: #fff;
    font-size: 1.75rem;
    font-weight: 750;
}

.login-eyebrow {
    margin: 0 0 3px;
    color: var(--brand);
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.login-card h1 {
    margin: 0;
    color: #24364f;
    font-size: 1.55rem;
    line-height: 1.2;
}

.login-subtitle {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: .92rem;
}

.login-field {
    margin-bottom: 17px;
}

    .login-field label {
        display: block;
        margin-bottom: 6px;
        color: #334155;
        font-size: .92rem;
        font-weight: 650;
    }

    .login-field .portal-field {
        min-height: 46px;
        margin: 0;
        padding: 10px 12px;
        background: #fff;
    }

    .login-field .text-danger {
        display: block;
        margin-top: 4px;
        font-size: .82rem;
    }

.login-validation:empty {
    display: none;
}

.login-validation ul {
    margin: 0;
    padding-left: 20px;
}

.login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 2px 0 20px;
    font-size: .9rem;
}

.remember-option {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
}

    .remember-option .form-check-input {
        margin: 0;
    }

.login-link {
    color: var(--brand-dark);
    font-weight: 600;
    text-decoration: none;
}

    .login-link:hover {
        color: var(--brand);
        text-decoration: underline;
    }

.login-submit {
    width: 100%;
    min-height: 47px;
    border: 0;
    border-radius: 8px;
    background: var(--brand);
    box-shadow: 0 5px 12px rgba(75, 107, 154, .2);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

    .login-submit:hover,
    .login-submit:focus {
        background: var(--brand-dark);
    }

.login-help {
    margin: 24px 0 0;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .82rem;
    line-height: 1.5;
    text-align: center;
}

@media (max-width: 850px) {
    .portal-header,
    .home-toolbar,
    .portal-flex,
    .quick-patient-grid {
        flex-direction: column;
        align-items: stretch;
    }

    .home-actions {
        width: auto;
    }
}

@media (max-width: 640px) {
    html {
        font-size: 15px;
    }

    .portal-container {
        padding: 10px;
    }

    .portal-card {
        margin-bottom: 10px;
        padding: 12px;
        border-radius: 9px;
    }

        .portal-card h3 {
            font-size: 1.15rem;
            margin-bottom: 8px;
        }

        .portal-card h4 {
            font-size: 1.3rem;
            margin-bottom: 8px;
        }

    .row-actions .portal-button {
        min-height: 44px;
        padding: 10px 14px;
    }

    .patients-table-wrap {
        overflow: visible;
    }

    .portal-table.patient-list-table,
    .patient-list-table tbody,
    .patient-list-table tr,
    .patient-list-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .patient-list-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .patient-list-table .patient-row {
        margin-bottom: 12px;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: #fff;
        box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    }

        .patient-list-table .patient-row:last-child {
            margin-bottom: 0;
        }

        .patient-list-table .patient-row td {
            display: grid;
            grid-template-columns: minmax(112px, 42%) minmax(0, 1fr);
            gap: 10px;
            align-items: baseline;
            padding: 6px 0;
            border: 0;
            font-size: .93rem;
            overflow-wrap: anywhere;
        }

            .patient-list-table .patient-row td::before {
                content: attr(data-label);
                color: var(--muted);
                font-size: .8rem;
                font-weight: 650;
            }

        .patient-list-table .patient-row .patient-card-name {
            display: block;
            padding: 0 0 9px;
            margin-bottom: 3px;
            border-bottom: 1px solid var(--border);
        }

    .patient-list-table .patient-card-name::before {
        display: none;
    }

    .patient-list-table .patient-name {
        font-size: 1.08rem;
    }

    .patient-list-table .patient-card-status {
        align-items: center;
        padding-top: 9px;
    }

    .patient-open-link {
        display: inline-flex;
        justify-content: center;
        align-items: center;
        grid-column: 1 / -1;
        min-height: 42px;
        margin-top: 5px;
        border-radius: 8px;
        background: var(--brand);
        color: #fff;
        font-weight: 650;
        text-decoration: none;
    }

        .patient-open-link:hover,
        .patient-open-link:focus {
            background: var(--brand-dark);
            color: #fff;
        }

    .login-page {
        min-height: calc(100vh - 64px);
        padding: 22px 0;
    }

    .login-card {
        padding: 24px 20px;
        border-radius: 10px;
    }

    .login-brand {
        align-items: flex-start;
    }

    .login-mark {
        width: 50px;
        height: 50px;
        flex-basis: 50px;
    }

    .login-card h1 {
        font-size: 1.35rem;
    }

    .login-options {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }
}
