/* ============================================================
   Cabinet Dr Benraouane — design system
   Calm · clinical · modern · mobile-first
   ============================================================ */

:root {
  /* --- brand: muted clinical teal ---------------------------- */
  --teal-50:  #f0faf5;
  --teal-100: #dbf3e6;
  --teal-200: #b7e6cc;
  --teal-300: #82d3ac;
  --teal-400: #4ebb89;
  --teal-500: #2aa073;
  --teal-600: #1b855e;
  --teal-700: #166a4d;
  --teal-800: #14553f;
  --teal-900: #0f4434;

  /* --- secondary: quiet indigo (used sparingly) ------------- */
  --indigo-50:  #f3f5fb;
  --indigo-100: #e3e8f5;
  --indigo-500: #5b6ee6;
  --indigo-600: #4656c2;
  --indigo-700: #3a479d;

  --accent:    var(--teal-600);
  --accent-2:  var(--indigo-600);
  --warn:      #d97706;
  --danger:    #dc2626;
  --ok:        #15803d;

  /* --- neutrals: warm, breathable --------------------------- */
  --bg:        #f7f6f3;              /* warm page background */
  --bg-elev:   #fdfdfc;              /* card surface (warm white) */
  --bg-soft:   #f1efea;              /* table head / muted card */
  --bg-sunk:   #ebe9e3;

  --ink-900:   #10151c;
  --ink-800:   #1e2530;
  --ink-700:   #333b48;
  --ink-600:   #4a5361;
  --ink-500:   #6b7280;
  --ink-400:   #8a90a0;
  --ink-300:   #b4b8c2;
  --ink-200:   #d9dbe2;
  --ink-100:   #ebe9e3;              /* warm divider */
  --ink-50:    #f3f1ec;

  --line:      #e7e4dd;              /* primary border color */
  --line-soft: #efede7;

  /* --- radius ---------------------------------------------- */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius:    16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  /* --- shadows: Linear / Notion feel (single soft shadow) -- */
  --shadow-1:  0 1px 2px rgba(16, 21, 28, .04);
  --shadow-2:  0 4px 14px -6px rgba(16, 21, 28, .10), 0 1px 2px rgba(16, 21, 28, .04);
  --shadow-3:  0 18px 40px -18px rgba(16, 21, 28, .22), 0 2px 4px rgba(16, 21, 28, .05);

  /* --- ring (focus) ---------------------------------------- */
  --ring:        0 0 0 3px rgba(42, 160, 115, .22);
  --ring-danger: 0 0 0 3px rgba(220, 38, 38, .18);

  /* --- layout ---------------------------------------------- */
  --sidebar-w: 248px;
  --topbar-h:  58px;

  /* --- type ------------------------------------------------ */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* --- motion ---------------------------------------------- */
  --dur-fast:  120ms;
  --dur-mid:   220ms;
  --ease:      cubic-bezier(.2,.7,.2,1);
}

