/* ==========================================================================
   New Smile: app stylesheet (DESIGN_SYSTEM.md). Loaded after Bootstrap, so it
   restyles the kit in place. Tokens: tokens.css.
   Raw colours and durations are not allowed here (ifr check).
   ========================================================================== */

/* ---- Base ---------------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
body {
  text-align: start;  /* Bootstrap 4 reboot says left; Arabic needs right */
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--neutral-100);
  letter-spacing: normal;
}
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); color: var(--blue-900); letter-spacing: normal; }
a { color: var(--color-text-brand); transition: color var(--motion-fast) var(--ease-standard); }
a:hover { color: var(--color-primary-hover); }
:focus-visible {
  outline: var(--focus-width) solid var(--focus-color);
  outline-offset: var(--focus-offset);
}
.ns-shell p { line-height: 1.5; }
.mono, .ns-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ns-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ns-skip {
  position: absolute; inset-inline-start: var(--space-4); top: calc(-1 * var(--space-16)); z-index: 10;
  background: var(--color-surface); color: var(--color-text-brand); padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md); box-shadow: var(--shadow-pop); font-weight: 600;
}
.ns-skip:focus { top: var(--space-4); }

/* Focus colour per surface (amendment E): Smile Blue on light, Fresh Sky on Deep Navy */
.ns-nav { --focus-color: var(--color-focus-ring); }

/* ---- Frame: header + nav band (DESIGN_SYSTEM.md §3) ----------------------- */
.ns-shell { max-width: calc(var(--layout-max, 1600px) + 2 * var(--gutter, 32px)); margin: 0 auto; padding: var(--space-4, 16px) var(--gutter, 32px) 0; }

.ns-header {
  display: flex; align-items: center; gap: var(--space-6);
  background: var(--color-surface);
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.ns-logo { display: block; flex-shrink: 0; }
.ns-logo img { display: block; width: var(--header-logo); height: auto; }

.ns-search { position: relative; flex: 1; max-width: 460px; margin: 0 0 0 auto; }
.ns-search .ti-search {
  position: absolute; inset-inline-start: var(--space-4); top: 50%; transform: translateY(-50%);
  color: var(--sky-600); pointer-events: none;
}
.ns-search input {
  width: 100%; height: var(--control-h);
  padding: 0 var(--space-10) 0 var(--space-10);
  font: inherit; font-size: var(--text-sm); color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  transition: border-color var(--motion-fast) var(--ease-standard);
}
.ns-search input::placeholder { color: var(--color-text-muted); }
.ns-search input:hover { border-color: var(--blue-300); }
.ns-search input:focus { outline: var(--focus-width) solid var(--focus-color); outline-offset: var(--focus-offset); border-color: var(--color-primary); }
.ns-search kbd {
  position: absolute; inset-inline-end: var(--space-3); top: 50%; transform: translateY(-50%);
  font: 500 var(--text-xs)/1.4 var(--font-mono); color: var(--color-text-muted);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: 0 var(--space-1); box-shadow: none;
}

.ns-header-actions { display: flex; align-items: center; gap: var(--space-2); }
.ns-icon-btn {
  width: var(--control-h); height: var(--control-h); border-radius: var(--radius-full);
  display: inline-grid; place-items: center; flex-shrink: 0;
  background: var(--color-bg-brand); color: var(--blue-800); border: 0; cursor: pointer;
  font-size: var(--text-lg); text-decoration: none;
  transition: background-color var(--motion-fast) var(--ease-standard);
}
.ns-icon-btn:hover { background: var(--blue-100); color: var(--blue-900); text-decoration: none; }
.ns-icon-btn:active { background: var(--blue-200); }
.ns-icon-btn:focus-visible { outline: var(--focus-width) solid var(--focus-color); outline-offset: var(--focus-offset); }

/* Account menu: toggled by custom.js (Bootstrap 4.0's dropdown forces Popper transforms) */
.ns-account { position: relative; }
.ns-account .dropdown-menu {
  position: absolute; top: 100%; inset-inline-end: 0; inset-inline-start: auto;
  min-width: 220px; padding: var(--space-2); margin-top: var(--space-2);
  border: 1px solid var(--neutral-100); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
  /* Motion: show change. Kept in the layout (display) so it can fade; hidden + inert until .show. */
  display: block; visibility: hidden; opacity: 0; transform: translateY(calc(-1 * var(--space-1))) scale(0.98);
  transform-origin: top right;
  /* visibility interpolates as "visible while either end is visible": it flips at the end of a hide and the start of a show */
  transition: opacity var(--motion-fast) var(--ease-out), transform var(--motion-fast) var(--ease-out), visibility var(--motion-fast);
}
.ns-account .dropdown-menu.show {
  visibility: visible; opacity: 1; transform: none;
  transition: opacity var(--motion-base) var(--ease-out), transform var(--motion-base) var(--ease-out), visibility var(--motion-base);
}
.ns-account-who { padding: var(--space-2) var(--space-3) var(--space-3); border-bottom: 1px solid var(--neutral-100); margin-bottom: var(--space-1); }
.ns-account-who strong { display: block; color: var(--color-text); font-size: var(--text-sm); }
.ns-account-who span { color: var(--color-text-muted); font-size: var(--text-xs); }
.ns-account .dropdown-item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  font-size: var(--text-sm); color: var(--color-text);
}
.ns-account .dropdown-item:hover, .ns-account .dropdown-item:focus { background: var(--color-bg-brand); color: var(--color-text-brand); }

