@font-face {
  font-family: "Speda";
  src: url("../fonts/Speda-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Speda";
  src: url("../fonts/Speda-Bold.ttf") format("truetype");
  font-weight: 600 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #17262a;
  --muted: #64777b;
  --paper: #ffffff;
  --canvas: #f5f7f6;
  --line: #dfe7e5;
  --brand: #8f1f2c;
  --brand-dark: #6f1520;
  --brand-soft: #f7e9eb;
  --teal: #176c68;
  --teal-soft: #e6f3f1;
  --gold: #ba792e;
  --danger: #b42318;
  --shadow: 0 12px 36px rgba(22, 44, 46, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Speda", "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}
html[dir="rtl"] body { line-height: 1.72; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }
.ui-icon { width: 1.15em; height: 1.15em; display: block; flex: 0 0 auto; overflow: visible; }
.btn > .ui-icon { width: 17px; height: 17px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 276px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px;
  background: linear-gradient(165deg, #5c1119 0%, #8f1f2c 50%, #ab2c3a 100%);
  color: white; display: flex; flex-direction: column; z-index: 20; overflow: hidden;
}
.sidebar:before { content: ""; position: absolute; width: 260px; height: 260px; border-radius: 50%; inset-inline-end: -140px; top: -150px; background: radial-gradient(circle, rgba(255,255,255,.1), transparent 70%); pointer-events: none; }
.sidebar:after { content: ""; position: absolute; width: 200px; height: 200px; border-radius: 50%; inset-inline-start: -120px; bottom: -110px; background: radial-gradient(circle, rgba(0,0,0,.14), transparent 70%); pointer-events: none; }
.brand { position: relative; display: flex; gap: 13px; align-items: center; margin: 2px 4px 28px; padding: 13px; border: 1px solid rgba(255,255,255,.16); border-radius: 18px; background: rgba(255,255,255,.09); box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 10px 28px rgba(0,0,0,.14); }
.brand-mark { flex: 0 0 auto; width: 54px; height: 54px; padding: 3px; overflow: hidden; border-radius: 17px; background: white; display: grid; place-items: center; box-shadow: 0 8px 20px rgba(0,0,0,.2); }
.brand-logo { width: 100%; height: 100%; display: block; object-fit: contain; }
.blood-drop { width: 20px; height: 26px; background: var(--brand); border-radius: 60% 40% 65% 35% / 70% 35% 65% 30%; transform: rotate(45deg); }
.brand-copy { min-width: 0; display: grid; gap: 3px; }
.brand-name { display: block; font-weight: 850; font-size: 14px; line-height: 1.45; }
.brand-sub { display: block; opacity: .74; font-size: 10.5px; line-height: 1.35; }
.nav { position: relative; display: grid; gap: 4px; overflow-y: auto; padding: 2px 3px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
.nav::-webkit-scrollbar { width: 5px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); border-radius: 99px; }
.nav a { position: relative; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 11px; border: 1px solid transparent; border-radius: 13px; color: rgba(255,255,255,.8); font-weight: 700; font-size: 13.5px; transition: background .16s ease, border-color .16s ease, transform .16s ease, color .16s ease; }
.nav a:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.12); color: white; transform: translateX(calc(var(--nav-shift, 1) * -3px)); }
html[dir="ltr"] .nav a:hover { --nav-shift: -1; }
.nav a.active { background: rgba(255,255,255,.17); border-color: rgba(255,255,255,.16); color: white; box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 10px 24px rgba(73,8,17,.18); }
.nav a.active:after { content: ""; position: absolute; inset-inline-start: -3px; width: 3.5px; height: 22px; border-radius: 99px; background: white; box-shadow: 0 0 10px rgba(255,255,255,.6); }
.nav-icon { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; text-align: center; font-size: 17px; background: rgba(255,255,255,.1); transition: background .16s ease, color .16s ease; }
.nav-icon .ui-icon { width: 18px; height: 18px; }
.nav a:hover .nav-icon { background: rgba(255,255,255,.18); }
.nav a.active .nav-icon { background: white; color: var(--brand); box-shadow: 0 4px 10px rgba(0,0,0,.18); }
.nav-separator { height: 1px; margin: 13px 9px 9px; background: linear-gradient(90deg, transparent, rgba(255,255,255,.4), transparent); }
.sidebar-accent { margin-top: auto; padding: 18px 10px 2px; display: flex; gap: 6px; opacity: .4; }
.sidebar-accent span { height: 4px; border-radius: 99px; background: white; }
.sidebar-accent span:nth-child(1) { width: 36px; }
.sidebar-accent span:nth-child(2) { width: 16px; }
.sidebar-accent span:nth-child(3) { width: 7px; }

.main { min-width: 0; }
.topbar { min-height: 72px; padding: 12px 30px; margin: 14px 24px 0; background: rgba(255,255,255,.92); backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 28px rgba(19,38,41,.06); display: flex; align-items: center; justify-content: space-between; gap: 18px; position: sticky; top: 14px; z-index: 10; }
.menu-button { display: none; width: 42px; height: 42px; place-items: center; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: white; }
.menu-button .ui-icon { width: 21px; height: 21px; }
.page-title { font-size: 19px; font-weight: 800; }
.top-actions, .topbar-context, .topbar-account { display: flex; align-items: center; gap: 10px; }
.topbar-account { min-width: 0; }
.lang-switch { display: inline-flex; background: #eef2f1; border-radius: 10px; padding: 3px; }
.lang-switch a { padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; transition: .15s ease; }
.lang-switch a.active { background: white; color: var(--brand); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.account-chip { min-width: 0; display: flex; align-items: center; gap: 9px; padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: 99px; background: white; box-shadow: 0 5px 16px rgba(22,44,46,.06); }
.account-avatar { position: relative; flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(150deg, var(--brand-soft), #f1d7da); color: var(--brand); font-weight: 900; font-size: 15px; }
.account-avatar:after { content: ""; position: absolute; inset-inline-end: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%; background: #2fa86a; border: 2px solid white; }
.account-copy { min-width: 0; display: grid; line-height: 1.25; }
.account-copy strong { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.account-copy span { color: var(--muted); font-size: 10.5px; white-space: nowrap; }
.top-logout { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 14px; border: 1px solid #efd2d5; border-radius: 99px; background: #fff7f8; color: var(--brand); font-size: 12px; font-weight: 800; transition: .15s ease; }
.top-logout:hover { background: var(--brand); border-color: var(--brand); color: white; box-shadow: 0 8px 20px rgba(143,31,44,.18); }
.logout-icon { display: grid; place-items: center; }
.logout-icon .ui-icon { width: 17px; height: 17px; }
.content { padding: 30px 34px 50px; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); line-height: 1.2; }
.eyebrow { margin: 0 0 4px; color: var(--brand); text-transform: uppercase; letter-spacing: .09em; font-weight: 800; font-size: 11px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card, .card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card { padding: 20px; overflow: hidden; position: relative; }
.stat-card:after { content: ""; position: absolute; width: 70px; height: 70px; border-radius: 50%; background: var(--brand-soft); inset-inline-end: -20px; top: -25px; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 750; }
.stat-value { margin-top: 5px; font-size: 30px; font-weight: 850; line-height: 1; }
.card { padding: 22px; }
.card-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.card-title h2, .card-title h3 { margin: 0; font-size: 17px; }
html[dir="rtl"] .card-title { text-align: right; }
html[dir="rtl"] .eyebrow:not(.code),
html[dir="rtl"] .form-section-title { letter-spacing: 0; text-transform: none; }

.btn { border: 0; border-radius: 11px; padding: 10px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 750; cursor: pointer; transition: .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--brand); color: white; box-shadow: 0 8px 20px rgba(143,31,44,.22); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--teal-soft); color: var(--teal); }
.btn-light { background: #eef2f1; color: var(--ink); }
.btn-outline { border: 1px solid var(--line); background: white; color: var(--ink); }
.btn-danger { background: #feeceb; color: var(--danger); }
.btn-sm { padding: 7px 10px; border-radius: 9px; font-size: 12px; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }

.alert { padding: 13px 15px; border-radius: 12px; margin-bottom: 18px; border: 1px solid transparent; }
.alert-success { background: #e8f6ef; border-color: #b9e2cc; color: #146c43; }
.alert-error { background: #fff0ef; border-color: #efc2be; color: #9a251c; }
.alert-info { background: #eaf4f6; border-color: #c5e0e4; color: #155d68; }

.form-section { margin-bottom: 28px; }
.form-section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--brand); border-bottom: 1px solid var(--line); padding-bottom: 9px; margin: 0 0 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; align-content: start; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 750; }
.required:after { content: " *"; color: var(--brand); }
.control { width: 100%; border: 1px solid #cfdad7; border-radius: 11px; padding: 10px 12px; color: var(--ink); background: white; outline: none; min-height: 44px; }
.control:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(23,108,104,.12); }
textarea.control { min-height: 94px; resize: vertical; }
.help { color: var(--muted); font-size: 11px; line-height: 1.4; }
/* Numeric value + unit badge always render LTR (see dir="ltr" on these inputs)
   regardless of page direction, so the badge is pinned to the physical right
   with `right`/`left` rather than `inset-inline-end`, which would flip in RTL. */
.input-unit { position: relative; }
.input-unit .control { padding-right: 70px; text-align: left; }
.unit { position: absolute; right: 11px; left: auto; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 11px; background: #eef2f1; padding: 3px 6px; border-radius: 6px; direction: ltr; pointer-events: none; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
.table-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.table-search-input { max-width: 260px; }
.table-toolbar-count { color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
th.sortable-column { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable-column:hover { color: var(--brand); }
th.sortable-column .sort-indicator { display: inline-block; width: 9px; margin-inline-start: 4px; opacity: .35; font-size: 9px; }
th.sortable-column .sort-indicator:after { content: "↕"; }
th.sortable-column[data-sort-dir="asc"] .sort-indicator { opacity: 1; }
th.sortable-column[data-sort-dir="asc"] .sort-indicator:after { content: "↑"; }
th.sortable-column[data-sort-dir="desc"] .sort-indicator { opacity: 1; }
th.sortable-column[data-sort-dir="desc"] .sort-indicator:after { content: "↓"; }
.table-empty-row td { text-align: center; }
table { width: 100%; border-collapse: collapse; min-width: 680px; background: white; }
th { text-align: start; background: #f1f5f4; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
.patient-cell { display: flex; align-items: center; gap: 11px; min-width: 200px; }
.avatar { width: 42px; height: 42px; border-radius: 13px; object-fit: cover; background: var(--brand-soft); border: 1px solid #ead3d6; }
.avatar-lg { width: 86px; height: 86px; border-radius: 22px; }
.patient-name { font-weight: 800; }
.code { font-family: Consolas, monospace; direction: ltr; display: inline-block; color: var(--brand); font-weight: 800; }
.ltr-value, [dir="ltr"] { unicode-bidi: isolate; }
.ltr-value { direction: ltr; display: inline-block; }
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 9px; background: #edf1f0; font-size: 11px; font-weight: 750; white-space: nowrap; }
.pill.active, .pill.transfused { color: #146c43; background: #e6f5ed; }
.pill.requested { color: #8b5a16; background: #fff4dc; }
.pill.inactive, .pill.cancelled { color: #8b3b35; background: #f9e9e7; }
.pill.critical, .alert-strip.critical { color: #8c1811; background: #fee4e2; }
.pill.warning, .alert-strip.warning { color: #8b5a16; background: #fff4dc; }
.pill.info, .alert-strip.info { color: #155d68; background: #eaf4f6; }
.pill.completed { color: #146c43; background: #e6f5ed; }
.pill.missed, .pill.overdue { color: #8c1811; background: #fee4e2; }
.blood-pill { color: var(--brand); background: var(--brand-soft); font-family: Arial, "Segoe UI", sans-serif; }

.alert-stack { display: grid; gap: 8px; margin: 16px 0; }
.alert-strip { border-radius: 11px; padding: 10px 13px; display: flex; justify-content: space-between; gap: 14px; font-size: 13px; }
.report-filters { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.report-filters .field { min-width: 150px; flex: 1; }
.print-document { background: white; max-width: 900px; margin: auto; padding: 34px; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.document-head { display: flex; justify-content: space-between; gap: 24px; border-bottom: 3px solid var(--brand); padding-bottom: 18px; margin-bottom: 24px; }
.document-brand { min-width: 0; display: flex; align-items: center; gap: 18px; }
.document-logo { flex: 0 0 auto; width: 92px; height: 92px; display: block; object-fit: contain; }
.document-brand h1 { margin: 2px 0 4px; font-size: 28px; line-height: 1.25; }
.summary-patient-mark { flex: 0 0 150px; display: grid; grid-template-columns: 58px minmax(0,1fr); align-content: center; align-items: center; gap: 3px 10px; }
.summary-patient-mark .avatar { width: 58px; height: 58px; grid-row: span 2; border-radius: 16px; }
.summary-patient-mark strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.summary-patient-mark > span { width: max-content; padding: 3px 8px; border-radius: 999px; color: var(--brand); background: var(--brand-soft); font-family: Arial, sans-serif; font-size: 11px; font-weight: 850; }
.summary-lab-date { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 11px; background: #f6f8f8; }
.summary-lab-date span { color: var(--muted); font-size: 11px; font-weight: 800; }
.summary-lab-date strong { font-size: 13px; }
.summary-lab-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; margin: 0; }
.summary-lab-metric { min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: white; }
.summary-lab-metric dt { min-height: 30px; color: var(--muted); font-size: 10.5px; font-weight: 750; line-height: 1.4; }
.summary-lab-metric dd { margin: 5px 0 0; color: var(--ink); font-family: Arial, "Segoe UI", sans-serif; font-size: 16px; font-weight: 850; }
.compact-table-wrap { overflow: hidden; }
.compact-table { min-width: 0; table-layout: fixed; }
.compact-table th, .compact-table td { padding: 10px; word-break: break-word; }
.public-lab-grid { margin-top: 2px; }
.signature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; margin-top: 55px; }
.signature-line { border-top: 1px solid var(--ink); padding-top: 7px; text-align: center; font-size: 12px; }

.search-bar { display: flex; gap: 10px; margin-bottom: 18px; }
.search-bar .control { max-width: 460px; }
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 18px; }
.pagination a, .pagination span { min-width: 36px; height: 36px; padding: 0 10px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: white; font-size: 12px; }
.pagination .current { background: var(--brand); color: white; border-color: var(--brand); }
.pagination-gap { border: 0 !important; background: transparent !important; color: var(--muted); }
.pagination-nav { padding-inline: 13px !important; }
.section-pager { padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--line); }
.section-pager .pagination { margin-top: 0; }
.patient-section-pagers:empty { display: none; }

.profile-hero { background: linear-gradient(135deg, #fff 0%, #fff 60%, #f8e7e9 100%); display: flex; align-items: center; gap: 20px; }
.profile-main { flex: 1; }
.profile-main h1 { margin: 0 0 4px; font-size: 27px; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.definition-list { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; margin: 0; }
.definition-list dt { color: var(--muted); font-size: 12px; }
.definition-list dd { margin: 0; font-weight: 650; }
.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; padding: 0; padding-inline-start: 30px; padding-block-end: 24px; border-inline-start: 2px solid var(--line); min-width: 0; }
.timeline-item:before { content: ""; position: absolute; inset-inline-start: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-title { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-weight: 800; line-height: 1.45; }
.timeline-date, .timeline-meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.timeline-meta { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
html[dir="rtl"] .timeline-date,
html[dir="rtl"] .timeline-meta { text-align: right; }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.quick-action { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfc; }
.quick-action strong { display: block; margin-top: 8px; }
.quick-action:hover { border-color: #c49a9f; background: var(--brand-soft); }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #f7dfe2 0, transparent 35%), linear-gradient(145deg, #f7f9f8, #eaf1ef); }
.login-card { width: min(960px, 100%); background: white; border-radius: 28px; overflow: hidden; box-shadow: 0 25px 70px rgba(36,52,54,.15); display: grid; grid-template-columns: .9fr 1.1fr; }
.login-brand { padding: 50px; background: linear-gradient(160deg, var(--brand-dark), var(--brand)); color: white; display: flex; flex-direction: column; justify-content: space-between; min-height: 520px; }
.login-brand .brand-mark { width: 64px; height: 64px; }
.login-brand h1 { font-size: 32px; margin: 24px 0 8px; line-height: 1.25; }
.login-form { padding: 56px; align-self: center; }
.login-form h2 { margin: 0 0 6px; font-size: 28px; }

.empty { text-align: center; padding: 36px 18px; color: var(--muted); }
.empty-icon { width: 56px; height: 56px; border-radius: 18px; margin: 0 auto 12px; display: grid; place-items: center; background: var(--teal-soft); font-size: 25px; }
.empty-icon .ui-icon { width: 25px; height: 25px; color: var(--teal); }
.mobile-only { display: none; }

/* Two-sided printable patient ID card (CR80 / 86mm x 54mm) */
.badge-hint { margin: 0 0 14px; }
.badge-stage { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 26px; padding: 26px 0; }
.badge-figure { margin: 0; display: grid; gap: 8px; justify-items: center; }
.badge-figure figcaption { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.patient-card {
  width: 86mm; height: 54mm; overflow: hidden; position: relative; isolation: isolate;
  background: white; border: 1px solid #d8dfdd; border-radius: 3.5mm;
  box-shadow: 0 20px 50px rgba(19,38,41,.18);
  display: grid; grid-template-rows: 12mm minmax(0, 1fr) 5.6mm;
  font-family: "Speda", "Segoe UI", Tahoma, Arial, sans-serif; color: var(--ink);
}
.card-front { background: radial-gradient(circle at 96% 118%, rgba(143,31,44,.07) 0 22mm, transparent 22mm), white; }
html[dir="rtl"] .card-front { background: radial-gradient(circle at 4% 118%, rgba(143,31,44,.07) 0 22mm, transparent 22mm), white; }

/* --- shared chrome --- */
.card-head { position: relative; z-index: 1; display: flex; align-items: center; gap: 2.4mm; padding: 0 3.2mm; color: white; background: linear-gradient(115deg, #68131d 0%, #8f1f2c 55%, #b12e3e 100%); }
.card-logo { flex: 0 0 auto; width: 9mm; height: 9mm; padding: .4mm; overflow: hidden; border-radius: 2.2mm; background: white; display: grid; place-items: center; box-shadow: 0 .6mm 1.8mm rgba(67,5,13,.25); }
.card-logo-img { width: 100%; height: 100%; display: block; object-fit: contain; }
.card-head-copy { min-width: 0; flex: 1 1 auto; display: grid; gap: .2mm; }
.card-center { font-size: 7.6pt; font-weight: 850; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-kicker { font-size: 5.6pt; font-weight: 700; letter-spacing: .04em; opacity: .78; }
/* The brand "Speda" font renders the hyphen in negative groups (O-, A-, B-, AB-)
   too low to read clearly at this weight/size, so the blood group mark uses a
   plain sans-serif stack instead — this value must never be ambiguous. */
.card-blood { flex: 0 0 auto; min-width: 11mm; height: 7.4mm; padding: 0 1.6mm; display: grid; place-items: center; border-radius: 2mm; background: white; color: var(--brand); font-family: Arial, "Segoe UI", sans-serif; font-size: 12pt; font-weight: 800; line-height: 1.5; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 2mm; padding: 0 3.4mm; background: #eef3f2; border-top: 1px solid #e2eae8; color: #4f6266; font-size: 5.5pt; line-height: 1.35; }
.card-foot > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-code { color: var(--brand); font-family: Consolas, "Courier New", monospace; font-size: 6.4pt; font-weight: 900; letter-spacing: 0; white-space: nowrap; }
.card-security { font-family: Consolas, "Courier New", monospace; font-weight: 800; unicode-bidi: isolate; }

/* --- front face --- */
.card-front-body { position: relative; z-index: 1; display: grid; grid-template-columns: 16mm minmax(0, 1fr) 17mm; gap: 2.3mm; padding: 2mm 3.2mm; align-items: start; min-height: 0; }
.card-photo-col { display: grid; gap: 1mm; justify-items: center; }
.card-photo { width: 16mm; height: 20mm; object-fit: cover; border-radius: 1.8mm; border: .45mm solid #ead2d5; background: var(--brand-soft); }
.card-ident { min-width: 0; }
.card-label { display: block; color: var(--muted); font-size: 5.2pt; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.card-name { margin: .4mm 0 1.6mm; font-size: 9.5pt; font-weight: 900; line-height: 1.4; max-height: 9mm; overflow: hidden; }
.card-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .8mm 1.8mm; margin: 0; font-size: 6.1pt; line-height: 1.45; }
.card-facts dt { color: var(--muted); font-weight: 700; white-space: nowrap; }
.card-facts dd { margin: 0; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-qr-col { display: grid; gap: .8mm; justify-items: center; }
.card-qr { width: 17mm; height: 17mm; display: grid; place-items: center; padding: .4mm; background: white; border: .3mm solid #e6ecea; border-radius: 1mm; }
.card-qr img, .card-qr canvas { width: 16mm !important; height: 16mm !important; display: block; }
.card-scan { color: var(--muted); font-size: 4.7pt; line-height: 1.2; text-align: center; }

/* --- back face --- */
.card-back { grid-template-rows: 9mm minmax(0, 1fr) 5.6mm; background: radial-gradient(circle at 4% 105%, rgba(143,31,44,.07) 0 17mm, transparent 17mm), #fff; }
.card-back-head { display: flex; align-items: center; justify-content: space-between; gap: 2mm; padding: 0 3.2mm; color: white; background: linear-gradient(115deg, #68131d 0%, #8f1f2c 55%, #b12e3e 100%); border-bottom: .4mm solid #7d1824; font-size: 6.6pt; font-weight: 850; }
.card-back-head > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-back-brand { display: flex; align-items: center; gap: 1.6mm; }
.card-back-logo { width: 6.7mm; height: 6.7mm; padding: .25mm; border-radius: 1.5mm; object-fit: contain; background: white; }
.card-back-head .card-code { color: white; opacity: .9; }
.card-back-body { display: grid; grid-template-columns: .9fr 1.1fr; gap: 2.6mm; padding: 2mm 3.2mm 1.7mm; min-height: 0; }
.card-block { min-width: 0; }
.card-block-alt { padding-inline-start: 2.4mm; border-inline-start: .3mm solid #e6ecea; }
.card-block h3 { margin: 0 0 .75mm; color: var(--brand); font-size: 5.4pt; font-weight: 900; line-height: 1.45; letter-spacing: .03em; text-transform: uppercase; }
.card-block h3 + * { margin-top: 0; }
.card-block h3:not(:first-child) { margin-top: 1.9mm; }
.card-block p { margin: 0 0 .55mm; font-size: 5.7pt; line-height: 1.55; overflow: hidden; text-overflow: ellipsis; }
.card-strong { font-weight: 850; }
.card-notes { margin: 0; padding-inline-start: 2.8mm; font-size: 5.2pt; line-height: 1.55; }
.card-notes li { margin-bottom: .55mm; }
.card-notes .card-lost-warning { color: #8f1f2c; font-weight: 900; font-size: 5pt; line-height: 1.45; }
.card-back .card-foot { font-size: 5pt; }

.pin-input { font-family: Consolas, monospace; font-size: 24px; text-align: center; letter-spacing: .35em; direction: ltr; }
.pin-input { font-family: Consolas, monospace; font-size: 24px; text-align: center; letter-spacing: .35em; direction: ltr; }
.public-shell { min-height: 100vh; background: radial-gradient(circle at top, var(--brand-soft), transparent 40%), var(--canvas); padding: 24px; }
.public-container { width: min(960px, 100%); margin: 0 auto; }
.public-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.public-patient-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }
.privacy-note { font-size: 12px; color: var(--muted); padding: 12px 14px; background: #f2f6f5; border-radius: 10px; }
.qr-security-card { margin: 16px 0 20px; border-inline-start: 4px solid var(--brand); }
.qr-security-card > p { margin: 0 0 15px; }
.qr-revoked-card .login-form { text-align: center; }
.qr-disabled-icon { width: 60px; height: 60px; display: grid; place-items: center; margin: 0 auto 18px; border-radius: 18px; color: var(--brand); background: var(--brand-soft); }
.qr-disabled-icon .ui-icon { width: 28px; height: 28px; }
.qr-center-contact { display: grid; gap: 7px; margin-top: 22px; padding: 16px; border-radius: 14px; background: #f4f7f7; }

.users-layout { display: grid; grid-template-columns: minmax(320px, .75fr) minmax(560px, 1.25fr); gap: 20px; align-items: start; }
.user-form-card { position: sticky; top: 94px; }
.user-form-card .card-title { align-items: flex-start; }
.user-form-card .card-title .eyebrow, .users-list-card .card-title .eyebrow { margin-bottom: 2px; }
.form-actions { margin-top: 20px; }
.users-table { min-width: 790px; }
.user-table-person { min-width: 235px; display: flex; align-items: flex-start; gap: 10px; }
.user-avatar-small { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: var(--teal-soft); color: var(--teal); font-weight: 900; font-size: 16px; }
.user-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 245px; }
.user-actions form { margin: 0; }

/* Advanced patient search and reporting */
.filter-panel { padding: 0; margin-bottom: 20px; overflow: hidden; }
.filter-panel summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 22px; background: linear-gradient(135deg,#fff,#f7faf9); }
.filter-panel summary::-webkit-details-marker { display: none; }
.filter-panel summary span:first-child { display: grid; gap: 3px; }
.filter-panel summary strong { color: var(--ink); }
.filter-panel summary small { color: var(--muted); font-weight: 500; }
.filter-toggle { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--brand-soft); color: var(--brand); transition: transform .2s ease; }
.filter-panel:not([open]) .filter-toggle { transform: rotate(180deg); }
.advanced-filter-form { border-top: 1px solid var(--line); padding: 20px 22px 22px; display: grid; grid-template-columns: repeat(4,minmax(145px,1fr)); gap: 15px; align-items: end; }
.filter-search { grid-column: span 2; }
.filter-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding-top: 4px; }
.patient-list-table { min-width: 1080px; }
.patient-stats { margin: 20px 0; }
.stat-date { font-size: 19px; font-weight: 850; margin-top: 6px; }
.patient-info-grid, .record-grid, .record-section { margin-bottom: 20px; }
.record-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.record-actions .inline-form, .inline-form { display: inline; margin: 0; }
.lab-table { min-width: 1480px; }

.report-document { background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.report-print-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; border-bottom: 3px solid var(--brand); padding-bottom: 18px; margin-bottom: 18px; }
.report-print-head h1 { margin: 2px 0 6px; font-size: 25px; }
.report-print-head p { margin: 0; color: var(--muted); }
.report-issued { display: grid; gap: 5px; min-width: 170px; padding: 12px 14px; border-radius: 12px; background: #f2f6f5; font-size: 12px; }
.report-filter-summary { padding: 12px 14px; margin-bottom: 18px; border: 1px solid #ead5d8; border-radius: 12px; background: var(--brand-soft); font-size: 13px; }
.report-stats { grid-template-columns: repeat(5,minmax(0,1fr)); margin-bottom: 20px; }
.report-stats .stat-card { min-width: 0; }
.report-stats .stat-value { font-size: 25px; }
.report-stats .stat-value small { font-size: 10px; }
.report-breakdowns { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; margin-bottom: 22px; }
.report-breakdown { border: 1px solid var(--line); border-radius: 14px; padding: 15px; break-inside: avoid; }
.report-breakdown h2 { margin: 0 0 11px; font-size: 14px; }
.breakdown-list { display: grid; gap: 7px; }
.breakdown-list > div { display: flex; justify-content: space-between; gap: 10px; padding-bottom: 7px; border-bottom: 1px dashed var(--line); font-size: 12px; }
.breakdown-list > div:last-child { border-bottom: 0; padding-bottom: 0; }
.breakdown-list strong { min-width: 28px; text-align: center; color: var(--brand); background: var(--brand-soft); border-radius: 999px; }
.report-table-section { margin-top: 4px; }
.report-patient-table { min-width: 1100px; }
.report-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; color: var(--muted); font-size: 10px; }

/* Patient-form lookup value manager */
.field-label-row { min-height: 26px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.manage-values-btn { border: 0; border-radius: 8px; padding: 3px 8px; background: var(--teal-soft); color: var(--teal); cursor: pointer; font-size: 10.5px; font-weight: 800; }
.manage-values-btn:hover { background: var(--teal); color: white; }
body.modal-open { overflow: hidden; }
.lookup-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; }
.lookup-modal[hidden] { display: none; }
.lookup-modal-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(12,27,30,.58); backdrop-filter: blur(4px); cursor: default; }
.lookup-dialog { position: relative; width: min(1080px,100%); max-height: calc(100vh - 48px); overflow: auto; background: white; border-radius: 22px; box-shadow: 0 28px 90px rgba(10,25,28,.3); padding: 24px; }
.lookup-dialog-head { position: sticky; top: -24px; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin: -24px -24px 20px; padding: 21px 24px 17px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.97); backdrop-filter: blur(10px); }
.lookup-dialog-head h2 { margin: 0; font-size: 22px; }
.lookup-dialog-head p { margin: 3px 0 0; }
.modal-close { flex: 0 0 auto; width: 38px; height: 38px; border: 0; border-radius: 12px; background: var(--brand-soft); color: var(--brand); cursor: pointer; font-size: 25px; line-height: 1; }
.lookup-add-form { border: 1px solid #d5e5e2; border-radius: 15px; padding: 15px; background: #f7fbfa; margin-bottom: 18px; }
.lookup-form-grid { display: grid; grid-template-columns: repeat(2,minmax(180px,1fr)) 110px auto; gap: 12px; align-items: end; }
.lookup-add-button { min-height: 44px; }
.lookup-list-head { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 10px; }
.lookup-list { display: grid; gap: 10px; }
.lookup-item { display: grid; grid-template-columns: minmax(100px,.55fr) repeat(2,minmax(170px,1fr)) 90px 125px auto; gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.lookup-item.is-inactive { background: #f7f8f8; opacity: .75; }
.lookup-code { align-self: center; min-width: 0; }
.lookup-code .code { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lookup-item .field { gap: 4px; }
.lookup-item .field label { font-size: 10px; }
.lookup-item .control { min-height: 38px; padding: 7px 9px; }
.lookup-item-actions { display: flex; gap: 6px; align-items: center; min-height: 38px; }
.lookup-item:has(select[name="parent_id"]) { grid-template-columns: minmax(90px,.45fr) repeat(3,minmax(145px,1fr)) 80px 115px auto; }

/* Appointment list and month calendar */
.appointment-view-tabs { margin-bottom: 18px; }
.appointment-list-card { margin-bottom: 20px; }
.appointments-table { min-width: 1050px; }
.calendar-card { overflow: hidden; }
.calendar-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 14px; }
.calendar-head h2 { margin: 0; font-size: 24px; }
.calendar-head p { margin: 3px 0 0; }
.calendar-nav, .calendar-legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.calendar-legend { justify-content: flex-end; margin-bottom: 12px; color: var(--muted); font-size: 11px; }
.calendar-legend span { display: inline-flex; align-items: center; gap: 5px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); }
.weekday-row { border: 1px solid var(--line); border-bottom: 0; border-radius: 13px 13px 0 0; background: #f1f5f4; }
.weekday-row > div { padding: 9px 6px; text-align: center; color: var(--muted); font-size: 11px; font-weight: 800; }
.month-grid { border-top: 1px solid var(--line); border-inline-start: 1px solid var(--line); }
.calendar-day { position: relative; min-height: 108px; padding: 10px; border: 0; border-inline-end: 1px solid var(--line); border-bottom: 1px solid var(--line); background: white; color: var(--ink); text-align: start; cursor: pointer; transition: .15s ease; }
.calendar-day:hover { z-index: 1; background: #f7fbfa; box-shadow: inset 0 0 0 2px var(--teal); }
.calendar-day.is-empty { cursor: default; background: #fafbfb; }
.calendar-day.is-empty:hover { box-shadow: none; }
.calendar-day.is-today { background: var(--brand-soft); }
.calendar-day.is-today .calendar-day-number { background: var(--brand); color: white; }
.calendar-day-number { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; font-weight: 850; direction: ltr; }
.calendar-count { position: absolute; inset-block-start: 10px; inset-inline-end: 10px; min-width: 25px; height: 25px; padding: 0 6px; display: grid; place-items: center; border-radius: 999px; background: var(--teal); color: white; font-size: 11px; font-weight: 900; }
.calendar-statuses { display: flex; gap: 4px; margin-top: 13px; }
.status-dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; background: var(--muted); }
.status-dot.scheduled { background: #ba792e; }
.status-dot.completed { background: #198754; }
.status-dot.missed { background: #c52c22; }
.status-dot.cancelled { background: #77878a; }
.calendar-day-label { display: block; margin-top: 7px; color: var(--muted); font-size: 10px; }
.calendar-modal { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 24px; }
.calendar-modal[hidden] { display: none; }
.calendar-modal-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(12,27,30,.58); backdrop-filter: blur(4px); }
.calendar-dialog { position: relative; width: min(820px,100%); max-height: calc(100vh - 48px); overflow: auto; background: white; border-radius: 20px; padding: 22px; box-shadow: 0 28px 90px rgba(10,25,28,.3); }
.calendar-dialog > header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.calendar-dialog h2 { margin: 0; direction: ltr; }
.day-detail-list { display: grid; gap: 9px; }
.day-detail-item { display: grid; grid-template-columns: 70px minmax(220px,1fr) minmax(150px,.65fr) auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; }
.day-detail-time { color: var(--brand); font-weight: 900; font-size: 17px; }
.day-detail-patient, .day-detail-contact { display: grid; gap: 2px; }
.day-detail-contact { justify-items: start; }

@media (max-width: 1380px) {
  .users-layout { grid-template-columns: 1fr; }
  .user-form-card { position: static; }
  .users-list-card { order: 1; }
  .user-form-card { order: 2; }
  .users-layout.is-editing .user-form-card { order: 1; }
  .users-layout.is-editing .users-list-card { order: 2; }
}

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .users-layout { grid-template-columns: 1fr; }
  .user-form-card { position: static; }
  .advanced-filter-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .report-stats { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .report-breakdowns { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .lookup-form-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .lookup-item, .lookup-item:has(select[name="parent_id"]) { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .lookup-code, .lookup-item-actions { grid-column: 1 / -1; }
  .calendar-head { flex-direction: column; }
  .day-detail-item { grid-template-columns: 70px 1fr auto; }
  .day-detail-contact { grid-column: 2; }
}
@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; inset-inline-start: -300px; width: 270px; transition: .2s ease; }
  body.nav-open .sidebar { inset-inline-start: 0; }
  .menu-button { display: block; }
  .mobile-only { display: inline-flex; }
  .topbar { padding: 9px 16px; margin: 10px 12px 0; top: 8px; border-radius: 15px; }
  .content { padding: 20px 18px 40px; }
  .page-title { display: none; }
  .grid-2, .form-grid, .login-card { grid-template-columns: 1fr; }
  .login-brand { min-height: 260px; padding: 34px; }
  .login-form { padding: 36px 30px; }
  .quick-grid { grid-template-columns: 1fr; }
  .users-list-card .table-wrap { overflow: visible; border: 0; border-radius: 0; }
  .users-table { display: block; min-width: 0; background: transparent; }
  .users-table thead { display: none; }
  .users-table tbody { display: grid; gap: 12px; }
  .users-table tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: white; }
  .users-table td { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0; border: 0; min-width: 0; }
  .users-table td:first-child { grid-column: 1 / -1; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
  .users-table td:last-child { grid-column: 1 / -1; padding-top: 10px; border-top: 1px solid var(--line); }
  .users-table td[data-label]:before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 700; }
  .users-table .user-table-person { min-width: 0; }
  .users-table .user-actions { min-width: 0; }
  .report-document { padding: 18px; }
  .report-print-head { flex-direction: column; }
  .report-issued { width: 100%; }
  .medical-summary-head { align-items: flex-start; flex-direction: column; }
  .summary-patient-mark { width: 100%; flex-basis: auto; }
  .summary-lab-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 560px) {
  .stats-grid, .grid-3, .form-grid-3 { grid-template-columns: 1fr; }
  .page-head { align-items: stretch; flex-direction: column; }
  .page-head .btn { width: 100%; }
  .profile-hero { align-items: flex-start; flex-direction: column; }
  .profile-hero .button-row { width: 100%; }
  .definition-list { grid-template-columns: 1fr; gap: 2px; }
  .definition-list dd { margin-bottom: 10px; }
  .document-brand { align-items: flex-start; }
  .document-logo { width: 72px; height: 72px; }
  .summary-lab-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .badge-stage { padding: 10px 0; gap: 18px; overflow-x: auto; justify-content: flex-start; }
  .topbar-account { gap: 6px; }
  .account-chip { padding: 5px 7px; }
  .account-copy strong { display: none; }
  .account-copy span { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
  .logout-text { display: none; }
  .top-logout { width: 42px; min-height: 42px; padding: 0; }
  .lang-switch a { padding: 6px 8px; }
  .users-table tr { grid-template-columns: 1fr; }
  .users-table td, .users-table td:first-child, .users-table td:last-child { grid-column: 1; }
  .advanced-filter-form { grid-template-columns: 1fr; }
  .filter-search, .filter-actions { grid-column: 1; }
  .filter-actions .btn { flex: 1; }
  .report-stats, .report-breakdowns { grid-template-columns: 1fr; }
  .report-footer { flex-direction: column; }
  .lookup-modal { padding: 0; }
  .lookup-dialog { width: 100%; max-height: 100vh; min-height: 100vh; border-radius: 0; padding: 18px; }
  .lookup-dialog-head { top: -18px; margin: -18px -18px 16px; padding: 16px 18px; }
  .lookup-form-grid, .lookup-item, .lookup-item:has(select[name="parent_id"]) { grid-template-columns: 1fr; }
  .lookup-code, .lookup-item-actions { grid-column: 1; }
  .lookup-item-actions .btn { flex: 1; }
  .calendar-card { padding: 14px; overflow: auto; }
  .calendar-head, .calendar-legend { min-width: 690px; }
  .calendar-grid { min-width: 690px; }
  .calendar-day { min-height: 90px; }
  .calendar-modal { padding: 0; }
  .calendar-dialog { width: 100%; max-height: 100vh; min-height: 100vh; border-radius: 0; padding: 18px; }
  .day-detail-item { grid-template-columns: 58px 1fr; }
  .day-detail-contact { grid-column: 2; }
  .day-detail-item > .btn { grid-column: 1 / -1; }
}

@media print {
  @page { size: A4 portrait; margin: 10mm; }
  @page badge { size: 86mm 54mm; margin: 0; }
  body { background: white; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .no-print, .sidebar, .topbar { display: none !important; }
  .app-shell, .main, .content { display: block; margin: 0; padding: 0; }
  .report-document { border: 0; border-radius: 0; box-shadow: none; padding: 0; }
  .report-print-head { margin-bottom: 4mm; }
  .report-stats { grid-template-columns: repeat(5,1fr); gap: 2mm; margin-bottom: 4mm; }
  .report-stats .stat-card { padding: 3mm; box-shadow: none; border: 1px solid var(--line); }
  .report-breakdowns { grid-template-columns: repeat(3,1fr); gap: 2.5mm; margin-bottom: 4mm; }
  .report-breakdown { padding: 3mm; }
  .report-table-section .table-wrap { overflow: visible; border: 0; }
  .report-patient-table { min-width: 0; table-layout: auto; font-size: 8pt; }
  .report-patient-table th, .report-patient-table td { padding: 1.7mm 1.2mm; }
  .report-patient-table thead { display: table-header-group; }
  .report-patient-table tr { break-inside: avoid; }
  .report-patient-table a { color: inherit; text-decoration: none; }
  .badge-page .app-shell, .badge-page .main, .badge-page .content, .badge-page .card, .badge-page .badge-stage, .badge-page .badge-figure { display: block; margin: 0; padding: 0; box-shadow: none; border: 0; gap: 0; }
  /* Each side prints on its own card-sized sheet so the two can be laminated back to back. */
  .badge-page .patient-card { page: badge; width: 86mm; height: 54mm; border: 0; border-radius: 0; box-shadow: none; break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge-page .badge-figure + .badge-figure .patient-card { break-before: page; }
  .print-document { max-width: none; padding: 12mm; border: 0; border-radius: 0; box-shadow: none; }
  .medical-summary-head { align-items: center; gap: 5mm; padding-bottom: 4mm; margin-bottom: 5mm; }
  .document-logo { width: 22mm; height: 22mm; }
  .document-brand { gap: 4mm; }
  .document-brand h1 { font-size: 18pt; }
  .summary-patient-mark { flex-basis: 39mm; grid-template-columns: 14mm minmax(0,1fr); }
  .summary-patient-mark .avatar { width: 14mm; height: 14mm; border-radius: 3mm; }
  .summary-lab-date { margin-bottom: 2mm; padding: 2mm 3mm; }
  .summary-lab-grid { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 1.5mm; }
  .summary-lab-metric { padding: 2mm 2.3mm; border-radius: 2mm; break-inside: avoid; }
  .summary-lab-metric dt { min-height: 7mm; font-size: 7pt; }
  .summary-lab-metric dd { margin-top: 1mm; font-size: 10pt; }
  /* Printed pages have no viewport to scroll, so every scrollable table must
     unclip and shrink to fit the page width instead of hiding columns. */
  .print-document .table-wrap { overflow: visible; border: 0; }
  .print-document table { width: 100%; min-width: 0; table-layout: auto; font-size: 8.2pt; }
  .print-document th, .print-document td { padding: 1.6mm 1.2mm; word-break: break-word; }
  .print-document .lab-table { font-size: 7pt; }
  .print-document thead { display: table-header-group; }
  .print-document tr { break-inside: avoid; }
  .public-patient-page .public-shell { min-height: 0; padding: 0; background: white; }
  .public-patient-page .public-container { width: 100%; max-width: none; }
  .public-patient-page .public-brand { padding-bottom: 4mm; margin-bottom: 5mm; border-bottom: 2px solid var(--brand); }
  .public-patient-page .profile-hero, .public-patient-page .card { box-shadow: none; border: 1px solid var(--line); break-inside: avoid; }
  .public-patient-page .grid { gap: 4mm; }
  .public-patient-page .table-wrap { overflow: visible; }
  .public-patient-page table { min-width: 0; width: 100%; }
  .public-patient-page .privacy-note { margin-top: 4mm; border: 1px solid var(--line); }
}

/* Public one-page center website */
.public-site { background: #fbfcfc; color: #14282b; }
.public-site:before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(circle at 8% 15%, rgba(23,108,104,.06), transparent 25%), radial-gradient(circle at 90% 8%, rgba(143,31,44,.07), transparent 24%); }
.landing-container { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.landing-header { position: sticky; top: 0; z-index: 40; border-bottom: 1px solid rgba(210,223,221,.8); background: rgba(255,255,255,.9); backdrop-filter: blur(18px); }
.landing-nav { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.landing-brand, .landing-footer-brand { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.landing-logo { flex: 0 0 auto; width: 58px; height: 58px; padding: 3px; overflow: hidden; display: grid; place-items: center; border: 1px solid #f0d7da; border-radius: 18px; background: white; box-shadow: 0 10px 25px rgba(143,31,44,.16); }
.landing-logo-img { width: 100%; height: 100%; display: block; object-fit: contain; }
.landing-brand > span:last-child, .landing-footer-brand > span:last-child { display: grid; line-height: 1.3; }
.landing-brand strong { font-size: 14px; }
.landing-brand small, .landing-footer-brand small { color: var(--muted); font-size: 10.5px; }
.landing-links { display: flex; align-items: center; justify-content: center; gap: 26px; }
.landing-links a { position: relative; padding: 8px 0; color: #3f5558; font-size: 13px; font-weight: 750; }
.landing-links a:after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 2px; border-radius: 10px; background: var(--brand); transform: scaleX(0); transition: .18s ease; }
.landing-links a:hover:after { transform: scaleX(1); }
.landing-actions { display: flex; align-items: center; gap: 8px; }
.landing-language, .landing-login { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; font-size: 12px; font-weight: 800; }
.landing-language { min-width: 45px; padding: 0 10px; background: #edf3f2; color: var(--teal); }
.landing-login { padding: 0 15px; border: 1px solid #e4c8cc; color: var(--brand); background: white; }
.landing-login:hover { color: white; border-color: var(--brand); background: var(--brand); }
.landing-hero { position: relative; min-height: 690px; display: grid; align-items: center; overflow: hidden; background: linear-gradient(135deg,#fff 0%,#f7fbfa 50%,#f9edef 100%); }
.landing-hero:after { content: ""; position: absolute; width: 560px; height: 560px; inset-inline-end: -250px; bottom: -320px; border-radius: 50%; border: 70px solid rgba(143,31,44,.04); }
.landing-hero-grid { position: relative; z-index: 2; display: grid; grid-template-columns: 1.05fr .95fr; align-items: center; gap: 70px; padding-block: 90px; }
.landing-kicker { display: inline-flex; align-items: center; gap: 9px; margin-bottom: 18px; color: var(--teal); font-size: 12px; font-weight: 850; letter-spacing: .04em; }
.landing-kicker span { width: 28px; height: 3px; border-radius: 10px; background: var(--teal); }
.landing-hero h1 { max-width: 700px; margin: 0; font-size: clamp(43px,5.8vw,76px); line-height: 1.08; letter-spacing: -.035em; }
html[dir="rtl"] .landing-hero h1 { letter-spacing: 0; line-height: 1.28; }
.landing-hero-copy > p { max-width: 620px; margin: 24px 0 32px; color: #5d7376; font-size: clamp(17px,2vw,21px); line-height: 1.8; }
.landing-hero-actions { display: flex; flex-wrap: wrap; gap: 11px; }
.landing-primary, .landing-secondary { min-height: 52px; display: inline-flex; align-items: center; justify-content: center; gap: 12px; padding: 0 22px; border-radius: 14px; font-size: 14px; font-weight: 850; }
.landing-primary { color: white; background: linear-gradient(135deg,var(--brand),#aa2b3a); box-shadow: 0 14px 28px rgba(143,31,44,.22); }
.landing-secondary { border: 1px solid #d8e3e1; background: white; }
.landing-hero-visual { position: relative; min-height: 430px; display: grid; place-items: center; }
.landing-orbit { position: absolute; border: 1px solid rgba(23,108,104,.15); border-radius: 50%; }
.orbit-one { width: 390px; height: 390px; }
.orbit-two { width: 300px; height: 300px; border-color: rgba(143,31,44,.13); }
.landing-heart { position: relative; z-index: 2; width: 196px; height: 196px; padding: 16px; display: grid; place-items: center; border: 12px solid white; border-radius: 56px; color: white; background: linear-gradient(145deg,#8f1f2c,#c14353); box-shadow: 0 30px 65px rgba(143,31,44,.25); transform: rotate(45deg); }
.hero-logo { width: 150px; height: 164px; display: block; object-fit: contain; border-radius: 36px; background: white; transform: rotate(-45deg); }
.landing-heart small { position: absolute; bottom: 10px; padding: 2px 10px; border-radius: 999px; color: var(--brand); background: white; font-weight: 850; transform: rotate(-45deg); }
.landing-float-card { position: absolute; z-index: 3; min-width: 190px; display: flex; align-items: center; gap: 11px; padding: 13px; border: 1px solid rgba(216,227,225,.9); border-radius: 16px; background: rgba(255,255,255,.94); box-shadow: 0 16px 40px rgba(19,49,50,.12); }
.landing-float-card > span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--brand); background: var(--brand-soft); font-size: 19px; }
.landing-float-card > span .ui-icon { width: 20px; height: 20px; }
.landing-float-card div { display: grid; }
.landing-float-card strong { font-size: 12.5px; }
.landing-float-card small { color: var(--muted); font-size: 10px; }
.float-blood { inset-inline-start: 0; top: 45px; }
.float-lab { inset-inline-end: -10px; top: 170px; }
.float-family { inset-inline-start: 18px; bottom: 25px; }
.landing-section { padding: 110px 0; scroll-margin-top: 78px; }
.landing-section-label { margin: 0 0 10px; color: var(--brand); font-size: 11px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.landing-section h2 { margin: 0; font-size: clamp(32px,4vw,50px); line-height: 1.24; }
.landing-about-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 90px; align-items: center; }
.landing-lead { margin: 24px 0 0; color: #5b7073; font-size: 18px; line-height: 2; }
.landing-mission { position: relative; overflow: hidden; padding: 40px; border: 1px solid #dce8e6; border-radius: 28px; background: white; box-shadow: 0 24px 60px rgba(19,49,50,.09); }
.landing-mission:after { content: ""; position: absolute; width: 150px; height: 150px; inset-inline-end: -65px; bottom: -75px; border-radius: 50%; background: var(--brand-soft); }
.landing-card-icon { width: 50px; height: 50px; display: grid; place-items: center; margin-bottom: 24px; border-radius: 16px; color: white; background: var(--teal); font-size: 21px; }
.landing-card-icon .ui-icon { width: 23px; height: 23px; }
.landing-mission h3 { margin: 0 0 13px; font-size: 23px; }
.landing-mission p { position: relative; z-index: 2; margin: 0; color: var(--muted); line-height: 1.9; }
.landing-services-section { background: #132e31; color: white; }
.landing-section-head { display: flex; align-items: end; justify-content: space-between; gap: 40px; margin-bottom: 48px; }
.landing-section-head > p { max-width: 430px; margin: 0; color: #a9c0c1; }
.landing-services { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.landing-service { min-height: 170px; display: flex; flex-direction: column; justify-content: space-between; padding: 25px; border: 1px solid rgba(255,255,255,.12); border-radius: 21px; background: rgba(255,255,255,.045); transition: .18s ease; }
.landing-service:hover { transform: translateY(-4px); border-color: rgba(255,255,255,.28); background: rgba(255,255,255,.08); }
.landing-service > span { color: #dca1a8; font-family: "Segoe UI",sans-serif; font-size: 12px; font-weight: 800; }
.landing-service h3 { margin: 30px 0 0; font-size: 19px; line-height: 1.55; }
.landing-contact { display: grid; grid-template-columns: .8fr 1.2fr; gap: 80px; align-items: start; padding: 58px; border-radius: 32px; color: white; background: linear-gradient(135deg,#7a1824,#a52c3a); box-shadow: 0 28px 70px rgba(110,22,33,.2); }
.landing-contact-copy > p:last-child { margin-top: 20px; color: #f4dfe2; line-height: 1.8; }
.landing-contact .landing-section-label { color: #f1b8bf; }
.landing-contact-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.landing-contact-list > div, .landing-contact-list > a { min-height: 105px; display: flex; gap: 13px; align-items: flex-start; padding: 18px; border: 1px solid rgba(255,255,255,.15); border-radius: 17px; background: rgba(255,255,255,.08); }
.landing-contact-list > * > span { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: white; color: var(--brand); }
.landing-contact-list > * > span .ui-icon { width: 18px; height: 18px; }
.landing-contact-list p { display: grid; gap: 4px; margin: 0; }
.landing-contact-list small { color: #f0cbd0; }
.landing-contact-list strong { font-size: 13px; line-height: 1.6; }
.landing-footer { border-top: 1px solid var(--line); background: white; }
.landing-footer > div { min-height: 125px; display: flex; align-items: center; justify-content: space-between; gap: 30px; }
.landing-footer p, .landing-footer > div > a { color: var(--muted); font-size: 11px; }
.landing-footer .khal-credit { padding-bottom: 3px; border-bottom: 1px solid #d8b6bb; color: var(--brand); font-weight: 850; transition: .15s ease; }
.landing-footer .khal-credit:hover { color: var(--teal); border-color: var(--teal); }
.landing-footer .landing-logo { width: 40px; height: 40px; border-radius: 13px; }

/* Administrator website content editor */
.site-content-form { display: grid; gap: 20px; }
.site-editor-section { display: grid; gap: 20px; }
.site-editor-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.site-editor-row:first-of-type { padding-top: 0; border-top: 0; }
.site-editor-row textarea { resize: vertical; }
.site-editor-save { position: sticky; bottom: 18px; z-index: 5; display: flex; justify-content: flex-end; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.92); box-shadow: var(--shadow); backdrop-filter: blur(12px); }

@media (max-width: 960px) {
  .landing-links { display: none; }
  .landing-hero-grid, .landing-about-grid { grid-template-columns: 1fr; }
  .landing-hero-copy { text-align: center; }
  .landing-kicker, .landing-hero-actions { justify-content: center; }
  .landing-hero-copy > p { margin-inline: auto; }
  .landing-hero-grid { gap: 35px; padding-block: 70px; }
  .landing-hero-visual { width: min(580px,100%); margin-inline: auto; }
  .landing-about-grid { gap: 36px; }
  .landing-services { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .landing-contact { grid-template-columns: 1fr; gap: 35px; }
}
@media (max-width: 650px) {
  .landing-container { width: min(100% - 28px,1180px); }
  .landing-nav { min-height: 72px; gap: 10px; }
  .landing-brand { min-width: 0; }
  .landing-brand strong { max-width: 150px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .landing-brand small { display: none; }
  .landing-logo { width: 40px; height: 40px; border-radius: 13px; }
  .landing-login { width: 42px; padding: 0; font-size: 0; }
  .landing-login:after { content: "↪"; font-size: 18px; }
  .landing-hero { min-height: auto; }
  .landing-hero-grid { padding-block: 62px; }
  .landing-hero h1 { font-size: 42px; }
  .landing-hero-visual { min-height: 360px; transform: scale(.86); margin-block: -20px; }
  .landing-float-card { min-width: 170px; }
  .float-blood { inset-inline-start: -18px; }
  .float-lab { inset-inline-end: -22px; }
  .landing-section { padding: 75px 0; }
  .landing-section-head { align-items: flex-start; flex-direction: column; margin-bottom: 32px; }
  .landing-services { grid-template-columns: 1fr; }
  .landing-service { min-height: 135px; }
  .landing-contact { padding: 30px 22px; border-radius: 24px; }
  .landing-contact-list { grid-template-columns: 1fr; }
  .landing-footer > div { align-items: flex-start; flex-direction: column; padding-block: 28px; gap: 15px; }
  .site-editor-row { grid-template-columns: 1fr; }
  .public-brand { align-items: flex-start; flex-wrap: wrap; }
  .public-patient-actions { width: 100%; margin-inline-start: 0; justify-content: space-between; }
}

/* Doctor directory and protected consultation history */
.doctor-editor { margin-bottom: 22px; }
.doctor-editor .check-row { align-self: end; min-height: 48px; }
.consultation-form-card { max-width: 1050px; margin-inline: auto; }
.consultation-original { margin-bottom: 24px; padding: 18px; border: 1px solid var(--line); border-inline-start: 4px solid var(--brand); border-radius: 14px; background: #fafcfc; }
.consultation-original > div, .consultation-head, .consultation-meta { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.consultation-list { display: grid; gap: 16px; }
.consultation-card { break-inside: avoid; }
.consultation-card h2, .consultation-card h3, .consultation-card p { margin-top: 0; }
.consultation-card-compact { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: #fbfdfd; }
.consultation-head { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.consultation-doctor { display: grid; justify-items: end; color: var(--muted); }
[dir="ltr"] .consultation-doctor { justify-items: start; }
.consultation-meta { justify-content: flex-start; margin-top: 12px; color: var(--muted); font-size: 12px; }
.consultation-meta span { padding-inline-end: 16px; border-inline-end: 1px solid var(--line); }
.consultation-notes-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; margin-top: 18px; }
.consultation-notes-grid > div { padding: 15px; border-radius: 13px; background: #f4f7f7; }
.consultation-notes-grid h3 { color: var(--brand); font-size: 13px; }
.consultation-notes-grid p { margin-bottom: 0; line-height: 1.8; }
.follow-up-banner { margin-top: 15px; padding: 12px 15px; border-radius: 12px; color: #11635e; background: #e7f5f2; font-weight: 800; }
.consultation-addendum { margin-top: 14px; padding: 14px 16px; border: 1px dashed #c7d7d5; border-radius: 12px; background: #fffdf5; }
.consultation-addendum strong { font-size: 12px; color: #765b10; }
.consultation-addendum p { margin: 8px 0 0; }
@media (max-width: 760px) {
  .consultation-notes-grid { grid-template-columns: 1fr; }
  .consultation-doctor { justify-items: start; }
}
@media print {
  .consultation-card { box-shadow: none; border: 1px solid #cfd8d7; }
  .consultation-notes-grid > div { background: white; border: 1px solid #e1e7e6; }
}