/* ============================================================ reset */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-800);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv02','cv03','cv04','cv11';
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--teal-700); }
input, select, textarea, button { font: inherit; color: inherit; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* ============================================================ typography */

h1,h2,h3,h4 {
  color: var(--ink-900);
  letter-spacing: -0.015em;
  margin: 0 0 .6rem;
  font-weight: 600;
}
h1 { font-size: 24px; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 600; }
h3 { font-size: 15px; line-height: 1.4; font-weight: 600; }
p  { margin: 0 0 .8rem; }

/* de-emphasize shouty micro-labels */
.stat small,
.t thead th,
label.small,
label.f {
  text-transform: none;
  letter-spacing: 0;
}

/* ============================================================ shell */

.has-shell { padding-left: var(--sidebar-w); padding-top: var(--topbar-h); }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: #0c111b;
  color: #dfe4ee;
  display: flex; flex-direction: column;
  padding: 14px 10px 12px;
  z-index: 40;
  border-right: 1px solid rgba(255,255,255,.04);
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px 14px;
  color: #fff;
}
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--teal-400), var(--teal-600));
  display: grid; place-items: center;
  font-weight: 700; font-size: 16px; color: #fff;
  box-shadow: 0 4px 12px -4px rgba(42,160,115,.55);
  letter-spacing: -.02em;
}
.brand-txt strong { font-size: 14px; display: block; letter-spacing: -.01em; color: #fff; font-weight: 600; }
.brand-txt small  { font-size: 11.5px; color: #8892a6; font-weight: 500; }

.nav { margin-top: 8px; display: flex; flex-direction: column; gap: 1px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: 8px;
  color: #a9b2c4; font-weight: 500; font-size: 14px;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast);
}
.nav-link svg {
  width: 18px; height: 18px;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: .85; flex-shrink: 0;
}
.nav-link:hover {
  background: rgba(255,255,255,.045);
  color: #fff;
}
.nav-link:hover svg { opacity: 1; }
.nav-link.is-active {
  background: rgba(42,160,115,.14);
  color: #fff;
  box-shadow: inset 2px 0 0 var(--teal-400);
}
.nav-link.is-active svg { opacity: 1; color: var(--teal-300); }

.sidebar-foot { margin-top: auto; padding-top: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  background: rgba(255,255,255,.03);
  position: relative;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo-500), var(--teal-500));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}