.ns-nav {
  display: flex; gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
  background: var(--color-bg-inverse);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  overflow-x: auto; scrollbar-width: none;
}
.ns-nav::-webkit-scrollbar { display: none; }
.ns-nav a {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: 40px; padding: 0 var(--space-4);
  color: var(--blue-100); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: background-color var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard);
}
.ns-nav a [class^="ti-"] { color: var(--sky-300); }
.ns-nav a:hover { background: var(--blue-800); color: var(--color-text-inverse); text-decoration: none; }
.ns-nav a[aria-current="page"] { background: var(--color-surface); color: var(--blue-900); font-weight: 600; }
.ns-nav a[aria-current="page"] [class^="ti-"] { color: var(--color-primary); }
.ns-nav a:focus-visible { outline-offset: calc(-1 * var(--focus-width)); }   /* inside the band, so it isn't clipped on phones */

.ns-main { padding: var(--space-6) 0 var(--space-10); }
.ns-footer { padding: 0 0 var(--space-8); text-align: center; font-size: var(--text-sm); color: var(--neutral-700); }

/* Title-row actions */
.ns-title-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ---- Buttons (Bootstrap .btn restyled, DESIGN_SYSTEM.md §4) --------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 40px; padding: 0 var(--space-4);
  font-family: var(--font-body); font-size: var(--text-sm); font-weight: 600; line-height: 1.2;
  letter-spacing: normal; text-transform: none;
  border-radius: var(--radius-md); border: 1px solid transparent; box-shadow: none; margin-bottom: 0;
  transition: background-color var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard);
}
.btn:focus, .btn.focus { box-shadow: none; }
/* Motion: press feedback (DESIGN_SYSTEM.md §7). Scale, not size, so nothing around it moves. */
.btn, .ns-icon-btn { transition-property: background-color, border-color, color, transform; transition-duration: var(--motion-fast); transition-timing-function: var(--ease-standard); }
.btn:not(:disabled):not(.disabled):active, .ns-icon-btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: var(--focus-width) solid var(--focus-color); outline-offset: var(--focus-offset); }
.btn-lg { min-height: var(--control-h); font-size: var(--text-base); padding: 0 var(--space-6); }
.btn-sm { min-height: var(--control-h-sm); padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-block { width: 100%; }
.btn-primary, .btn-primary:not(:disabled):not(.disabled):active {
  background: var(--color-primary); border-color: var(--color-primary); color: var(--color-primary-fg); opacity: 1;
}
.btn-primary:hover, .btn-primary:focus { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: var(--color-primary-fg); opacity: 1; }
.btn-primary:not(:disabled):not(.disabled):active { background: var(--blue-800); border-color: var(--blue-800); }
.btn-secondary, .btn-outline-primary, .btn-light, .btn-dark, .btn-success, .btn-info, .btn-outline-info {
  background: var(--color-surface); color: var(--color-text-brand); border-color: var(--color-border);
}
.btn-secondary:hover, .btn-outline-primary:hover, .btn-light:hover, .btn-dark:hover, .btn-success:hover, .btn-info:hover, .btn-outline-info:hover {
  background: var(--blue-50); border-color: var(--blue-300); color: var(--color-text-brand);
}
.btn-danger { background: var(--color-surface); color: var(--color-error); border-color: color-mix(in oklch, var(--color-error) 45%, var(--color-surface)); }
.btn-danger:hover { background: var(--status-canceled-bg); color: var(--status-canceled-fg); border-color: var(--color-error); }

/* ---- Form fields (DESIGN_SYSTEM.md §4) ------------------------------------ */
.form-control {
  height: var(--control-h); padding: 0 var(--space-3);
  font-family: var(--font-body); font-size: var(--text-sm); color: var(--color-text);
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  box-shadow: none;
  transition: border-color var(--motion-fast) var(--ease-standard);
}
textarea.form-control { height: auto; padding: var(--space-3); line-height: 1.5; }
.form-control:hover { border-color: var(--blue-300); }
.form-control:focus {
  border-color: var(--color-primary); box-shadow: none;
  outline: var(--focus-width) solid var(--focus-color); outline-offset: var(--focus-offset);
}
.form-control::placeholder { color: var(--color-text-muted); }
.form-control:disabled, .form-control[readonly] { background: var(--neutral-100); color: var(--neutral-700); }
label { font-size: var(--text-sm); font-weight: 600; color: var(--blue-900); margin-bottom: var(--space-1); }

/* ---- Alerts -------------------------------------------------------------- */
.alert { border: 0; border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); font-size: var(--text-sm); display: flex; gap: var(--space-2); align-items: baseline; }
.alert > [class^="ti-"] { flex-shrink: 0; }
/* Motion: guide attention to a new message (fade + short rise), once, on render. */
.alert { animation: ns-rise var(--motion-base) var(--ease-out) both; }
@keyframes ns-rise { from { opacity: 0; transform: translateY(var(--space-1)); } to { opacity: 1; transform: none; } }
.alert-danger { background: var(--status-canceled-bg); color: var(--status-canceled-fg); }
.alert-success { background: var(--status-completed-bg); color: var(--status-completed-fg); }
.alert-warning { background: var(--status-pending-bg); color: var(--status-pending-fg); }
.alert-info { background: var(--blue-50); color: var(--blue-900); }
.ns-messages { display: grid; gap: var(--space-2); margin-bottom: var(--space-5); }

/* ==========================================================================
   Kit: content components (DESIGN_SYSTEM.md §4). Class prefix ns-.
   Template partials that use them live in templates/components/.
   ========================================================================== */

/* Title row: H1 + context line on the left, actions on the right (no second title bar) */
.ns-title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin: 0 0 var(--space-5); }
.ns-title-row h1 { margin: 0; font-size: var(--text-2xl); font-weight: 700; line-height: 1.2; }
.ns-title-row .ns-context { display: block; margin-top: var(--space-1); font-size: var(--text-sm); color: var(--neutral-700); }

/* Layout: main column + right rail (rail joins the flow below 1100px) */
.ns-stack { display: grid; gap: var(--space-5); }
.ns-layout { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail-width); gap: var(--space-5); align-items: start; }
.ns-rail { display: grid; gap: var(--space-5); }
.ns-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); align-items: start; }

