/* ============================================================
   ClinicPro — Demo Design System
   Modern SaaS aesthetic (Linear / Notion / Stripe inspired)
   ============================================================ */

/* ---------- Fonts (Inter via Google, with system fallback) ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---------- Design Tokens ---------- */
:root {
  /* Brand */
  --blue-50:  #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;

  --green-50:  #ecfdf5;
  --green-500: #10b981;
  --green-600: #059669;

  --orange-50:  #fff7ed;
  --orange-500: #f59e0b;
  --orange-600: #d97706;

  --red-50:  #fef2f2;
  --red-500: #ef4444;
  --red-600: #dc2626;

  --violet-500: #8b5cf6;
  --cyan-500:   #06b6d4;
  --pink-500:   #ec4899;

  /* Neutrals — Light theme */
  --bg:        #f7f8fa;
  --surface:   #ffffff;
  --surface-2: #f9fafb;
  --border:    #eceef1;
  --border-strong: #e2e5ea;

  --text:      #0f172a;
  --text-2:    #475569;
  --text-3:    #94a3b8;

  --primary:   var(--blue-600);
  --primary-weak: var(--blue-50);

  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow:    0 4px 16px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
  --shadow-lg: 0 12px 40px rgba(15,23,42,.12);

  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --sidebar-w: 244px;
  --topbar-h:  62px;

  --ease: cubic-bezier(.4,0,.2,1);
}

/* ---------- Dark theme ---------- */
html[data-theme="dark"] {
  --bg:        #0b0f17;
  --surface:   #121826;
  --surface-2: #0f1522;
  --border:    #232b3a;
  --border-strong: #2c3547;

  --text:      #f1f5f9;
  --text-2:    #a3adbe;
  --text-3:    #64748b;

  --primary:   var(--blue-500);
  --primary-weak: rgba(59,130,246,.12);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 4px 16px rgba(0,0,0,.35), 0 1px 3px rgba(0,0,0,.3);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.55);

  --blue-50:  rgba(59,130,246,.14);
  --green-50: rgba(16,185,129,.14);
  --orange-50: rgba(245,158,11,.14);
  --red-50:   rgba(239,68,68,.14);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .25s var(--ease), color .25s var(--ease);
}
h1,h2,h3,h4,h5 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

/* Default icon sizing — every inline SVG icon is 18px unless a container overrides it.
   Charts opt out via the .chart class. */
svg:not(.chart) { width: 18px; height: 18px; flex: 0 0 auto; }
.kpi__ic svg { width: 20px; height: 20px; }
.logo-mark svg { width: 20px; height: 20px; }
.sidebar__brand .logo-mark svg { width: 18px; height: 18px; }
.auth__logo .logo-mark svg { width: 20px; height: 20px; }
.role-chip .ic svg { width: 17px; height: 17px; }
.stub__ic svg { width: 30px; height: 30px; }
.profile-head .avatar { }
.rx-ic svg, .num svg { width: 16px; height: 16px; }
.meta-row svg { width: 14px; height: 14px; }
.demo-note > svg { width: 17px; height: 17px; margin-top: 1px; }
.alert-tag svg { width: 13px; height: 13px; }
.btn svg { width: 16px; height: 16px; }
.btn--icon svg { width: 18px; height: 18px; }
::selection { background: var(--blue-200); color: var(--text); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 20px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }

/* ============================================================
   LOGIN / ROLE PICKER
   ============================================================ */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
.auth__brandside {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255,255,255,.18), transparent 55%),
    linear-gradient(135deg, #1d4ed8 0%, #2563eb 45%, #3b82f6 100%);
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.auth__brandside::after {
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 80% 20%, rgba(255,255,255,.12) 0, transparent 30%),
    radial-gradient(circle at 30% 80%, rgba(255,255,255,.10) 0, transparent 35%);
  pointer-events: none;
}
.auth__logo { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; z-index: 1; }
.auth__logo .logo-mark { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,.18); display: grid; place-items: center; backdrop-filter: blur(6px); }
.auth__hero { z-index: 1; max-width: 460px; }
.auth__hero h1 { font-size: 40px; line-height: 1.1; font-weight: 800; letter-spacing: -.03em; }
.auth__hero p { margin-top: 18px; font-size: 16px; color: rgba(255,255,255,.85); }
.auth__stats { display: flex; gap: 34px; margin-top: 38px; z-index: 1; }
.auth__stat b { display: block; font-size: 26px; font-weight: 800; }
.auth__stat span { font-size: 12.5px; color: rgba(255,255,255,.8); }
.auth__badges { display: flex; gap: 10px; flex-wrap: wrap; z-index: 1; }
.auth__badge { font-size: 12px; padding: 7px 12px; border-radius: 999px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.18); }