.user-meta { min-width: 0; }
.user-meta strong { font-size: 13px; color: #fff; display: block; line-height: 1.2; font-weight: 600; }
.user-meta small  { color: #8892a6; font-size: 11.5px; }
.btn-ghost {
  margin-left: auto; width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: transparent; color: #a9b2c4;
  border: 0;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.btn-ghost svg { width: 15px; height: 15px; }
.btn-ghost:hover { background: rgba(220,38,38,.18); color: #ff9898; }

/* ============================================================ topbar */

.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: rgba(247, 246, 243, .78);
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  z-index: 20;
}
.topbar-title {
  font-weight: 600; color: var(--ink-900); font-size: 15px;
  letter-spacing: -.01em;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-700);
  display: none; place-items: center; cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.icon-btn:hover { background: var(--bg-soft); }
.icon-btn:focus { outline: 0; }
.icon-btn svg { width: 18px; height: 18px; }

.main { padding: 22px 26px 64px; max-width: 1400px; margin: 0 auto; }
.main-plain { padding: 0; min-height: 100vh; background: var(--bg); }

/* ============================================================ buttons */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 13px; border-radius: 10px;
  font-weight: 500; font-size: 14px;
  line-height: 1.2;
  border: 1px solid transparent;
  background: #fff; color: var(--ink-800);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--dur-fast), box-shadow var(--dur-fast),
              background var(--dur-fast), border-color var(--dur-fast),
              color var(--dur-fast);
}
.btn:hover { box-shadow: var(--shadow-2); }
.btn:active { transform: translateY(1px); }
/* No outline for mouse clicks; only show ring on keyboard focus */
.btn:focus { outline: 0; }
.btn:focus-visible,
.icon-btn:focus-visible,
.btn-ghost:focus-visible {
  outline: 0;
  box-shadow: var(--ring), var(--shadow-1);
}
.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--teal-600);
  color: #fff;
  border-color: var(--teal-600);
  box-shadow: 0 1px 2px rgba(16,21,28,.08), 0 4px 14px -6px rgba(27,133,94,.5);
}
.btn-primary:hover {
  background: var(--teal-700);
  border-color: var(--teal-700);
  color: #fff;
}
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--ink-200);
  color: var(--ink-800);
  box-shadow: none;
  padding: 7px 12px;
  font-weight: 500;
}
.btn-outline:hover {
  background: var(--ink-900);
  border-color: var(--ink-900);
  color: #fff;
  box-shadow: none;
}
.btn-outline:active { background: var(--ink-800); border-color: var(--ink-800); }
.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1.5px solid #fecaca;
  padding: 7px 12px;
  box-shadow: none;
}
.btn-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:focus-visible { box-shadow: var(--ring-danger), var(--shadow-1); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-outline.btn-sm, .btn-danger.btn-sm { padding: 4px 9px; }
.btn-icon-only { padding: 8px; }

.btn.is-disabled,
.btn[aria-disabled="true"] {
  opacity: .5; pointer-events: none;
}

/* ============================================================ cards */

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;                /* avoid double border + shadow */
  /* visible by default so autocomplete popups aren't clipped */
  overflow: visible;
}
.card-clip { overflow: hidden; }
.card + .card { margin-top: 14px; }
.card-head {
  padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head strong { font-size: 15px; font-weight: 600; color: var(--ink-900); }
.card-body { padding: 16px 18px; }
.card-muted {
  background: var(--bg-soft);
  border-color: transparent;
}

/* "section.card" convention used in finance / medicaments / rdv:
   the title sits at the top, no card-head wrapper. Add inner padding. */
section.card { padding: 14px 18px; }
section.card > h2:first-child { margin-top: 0; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid.cols-6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
@media (max-width: 920px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-6 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-6 { grid-template-columns: 1fr; }
}

/* ============================================================ stat tiles */

.stat {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  box-shadow: none;
  position: relative; overflow: hidden;
}
.stat small {
  color: var(--ink-500);
  font-weight: 500;
  font-size: 13px;
  display: block;
  margin-bottom: 4px;
  text-transform: none;
  letter-spacing: 0;
}
.stat strong {
  font-size: 26px;
  color: var(--ink-900);
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  display: block;
}
.stat .hint { font-size: 12px; color: var(--ink-400); margin-top: 4px; }
.stat.stat-accent {
  background: linear-gradient(135deg, var(--teal-700) 0%, var(--teal-900) 100%);
  color: #fff;
  border-color: transparent;
}
.stat.stat-accent small { color: rgba(255,255,255,.78); }
.stat.stat-accent strong { color: #fff; }
.stat.stat-accent .hint { color: rgba(255,255,255,.6); }

/* ============================================================ tables */

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card, section.card { max-width: 100%; }
.card-body:has(> table.t),
section.card:has(> table.t) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table.t {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 14px;
}
.t th, .t td { padding: 11px 14px; text-align: left; vertical-align: middle; }
.t thead th {
  color: var(--ink-500);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.t tbody tr { border-bottom: 1px solid var(--line-soft); }
.t tbody tr:last-child { border-bottom: 0; }
.t tbody tr:hover { background: var(--bg-soft); }
.t tbody td { color: var(--ink-800); }
.t tbody td strong { font-weight: 600; color: var(--ink-900); }
.t .num,
.t .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; }
.t .num { text-align: right; }
.t th.right, .t td.right { text-align: right; }

/* faded past rendez-vous rows */
.t tbody tr.rdv-past { opacity: .5; }
.t tbody tr.rdv-past:hover { opacity: 1; }

/* zero-amount / muted row in finance list */
.t tbody tr.row-muted td { color: var(--ink-400); }

/* Quiet "—" placeholder cells. The class vocabulary stays the same:
   <span class="muted">—</span> just renders subtler now. */
.muted {
  color: var(--ink-500);
  font-weight: 500;
}
.t td .muted,
.t td.mono .muted {
  font-size: 12px;
  color: var(--ink-300);
  font-weight: 400;
}
/* Hover hint on table row: slight underline on empty placeholder cells */
.t tbody tr:hover td .muted {
  color: var(--ink-400);
  border-bottom: 1px dashed var(--ink-200);
  padding-bottom: 1px;
}

/* ============================================================ forms */

.form-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
@media (max-width: 720px) { .form-row, .form-row.cols-3 { grid-template-columns: 1fr; } }

label.f,
label.small.muted,
label.small {
  display: block;
  font-size: 13px;
  color: var(--ink-600);
  font-weight: 500;
  margin-bottom: 4px;
  letter-spacing: 0;
  text-transform: none;
}
.input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--ink-200);
  background: #fff;
  color: var(--ink-900);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
  font-size: 14px;
  line-height: 1.4;
}
textarea { min-height: 80px; resize: vertical; padding: 10px 12px; font-size: 14px; }
.input::placeholder, textarea::placeholder { color: var(--ink-400); }
.input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--teal-500);
  box-shadow: var(--ring);
}
.input-lg { padding: 12px 14px; font-size: 15px; border-radius: 12px; }
.input-with-icon { position: relative; }
.input-with-icon svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--ink-400); pointer-events: none;
}
.input-with-icon .input { padding-left: 36px; }