/* Card */
.ns-card { background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); min-width: 0; }
.ns-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--neutral-100);
}
.ns-card-head h2 { margin: 0; font-size: var(--text-base); font-weight: 700; }
.ns-card-head .ns-meta { font-size: var(--text-xs); color: var(--color-text-muted); }
.ns-card-body { padding: var(--space-5); }
.ns-card-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--neutral-100); }

/* Stat cards */
.ns-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5); }
.ns-stat { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-5); }
.ns-stat-tile { flex-shrink: 0; width: 52px; height: 52px; border-radius: var(--radius-lg); display: grid; place-items: center; background: var(--sky-50); color: var(--sky-600); font-size: var(--text-xl); }
.ns-stat p { margin: 0; color: var(--color-text-muted); font-size: var(--text-sm); line-height: 1.3; }
.ns-stat strong { display: block; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--text-3xl); font-weight: 500; color: var(--blue-900); line-height: 1.15; }
.ns-stat small { display: block; font-size: var(--text-xs); color: var(--color-text-muted); }
.ns-stat a small { color: var(--color-text-brand); }

/* Next-up card (Deep Navy panel) */
.ns-next { background: var(--color-bg-inverse); color: var(--blue-100); border-radius: var(--radius-xl); padding: var(--space-5); --focus-color: var(--color-focus-ring); }
.ns-next .ns-eyebrow { margin: 0; color: var(--sky-300); font-weight: 600; font-size: var(--text-sm); }
.ns-next h2 { margin: var(--space-1) 0; color: var(--color-text-inverse); font-size: var(--text-2xl); font-weight: 700; }
.ns-next p { margin: 0; color: var(--blue-200); }
.ns-next dl { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-4); margin: var(--space-4) 0; font-size: var(--text-sm); }
.ns-next dt { color: var(--blue-200); font-weight: 400; }
.ns-next dd { margin: 0; color: var(--color-text-inverse); }
.ns-next .ns-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ns-next p + .ns-actions { margin-top: var(--space-4); }
.ns-next .btn-primary { background: var(--color-surface); border-color: var(--color-surface); color: var(--blue-900); }
.ns-next .btn-primary:hover { background: var(--blue-50); border-color: var(--blue-50); color: var(--blue-900); }
.ns-next .btn-secondary { background: transparent; color: var(--color-text-inverse); border-color: var(--blue-700); }
.ns-next .btn-secondary:hover { background: var(--blue-800); color: var(--color-text-inverse); border-color: var(--blue-700); }
.ns-next.is-empty h2 { font-size: var(--text-lg); }

/* Bar chart (CSS only): values set per bar with style="--v:<0-100>" */
.ns-bars { list-style: none; margin: 0; padding: var(--space-4) var(--space-5) var(--space-5); display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--space-2); height: 180px; align-items: end; }
.ns-bars li { display: grid; grid-template-rows: 1fr auto auto; justify-items: center; height: 100%; gap: 2px; }
.ns-bar { align-self: end; width: 100%; max-width: 24px; height: max(2px, calc(var(--v) * 1%)); background: var(--blue-200); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.ns-bars li.is-current .ns-bar { background: var(--sky-500); }
.ns-bars .ns-val { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--blue-900); }
.ns-bars .ns-lbl { font-size: var(--text-xs); color: var(--color-text-muted); }

/* Status pill: dot + word, never colour alone */
.ns-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px var(--space-3); border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 600; line-height: 1.6; white-space: nowrap; }
.ns-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ns-pill--pending { background: var(--status-pending-bg); color: var(--status-pending-fg); }
.ns-pill--completed { background: var(--status-completed-bg); color: var(--status-completed-fg); }
.ns-pill--canceled { background: var(--status-canceled-bg); color: var(--status-canceled-fg); }
.ns-pill--neutral { background: var(--neutral-100); color: var(--neutral-800); }

/* ID chip (patient ID next to a name) */
.ns-chip { display: inline-block; padding: 0 var(--space-2); border-radius: var(--radius-sm); background: var(--color-bg-brand); color: var(--blue-800); font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500; vertical-align: middle; }

/* Table: no zebra, no vertical rules, row action last */
.ns-table-wrap { overflow-x: auto; }
.ns-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); color: var(--color-text); }
.ns-table th {
  text-align: start; font-size: var(--text-xs); font-weight: 600; color: var(--neutral-700);
  padding: var(--space-3); border-bottom: 1px solid var(--color-border); white-space: nowrap; background: none;
}
.ns-table td { padding: var(--space-3); border-bottom: 1px solid var(--neutral-100); vertical-align: middle; }
.ns-table tbody tr:last-child td { border-bottom: 0; }
.ns-table tbody tr:hover td { background: var(--blue-50); }
.ns-table th:first-child, .ns-table td:first-child { padding-inline-start: var(--space-5); }
.ns-table th:last-child, .ns-table td:last-child { padding-inline-end: var(--space-5); }
.ns-table .ns-num { text-align: end; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ns-table th.ns-num { font-family: var(--font-body); }
.ns-table .ns-time { font-family: var(--font-mono); font-weight: 500; color: var(--blue-900); white-space: nowrap; }
.ns-table .ns-who strong { display: block; font-weight: 600; color: var(--color-text); }
.ns-table .ns-who a { color: var(--color-text); text-decoration: none; }
.ns-table .ns-who a:hover strong { color: var(--color-text-brand); text-decoration: underline; }
.ns-table .ns-who span { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-text-muted); }
.ns-table .ns-action { text-align: end; white-space: nowrap; }
.ns-table .ns-action .btn + .btn { margin-inline-start: var(--space-1); }

/* Detail list (key/value, GOV.UK summary-list pattern) */
.ns-dl { margin: 0; }
.ns-dl > div { display: grid; grid-template-columns: minmax(120px, 30%) 1fr auto; gap: var(--space-4); padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--neutral-100); align-items: baseline; }
.ns-dl > div:last-child { border-bottom: 0; }
.ns-dl dt { font-size: var(--text-sm); font-weight: 500; color: var(--neutral-700); }
.ns-dl dd { margin: 0; font-size: var(--text-sm); color: var(--color-text); overflow-wrap: anywhere; white-space: pre-line; }
.ns-dl .ns-empty-value { color: var(--color-text-muted); }