.auth__formside { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--surface); }
.auth__card { width: 100%; max-width: 420px; }
.auth__card h2 { font-size: 24px; }
.auth__card > p.sub { color: var(--text-2); margin-top: 6px; margin-bottom: 26px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.input {
  width: 100%; height: 44px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }

.role-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); margin: 6px 0 10px; }
.role-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 22px; }
.role-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); text-align: left; transition: all .15s var(--ease);
}
.role-chip:hover { border-color: var(--blue-200); background: var(--surface-2); }
.role-chip.active { border-color: var(--primary); background: var(--primary-weak); box-shadow: 0 0 0 3px var(--primary-weak); }
.role-chip .ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.role-chip b { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.role-chip span { display: block; font-size: 11px; color: var(--text-3); }

.btn {
  height: 46px; padding: 0 18px; border-radius: var(--radius-sm); border: none;
  font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .06s var(--ease), box-shadow .2s, background .2s, opacity .2s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn:disabled:active { transform: none; }
.btn--primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(37,99,235,.28); width: 100%; }
.btn--primary:hover { background: var(--blue-700); }
.btn--ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border-strong); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--sm { height: 36px; font-size: 13px; padding: 0 14px; }
.btn--icon { width: 38px; height: 38px; padding: 0; border-radius: 10px; background: transparent; color: var(--text-2); border: 1px solid transparent; }
.btn--icon:hover { background: var(--surface-2); color: var(--text); }

.auth__foot { margin-top: 20px; font-size: 12.5px; color: var(--text-3); text-align: center; }
.demo-note {
  margin-top: 18px; padding: 12px 14px; border-radius: 10px;
  background: var(--orange-50); border: 1px solid rgba(245,158,11,.3);
  font-size: 12.5px; color: var(--orange-600); display: flex; gap: 9px; align-items: flex-start;
}
html[data-theme="dark"] .demo-note { color: #fbbf24; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar__brand { display: flex; align-items: center; gap: 11px; padding: 17px 18px; font-weight: 800; font-size: 16.5px; letter-spacing: -.02em; }
.sidebar__brand .logo-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--blue-600), var(--blue-500)); display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-sm); }
.sidebar__clinic {
  margin: 0 12px 8px; padding: 9px 11px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border); display: flex; align-items: center; gap: 9px; cursor: pointer;
}
.sidebar__clinic:hover { border-color: var(--border-strong); }
.sidebar__clinic .dot { width: 26px; height: 26px; border-radius: 7px; background: var(--blue-100); color: var(--blue-700); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.sidebar__clinic b { font-size: 12.5px; font-weight: 600; }
.sidebar__clinic span { font-size: 10.5px; color: var(--text-3); display: block; }

.nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; }
.nav__group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 700; padding: 12px 10px 6px; }
.nav__item {
  display: flex; align-items: center; gap: 11px; padding: 8.5px 11px; border-radius: 9px;
  color: var(--text-2); font-size: 13.5px; font-weight: 500; margin-bottom: 1px;
  transition: background .13s, color .13s; position: relative;
}
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item.active { background: var(--primary-weak); color: var(--primary); font-weight: 600; }
.nav__item .nav-ic { width: 18px; height: 18px; flex-shrink: 0; }
.nav__item .badge { margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--red-500); color: #fff; }
.nav__item .badge--soft { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }

.sidebar__user { border-top: 1px solid var(--border); padding: 11px 14px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.sidebar__user .meta { flex: 1; min-width: 0; }
.sidebar__user .meta b { font-size: 12.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user .meta span { font-size: 11px; color: var(--text-3); }

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
}
.topbar__title h2 { font-size: 17px; }
.topbar__title span { font-size: 12px; color: var(--text-3); }
.topbar__search {
  margin-left: auto; display: flex; align-items: center; gap: 9px;
  width: 300px; max-width: 34vw; height: 40px; padding: 0 13px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2); color: var(--text-3);
}
.topbar__search input { border: none; background: transparent; outline: none; color: var(--text); font-size: 13.5px; width: 100%; }
.topbar__actions { display: flex; align-items: center; gap: 6px; }

.lang-toggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.lang-toggle button { background: transparent; border: none; padding: 0 11px; height: 38px; font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.lang-toggle button.active { background: var(--primary); color: #fff; }

.content { padding: 26px 26px 60px; max-width: 1360px; width: 100%; margin: 0 auto; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; letter-spacing: -.02em; }
.page-head p { color: var(--text-2); margin-top: 4px; font-size: 13.5px; }
.page-head__actions { display: flex; gap: 9px; align-items: center; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card--pad { padding: 18px; }
.card__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.card__head h3 { font-size: 14.5px; }
.card__head .muted { font-size: 12px; color: var(--text-3); }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 17px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform .18s var(--ease), box-shadow .18s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kpi__ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; }
.kpi__label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.kpi__value { font-size: 27px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.kpi__delta { font-size: 12px; font-weight: 600; margin-top: 8px; display: inline-flex; align-items: center; gap: 4px; }
.delta-up { color: var(--green-600); }
.delta-down { color: var(--red-600); }
.delta-flat { color: var(--text-3); }

/* Soft tint helpers */
.t-blue   { background: var(--blue-50);   color: var(--blue-600); }
.t-green  { background: var(--green-50);  color: var(--green-600); }
.t-orange { background: var(--orange-50); color: var(--orange-600); }
.t-red    { background: var(--red-50);    color: var(--red-600); }
.t-violet { background: rgba(139,92,246,.12); color: var(--violet-500); }
.t-cyan   { background: rgba(6,182,212,.12);  color: var(--cyan-500); }

/* Grid utility */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.col-2 { grid-column: span 2; }
.span-2 { grid-template-columns: 1.6fr 1fr; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 700; padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.tbl tbody tr:last-child td { border-bottom: none; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user .avatar { width: 30px; height: 30px; font-size: 11.5px; }
.cell-user b { font-size: 13px; font-weight: 600; }
.cell-user span { font-size: 11.5px; color: var(--text-3); }

/* ---------- Pills / badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill .pd { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-blue   { background: var(--blue-50);   color: var(--blue-600); }
.pill-green  { background: var(--green-50);  color: var(--green-600); }
.pill-orange { background: var(--orange-50); color: var(--orange-600); }
.pill-red    { background: var(--red-50);    color: var(--red-600); }
.pill-gray   { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.pill-violet { background: rgba(139,92,246,.12); color: var(--violet-500); }

/* ---------- Charts ---------- */
.chart { width: 100%; }
.bar-chart { display: flex; align-items: flex-end; gap: 9px; height: 190px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 34px; border-radius: 7px 7px 4px 4px; background: linear-gradient(180deg, var(--blue-500), var(--blue-600)); transition: height .6s var(--ease); position: relative; }
.bar:hover::after { content: attr(data-val); position: absolute; top: -24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 5px; white-space: nowrap; }
.bar-label { font-size: 10.5px; color: var(--text-3); font-weight: 500; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.legend span { font-size: 11.5px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut { position: relative; width: 150px; height: 150px; flex-shrink: 0; }
.donut .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.donut .center b { font-size: 24px; font-weight: 800; }
.donut .center span { font-size: 11px; color: var(--text-3); }

/* Progress bars */
.pbar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.pbar > i { display: block; height: 100%; border-radius: 999px; background: var(--primary); }

/* ---------- Calendar ---------- */
.cal-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-legendwrap { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg button { border: none; background: transparent; padding: 7px 14px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Appointments layout: calendar + waiting list, stacks on smaller screens */
.appt-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 980px) { .appt-layout { grid-template-columns: 1fr; } }

/* Horizontal scroll wrapper so Day/Week columns never squish */
.cal-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.cal--week { min-width: 720px; }
.cal--day { min-width: 560px; }
.cal__colhead--today { background: var(--primary-weak); }
.cal__colhead--today b { color: var(--primary); }

.cal { display: grid; grid-template-columns: 60px 1fr; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal__times { border-right: 1px solid var(--border); }
.cal__time { height: 62px; font-size: 11px; color: var(--text-3); text-align: right; padding: 4px 8px 0 0; position: relative; }
.cal__cols { display: grid; }
.cal__col { border-right: 1px solid var(--border); position: relative; }
.cal__col:last-child { border-right: none; }
.cal__colhead { height: 46px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.cal__colhead { padding: 0 6px; }
.cal__colhead b { font-size: 12.5px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal__colhead span { font-size: 10.5px; color: var(--text-3); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal__grid { position: relative; }
.cal__row { height: 62px; border-bottom: 1px solid var(--border); }
.appt {
  position: absolute; left: 4px; right: 4px; border-radius: 8px; padding: 6px 9px;
  font-size: 11.5px; overflow: hidden; cursor: pointer; border-left: 3px solid; box-shadow: var(--shadow-sm);
  transition: transform .12s, box-shadow .12s;
}
.appt:hover { transform: scale(1.015); box-shadow: var(--shadow); z-index: 5; }
.appt b { font-size: 12px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt span { opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.appt-blue   { background: var(--blue-50);   border-color: var(--blue-500);   color: var(--blue-700); }
.appt-green  { background: var(--green-50);  border-color: var(--green-500);  color: var(--green-600); }
.appt-orange { background: var(--orange-50); border-color: var(--orange-500); color: var(--orange-600); }
.appt-violet { background: rgba(139,92,246,.13); border-color: var(--violet-500); color: var(--violet-500); }
.appt-cyan   { background: rgba(6,182,212,.13);  border-color: var(--cyan-500);   color: var(--cyan-500); }
html[data-theme="dark"] .appt b { color: var(--text); }

/* Agenda (mobile day/week) */
.agenda { overflow: hidden; }
.agenda-day { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-size: 12px; font-weight: 700; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: .03em; }
.agenda-day span { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--text-3); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }
.agenda-day--today { color: var(--primary); }
.agenda-day--today span { color: var(--primary); border-color: var(--primary); }
.agenda-row { display: flex; align-items: center; gap: 11px; padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.agenda-row:last-child { border-bottom: none; }
.agenda-row:hover { background: var(--surface-2); }
.agenda-time { font-size: 12.5px; font-weight: 700; color: var(--text); width: 42px; flex-shrink: 0; }

/* Month grid */
.month { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.month__head, .month__row { display: grid; grid-template-columns: repeat(7, 1fr); }
.month__head div { padding: 10px; font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; text-align: center; border-bottom: 1px solid var(--border); }
.month__cell { min-height: 108px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 7px 8px; }
.month__cell:nth-child(7n) { border-right: none; }
.month__cell.dim { background: var(--surface-2); }
.month__cell .dnum { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.month__cell.today .dnum { background: var(--primary); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.mev { font-size: 10.5px; padding: 2px 6px; border-radius: 5px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Waiting list ---------- */
.wlist-item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.wlist-item:last-child { border-bottom: none; }
.wlist-item .num { width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--text-2); }

/* ---------- Patient profile ---------- */
.profile-head { display: flex; gap: 18px; align-items: center; padding: 22px; }
.profile-head__info { flex: 1; min-width: 0; }
.profile-head__actions { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.profile-head .avatar { width: 72px; height: 72px; font-size: 26px; border-radius: 18px; }
.profile-head h2 { font-size: 22px; }
.profile-head .meta-row { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; color: var(--text-2); font-size: 12.5px; }
.profile-head .meta-row span { display: inline-flex; align-items: center; gap: 5px; }
.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--border); padding: 0 16px; overflow-x: auto; }
.tab { padding: 12px 14px; font-size: 13px; font-weight: 600; color: var(--text-3); border-bottom: 2px solid transparent; white-space: nowrap; transition: color .13s; }
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 1px; background: var(--border); border-radius: var(--radius); overflow: hidden; }
.info-cell { background: var(--surface); padding: 14px 16px; }
.info-cell .k { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.info-cell .v { font-size: 14px; font-weight: 500; margin-top: 4px; }

.alert-tag { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; }

/* Timeline */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 22px 4px; }
.tl-item::before { content: ""; position: absolute; left: -22px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--primary); }
.tl-item .tl-date { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.tl-item .tl-card { margin-top: 7px; padding: 13px 15px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.tl-item .tl-card b { font-size: 13.5px; }
.tl-item .tl-card p { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }

/* Files grid */
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 12px; }
.file-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); transition: box-shadow .15s, transform .15s; }
.file-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.file-card .thumb { height: 92px; display: grid; place-items: center; }
.file-card .fmeta { padding: 9px 11px; border-top: 1px solid var(--border); }
.file-card .fmeta b { font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card .fmeta span { font-size: 10.5px; color: var(--text-3); }

/* ---------- EMR ---------- */
.emr { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.emr__section { padding: 18px; border-bottom: 1px solid var(--border); }
.emr__section:last-child { border-bottom: none; }
.emr__label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 700; margin-bottom: 9px; }
.emr-textarea { width: 100%; min-height: 90px; border: 1px solid var(--border-strong); border-radius: 10px; padding: 12px 14px; background: var(--surface-2); color: var(--text); font-family: inherit; font-size: 13.5px; resize: vertical; line-height: 1.6; }
.emr-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); background: var(--surface); }
.rx-row { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--surface-2); }
.rx-row .rx-ic { width: 32px; height: 32px; border-radius: 8px; background: var(--blue-50); color: var(--blue-600); display: grid; place-items: center; flex-shrink: 0; }
.rx-row b { font-size: 13px; }
.rx-row span { font-size: 11.5px; color: var(--text-3); }
.icd-tag { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 12.5px; background: var(--surface-2); margin: 0 8px 8px 0; }
.icd-tag code { font-weight: 700; color: var(--primary); }

.vital-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.vital { padding: 12px; border: 1px solid var(--border); border-radius: 10px; text-align: center; background: var(--surface-2); }
.vital .vlabel { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
.vital .vval { font-size: 19px; font-weight: 800; margin-top: 3px; }
.vital .vunit { font-size: 10.5px; color: var(--text-3); font-weight: 500; }

/* ---------- Empty / stub ---------- */
.stub { display: grid; place-items: center; min-height: 60vh; text-align: center; }
.stub__inner { max-width: 440px; }
.stub__ic { width: 76px; height: 76px; border-radius: 20px; display: grid; place-items: center; margin: 0 auto 20px; background: var(--primary-weak); color: var(--primary); }
.stub h2 { font-size: 21px; }
.stub p { color: var(--text-2); margin-top: 10px; font-size: 13.5px; }
.stub .feat { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 20px; }
.stub .feat span { font-size: 12px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 999; }
.toast {
  background: var(--text); color: var(--surface); padding: 12px 16px; border-radius: 11px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px;
  animation: toastin .3s var(--ease); max-width: 340px;
}
html[data-theme="dark"] .toast { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
@keyframes toastin { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 200; animation: fade .2s; padding: 20px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 500px; overflow: hidden; animation: pop .25s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
.modal__head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal__head h3 { font-size: 16px; }
.modal__body { padding: 20px; }
.modal__foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Animations for view transitions ---------- */
.fade-in { animation: fadein .35s var(--ease); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Bilingual contact note (purchase / install / pricing) ---------- */
.contact-note {
  margin-top: 18px; padding: 13px 15px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2);
  display: flex; gap: 11px; align-items: flex-start;
}
.contact-note__ic { color: var(--primary); flex-shrink: 0; margin-top: 1px; }
.contact-note__txt { font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.contact-note__txt .zh { margin-top: 3px; }
.contact-note__txt a { color: var(--primary); font-weight: 600; word-break: break-all; }
.contact-note__txt a:hover { text-decoration: underline; }
/* On the booking portal the note sits in a wide centered column */
.bkp__body .contact-note { max-width: 560px; margin-left: auto; margin-right: auto; text-align: left; }

/* ============================================================
   PATIENT SELF-BOOKING PORTAL
   ============================================================ */
.auth__or { display: flex; align-items: center; gap: 12px; margin: 18px 0 12px; color: var(--text-3); font-size: 12px; }
.auth__or::before, .auth__or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* #auth is a 2-column grid (login layout); make the booking portal span the
   full width so its inner body (max-width + margin:auto) centers on desktop. */
.bkp { grid-column: 1 / -1; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.bkp__top {
  height: 64px; display: flex; align-items: center; gap: 14px; padding: 0 22px;
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20;
}
.bkp__brand { display: flex; align-items: center; gap: 11px; font-weight: 800; font-size: 16.5px; letter-spacing: -.02em; }
.bkp__brand .logo-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--blue-600), var(--blue-500)); display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-sm); }
.bkp__top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.bkp__body { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 30px 22px 70px; }
.bkp__head h1 { font-size: 27px; letter-spacing: -.025em; }
.bkp__head p { color: var(--text-2); margin-top: 8px; font-size: 14.5px; max-width: 560px; }

.bk-steps { display: flex; gap: 8px; margin: 24px 0 22px; }
.bk-step { flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.bk-step .bar { height: 5px; border-radius: 999px; background: var(--border-strong); transition: background .25s var(--ease); }
.bk-step.done .bar, .bk-step.active .bar { background: var(--primary); }
.bk-step.active { color: var(--primary); }
.bk-step span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bk-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 24px; }
.bk-qh { font-size: 17px; margin-bottom: 4px; }
.bk-qs { color: var(--text-3); font-size: 13px; margin-bottom: 20px; }
.bk-hint { color: var(--text-3); font-size: 13px; margin-top: 16px; }

.bk-opt-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.bk-opt {
  display: flex; align-items: center; gap: 13px; padding: 15px;
  border: 1.5px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); text-align: left; transition: all .15s var(--ease); width: 100%;
}
.bk-opt:hover { border-color: var(--blue-200); background: var(--surface-2); transform: translateY(-1px); }
.bk-opt.active { border-color: var(--primary); background: var(--primary-weak); box-shadow: 0 0 0 3px var(--primary-weak); }
.bk-opt .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; flex-shrink: 0; font-weight: 700; font-size: 14px; }
.bk-opt .ic svg { width: 21px; height: 21px; }
.bk-opt b { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.bk-opt small { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.bk-opt .chk { margin-left: auto; color: var(--primary); opacity: 0; transition: opacity .15s; flex-shrink: 0; }
.bk-opt.active .chk { opacity: 1; }

.bk-days { display: flex; gap: 9px; overflow-x: auto; padding-bottom: 6px; }
.bk-day { flex: 0 0 auto; width: 66px; padding: 11px 0; border: 1.5px solid var(--border-strong); border-radius: 12px; background: var(--surface); text-align: center; transition: all .15s; }
.bk-day:hover { border-color: var(--blue-200); }
.bk-day.active { border-color: var(--primary); background: var(--primary-weak); box-shadow: 0 0 0 3px var(--primary-weak); }
.bk-day .dw { font-size: 11px; color: var(--text-3); font-weight: 600; }
.bk-day .dn { font-size: 20px; font-weight: 800; margin-top: 2px; letter-spacing: -.02em; }
.bk-day .dm { font-size: 10.5px; color: var(--text-3); }
.bk-day.active .dw, .bk-day.active .dm { color: var(--primary); }

.bk-slot-group { margin-top: 18px; }
.bk-slot-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); margin-bottom: 11px; display: flex; align-items: center; gap: 7px; }
.bk-slot-label svg { width: 15px; height: 15px; }
.bk-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 9px; }
.bk-slot { height: 44px; border: 1.5px solid var(--border-strong); border-radius: 10px; background: var(--surface); font-weight: 600; font-size: 13.5px; color: var(--text); transition: all .13s; }
.bk-slot:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.bk-slot.active { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(37,99,235,.28); }
.bk-slot:disabled { opacity: .4; cursor: not-allowed; text-decoration: line-through; }

.bk-summary { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 6px 15px; margin-bottom: 18px; }
.bk-sum-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.bk-sum-row + .bk-sum-row { border-top: 1px dashed var(--border); }
.bk-sum-row .ic2 { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.bk-sum-row .k { font-size: 11px; color: var(--text-3); }
.bk-sum-row .v { font-size: 13.5px; font-weight: 600; margin-top: 1px; }
.bk-auto { margin-top: 2px; background: var(--green-50); border-color: rgba(16,185,129,.3); color: var(--green-600); }
html[data-theme="dark"] .bk-auto { color: #34d399; }

.bk-foot { display: flex; gap: 11px; margin-top: 22px; }
.bk-foot .btn { width: auto; flex: 1; }
.bk-back-link { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 16px auto 0; background: transparent; border: none; color: var(--text-3); font-weight: 600; font-size: 13px; padding: 8px; }
.bk-back-link:hover { color: var(--text-2); }
.bk-back-link svg { width: 15px; height: 15px; }

/* Confirmation */
.bk-done { text-align: center; padding: 30px 24px 26px; }
.bk-done h1 { font-size: 25px; }
.bk-done__ic { width: 78px; height: 78px; border-radius: 50%; background: var(--green-50); color: var(--green-600); display: grid; place-items: center; margin: 0 auto 20px; animation: bkpop .45s var(--ease); }
.bk-done__ic svg { width: 40px; height: 40px; stroke-width: 2.2; }
@keyframes bkpop { 0% { transform: scale(.5); opacity: 0; } 60% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
.bk-done__sub { color: var(--text-2); margin: 10px auto 0; max-width: 430px; font-size: 14px; }
.bk-ref { display: inline-flex; align-items: center; gap: 9px; margin-top: 18px; padding: 10px 18px; border: 1px dashed var(--border-strong); border-radius: 10px; font-weight: 700; font-size: 13px; color: var(--text-2); }
.bk-ref code { font-size: 15.5px; color: var(--primary); font-weight: 800; letter-spacing: .02em; }
.bk-done__sum { text-align: left; margin: 24px auto 0; max-width: 460px; }
.bk-done__foot { max-width: 460px; margin-left: auto; margin-right: auto; }
.bk-done__link { margin-top: 14px; }

/* ---------- Responsive ---------- */
.menu-btn { display: none; }
@media (max-width: 1100px) {
  .span-2 { grid-template-columns: 1fr; }
  .emr { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 100; width: 260px; transform: translateX(-102%); transition: transform .28s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .menu-btn { display: grid; }
  .scrim { position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 90; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar__search { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth__brandside { display: none; }
}
@media (max-width: 640px) {
  .bk-opt-grid { grid-template-columns: 1fr; }
  .bkp__head h1 { font-size: 23px; }
  .bk-step span { font-size: 10.5px; }

  /* Calendar toolbar → stacked rows, full-width segment */
  .cal-toolbar { gap: 10px; }
  .cal-toolbar .seg { width: 100%; }
  .cal-toolbar .seg button { flex: 1; }
  .cal-nav { width: 100%; justify-content: space-between; }
  .cal-legendwrap { width: 100%; margin-left: 0; }

  /* Patient profile header → avatar+info on top, actions full-width below */
  .profile-head { flex-wrap: wrap; align-items: flex-start; gap: 14px; padding: 18px; }
  .profile-head .avatar { width: 58px; height: 58px; font-size: 22px; border-radius: 15px; }
  .profile-head h2 { font-size: 20px; }
  .profile-head__actions { flex-direction: row; width: 100%; }
  .profile-head__actions .btn { flex: 1; }

  /* Page header actions wrap cleanly */
  .page-head__actions { flex-wrap: wrap; }
}
@media (max-width: 520px) {
  .content { padding: 18px 14px 50px; }
  .role-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