/* ============================================================ pills / chips */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500;
  background: transparent;
  color: var(--ink-700);
  border: 1px solid var(--ink-200);
  white-space: nowrap;
  line-height: 1.55;
}
.pill.mono { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: -.01em; }

/* WCAG AA: each variant pairs a darker text on a tinted bg, with a
   matching border 1px ring. Verified contrast >= 4.5:1 vs the bg. */
.pill-ok    { color: #15803d; border-color: #bbf7d0; background: #f0fdf4; }
.pill-warn  { color: #92400e; border-color: #fde68a; background: #fffbeb; }
.pill-danger{ color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.pill-info  { color: var(--indigo-700); border-color: #dbe2f5; background: #f3f5fb; }
.pill-teal  { color: var(--teal-800); border-color: var(--teal-200); background: var(--teal-50); }

/* ghost variant: text + colored dot, transparent bg */
.pill-ghost {
  background: transparent;
  border-color: var(--ink-200);
  color: var(--ink-700);
}
.pill-ghost::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-400);
  display: inline-block;
}

/* ============================================================ autocomplete */

.ac-wrap { position: relative; }
.ac-pop {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
  max-height: 320px; overflow-y: auto;
  z-index: 50;
  display: none;
  padding: 4px;
}
.ac-pop.open { display: block; }
.ac-item {
  padding: 9px 12px; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  border-radius: 8px;
  margin-bottom: 1px;
}
.ac-item:last-child { margin-bottom: 0; }
.ac-item:hover, .ac-item.is-active { background: var(--teal-50); }
.ac-item .ac-name   { font-weight: 500; color: var(--ink-900); font-size: 14px; }
.ac-item .ac-meta   { color: var(--ink-500); font-size: 12px; }
.ac-item .ac-badge  { margin-left: auto; font-size: 11px; color: var(--ink-400); font-variant-numeric: tabular-nums; }

mark.hit { background: rgba(42,160,115,.22); color: inherit; padding: 0 2px; border-radius: 3px; }

/* rx lines */
.rx-lines { display: flex; flex-direction: column; gap: 8px; }
.rx-line {
  display: grid; grid-template-columns: 1fr 160px auto; gap: 8px; align-items: center;
}
@media (max-width: 720px) { .rx-line { grid-template-columns: 1fr; } }
.rx-add {
  align-self: flex-start;
  background: transparent;
  border: 1px dashed var(--ink-200);
  color: var(--teal-700);
  padding: 8px 12px; border-radius: 10px; cursor: pointer;
  font-size: 13px; font-weight: 500;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.rx-add:hover {
  background: var(--teal-50);
  border-color: var(--teal-300);
  border-style: solid;
}
.rx-add:focus { outline: 0; }
.rx-add:focus-visible { box-shadow: var(--ring); border-style: solid; }

/* ============================================================ patient list */

.patient-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
}
.patient-row:hover { background: var(--bg-soft); }
.patient-row .avatar { width: 40px; height: 40px; font-size: 13px; }
.patient-name { font-weight: 600; color: var(--ink-900); font-size: 14px; }
.patient-meta { color: var(--ink-500); font-size: 13px; }

/* ============================================================ flash */

.flash {
  padding: 11px 14px; border-radius: 10px; margin-bottom: 12px;
  border: 1px solid transparent; font-weight: 500; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.flash-success { background: #f0fdf4; color: #14532d; border-color: #bbf7d0; }
.flash-error   { background: #fef2f2; color: #7f1d1d; border-color: #fca5a5; }
.flash-info    { background: var(--indigo-50); color: var(--indigo-700); border-color: #dbe2f5; }
.flash-ok      { background: #f0fdf4; color: #14532d; border-color: #bbf7d0; }

/* ============================================================ login */

.login-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse at 15% -5%, rgba(74,187,137,.18) 0%, transparent 55%),
    radial-gradient(ellipse at 105% 110%, rgba(91,110,230,.14) 0%, transparent 55%),
    var(--bg);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
/* subtle Arabic clinic name watermark */
.login-wrap::before {
  content: 'عيادة';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Amiri', 'Traditional Arabic', 'Segoe UI', sans-serif;
  font-size: 42vmin;
  color: var(--teal-900);
  opacity: 0.04;
  pointer-events: none;
  user-select: none;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -.04em;
  z-index: 0;
}
.login-wrap > * { position: relative; z-index: 1; }

.login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-elev);
  border-radius: 18px;
  padding: 30px 28px;
  box-shadow: var(--shadow-3);
  border: 1px solid var(--line);
}
.login-logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, var(--teal-400), var(--teal-600));
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 22px;
  margin: 0 auto 16px;
  box-shadow: 0 10px 24px -10px rgba(42,160,115,.55);
  letter-spacing: -.02em;
}
.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.02em;
}

/* ============================================================ page header */

.page-head {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; }
.page-head .tools {
  margin-left: auto;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}

.kbd {
  font-family: var(--font-mono); font-size: 11px;
  padding: 1px 5px; border-radius: 5px;
  background: var(--ink-50); border: 1px solid var(--line); color: var(--ink-500);
}

/* ============================================================ patient detail */

.patient-head {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 22px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--teal-700) 0%, #0b5f6e 100%);
  color: #fff;
  margin-bottom: 16px;
  box-shadow: 0 14px 30px -18px rgba(11,19,36,.38);
}
.patient-head .avatar {
  width: 56px; height: 56px; font-size: 18px;
  background: rgba(255,255,255,.18);
  backdrop-filter: blur(8px);
}
.patient-head h1 { color: #fff; margin: 0; font-size: 22px; letter-spacing: -.02em; }
.patient-head .chips { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.patient-head .chips .pill {
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.1);
  color: #eafff5;
}

.timeline { display: flex; flex-direction: column; gap: 8px; }
.timeline-item {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  display: grid; grid-template-columns: 110px 1fr; gap: 14px; align-items: start;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.timeline-item:hover { border-color: var(--ink-200); }
@media (max-width: 640px) { .timeline-item { grid-template-columns: 1fr; gap: 4px; } }
.timeline-date {
  color: var(--ink-500); font-size: 13px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.timeline-body { white-space: pre-wrap; word-break: break-word; font-size: 14px; }

/* ============================================================ finance: installment progress */

.progress {
  background: var(--ink-100);
  border-radius: var(--radius-pill);
  height: 6px;
  overflow: hidden;
}
.progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--teal-500), var(--teal-700));
  border-radius: var(--radius-pill);
  transition: width var(--dur-mid) var(--ease);
}