/* Empty state */
.ns-empty { padding: var(--space-8) var(--space-5); text-align: center; display: grid; gap: var(--space-3); justify-items: center; }
.ns-empty p { margin: 0; color: var(--neutral-700); max-width: 42ch; }

/* Pagination */
.ns-pagination { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.ns-pagination a, .ns-pagination span {
  display: inline-grid; place-items: center; min-width: 40px; min-height: 40px; padding: 0 var(--space-3);
  border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 500; text-decoration: none; color: var(--color-text-brand);
}
.ns-pagination a:hover { background: var(--blue-50); text-decoration: none; }
.ns-pagination [aria-current="page"] { background: var(--color-primary); color: var(--color-primary-fg); }
.ns-pagination .ns-gap { color: var(--color-text-muted); min-width: 24px; padding: 0; }

/* Forms (DESIGN_SYSTEM.md §4 form field) */
.ns-form-page { max-width: 760px; }   /* forms read best at a comfortable line length */
.ns-form { display: grid; gap: var(--space-5); }
.ns-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-5); }
.ns-form-grid .ns-span-2 { grid-column: 1 / -1; }
.ns-form-section { margin: 0; font-size: var(--text-base); font-weight: 700; color: var(--blue-900); }
.ns-hint { font-size: var(--text-xs); font-weight: 400; color: var(--neutral-700); }
.ns-field label { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1); line-height: 1.5; }   /* one line box even with the smaller "(optional)" */
.ns-field .ns-error { font-size: var(--text-xs); font-weight: 600; color: var(--status-canceled-fg); }
.ns-field.has-error .form-control { border-color: var(--color-error); }
.ns-form-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
select.form-control { padding-inline-end: var(--space-8); }
select.form-control:not([size]):not([multiple]) { height: var(--control-h); }   /* Bootstrap 4.0 sets 42px */

/* Time-slot buttons (booking): radio inputs styled as a grid of times */
fieldset.ns-field { border: 0; margin: 0; padding: 0; min-width: 0; }
.ns-legend { font-size: var(--text-sm); font-weight: 600; color: var(--blue-900); margin-bottom: var(--space-2); display: flex; gap: var(--space-1); align-items: baseline; width: auto; }
.ns-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: var(--space-2); }
.ns-slots .ns-slot { position: relative; margin: 0; display: block; }   /* not the flex label rule of .ns-field */
.ns-slot input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.ns-slot span {
  display: grid; place-items: center; min-height: var(--control-h);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface);
  font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 500; color: var(--blue-900);
  transition: background-color var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard);
}
.ns-slot:hover span { border-color: var(--blue-300); background: var(--blue-50); }
.ns-slot input:checked + span { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-primary-fg); }
.ns-slot input:focus-visible + span { outline: var(--focus-width) solid var(--focus-color); outline-offset: var(--focus-offset); }
.ns-slot.is-taken span { background: var(--neutral-100); border-color: var(--neutral-100); color: var(--neutral-600); text-decoration: line-through; }
.ns-slot input:disabled { cursor: not-allowed; }

/* Filter bar above lists */
.ns-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-4); padding: var(--space-4) var(--space-5); margin-bottom: var(--space-5); }
.ns-filters .ns-field { min-width: 180px; flex: 0 1 220px; }
@media (max-width: 640px) { .ns-filters { padding: var(--space-4); gap: var(--space-3); } .ns-filters .ns-field { min-width: 0; flex: 1 1 calc(50% - var(--space-3)); } }

/* Secondary links row (Print / Excel etc.) */
.ns-tools { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Phone: stacked tables, single column layouts */
@media (max-width: 1100px) {
  .ns-layout { grid-template-columns: minmax(0, 1fr); }
  .ns-layout > .ns-rail { display: contents; }
  .ns-layout .ns-first-on-small { order: -1; }
  .ns-layout > .ns-main-col { display: contents; }   /* dashboard: stats, next up, today's list */
  .ns-layout .ns-stats--lead { order: -2; }
}
@media (max-width: 900px) { .ns-grid-2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .ns-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
  .ns-stat { padding: var(--space-3); }
  .ns-stat-tile { display: none; }
  .ns-stat p { font-size: var(--text-xs); }
  .ns-stat strong { font-size: var(--text-xl); overflow-wrap: anywhere; }
  .ns-stat small { display: none; }
  .ns-card-head, .ns-card-body, .ns-card-foot { padding-inline-start: var(--space-4); padding-inline-end: var(--space-4); }
  .ns-form-grid { grid-template-columns: minmax(0, 1fr); }
  .ns-dl > div { grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-1) var(--space-3); padding: var(--space-3) var(--space-4); }
  .ns-dl dt { grid-column: 1 / -1; font-size: var(--text-xs); }
  /* Stacked table: every row becomes a small card; cells show their label (data-label) */
  .ns-table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ns-table--stack, .ns-table--stack tbody, .ns-table--stack tr, .ns-table--stack td { display: block; width: 100%; }
  .ns-table--stack tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--neutral-100); }
  .ns-table--stack tbody tr:last-child { border-bottom: 0; }
  .ns-table--stack tbody tr:hover td { background: none; }
  .ns-table--stack td, .ns-table--stack td:first-child, .ns-table--stack td:last-child { padding: 2px 0; border: 0; text-align: start; }
  .ns-table--stack:not(.ns-table--schedule) td[data-label]:not(.ns-who):not(.ns-action)::before { content: attr(data-label) ": "; color: var(--color-text-muted); font-family: var(--font-body); font-size: var(--text-xs); }
  .ns-table--stack .ns-num { text-align: start; }
  .ns-table--stack .ns-action { padding-top: var(--space-2); }
  .ns-table--stack .ns-action .btn { min-width: 0; }
  /* Compact list rows: name + action on top, the other cells as one small wrapped line */
  .ns-table--compact tr { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--space-3); row-gap: 2px; }
  .ns-table--compact td { width: auto; }
  .ns-table--compact .ns-who { flex: 1 1 calc(100% - 140px); min-width: 0; order: 0; }   /* leaves room only for the action, so details wrap below */
  .ns-table--compact .ns-action { flex: 0 0 auto; order: 1; padding-top: 0; }
  .ns-table--compact td:not(.ns-who):not(.ns-action) { order: 2; font-size: var(--text-xs); color: var(--neutral-700); }
  .ns-table--compact .ns-who:has(~ .ns-action .btn + .btn) { flex-basis: 100%; }        /* two actions: name takes the row... */
  .ns-table--compact .ns-action:has(.btn + .btn) { order: 3; flex-basis: 100%; text-align: start; padding-top: var(--space-2); }  /* ...buttons go last */
  .ns-table--compact td:not(.ns-who):not(.ns-action) + td:not(.ns-who):not(.ns-action)::after { content: none; }
  /* Schedule tables (time-led): compact rows like the approved direction, no per-cell labels */
  .ns-table--schedule tr { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; column-gap: var(--space-3); row-gap: 2px; align-items: center; }
  .ns-table--schedule .ns-time { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
  .ns-table--schedule .ns-who { grid-column: 2; grid-row: 1 / span 2; }
  .ns-table--schedule .ns-cell-status { grid-column: 3; grid-row: 1; text-align: end; }
  .ns-table--schedule .ns-action { grid-column: 3; grid-row: 2 / span 2; padding-top: 0; }
  .ns-table--schedule .ns-cell-muted { grid-column: 2; font-size: var(--text-xs); color: var(--neutral-700); }
}

