:root {
    color-scheme: light;
    --brand-900: #073b4c;
    --brand-800: #07536a;
    --brand-700: #076b86;
    --brand-600: #0787a5;
    --brand-500: #08a6c8;
    --brand-100: #dff7fb;
    --brand-50: #effbfd;
    --blue-600: #2563eb;
    --blue-50: #eff6ff;
    --green-700: #15803d;
    --green-50: #f0fdf4;
    --amber-700: #a16207;
    --amber-50: #fffbeb;
    --red-700: #b91c1c;
    --red-50: #fef2f2;
    --ink-950: #0f172a;
    --ink-900: #172033;
    --ink-800: #1e293b;
    --ink-700: #334155;
    --ink-600: #475569;
    --ink-500: #64748b;
    --ink-400: #64748b;
    --line: #dfe6ee;
    --line-soft: #edf1f5;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --surface-hover: #fafcfd;
    --surface-tint: #eef3f7;
    --canvas: #f5f8fb;
    --button-primary: #076b86;
    --button-primary-hover: #07536a;
    --button-primary-text: #ffffff;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
}

html[data-theme="dark"] {
    --brand-900: #cffafe;
    --brand-800: #a5f3fc;
    --brand-700: #67e8f9;
    --brand-600: #22d3ee;
    --brand-500: #06b6d4;
    --brand-100: #123845;
    --brand-50: #0d2832;
    --blue-600: #60a5fa;
    --blue-50: #132a46;
    --green-700: #4ade80;
    --green-50: #122f25;
    --amber-700: #fbbf24;
    --amber-50: #342812;
    --red-700: #f87171;
    --red-50: #381c24;
    --ink-950: #f8fafc;
    --ink-900: #f1f5f9;
    --ink-800: #e2e8f0;
    --ink-700: #cbd5e1;
    --ink-600: #b1bdcc;
    --ink-500: #94a3b8;
    --ink-400: #a8b6c9;
    --line: #2b394d;
    --line-soft: #213044;
    --surface: #111c2c;
    --surface-muted: #162235;
    --surface-hover: #172438;
    --surface-tint: #1a293d;
    --canvas: #0b1320;
    --button-primary: #0891b2;
    --button-primary-hover: #06a5c7;
    --button-primary-text: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2), 0 1px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.28);
}

html,
body {
    background: var(--canvas);
    color: var(--ink-950);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    margin: 0;
    min-height: 100%;
    text-rendering: optimizeLegibility;
    transition: background-color 160ms ease, color 160ms ease;
}

* {
    box-sizing: border-box;
}

button,
input,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--brand-700);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(8, 166, 200, 0.25);
    outline-offset: 2px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.62;
    transform: none;
}

.my-health-page .file-input {
    background: var(--surface-muted);
    border: 1px dashed var(--ink-400);
    border-radius: 10px;
    color: var(--ink-600);
    cursor: pointer;
    min-height: 64px;
    padding: 0.65rem;
    width: 100%;
}

.my-health-page .file-input::file-selector-button {
    background: var(--button-primary);
    border: 1px solid var(--button-primary);
    border-radius: 8px;
    color: var(--button-primary-text);
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    margin-inline-end: 0.85rem;
    min-height: 40px;
    padding: 0.55rem 0.85rem;
    transition: background-color 140ms ease, border-color 140ms ease;
}

.my-health-page .file-input:hover::file-selector-button {
    background: var(--button-primary-hover);
    border-color: var(--button-primary-hover);
}

