:root {
  color-scheme: light;
  --bg: #f5f8f8;
  --surface: #fff;
  --text: #132a39;
  --muted: #526671;
  --line: #dfebeb;
  --teal: #087b72;
  --teal-deep: #09655e;
  --mint: #e8f6f2;
  --blue: #eaf2ff;
  --danger: #a3363b;
  --shadow: 0 3px 9px #16323a05, 0 10px 26px #16323a04;
  --radius: 16px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); line-height: 1.55; }
[hidden] { display: none !important; }
a { color: var(--teal-deep); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid #168d9e; outline-offset: 3px;
}
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { line-height: 1.18; }
h1 { font-size: clamp(1.9rem, 4vw, 2.65rem); font-weight: 720; letter-spacing: -.047em; }
h2 { font-size: 1.18rem; letter-spacing: -.021em; }
h3 { font-size: 1rem; }
img { max-width: 100%; }
svg { flex: 0 0 auto; vertical-align: middle; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .58; }

.page { display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar {
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh;
  background: #fff; border-right: 1px solid var(--line); padding: 27px 17px 18px;
  overflow: auto; z-index: 5;
}
.brand { text-decoration: none; display: inline-flex; align-items: center; gap: 11px; color: var(--text); font-size: 1.275rem; font-weight: 760; letter-spacing: -.044em; width: fit-content; }
.sidebar .brand { margin: 0 10px 33px; }
.brand-mark { background: var(--teal); color: #fff; display: grid; place-items: center; width: 37px; height: 37px; border-radius: 11px; flex: 0 0 auto; }
.clinic-switch { background: #f5f9f9; border: 1px solid #e8f0f0; border-radius: 11px; display: flex; align-items: center; gap: 10px; padding: 10px; margin: 0 2px 28px; }
.clinic-avatar, .account-avatar { display: grid; place-items: center; border-radius: 9px; width: 34px; height: 34px; flex: 0 0 34px; background: #dcefe8; color: #0b665e; font-weight: 750; font-size: .79rem; overflow: hidden; }
.clinic-avatar img { width: 100%; height: 100%; object-fit: cover; }
.clinic-info { min-width: 0; }
.clinic-info strong, .clinic-info small { display: block; overflow-wrap: anywhere; }
.clinic-info strong { font-size: .84rem; line-height: 1.3; }
.clinic-info small { font-size: .75rem; color: var(--muted); }
.nav-label { font-size: .68rem; font-weight: 750; letter-spacing: .11em; color: #637780; margin: 0 12px 9px; }
.sidebar-nav { display: grid; gap: 5px; }
.nav-link {
  display: flex; gap: 11px; align-items: center; width: 100%; padding: 11px 12px; border: 0; border-radius: 9px;
  background: transparent; font-size: .92rem; font-weight: 620; color: #465f69; text-decoration: none; text-align: start;
}
.nav-link:hover { background: #f0f6f6; color: var(--text); }
.nav-link.active { background: #e4f4ee; color: #0b655a; }
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.logout-link { margin-top: 1px; }
.workspace { min-width: 0; }
.topbar {
  min-height: 73px; padding: 11px clamp(18px, 3vw, 42px); display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar-start, .account { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title { color: var(--text); font-weight: 710; font-size: .94rem; }
.account-avatar { background: #e8f4f2; border-radius: 50%; height: 37px; width: 37px; flex-basis: 37px; }
.account-text { min-width: 0; }
.account-text strong, .account-text span { display: block; overflow-wrap: anywhere; line-height: 1.3; }
.account-text strong { font-size: .85rem; }
.account-text span { color: var(--muted); font-size: .74rem; margin-top: 3px; }
.main-content { max-width: 1440px; margin-inline: auto; padding: 32px clamp(18px, 3vw, 42px) 56px; }
.menu-toggle { display: none !important; }
.menu-backdrop { position: fixed; inset: 0; z-index: 4; border: 0; background: #132a3960; }
.skip-link { position: fixed; left: 14px; top: 14px; transform: translateY(-150%); padding: 8px 12px; background: #fff; z-index: 20; }
.skip-link:focus { transform: none; }

.page-heading { margin-bottom: 23px; min-width: 0; }
.page-heading > * + *, .heading-stack > * + * { margin-top: 7px; }
.page-heading-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 23px; }
.page-heading-row .page-heading { margin: 0; }
.eyebrow { color: var(--teal-deep); font-size: .74rem; letter-spacing: .11em; font-weight: 750; text-transform: uppercase; }
.subtitle, .muted { color: var(--muted); }
.subtitle { font-size: .97rem; }
.bilingual-label {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: .38em;
  row-gap: .12em;
  max-width: 100%;
  line-height: 1.35;
  vertical-align: baseline;
}
.bilingual-label [lang="ar"] {
  color: var(--muted);
  direction: rtl;
  unicode-bidi: isolate;
  font-size: .82em;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.bilingual-label > span:first-child::after {
  content: " /";
  direction: ltr;
  unicode-bidi: isolate;
  color: var(--muted);
  font-size: .9em;
  font-weight: 400;
}
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); min-width: 0; }
.card-pad { padding: clamp(18px, 3vw, 25px); }
.card-title { padding: 19px 22px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.card-title p { margin-top: 5px; }
.button, .icon-button {
  display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 43px; min-width: 42px;
  border-radius: 9px; border: 1px solid transparent; font-weight: 700; font-size: .9rem; text-decoration: none; line-height: 1.25;
}
.button { padding: 10px 15px; }
.button.primary { color: #fff; background: var(--teal); box-shadow: 0 2px 4px #0b53431a; }
.button.primary:hover:not(:disabled) { background: var(--teal-deep); }
.add-patient.button.primary,
.add-patient.button.primary:hover:not(:disabled),
.add-patient.button.primary:focus-visible,
.add-patient.button.primary:active { color: #fff; }
.add-patient .bilingual-label { flex-direction: column; align-items: center; gap: .12em; }
.add-patient .bilingual-label [lang="ar"] { color: #000; font-size: .88em; font-weight: 600; line-height: 1.3; }
.add-patient .bilingual-label > span:first-child::after { content: none; }
.button.secondary { color: #243d49; background: #fff; border-color: #d7e5e6; }
.button.secondary:hover:not(:disabled) { background: #f2f8f8; }
.button.danger { background: var(--danger); color: #fff; }
.button.danger:hover:not(:disabled) { background: #87252a; }
.button.small { min-height: 36px; padding: 7px 11px; }
.icon-button { color: var(--muted); background: transparent; padding: 0; }
.icon-button:hover:not(:disabled) { background: #eaf3f3; color: var(--text); }
.text-link { color: var(--teal-deep); font-size: .91rem; font-weight: 720; text-underline-offset: .22em; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 6px; padding: 3px 8px; background: #e8f4f0; color: #165d52; font-size: .8rem; font-weight: 670; }
.badge.neutral { color: #4d626e; background: #edf2f4; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px 19px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label, .field-label { font-weight: 710; font-size: .9rem; }
input:not([type="checkbox"]), textarea, select {
  width: 100%; border: 1px solid #cfdfe2; color: var(--text); background: #fff; border-radius: 9px; padding: 10px 12px; min-height: 45px;
}
input::placeholder, textarea::placeholder { color: #617780; opacity: 1; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: #c94950; }
input[type="file"] { padding: 8px; }
input::file-selector-button { margin-right: 8px; border: 0; background: #e8f5f2; color: var(--teal-deep); border-radius: 6px; padding: 5px 9px; cursor: pointer; font-weight: 650; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--teal); margin: 0; flex: 0 0 auto; }
textarea { min-height: 110px; resize: vertical; }
select { padding-right: 30px; }
.field-error { color: #972e35; font-size: .85rem; }
.field-error:empty { display: none; }
.field-help { font-size: .85rem; color: var(--muted); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; align-items: center; padding-top: 18px; }
.form-status { margin: 12px 0; color: var(--danger); font-size: .92rem; }
.form-status:empty { display: none; }
.form-status.success { color: var(--teal-deep); }
.empty-state { padding: 30px 18px; display: grid; justify-items: center; gap: 8px; text-align: center; }
.empty-state p { color: var(--muted); max-width: 42ch; }
.empty-state .button { margin-top: 6px; }
.table-wrap { width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: .91rem; }
th { color: #536b75; background: #f6f9fa; text-align: start; font-size: .76rem; letter-spacing: .045em; text-transform: uppercase; font-weight: 750; }
td, th { padding: 12px 17px; border-bottom: 1px solid #e7eeee; overflow-wrap: anywhere; }
td { background: #fff; }
tr:last-child td { border-bottom: 0; }
.table-person { display: flex; align-items: center; gap: 9px; min-width: 0; }
.table-person a { color: var(--text); text-decoration: none; font-weight: 710; }
.table-person a:hover { text-decoration: underline; text-underline-offset: 3px; }
.table-avatar { flex: 0 0 31px; width: 31px; height: 31px; border-radius: 50%; display: grid; place-items: center; background: #e9f4ef; color: #185e53; font-size: .71rem; font-weight: 750; }
.table-person small { display: block; color: var(--muted); }
.table-action { text-align: end; white-space: nowrap; }
.record-id { white-space: nowrap; font-variant-numeric: tabular-nums; }
.notice-icon, .metric-icon { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 11px; background: #e6f5ef; color: #0c6e61; flex: 0 0 auto; }
.notice-icon.blue, .metric-icon.blue { background: #eaf2ff; color: #345d93; }
.notice-icon.lilac, .metric-icon.lilac { background: #f0ebfc; color: #664c9c; }
.list-status { color: var(--muted); padding: 23px 20px; display: flex; gap: 9px; align-items: center; justify-content: center; text-align: center; }
.list-status.error { color: var(--danger); }
.spinner { width: 15px; height: 15px; border: 2px solid #b9d8d4; border-top-color: var(--teal); border-radius: 50%; animation: spin .75s linear infinite; flex: 0 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.pagination { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 10px; padding: 15px 19px; border-top: 1px solid var(--line); color: var(--muted); font-size: .86rem; }
.pagination > div { display: flex; gap: 7px; }
.notifications { position: fixed; z-index: 15; right: 16px; bottom: 16px; max-width: min(390px, calc(100vw - 32px)); }
.toast { display: flex; align-items: center; gap: 8px; background: #123e38; color: #fff; padding: 8px 9px 8px 15px; border-radius: 9px; box-shadow: 0 8px 22px #102b3d25; }
.toast.error { background: #822c33; }
.toast .icon-button { color: #fff; }
.toast .icon-button:hover { background: #ffffff22; color: #fff; }
.confirm-dialog { width: min(430px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 14px; color: var(--text); padding: 23px; box-shadow: 0 15px 45px #132a3940; }
.confirm-dialog p { margin-top: 10px; color: var(--muted); }
.confirm-dialog::backdrop { background: #132a3980; }
.entry-page { display: grid; place-items: center; align-content: center; color: var(--muted); }

.hero {
  position: relative; isolation: isolate; border: 1px solid #d5ebe3; border-radius: 19px; background: #e8f5f0;
  padding: clamp(23px, 3vw, 36px); min-height: 220px; margin: 0 0 31px; overflow: hidden;
}
.hero > *:not(.hero-art) { position: relative; z-index: 1; }
.hero h2 { font-size: clamp(1.5rem, 3vw, 2.15rem); letter-spacing: -.045em; margin-bottom: 7px; }
.hero .bilingual-heading { margin-bottom: 12px; }
.bilingual-heading { min-width: 0; }
.bilingual-heading .bilingual-label { display: flex; align-items: baseline; flex-wrap: wrap; }
.hero p { color: #365a59; margin-bottom: 20px; }
.hero-art { position: absolute; width: 380px; height: 300px; right: 5%; top: -33px; color: #92cdbd; }
.orbit { position: absolute; display: block; border: 1px solid #9bcfbf; border-radius: 50%; width: 300px; height: 104px; top: 101px; left: 53px; transform: rotate(-26deg); }
.orbit:nth-child(2) { transform: rotate(30deg); }
.orbit:nth-child(3) { transform: rotate(90deg); }
.orbit-core { position: absolute; display: grid; place-items: center; top: 96px; left: 145px; width: 114px; height: 114px; border-radius: 28px; background: #d0eae1; color: #489b88; border: 1px solid #b7ded0; transform: rotate(-12deg); }
.orbit-core::before, .orbit-core::after { content: ""; grid-area: 1 / 1; height: 15px; width: 48px; background: currentColor; border-radius: 4px; }
.orbit-core::after { transform: rotate(90deg); }
.orbit-dot { position: absolute; top: 69px; left: 70px; width: 11px; height: 11px; border-radius: 50%; background: #8fc9ba; }
.orbit-dot:last-child { top: 194px; left: 324px; width: 15px; height: 15px; background: #78b9ad; }
.search-field { position: relative; display: flex; align-items: center; min-width: 0; }
.search-field > svg { position: absolute; left: 14px; color: #496e75; pointer-events: none; }
.search-field > input { padding-left: 43px; padding-right: 13px; min-height: 48px; }
.hero .search-field { max-width: 530px; }
.hero .search-field input { min-height: 53px; border-color: #bfd9d2; box-shadow: 0 3px 9px #123d3520; }
.hero-results { position: relative; z-index: 1; margin: -18px 0 29px; }
.hero-results:not([hidden]) { display: block; }
.date-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; color: #43616a; background: #fff; font-size: .85rem; white-space: nowrap; }
.heading-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.section-heading { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin-bottom: 30px; }
.metric { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 12px; padding: 17px; }
.metric h3 { color: var(--muted); line-height: 1.35; font-weight: 620; font-size: .88rem; }
.metric strong { display: block; line-height: 1.15; font-size: 1.9rem; letter-spacing: -.045em; margin-top: 4px; }
.dashboard-columns { display: grid; grid-template-columns: minmax(0, 1.95fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.followup-list { list-style: none; margin: 0; padding: 0 19px 10px; }
.followup-list li { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 10px 0; min-width: 0; }
.followup-list li > div { min-width: 0; overflow-wrap: anywhere; }
.followup-list li a { display: block; }
.followup-list small { display: block; color: var(--muted); }
.list-search { padding: 18px 19px; }
.list-search .bilingual-heading { margin: 0 0 14px; line-height: 1.3; }
.list-search .search-field { max-width: 500px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.settings-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.settings-grid .card-title { padding: 0 0 16px; }
.settings-grid .card { padding: 22px; }
.settings-grid .form-grid { grid-template-columns: 1fr; }
.check-label { display: inline-flex; align-items: center; gap: 7px; width: fit-content; }
.logo-preview { display: block; max-width: 112px; max-height: 88px; object-fit: contain; background: #f5f9f9; border-radius: 8px; padding: 5px; }
.doctor-list { margin: 19px 0 0; padding: 0; list-style: none; }
.doctor-list li { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
.doctor-list li > div { min-width: 0; overflow-wrap: anywhere; }
.doctor-list li p { font-size: .83rem; color: var(--muted); }

@media (max-width: 1050px) {
  .page { grid-template-columns: 202px minmax(0, 1fr); }
  .dashboard-columns { grid-template-columns: minmax(0, 1fr); }
  .hero-art { right: 0; }
}
@media (max-width: 820px) {
  .page { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(275px, 83vw); visibility: hidden; transform: translateX(-100%); }
  .sidebar.open { visibility: visible; transform: none; }
  .menu-toggle { display: inline-flex !important; margin-left: -8px; }
  .topbar { min-height: 63px; }
  .main-content { padding-top: 24px; }
}
@media (max-width: 620px) {
  .main-content { padding-inline: 15px; }
  .topbar { padding-inline: 15px; }
  .account { gap: 7px; }
  .account-text strong { max-width: 34vw; }
  .hero-art { opacity: .32; width: 340px; right: -142px; }
  .hero { min-height: 0; }
  .metrics { grid-template-columns: 1fr; gap: 9px; }
  .metric { align-items: center; padding: 12px 14px; }
  .metric > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .metric strong { margin-top: 0; font-size: 1.48rem; }
  .metric-icon { width: 36px; height: 36px; }
  .form-grid, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .responsive-table thead { position: absolute; width: 1px; height: 1px; clip: rect(0, 0, 0, 0); overflow: hidden; }
  .responsive-table tbody, .responsive-table { display: block; }
  .responsive-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; border-top: 1px solid var(--line); margin: 0; padding: 10px 15px; gap: 5px 8px; }
  .responsive-table td { display: block; min-width: 0; padding: 0; border: 0; text-align: start; }
  .responsive-table td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: .76rem; margin-right: 3px; }
  .responsive-table td:first-child { grid-column: 1 / -1; padding: 4px 0; }
  .responsive-table td.table-action { grid-column: 1 / -1; }
  .card-title, .list-search { padding-inline: 15px; }
}