/* ==========================================================================
   Official documents (templates/print/base.html): invoice, prescription, patient
   record, visit summary and reports. A4 paper on screen, letterhead, reference,
   page numbers in print. The toolbar never prints.
   ========================================================================== */
.ns-print-page { background: var(--neutral-100); min-height: 100vh; }
.ns-print-bar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: var(--space-3);
  max-width: calc(210mm + 2 * var(--space-6)); margin: 0 auto; padding: var(--space-4) var(--space-6);
  background: var(--neutral-100);
}
.ns-print-bar-title { flex: 1; text-align: center; font-weight: 600; color: var(--blue-900); font-size: var(--text-sm); }
.ns-print-bar-title .ns-mono { color: var(--neutral-700); font-weight: 500; margin-inline-start: var(--space-2); }
.ns-paper {
  width: 210mm; max-width: calc(100% - 2 * var(--space-4)); min-height: 297mm; margin: 0 auto var(--space-12);
  background: var(--color-surface); box-shadow: var(--shadow-pop); border-radius: var(--radius-sm);
  padding: 16mm 15mm 14mm; color: var(--color-text); font-size: var(--text-sm);
  display: flex; flex-direction: column;
}
.ns-letterhead { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-8); }
.ns-letterhead-brand { display: grid; gap: var(--space-4); }
.ns-letterhead-brand img { width: 190px; height: auto; display: block; }
.ns-letterhead-brand .ns-address { font-family: 'Noto Sans Arabic', var(--font-body); font-size: var(--text-sm); color: var(--blue-900); }
.ns-letterhead-brand address { margin: 0; display: grid; gap: var(--space-1); font-style: normal; font-size: var(--text-xs); color: var(--neutral-700); line-height: 1.5; }
.ns-letterhead-doc { text-align: end; display: grid; gap: var(--space-3); justify-items: end; }
.ns-letterhead-doc h1 { margin: 0; font-size: var(--text-3xl); font-weight: 800; letter-spacing: -0.01em; color: var(--blue-900); line-height: 1.1; }
.ns-letterhead-doc dl { margin: 0; display: grid; gap: var(--space-1); font-size: var(--text-xs); }
.ns-letterhead-doc dl > div { display: flex; justify-content: flex-end; gap: var(--space-3); }
.ns-letterhead-doc dt { font-weight: 500; color: var(--neutral-700); }
.ns-letterhead-doc dd { margin: 0; color: var(--color-text); font-weight: 600; }
/* Brand rule under the letterhead: Smile Blue line with a Fresh Sky lead (echoes the swoosh) */
.ns-paper-rule { position: relative; height: 3px; margin: var(--space-6) 0 var(--space-2); background: var(--color-primary); border-radius: var(--radius-full); }
.ns-paper-rule::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 56px; background: var(--color-accent); border-radius: var(--radius-full); }