.my-health-page .file-input:focus-visible {
    border-color: var(--brand-600);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.app-icon {
    display: block;
    flex: 0 0 auto;
    height: 1.25rem;
    width: 1.25rem;
}

.page {
    margin: 0 auto;
    max-width: 1280px;
    width: 100%;
}

.page-header {
    align-items: flex-end;
    display: flex;
    gap: 1.5rem;
    justify-content: space-between;
    margin-bottom: 1.75rem;
}

.page-eyebrow {
    color: var(--brand-700);
    font-size: 0.875rem;
    font-weight: 750;
    letter-spacing: 0.09em;
    margin: 0 0 0.4rem;
    text-transform: uppercase;
}

.page-title {
    color: var(--ink-950);
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 720;
    letter-spacing: -0.035em;
    line-height: 1.15;
    margin: 0;
}

.page-subtitle {
    color: var(--ink-500);
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0.45rem 0 0;
}

.surface-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.section-heading {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.section-heading h2 {
    color: var(--ink-950);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    margin: 0;
}

.section-heading a {
    font-size: 0.85rem;
    font-weight: 650;
    text-decoration: none;
}

.button {
    align-items: center;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    font-size: 0.875rem;
    font-weight: 700;
    gap: 0.55rem;
    justify-content: center;
    min-height: 44px;
    padding: 0.65rem 1rem;
    text-decoration: none;
    transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    background: var(--button-primary);
    box-shadow: 0 4px 10px rgba(7, 107, 134, 0.18);
    color: var(--button-primary-text);
}

.button-primary:hover {
    background: var(--button-primary-hover);
}

.button-secondary {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink-700);
}

.button-secondary:hover {
    background: var(--canvas);
    border-color: var(--ink-400);
}

.button-danger {
    background: var(--surface);
    border-color: #fecaca;
    color: var(--red-700);
}

.button-compact {
    min-height: 40px;
    padding: 0.45rem 0.75rem;
}

.segmented-control {
    align-items: center;
    background: var(--surface-tint);
    border-radius: 10px;
    display: flex;
    gap: 0.2rem;
    overflow-x: auto;
    padding: 0.25rem;
    width: fit-content;
}

.segmented-control button {
    background: transparent;
    border: 0;
    border-radius: 7px;
    color: var(--ink-600);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 650;
    min-height: 40px;
    padding: 0.45rem 0.8rem;
    white-space: nowrap;
}

.segmented-control button:hover {
    color: var(--ink-950);
}

.segmented-control button.active {
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
    color: var(--brand-800);
}

.status-pill {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    font-size: 0.875rem;
    font-weight: 750;
    gap: 0.35rem;
    line-height: 1;
    padding: 0.4rem 0.65rem;
    white-space: nowrap;
}

.status-scheduled {
    background: var(--blue-50);
    color: var(--blue-600);
}

.status-completed,
.status-secure {
    background: var(--green-50);
    color: var(--green-700);
}

.status-cancelled {
    background: var(--red-50);
    color: var(--red-700);
}

.empty-state {
    color: var(--ink-500);
    padding: 3rem 1.5rem;
    text-align: center;
}

.field-label {
    color: var(--ink-700);
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
    margin-bottom: 0.45rem;
}

.field-input {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink-950);
    min-height: 44px;
    padding: 0.7rem 0.8rem;
    transition: border-color 140ms ease, box-shadow 140ms ease;
    width: 100%;
}

.field-input:focus {
    border-color: var(--brand-600);
    box-shadow: 0 0 0 3px rgba(8, 166, 200, 0.12);
    outline: none;
}

.field-input:disabled {
    background: var(--surface-tint);
    color: var(--ink-500);
}