/* ============================================================ utility */

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.right { justify-content: flex-end; }
.muted { color: var(--ink-500); }
.small { font-size: 13px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0 !important; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.w-100 { width: 100%; }
.sep { height: 1px; background: var(--line); margin: 14px 0; }

/* ============================================================ responsive */

@media (max-width: 980px) {
  :root { --sidebar-w: 0; }
  .has-shell { padding-left: 0; }
  .sidebar {
    width: 268px; transform: translateX(-100%);
    transition: transform var(--dur-mid) var(--ease);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar { left: 0; padding: 0 16px; gap: 10px; }
  .main   { padding: 18px 16px 90px; }
  .icon-btn { display: inline-grid; }
  body.sidebar-open::after {
    content: ''; position: fixed; inset: 0;
    background: rgba(11,19,36,.44); z-index: 30;
    backdrop-filter: blur(2px);
  }
  /* filter / tools bars */
  .page-head .tools { width: 100%; }
  .page-head .tools > form { width: 100%; flex-wrap: wrap; }
  .page-head .tools .input,
  .page-head .tools select,
  .page-head .tools input[type=date],
  .page-head .tools input[type=time],
  .page-head .tools input[type=search],
  .page-head .tools input[type=text] { min-width: 0; flex: 1 1 140px; }
  .page-head .tools .btn { flex: 0 0 auto; }
}

@media (max-width: 640px) {
  /* topbar CTA → icon-only on phones */
  .topbar .btn-primary .btn-label { display: none; }
  .topbar .btn-primary { padding: 8px; }
  /* Bump small buttons to ~36px tap target on touch */
  .btn-sm { padding: 7px 11px; font-size: 13px; min-height: 34px; }
  .page-head .tools > form { gap: 8px; }
  .page-head .tools .input,
  .page-head .tools select,
  .page-head .tools input[type=date],
  .page-head .tools input[type=time],
  .page-head .tools input[type=search],
  .page-head .tools input[type=text] { flex: 1 1 100%; }
  /* tighter cards on phones */
  section.card { padding: 12px 14px; }
  .card-body { padding: 14px; }
  .card-head { padding: 12px 14px; }
}

/* ============================================================ print */

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .btn { display: none !important; }
  .has-shell { padding: 0; }
  .main { padding: 0; max-width: 100%; }
  .card { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
}

/* ============================================================ dark mode (bonus, opt-in via OS preference) */

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0e131b;
    --bg-elev:   #161c27;
    --bg-soft:   #1c2330;
    --bg-sunk:   #0a0e15;

    --ink-900:   #f1f4fa;
    --ink-800:   #e3e7f0;
    --ink-700:   #c8cedb;
    --ink-600:   #a4abba;
    --ink-500:   #8a91a2;
    --ink-400:   #6b7388;
    --ink-300:   #505766;
    --ink-200:   #3a4050;
    --ink-100:   #262c39;
    --ink-50:    #1a202b;

    --line:      #242a36;
    --line-soft: #1d222d;

    --teal-50:   #0f2b22;
    --teal-100:  #123a2e;

    --indigo-50: #1a1f35;
  }
  body { color: var(--ink-800); }
  .topbar {
    background: rgba(14, 19, 27, .78);
    border-bottom-color: var(--line);
  }
  .input, select, textarea {
    background: var(--bg-sunk);
    border-color: var(--ink-200);
    color: var(--ink-900);
  }
  .input::placeholder, textarea::placeholder { color: var(--ink-400); }
  .btn { background: var(--bg-elev); color: var(--ink-800); border-color: var(--ink-200); }
  .btn-outline { background: transparent; color: var(--ink-800); border-color: var(--ink-300); }
  .btn-outline:hover { background: var(--ink-800); color: var(--bg); border-color: var(--ink-800); }
  .btn-danger { background: transparent; color: #f87171; border-color: #7f1d1d; }
  .btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
  .icon-btn { background: var(--bg-elev); color: var(--ink-700); border-color: var(--ink-200); }
  .ac-pop { background: var(--bg-elev); border-color: var(--line); }
  .ac-item:hover, .ac-item.is-active { background: var(--teal-100); }
  .login-wrap::before { color: var(--teal-300); opacity: 0.04; }
  .login-card { background: var(--bg-elev); border-color: var(--line); }
  .pill-ok    { background: #062912; color: #86efac; border-color: #14532d; }
  .pill-warn  { background: #27190a; color: #fbbf24; border-color: #78350f; }
  .pill-danger{ background: #2a0c0c; color: #fca5a5; border-color: #7f1d1d; }
  .pill-info  { background: #171c31; color: #a5b4fc; border-color: #3730a3; }
  .pill-teal  { background: var(--teal-50); color: #86efac; border-color: var(--teal-100); }
  .flash-success, .flash-ok { background: #062912; color: #bbf7d0; border-color: #14532d; }
  .flash-error { background: #2a0c0c; color: #fecaca; border-color: #7f1d1d; }
  .flash-info  { background: #171c31; color: #c7d2fe; border-color: #3730a3; }
  mark.hit { background: rgba(42,160,115,.35); }
}