.ns-doc-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); padding: var(--space-5) 0; }
.ns-doc-parties h2, .ns-doc-section { font-family: var(--font-body); font-size: var(--text-xs); font-weight: 600; color: var(--sky-600); margin: 0 0 var(--space-2); }
.ns-doc-section { margin: var(--space-6) 0 var(--space-3); padding-bottom: var(--space-2); border-bottom: 1px solid var(--color-border); display: flex; align-items: baseline; gap: var(--space-2); }
.ns-doc-count { font-family: var(--font-mono); color: var(--neutral-700); font-weight: 500; }
.ns-doc-parties p { margin: 0; line-height: 1.65; }
.ns-doc-parties strong { font-size: var(--text-base); color: var(--blue-900); }
.ns-doc-text { margin: 0; white-space: pre-line; line-height: 1.6; }
.ns-doc-dl { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-6); }
.ns-doc-dl > div { display: grid; gap: 2px; break-inside: avoid; }
.ns-doc-dl dt { font-size: var(--text-xs); font-weight: 500; color: var(--neutral-700); }
.ns-doc-dl dd { margin: 0; white-space: pre-line; }
.ns-doc-table { font-size: var(--text-xs); }
.ns-doc-table th { color: var(--blue-900); border-bottom: 1.5px solid var(--blue-900); padding: var(--space-2) var(--space-2); }
.ns-doc-table td { padding: var(--space-2); border-bottom: 1px solid var(--neutral-100); }
.ns-doc-table th:first-child, .ns-doc-table td:first-child { padding-inline-start: 0; }
.ns-doc-table th:last-child, .ns-doc-table td:last-child { padding-inline-end: 0; }
.ns-doc-table tbody tr:hover td { background: none; }
.ns-doc-table tr { break-inside: avoid; }
.ns-doc-table--dense td { padding-top: 3px; padding-bottom: 3px; }
.ns-doc-totals { margin: var(--space-4) 0 0 auto; width: min(100%, 300px); border-collapse: collapse; }
.ns-doc-totals--left { margin-inline-start: 0; }
.ns-doc-totals th { text-align: start; font-weight: 500; color: var(--neutral-700); padding: var(--space-1) 0; }
.ns-doc-totals td { text-align: end; font-family: var(--font-mono); font-variant-numeric: tabular-nums; padding: var(--space-1) 0; }
.ns-doc-totals tr.is-total th, .ns-doc-totals tr.is-total td { border-top: 1.5px solid var(--blue-900); padding-top: var(--space-3); font-size: var(--text-lg); font-weight: 700; color: var(--blue-900); }
.ns-doc-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); margin: var(--space-5) 0; }
.ns-doc-kpis > div { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); display: grid; gap: 2px; }
.ns-doc-kpis span { font-size: var(--text-xs); color: var(--neutral-700); }
.ns-doc-kpis strong { font-family: var(--font-mono); font-size: var(--text-lg); font-weight: 500; color: var(--blue-900); }
.ns-doc-kpis .is-key { border-color: var(--color-primary); }
.ns-doc-summary { margin: var(--space-5) 0 var(--space-3); color: var(--neutral-700); }
.ns-doc-summary strong { color: var(--blue-900); font-family: var(--font-mono); }
.ns-doc-empty { margin: var(--space-3) 0; color: var(--neutral-700); font-style: italic; }
.ns-doc-check { width: 64px; text-align: center; }
.ns-doc-box { display: inline-block; width: 14px; height: 14px; border: 1.5px solid var(--neutral-700); border-radius: 3px; vertical-align: middle; }
.ns-doc-rx { margin: var(--space-6) 0; display: grid; grid-template-columns: auto 1fr; gap: var(--space-5); align-items: start; }
.ns-doc-rx .ns-rx-mark { font-family: var(--font-display); font-size: var(--text-5xl); font-weight: 800; color: var(--color-primary); line-height: 0.9; }
.ns-doc-rx .ns-rx-body { white-space: pre-line; font-size: var(--text-base); line-height: 1.8; min-height: 200px; padding-top: var(--space-2); }
.ns-doc-signs { display: flex; justify-content: flex-end; gap: var(--space-10); margin-top: var(--space-12); break-inside: avoid; }
.ns-doc-sign { min-width: 200px; text-align: center; border-top: 1px solid var(--neutral-800); padding-top: var(--space-2); font-size: var(--text-xs); color: var(--neutral-700); }
.ns-paper-foot { margin-top: auto; padding-top: var(--space-8); display: flex; justify-content: space-between; gap: var(--space-4); font-size: 10px; color: var(--neutral-700); border-top: 1px solid var(--neutral-100); }
.ns-paper-foot span { padding-top: var(--space-2); }
@media screen and (max-width: 820px) {   /* screen only: an A4 page is ~680px wide and must keep the desktop layout */
  .ns-paper { width: auto; min-height: 0; padding: var(--space-6) var(--space-5); }
  .ns-letterhead { flex-direction: column; gap: var(--space-4); }
  .ns-letterhead-doc { text-align: start; justify-items: start; }
  .ns-letterhead-doc dl > div { justify-content: flex-start; }
  .ns-doc-parties, .ns-doc-dl { grid-template-columns: minmax(0, 1fr); }
  .ns-doc-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ns-paper-foot { flex-direction: column; }
  .ns-print-bar-title { display: none; }
  .ns-print-bar { justify-content: space-between; padding: var(--space-3) var(--space-4); }
  .ns-doc-table { display: block; overflow-x: auto; }
}
@page {
  size: A4; margin: 14mm 14mm 16mm;
  @bottom-left { content: "New Smile Dental Clinic"; font-family: "DM Sans", sans-serif; font-size: 8pt; color: var(--neutral-600); }
  @bottom-right { content: "Page " counter(page) " of " counter(pages); font-family: "DM Sans", sans-serif; font-size: 8pt; color: var(--neutral-600); }
}
@media print {
  .ns-print-bar, .ns-no-print, .ns-title-actions, .ns-messages, .ns-tools, .ns-table .ns-action, .ns-pagination, .ns-filters { display: none !important; }
  .ns-print-page, body { background: var(--color-surface); }
  .ns-paper { width: auto; max-width: none; min-height: 0; margin: 0; padding: 0; box-shadow: none; border-radius: 0; }
  .ns-main { padding: 0; }
  .ns-pill { border: 1px solid currentColor; }
  a { color: inherit; text-decoration: none; }
}

/* ---- Sign-in (DESIGN_SYSTEM.md §5 Login) --------------------------------
   Deep Navy brand panel (reversed logo, headline, decorative smile curves drawn
   for this page) + a white form panel. No gradients, glows or logo effects. */