.sr-only {
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

.auth-flow-page {
    align-items: flex-start;
    background:
        radial-gradient(circle at 15% 0%, var(--brand-50), transparent 30%),
        var(--canvas);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 6.5rem 1rem 3rem;
    position: relative;
}

.auth-flow-brand {
    align-items: center;
    color: var(--ink-950);
    display: flex;
    font-size: 1.05rem;
    font-weight: 800;
    gap: 0.6rem;
    inset-inline-start: clamp(1rem, 4vw, 4rem);
    position: absolute;
    text-decoration: none;
    top: 1.5rem;
}

.auth-flow-brand > span:last-child span {
    color: var(--brand-600);
}

.auth-flow-brand-mark {
    align-items: center;
    background: linear-gradient(145deg, #22d3ee, #0891b2);
    border-radius: 10px;
    color: #fff;
    display: inline-flex;
    height: 38px;
    justify-content: center;
    width: 38px;
}

.auth-flow-card {
    max-width: 620px;
    padding: clamp(1.25rem, 4vw, 2rem);
    width: 100%;
}

.auth-flow-card .secure-label {
    align-items: center;
    color: var(--green-700);
    display: flex;
    font-size: 0.72rem;
    font-weight: 750;
    gap: 0.45rem;
    letter-spacing: 0.04em;
    margin-bottom: 1rem;
    text-transform: uppercase;
}

.auth-flow-card h1 {
    color: var(--ink-950);
    font-size: clamp(1.65rem, 4vw, 2.1rem);
    letter-spacing: -0.035em;
    margin-bottom: 0.5rem;
}

.auth-flow-subtitle {
    color: var(--ink-600);
    line-height: 1.55;
    margin-bottom: 1.5rem;
}

.auth-flow-form {
    display: grid;
    gap: 1rem;
}

.auth-provider-grid {
    display: grid;
    gap: 0.55rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.auth-provider-grid button {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--ink-700);
    cursor: pointer;
    display: flex;
    font-size: 0.75rem;
    font-weight: 700;
    gap: 0.4rem;
    justify-content: center;
    min-height: 44px;
}

.auth-provider-grid button:hover {
    background: var(--surface-muted);
    border-color: var(--ink-400);
}

.auth-provider-grid button > span {
    align-items: center;
    background: var(--surface-tint);
    border-radius: 50%;
    display: inline-flex;
    font-size: 0.68rem;
    height: 22px;
    justify-content: center;
    width: 22px;
}

.auth-flow-divider {
    align-items: center;
    color: var(--ink-500);
    display: flex;
    font-size: 0.7rem;
    gap: 0.7rem;
    margin: 1.25rem 0;
}

.auth-flow-divider::before,
.auth-flow-divider::after {
    background: var(--line);
    content: "";
    flex: 1;
    height: 1px;
}

.auth-flow-divider span {
    white-space: nowrap;
}

.auth-flow-form .form-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auth-flow-form .form-group {
    display: grid;
}

.auth-flow-form .form-group small,
.password-guidance {
    color: var(--ink-500);
    font-size: 0.75rem;
    line-height: 1.4;
    margin-top: 0.35rem;
}

.auth-checkbox {
    align-items: flex-start;
    color: var(--ink-700);
    display: flex;
    font-size: 0.82rem;
    gap: 0.6rem;
    line-height: 1.45;
}

.auth-checkbox input {
    height: 18px;
    margin-top: 0.1rem;
    width: 18px;
}

.auth-flow-status {
    border-radius: 8px;
    font-size: 0.82rem;
    line-height: 1.45;
    padding: 0.7rem 0.8rem;
}

.auth-flow-status.error {
    background: var(--red-50);
    color: var(--red-700);
}

.auth-flow-status.success {
    background: var(--green-50);
    color: var(--green-700);
}

.auth-flow-submit {
    width: 100%;
}

.auth-flow-footer {
    color: var(--ink-600);
    font-size: 0.82rem;
    margin: 1.25rem 0 0;
    text-align: center;
}

.auth-flow-footer a {
    font-weight: 750;
    text-decoration: none;
}

.auth-text-action {
    background: transparent;
    border: 0;
    color: var(--brand-700);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    justify-self: center;
}

.auth-success-panel {
    align-items: center;
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    text-align: center;
}

.auth-success-panel > span {
    align-items: center;
    background: var(--green-50);
    border-radius: 50%;
    color: var(--green-700);
    display: inline-flex;
    height: 54px;
    justify-content: center;
    width: 54px;
}

.auth-success-panel h2 {
    margin: 1rem 0 0.35rem;
}

.auth-success-panel p {
    color: var(--ink-600);
    margin-bottom: 1.25rem;
}

@media (max-width: 600px) {
    .auth-flow-page {
        padding-top: 5.5rem;
    }

    .auth-flow-card {
        padding: 1.25rem;
    }

    .auth-flow-form .form-grid {
        grid-template-columns: 1fr;
    }

    .auth-provider-grid {
        grid-template-columns: 1fr;
    }
}

.valid.modified:not([type=checkbox]) {
    border-color: var(--green-700);
}

.invalid {
    border-color: var(--red-700);
}

.validation-message {
    color: var(--red-700);
    font-size: 0.875rem;
}

.page-state {
    align-items: center;
    color: var(--ink-600);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    justify-content: center;
    min-height: 260px;
    padding: 2rem;
    text-align: center;
}

.page-state h2 {
    color: var(--ink-950);
    font-size: 1.125rem;
    margin: 0;
}

.page-state p {
    line-height: 1.5;
    margin: 0;
    max-width: 34rem;
}

.loading-indicator {
    animation: spin 0.8s linear infinite;
    border: 3px solid var(--brand-100);
    border-radius: 50%;
    border-top-color: var(--brand-700);
    height: 2rem;
    width: 2rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

html[dir="rtl"] .icon-chevron {
    transform: rotate(180deg);
}

html[data-theme="dark"] .login-page,
html[data-theme="dark"] .login-panel {
    background: var(--canvas);
}

html[data-theme="dark"] .appointment-summary {
    background: linear-gradient(110deg, var(--surface) 55%, var(--brand-50));
}

html[data-theme="dark"] .record-list-header,
html[data-theme="dark"] .form-footer {
    background: var(--surface-muted);
}

html[data-theme="dark"] .record-row:hover,
html[data-theme="dark"] .message-row:hover {
    background: var(--surface-hover);
}

html[data-theme="dark"] .message-row.unread {
    background: linear-gradient(90deg, var(--brand-50), var(--surface) 50%);
}

html[dir="rtl"] .message-row.unread {
    background: linear-gradient(270deg, var(--brand-50), var(--surface) 45%);
}

html[dir="rtl"][data-theme="dark"] .message-row.unread {
    background: linear-gradient(270deg, var(--brand-50), var(--surface) 50%);
}

html[data-theme="dark"] .notification-dot {
    border-color: var(--surface);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

html[data-theme="dark"] .date-tile,
html[data-theme="dark"] .appointment-date {
    border-color: #234369;
}

@media (max-width: 700px) {
    .page-header {
        align-items: stretch;
        flex-direction: column;
        gap: 1rem;
    }

    .page-header > .button {
        width: 100%;
    }
}
