/* Assistant (SIL Open Font License), variable weight, self-hosted from @fontsource-variable/assistant. */
@font-face {
    font-family: 'Assistant';
    font-style: normal;
    font-display: swap;
    font-weight: 200 800;
    src: url('../fonts/assistant-hebrew-wght.woff2') format('woff2-variations');
    unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
    font-family: 'Assistant';
    font-style: normal;
    font-display: swap;
    font-weight: 200 800;
    src: url('../fonts/assistant-latin-wght.woff2') format('woff2-variations');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ObGyn Assistant — base styles. Navy accent; green/orange/red only for clinical meaning. RTL throughout. */
:root {
    --navy: #1B3A6B;
    --navy-hover: #15305a;
    --navy-soft: #E6ECF6;
    --bg: #F1F4F8;
    --surface: #FFFFFF;
    --border: #DCE2EA;
    --text: #15202E;
    --muted: #6B7686;
    --ok: #1F7A45;
    --pending: #B35C00;
    --pending-soft: #FDF3E4;
    --risk: #B42318;
    --risk-soft: #FDECEA;
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: 'Assistant', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--navy); }

.muted { color: var(--muted); margin: 0 0 16px; }

.h1 { font-size: 22px; font-weight: 700; margin: 0 0 12px; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

/* Pill / chips */
.pill {
    display: inline-block;
    padding: 2px 10px;
    font-size: 13px;
    border-radius: 999px;
    background: #E9EDF2;
    color: var(--text);
    white-space: nowrap;
}

/* Top bar */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-actions form { margin: 0; }
.brand-name { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }

.search { margin-top: 10px; }
.search input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #F6F8FB;
    font: inherit;
}

.page { max-width: 1440px; margin: 0 auto; padding: 16px; display: grid; gap: 12px; }

/* Forms */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field-label { font-size: 14px; font-weight: 600; }
.field input {
    font: inherit;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    width: 100%;
}
.field input:focus, .search input:focus {
    outline: 2px solid var(--navy);
    outline-offset: 1px;
    border-color: var(--navy);
}
.code-input { font-size: 22px; letter-spacing: 6px; text-align: center; }

.btn {
    font: inherit;
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 11px 16px;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}
.btn-block { width: 100%; display: block; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-hover); }
.btn-secondary { background: var(--surface); color: var(--navy); border-color: var(--border); }

.link-btn {
    font: inherit;
    background: none;
    border: 0;
    padding: 0;
    color: var(--navy);
    cursor: pointer;
    text-decoration: underline;
}

.alert { border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 14px; font-size: 15px; }
.alert-danger { background: var(--risk-soft); color: var(--risk); }

/* Guest pages (login, 2FA) */
.guest-wrap { min-height: 100vh; display: grid; place-content: center; padding: 24px 16px; gap: 16px; }
.guest-brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.guest-card { width: min(400px, calc(100vw - 32px)); padding: 24px; }
.guest-footer { margin-top: 16px; text-align: center; }

.recovery { margin-top: 16px; font-size: 15px; }
.recovery summary { cursor: pointer; color: var(--navy); margin-bottom: 12px; }

.qr { display: grid; place-items: center; padding: 12px; margin-bottom: 8px; }
.qr svg { width: 200px; height: 200px; }
.secret { display: block; padding: 10px; background: #F6F8FB; border-radius: var(--radius-sm); word-break: break-all; }

.recovery-codes {
    list-style: none;
    padding: 12px;
    margin: 0 0 16px;
    background: #F6F8FB;
    border-radius: var(--radius-sm);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 14px;
}

/* Search */
.search { position: relative; }
.search-results {
    display: none;
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 6px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(21, 32, 46, .12);
    max-height: 70vh;
    overflow-y: auto;
    z-index: 20;
}
.search-results.open { display: block; }
.result { display: grid; gap: 2px; padding: 12px 14px; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--border); }
.result:last-child { border-bottom: 0; }
.result:hover, .result:focus { background: var(--navy-soft); outline: none; }
.result-name { font-weight: 700; }
.result-meta { font-size: 14px; color: var(--muted); }
.result-empty { margin: 0; padding: 12px 14px; color: var(--muted); font-size: 15px; }
.results-page { padding: 0; overflow: hidden; }
.empty-state p { margin: 0 0 6px; }