.ns-signin-page { background: var(--color-surface); }
.ns-signin { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); }
.ns-signin-brand {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--color-bg-inverse); color: var(--blue-100);
  display: grid; grid-template-rows: auto 1fr auto; gap: var(--space-10);
  padding: var(--space-12) clamp(var(--space-8), 5vw, var(--space-20));
  --focus-color: var(--color-focus-ring);
}
.ns-signin-logo { width: 220px; height: auto; display: block; }
.ns-signin-pitch { align-self: center; max-width: 520px; display: grid; gap: var(--space-5); }
.ns-signin-headline {
  margin: 0; font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em;
  font-size: clamp(var(--text-4xl), 4.6vw, var(--text-6xl)); line-height: 1.02; color: var(--color-text-inverse);
}
.ns-signin-headline span { color: var(--sky-300); display: block; }
.ns-signin-lead { margin: 0; max-width: 38ch; font-size: var(--text-lg); line-height: 1.55; color: var(--blue-200); }
.ns-signin-tags { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ns-signin-tags li {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4); border: 1px solid var(--blue-700); border-radius: var(--radius-full);
  font-size: var(--text-sm); color: var(--blue-100);
}
.ns-signin-tags [class^="ti-"] { color: var(--sky-300); }
.ns-signin-meta { margin: 0; display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--blue-200); }
.ns-signin-meta [class^="ti-"] { color: var(--sky-300); }
.ns-signin-curves {
  position: absolute; z-index: -1; inset-inline-end: calc(-1 * var(--space-6)); bottom: calc(-1 * var(--space-12)); width: clamp(340px, 46%, 560px); height: auto;
  fill: none; stroke: var(--blue-800); stroke-width: 2; stroke-linecap: round;
}
.ns-signin-curves .is-accent { stroke: var(--sky-500); stroke-width: 3; }
.ns-signin-curves .is-spark { fill: var(--sky-500); stroke: none; }

.ns-signin-main { display: grid; grid-template-rows: 1fr auto; justify-items: center; padding: var(--space-10) var(--space-8) var(--space-6); }
.ns-signin-card { align-self: center; width: 100%; max-width: 400px; display: grid; gap: var(--space-5); }
.ns-signin-eyebrow { margin: 0 0 calc(-1 * var(--space-3)); font-size: var(--text-sm); font-weight: 600; color: var(--sky-600); }
.ns-signin-card h1 { margin: 0; font-size: var(--text-4xl); font-weight: 800; letter-spacing: -0.015em; color: var(--blue-900); line-height: 1.1; }
.ns-signin-sub { margin: calc(-1 * var(--space-2)) 0 var(--space-1); color: var(--neutral-700); line-height: 1.55; }
.ns-signin-field { display: grid; gap: var(--space-2); }
.ns-signin-field label { margin: 0; font-size: var(--text-sm); font-weight: 600; color: var(--blue-900); }
.ns-input-icon { position: relative; }
.ns-input-icon > [class^="ti-"] { position: absolute; inset-inline-start: var(--space-4); top: 50%; transform: translateY(-50%); color: var(--neutral-600); pointer-events: none; transition: color var(--motion-fast) var(--ease-standard); }
.ns-input-icon .form-control { height: 52px; padding-inline-start: var(--space-12); font-size: var(--text-base); border-radius: var(--radius-lg); background: var(--color-bg-brand); border-color: var(--color-bg-brand); }
.ns-input-icon .form-control:hover { border-color: var(--blue-200); }
.ns-input-icon .form-control:focus { background: var(--color-surface); border-color: var(--color-primary); }
.ns-input-icon:focus-within > [class^="ti-"] { color: var(--color-primary); }
.ns-input-icon.has-action .form-control { padding-inline-end: var(--space-12); }
.ns-reveal {
  position: absolute; inset-inline-end: var(--space-1); top: 50%; transform: translateY(-50%);
  width: var(--control-h); height: var(--control-h); border: 0; border-radius: var(--radius-md); background: transparent;
  color: var(--neutral-700); display: grid; place-items: center; cursor: pointer;
  transition: color var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard);
}
.ns-reveal:hover { background: var(--blue-50); color: var(--color-primary); }
.ns-reveal[aria-pressed="true"] { color: var(--color-primary); }
.ns-signin-caps { display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-xs); font-weight: 600; color: var(--status-pending-fg); }
.ns-signin-submit { height: 52px; margin-top: var(--space-1); border-radius: var(--radius-lg); font-size: var(--text-base); gap: var(--space-3); }
.ns-signin-submit [class^="ti-"] { transition: transform var(--motion-fast) var(--ease-out); }
.ns-signin-submit:hover [class^="ti-"] { transform: translateX(var(--space-1)); }
.ns-signin-submit[aria-busy="true"] { opacity: 0.85; cursor: progress; }
.ns-signin-help { margin: 0; text-align: center; font-size: var(--text-sm); color: var(--neutral-700); }
.ns-signin-foot { margin: var(--space-8) 0 0; font-size: var(--text-xs); color: var(--neutral-600); }
.ns-signin .alert { margin: 0; }

@media (max-width: 900px) {
  .ns-signin { grid-template-columns: minmax(0, 1fr); }
  .ns-signin-brand { grid-template-rows: auto auto; gap: var(--space-6); padding: var(--space-8) var(--space-6) var(--space-10); }
  .ns-signin-logo { width: var(--header-logo-sm); }
  .ns-signin-pitch { gap: var(--space-3); }
  .ns-signin-headline { font-size: var(--text-4xl); }
  .ns-signin-headline span { display: inline; }
  .ns-signin-lead { font-size: var(--text-base); }
  .ns-signin-tags, .ns-signin-meta { display: none; }
  .ns-signin-curves { width: 300px; inset-inline-end: calc(-1 * var(--space-16)); bottom: calc(-1 * var(--space-20)); }
  .ns-signin-main { padding: var(--space-8) var(--space-5) var(--space-6); }
  .ns-signin-card h1 { font-size: var(--text-3xl); }
}

.ns-field { display: grid; gap: var(--space-1); align-content: start; }   /* stretched cells must not grow the label row */
.ns-field label { margin: 0; }

/* ---- Error page ---------------------------------------------------------- */
.ns-error-page { min-height: 100vh; display: grid; place-items: center; padding: var(--space-6); background: var(--color-bg-brand); text-align: center; }
.ns-error-card { max-width: 440px; display: grid; gap: var(--space-4); justify-items: center; }
.ns-error-card img { width: var(--header-logo-sm); height: auto; }
.ns-error-card h1 { margin: 0; font-size: var(--text-3xl); font-weight: 700; }
.ns-error-card p { margin: 0; color: var(--color-text-muted); }

/* ---- Responsive frame ---------------------------------------------------- */
@media (pointer: coarse) { .ns-search kbd { display: none; } }   /* no "/" key on touch */
/* Touch: 44px targets for buttons and nav links (DESIGN_SYSTEM.md §4, §8) */
@media (pointer: coarse), (max-width: 640px) {
  .btn, .ns-nav a { min-height: var(--control-h); }
  .btn-sm { min-height: var(--control-h); }
  .ns-pagination a, .ns-pagination span { min-width: var(--control-h); min-height: var(--control-h); }
}
@media (max-width: 640px) {
  .ns-shell { padding: 0; }
  .ns-header { flex-wrap: wrap; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: 0; }
  .ns-logo img { width: var(--header-logo-sm); }
  .ns-header-actions { margin-inline-start: auto; }
  .ns-search { order: 3; flex-basis: 100%; max-width: none; margin: 0; }
  .ns-search kbd { display: none; }
  .ns-nav { border-radius: 0; padding: var(--space-2) var(--space-3); }
  .ns-main { padding: var(--space-5) var(--space-4) var(--space-8); }
}

/* ---- Print: the frame never prints --------------------------------------- */
@media print {
  .ns-header, .ns-nav, .ns-footer, .ns-skip { display: none !important; }
  body { background: var(--color-surface); }
  .ns-shell { max-width: none; padding: 0; }
}

/* ---- Reduced motion (DESIGN_SYSTEM.md §7) -------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: var(--motion-off) !important; animation-iteration-count: 1 !important; transition-duration: var(--motion-off) !important; scroll-behavior: auto !important; }
}

/* 7-day strip on the dashboard (amendment I) */
.ns-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--space-2); }
.ns-day { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); min-height: 44px; padding: var(--space-3) var(--space-1); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); color: var(--color-text); text-decoration: none; }
.ns-day:hover { border-color: var(--color-primary); color: var(--color-text); }
.ns-day.is-today { background: var(--color-bg-inverse); border-color: var(--color-bg-inverse); color: var(--color-text-inverse); }
.ns-day-name { font-size: var(--text-xs); color: inherit; opacity: .8; }
.ns-day-num { font-family: var(--font-mono); font-size: var(--text-xl); font-weight: 600; line-height: 1; }
.ns-day-count { min-width: 1.75rem; padding: 0 var(--space-2); border-radius: 999px; background: var(--sky-50); color: var(--sky-700); font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 600; text-align: center; }
.ns-day.is-today .ns-day-count { background: var(--sky-500); color: var(--blue-900); }
@media (max-width: 575.98px) { .ns-week { gap: var(--space-1); } .ns-day { padding: var(--space-2) 0; } .ns-day-num { font-size: var(--text-base); } }

/* Upcoming calls page (amendment I) */
.ns-group-row th { padding: var(--space-3) var(--space-5) var(--space-2); background: var(--color-surface-muted); color: var(--blue-900); font-weight: 600; font-size: var(--text-sm); }
.ns-action .ns-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }
.ns-action .ns-actions form { margin: 0; }

/* Patient cancel page: public, Arabic, no login (amendment I) */
.ns-public { min-height: 100vh; margin: 0; padding: var(--space-5) var(--space-4); background: var(--color-bg-brand); font-family: 'Noto Sans Arabic', var(--font-body); color: var(--color-text); }
.ns-public-card { max-width: 30rem; margin: 0 auto; padding: var(--space-6) var(--space-5); background: var(--color-surface); border-radius: var(--radius-xl); border: 1px solid var(--color-border); }
.ns-public-logo { display: block; margin: 0 auto var(--space-5); height: auto; }
.ns-public h1 { margin: 0 0 var(--space-4); font-family: inherit; font-size: var(--text-2xl); font-weight: 700; color: var(--blue-900); text-align: center; }
.ns-public .ns-dl { margin-bottom: var(--space-5); }
.ns-public-form { display: grid; gap: var(--space-3); }
.ns-public-confirm { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; font-weight: 600; }
.ns-public-confirm input { width: 1.25rem; height: 1.25rem; }
.ns-public-contact { margin: var(--space-5) 0 0; font-size: var(--text-sm); color: var(--color-text-muted); text-align: center; }
.ns-share { display: grid; gap: var(--space-3); }
.ns-share .ns-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ns-doc-qr { display: flex; align-items: center; gap: var(--space-4); margin-top: var(--space-5); padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); break-inside: avoid; font-family: 'Noto Sans Arabic', var(--font-body); font-size: var(--text-sm); }
.ns-doc-qr svg { flex-shrink: 0; width: 96px; height: 96px; }
.ns-doc-qr p { margin: 0; }

/* Arabic, right to left (amendment I). Layout uses logical properties (inline-start/end), so it mirrors by itself;
   these are the few things that don't. */
[dir="rtl"] h1, [dir="rtl"] .ns-letterhead-doc h1, [dir="rtl"] .ns-signin-card h1, [dir="rtl"] .ns-signin-headline { letter-spacing: normal; }  /* spacing breaks joined Arabic letters */
[dir="rtl"] .ti-arrow-right, [dir="rtl"] .ti-arrow-left { display: inline-block; transform: scaleX(-1); }
[dir="rtl"] .ns-account .dropdown-menu { transform-origin: top left; }
.ns-lang-form { margin: 0; }
.ns-lang-btn { font-family: var(--font-body); font-weight: 700; font-size: var(--text-sm); }
.ns-signin-lang { align-self: flex-end; }