/* Call screen */
.page.call { max-width: 1120px; }
.call-grid { display: grid; gap: 12px; }
.call-col { display: grid; gap: 12px; align-content: start; }
@media (min-width: 900px) {
    .call-grid { grid-template-columns: 1fr 1fr; align-items: start; }
}

.identity-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.patient-name { font-size: 24px; font-weight: 700; margin: 0; line-height: 1.2; }
.patient-meta { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.call-btn { flex: none; padding: 8px 14px; }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.card-title { font-size: 17px; font-weight: 700; margin: 0 0 10px; }
.card-head .card-title { margin: 0; }
.card-meta, .muted-inline { color: var(--muted); font-size: 14px; font-weight: 400; }

.kv { margin: 0; display: grid; gap: 8px; }
.kv-row { display: flex; justify-content: space-between; gap: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: end; }
.kv dd a { color: var(--text); text-decoration: none; }
.kv-stacked .kv-row { display: grid; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.kv-stacked .kv-row:last-child { border-bottom: 0; padding-bottom: 0; }
.kv-stacked dd { text-align: start; font-weight: 500; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { font-size: 14px; padding: 2px 10px; border-radius: 999px; background: #EEF1F5; border: 1px solid var(--border); }
.tag-label { color: var(--muted); }
.tag-risk { background: var(--risk-soft); color: var(--risk); border-color: #F4C7C2; }
.tag-pending { background: var(--pending-soft); color: var(--pending); border-color: #F1D5AE; }

.pregnancy-current { background: var(--navy-soft); border-color: #C9D5EA; }
.pregnancy-current .card-title { color: var(--navy); }
.pregnancy-stale { background: var(--pending-soft); border-color: #F1D5AE; }
.pregnancy-stale .card-title { color: var(--pending); }
.note { margin: 0 0 10px; font-size: 15px; }

.file-switch { position: relative; font-size: 14px; }
.file-switch summary { cursor: pointer; color: var(--navy); list-style: none; }
.file-switch summary::-webkit-details-marker { display: none; }
.file-switch ul {
    position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 5;
    list-style: none; margin: 0; padding: 6px 0; min-width: 240px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(21, 32, 46, .12);
}
.file-switch a { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; color: var(--text); text-decoration: none; }
.file-switch a[aria-current] { background: var(--navy-soft); font-weight: 700; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.metric { display: grid; gap: 2px; }
.metric-label { font-size: 13px; color: var(--muted); }
.metric-value { font-size: 17px; font-weight: 700; }
.metric-risk .metric-value, .metric-risk .metric-label { color: var(--risk); }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; padding-bottom: 0; }
.timeline p { margin: 2px 0 0; }
.timeline-meta { font-size: 14px; color: var(--muted); }

.plain-list, .link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.quick-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick-links .btn { padding: 9px 6px; }
.is-disabled { opacity: .5; cursor: default; }
.footnote { text-align: center; color: var(--muted); font-size: 13px; margin: 0; }

/* Patient screens (shared header + nav) */
.page.patient-page { padding: 0; gap: 0; max-width: none; }
.patient-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px; display: grid; gap: 12px; }
.patient-header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.patient-header .tags { margin-top: 0; }
.banner { margin: 0; padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; }
.banner-pending { background: var(--pending-soft); color: var(--pending); border: 1px solid #F1D5AE; }
.banner-risk { background: var(--risk-soft); color: var(--risk); border: 1px solid #F4C7C2; }

.file-switch-pill summary {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 14px; border: 1px solid #C9D5EA; border-radius: var(--radius-sm);
    background: var(--navy-soft); color: var(--navy);
}

.patient-body { display: block; }
.patient-main { padding: 16px; display: grid; gap: 12px; min-width: 0; }

.side-nav { display: none; }
.side-nav-group { margin: 12px 12px 4px; font-size: 12px; color: var(--muted); }
.side-nav-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 12px; margin: 2px 0; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.side-nav-item:hover { background: #EEF1F5; }
.side-nav-item.is-active { background: var(--navy-soft); color: var(--navy); font-weight: 700; }
.side-nav-item.is-disabled { color: var(--muted); opacity: .6; }
.side-nav hr { border: 0; border-top: 1px solid var(--border); margin: 8px 12px; }
.lock { font-size: 12px; color: var(--pending); }

.tab-scroller { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.tab-scroller::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font-size: 15px; }
.tab.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.tab.is-disabled { color: var(--muted); opacity: .6; }

@media (min-width: 900px) {
    .patient-header { padding: 20px 24px; }
    .patient-body { display: grid; grid-template-columns: 268px 1fr; align-items: start; }
    .side-nav { display: block; padding: 8px 12px 16px; border-inline-start: 1px solid var(--border); min-height: calc(100vh - 120px); background: var(--surface); position: sticky; top: 0; }
    .patient-main { padding: 20px 24px; }
    .tab-scroller { display: none; }
}

/* Follow-up card */
.card-sub { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.table-wrap { display: none; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.followup-table, .data-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.followup-table th, .data-table th { background: #F6F8FB; color: var(--muted); font-weight: 600; font-size: 13px; text-align: start; padding: 10px 12px; position: sticky; top: 0; white-space: nowrap; }
.followup-table td, .data-table td { padding: 10px 12px; border-top: 1px solid var(--border); }
.followup-table tbody tr:nth-child(even) td, .data-table tbody tr:nth-child(even) td { background: #FAFBFD; }
.followup-table .cell-risk { color: var(--risk); font-weight: 700; background: var(--risk-soft) !important; }
.followup-table .col-notes { min-width: 220px; white-space: normal; }
.nowrap { white-space: nowrap; }

.visit-cards { display: grid; gap: 12px; }
.visit-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.visit-card.has-alert { border-color: #F4C7C2; }
.visit-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.visit-date { font-weight: 700; }
.week-pill { font-size: 13px; padding: 1px 8px; border-radius: 999px; background: var(--navy-soft); color: var(--navy); }
.visit-extra { margin-top: 10px; font-size: 15px; }
.visit-extra summary { cursor: pointer; color: var(--navy); margin-bottom: 8px; }
.more-visits { display: grid; gap: 12px; }
.more-visits[open] > summary { display: none; }
.more-visits > .visit-card { margin-top: 12px; }

@media (min-width: 900px) {
    .table-wrap { display: block; }
    .visit-cards { display: none; }
}

/* Lab */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head .card-title { margin: 0; font-size: 20px; }
.section-head .tags { margin: 0; }
.jump-links { display: flex; flex-wrap: wrap; gap: 6px; }
.jump-links a { font-size: 14px; padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--navy); text-decoration: none; }
.lab-section { scroll-margin-top: 150px; }
.data-table .row-risk td { color: var(--risk); font-weight: 700; background: var(--risk-soft) !important; }

.result-list { list-style: none; margin: 0; padding: 0; display: grid; }
.result-list li { padding: 9px 0; border-bottom: 1px solid var(--border); display: grid; gap: 2px; }
.result-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.result-list li:first-child { padding-top: 0; }
.result-line { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.result-name-inline { font-weight: 600; }
.result-values { font-weight: 600; text-align: end; }
.result-list .result-name-inline + .result-values { font-weight: 500; }
.result-when { font-size: 13px; color: var(--muted); }
.result-list li.is-risk .result-values, .result-list li.is-risk .result-name-inline { color: var(--risk); }
.small { font-size: 14px; }

@media (min-width: 900px) {
    .result-list { display: none; }
}
.result-values { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 12px; }
.result-value { max-width: 100%; overflow-wrap: anywhere; }

/* Medical history */
.two-col { display: grid; gap: 12px; }
@media (min-width: 1100px) { .two-col { grid-template-columns: 1fr 1fr; align-items: start; } }
.kv-history .kv-row { padding: 6px 0; border-bottom: 1px solid var(--border); align-items: baseline; }
.kv-history .kv-row:last-child { border-bottom: 0; }
.kv-history dt { flex: none; min-width: 120px; }
.kv-history dd { font-weight: 400; color: var(--muted); text-align: end; white-space: pre-line; }
.kv-history .is-noted dd { color: var(--text); font-weight: 600; }
.partner-name { margin: 0 0 8px; font-weight: 700; }
.sub-title { margin: 16px 0 4px; font-size: 15px; color: var(--navy); }

/* Anatomy scan */
.scan .card-title { display: flex; align-items: center; gap: 8px; }
.scan-summary { margin: 0 0 12px; padding: 10px 12px; background: #F6F8FB; border-radius: var(--radius-sm); }
.scan-top { display: grid; gap: 16px; }
@media (min-width: 1000px) { .scan-top { grid-template-columns: 1fr 1fr; align-items: start; } }
.kv-compact .kv-row { padding: 4px 0; border-bottom: 1px solid var(--border); }
.kv-compact .kv-row:last-child { border-bottom: 0; }
.biometry { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.organ-groups { display: grid; gap: 8px; }
@media (min-width: 1000px) { .organ-groups { grid-template-columns: 1fr 1fr; align-items: start; } }
.organ-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; }
.organ-group.has-not { border-color: #F1D5AE; background: #FFFCF7; }
.organ-group summary { display: flex; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none; }
.organ-group summary::-webkit-details-marker { display: none; }
.organ-title { font-weight: 700; }
.organ-count { font-size: 14px; color: var(--muted); }
.text-pending { color: var(--pending); font-weight: 600; }
.organ-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: 15px; }
.organ { display: grid; grid-template-columns: 18px 1fr; gap: 0 6px; }
.organ-state { color: var(--muted); text-align: center; }
.organ.is-ok .organ-state { color: var(--ok); }
.organ.is-not .organ-state { color: var(--pending); font-weight: 700; }
.organ-text { grid-column: 2; font-size: 14px; color: var(--text); background: #F6F8FB; padding: 2px 8px; border-radius: 6px; justify-self: start; }
.reveal { margin-top: 12px; font-size: 15px; }
.reveal summary { cursor: pointer; color: var(--navy); }
.reveal p { margin: 6px 0 0; font-weight: 700; }

/* Previous pregnancies */
.past-item { padding: 12px 0; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.past-item:first-of-type { padding-top: 0; }
.past-item:last-child { border-bottom: 0; padding-bottom: 0; }
.past-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.past-notes { margin: 0; font-size: 15px; white-space: pre-line; background: #F6F8FB; padding: 8px 10px; border-radius: var(--radius-sm); }
.file-links { display: flex; flex-wrap: wrap; gap: 6px; }
.file-links .btn { padding: 6px 12px; font-size: 14px; }

/* Account menu + password page */
.account-menu { position: relative; }
.account-menu summary { cursor: pointer; color: var(--navy); list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary::after { content: ' ▾'; font-size: 12px; }
.account-menu-panel {
    position: absolute; inset-inline-end: 0; top: calc(100% + 8px); z-index: 30;
    min-width: 180px; padding: 10px 14px; display: grid; gap: 8px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(21, 32, 46, .12);
}
.account-menu-panel a { color: var(--text); text-decoration: none; }
.account-menu-panel form { margin: 0; }
.account-menu-panel .link-btn { text-decoration: none; color: var(--risk); }
.account-name { margin: 0; font-weight: 700; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.narrow-card { max-width: 440px; width: 100%; justify-self: center; }
.field-hint { font-size: 13px; color: var(--muted); }
.alert-ok { background: #E8F5EC; color: var(--ok); }

/* Patient activities (call summaries) */
.activity-add { margin-bottom: 14px; }
.activity-add > summary { list-style: none; }
.activity-add > summary::-webkit-details-marker { display: none; }
.activity-add[open] > summary { display: none; }
.activity-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field select, .field textarea {
    font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); width: 100%;
}
.field textarea { resize: vertical; min-height: 96px; }
.field select:focus, .field textarea:focus { outline: 2px solid var(--navy); outline-offset: 1px; border-color: var(--navy); }
.activity-list p { white-space: pre-line; }
.done-mark { color: var(--ok); font-weight: 600; }
