/* Clinic HIS — shared styles for the clinic app and platform console.
   No inline styles anywhere (CSP style-src 'self'); all theming via tokens below. */

/* CoreVia Clinic EMR theme "Aqua": cyan-to-teal brand gradient, teal navigation. */
:root {
  --bg: #f3f8fa;
  --surface: #ffffff;
  --surface-2: #f8fbfc;
  --border: #dde9ee;
  --border-strong: #c3d5dc;
  --text: #13252b;
  --text-2: #475e66;
  --text-3: #6a8088;
  --primary: #0891b2;
  --primary-hover: #0e7490;
  --primary-soft: #e3f6fa;
  --on-primary: #ffffff;
  --brand: #06b6d4;
  --brand-light: #67e8f9;
  --brand-pale: #cffafe;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warning: #9a5b00;
  --warning-soft: #fff4e0;
  --success: #1a7f45;
  --success-soft: #e6f5ec;
  --info-soft: #e8f6f9;
  --focus: #06b6d4;
  --sidebar: #0f766e;
  --sidebar-grad: linear-gradient(180deg, #0e7490 0%, #0f766e 55%, #115e59 100%);
  --sidebar-text: #e6fbfb;
  --sidebar-muted: #a7dcd9;
  --sidebar-active: rgba(255, 255, 255, .17);
  --sidebar-hover: rgba(255, 255, 255, .09);
  --nav-indicator: #a5f3fc;
  --hero-grad: linear-gradient(150deg, #06b6d4 0%, #0e7490 50%, #115e59 100%);
  --logo-ring: #0b3b44;
  --logo-word: #0b3b44;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(8, 47, 56, .05), 0 2px 6px rgba(8, 47, 56, .06);
  --shadow-lg: 0 18px 50px rgba(8, 47, 56, .14);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Malayalam", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #071417; --surface: #0d1e22; --surface-2: #12272c; --border: #1f3a40; --border-strong: #2c4d54;
    --text: #e6f4f6; --text-2: #b2ccd1; --text-3: #86a5ab; --primary: #22c3dd; --primary-hover: #4fd6ea;
    --primary-soft: #0f3038; --on-primary: #04161a; --danger: #f0786d; --danger-soft: #3a1714; --warning: #f2b45a;
    --warning-soft: #3a2a10; --success: #5cc98a; --success-soft: #12301f; --info-soft: #10262b; --sidebar: #08302f;
    --sidebar-grad: linear-gradient(180deg, #0a3f4c 0%, #08342f 55%, #062824 100%); --sidebar-active: rgba(255, 255, 255, .12);
    --hero-grad: linear-gradient(150deg, #0e7490 0%, #0b4f5c 50%, #083c38 100%); --logo-ring: #ffffff; --logo-word: #ffffff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #071417; --surface: #0d1e22; --surface-2: #12272c; --border: #1f3a40; --border-strong: #2c4d54;
  --text: #e6f4f6; --text-2: #b2ccd1; --text-3: #86a5ab; --primary: #22c3dd; --primary-hover: #4fd6ea;
  --primary-soft: #0f3038; --on-primary: #04161a; --danger: #f0786d; --danger-soft: #3a1714; --warning: #f2b45a;
  --warning-soft: #3a2a10; --success: #5cc98a; --success-soft: #12301f; --info-soft: #10262b; --sidebar: #08302f;
  --sidebar-grad: linear-gradient(180deg, #0a3f4c 0%, #08342f 55%, #062824 100%); --sidebar-active: rgba(255, 255, 255, .12);
  --hero-grad: linear-gradient(150deg, #0e7490 0%, #0b4f5c 50%, #083c38 100%); --logo-ring: #ffffff; --logo-word: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .5); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.5; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; }

/* Icons and logo */
.icon { width: 18px; height: 18px; flex: none; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-mark { width: 38px; height: 38px; flex: none; }
.logo-ring { stroke: var(--logo-ring); }
.logo-text { display: flex; flex-direction: column; line-height: 1; }
.logo-word { font-size: 1.35rem; font-weight: 750; letter-spacing: -.02em; color: var(--logo-word); }
.logo-via { color: var(--brand); }
.logo-sub { margin-top: 5px; font-size: .62rem; font-weight: 650; letter-spacing: .32em; color: var(--primary); }
.logo-on-dark .logo-ring, .sidebar .logo-ring { stroke: #ffffff; }
.logo-on-dark .logo-word, .sidebar .logo-word { color: #ffffff; }
.logo-on-dark .logo-via, .sidebar .logo-via { color: var(--brand-light); }
.logo-on-dark .logo-sub, .sidebar .logo-sub { color: var(--brand-pale); }
.logo-lg .logo-mark { width: 58px; height: 58px; }
.logo-lg { gap: 14px; }
.logo-lg .logo-word { font-size: 2.05rem; }
.logo-lg .logo-sub { font-size: .72rem; margin-top: 7px; }

/* Shell: collapsible sidebar + top bar */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); background-image: var(--sidebar-grad); color: var(--sidebar-text); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; border-right: 1px solid rgba(255, 255, 255, .04); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 12px 12px 16px; }
.sidebar-logo { display: flex; min-width: 0; text-decoration: none; }
.sidebar .logo-mark { width: 34px; height: 34px; }
.sidebar .logo-word { font-size: 1.2rem; }
.sidebar .logo-sub { font-size: .56rem; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid transparent; background: transparent;
  color: inherit; cursor: pointer; padding: 0; }
.icon-btn:hover { background: var(--surface-2); }
.sidebar .icon-btn { color: var(--sidebar-muted); }
.sidebar .icon-btn:hover { background: var(--sidebar-hover); color: #fff; }
.clinic-chip { display: flex; align-items: center; gap: 10px; margin: 2px 12px 8px; padding: 9px 10px; border-radius: 10px; background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .06); color: #fff; font-weight: 600; font-size: .9rem; min-width: 0; }
.clinic-chip img { width: 28px; height: 28px; object-fit: contain; border-radius: 6px; background: #fff; flex: none; }
.clinic-chip .mark { width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(135deg, var(--brand-light), var(--brand)); display: grid; place-items: center; color: #fff; font-size: .85rem; flex: none; }
.clinic-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clinic-name small { display: block; font-weight: 400; color: var(--sidebar-muted); font-size: .76rem; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 0 10px 16px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .15) transparent; }
.nav-group { margin: 16px 8px 6px; font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--sidebar-muted); font-weight: 650; }
.nav a { position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px; margin: 1px 0; border-radius: 8px; color: var(--sidebar-text);
  text-decoration: none; font-size: .92rem; white-space: nowrap; }
.nav a .icon { opacity: .85; }
.nav a:hover { background: var(--sidebar-hover); color: #fff; }
.nav a[aria-current="page"] { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--nav-indicator); }
.nav a[aria-current="page"] .icon { color: var(--nav-indicator); opacity: 1; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar-backdrop { display: none; }

.shell.collapsed { grid-template-columns: 76px 1fr; }
.shell.collapsed .sidebar-head { flex-direction: column; padding: 14px 8px 8px; }
.shell.collapsed .logo-text, .shell.collapsed .clinic-name, .shell.collapsed .nav-label { display: none; }
.shell.collapsed .clinic-chip { justify-content: center; margin: 4px 10px 6px; padding: 8px 0; }
.shell.collapsed .nav-group { height: 1px; margin: 12px 10px; background: rgba(255, 255, 255, .1); font-size: 0; }
.shell.collapsed .nav a { justify-content: center; padding: 10px 0; }
.shell.collapsed .nav a .icon { width: 20px; height: 20px; }
.shell.collapsed .collapse-btn { transform: scaleX(-1); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; gap: 12px; align-items: center; padding: 10px 24px; min-height: 62px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; }
.topbar .search { flex: 1; max-width: 520px; position: relative; display: flex; align-items: center; }
.topbar .search .icon { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.topbar .search input { width: 100%; padding-left: 36px; border-radius: 999px; background: var(--surface-2); }
.topbar .spacer { flex: 1; }
.content { padding: 24px 28px; max-width: 1280px; width: 100%; }
.page-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-weight: 700; letter-spacing: -.01em; }
.page-head p { color: var(--text-2); margin: 0; }
.menu-toggle { display: none; }

/* Theme switch (light / dark / device) */
.theme-switch { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.theme-switch button { display: grid; place-items: center; width: 30px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--text-3); cursor: pointer; padding: 0; }
.theme-switch button .icon { width: 16px; height: 16px; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* Profile menu */
.profile-menu { position: relative; }
.profile-menu > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 999px; cursor: pointer;
  border: 1px solid transparent; font-weight: 400; }
.profile-menu > summary::-webkit-details-marker { display: none; }
.profile-menu > summary:hover, .profile-menu[open] > summary { background: var(--surface-2); border-color: var(--border); }
.profile-menu > summary .icon { width: 16px; height: 16px; color: var(--text-3); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: #fff;
  background: linear-gradient(135deg, var(--brand-light), var(--primary-hover)); flex: none; }
.profile-text { display: flex; flex-direction: column; line-height: 1.25; max-width: 200px; }
.profile-text strong { font-size: .9rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-text span { font-size: .76rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); width: 260px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 40; }
.menu-head { padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; display: flex; flex-direction: column; gap: 2px; }
.menu-head span { color: var(--text-3); font-size: .8rem; overflow-wrap: anywhere; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0; background: none;
  color: var(--text); text-decoration: none; font: inherit; font-size: .9rem; cursor: pointer; text-align: left; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--primary-soft); color: var(--primary); }
.menu-pop form { margin: 0; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }

@media (max-width: 900px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; transform: translateX(-100%); transition: transform .2s; z-index: 30; }
  .sidebar.open { transform: none; }
  .shell.collapsed .logo-text, .shell.collapsed .clinic-name, .shell.collapsed .nav-label { display: initial; }
  .collapse-btn { display: none; }
  .sidebar.open + .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(4, 22, 26, .45); z-index: 25; }
  .menu-toggle { display: inline-grid; }
  .content { padding: 16px; }
  .profile-text, .profile-menu > summary .icon { display: none; }
  .topbar { padding: 8px 12px; gap: 8px; }
}

/* Cards, grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.card > h2:first-child { margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
[hidden] { display: none !important; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--text-2); font-size: .85rem; }
.stat .value { font-size: 1.6rem; font-weight: 650; }
.stat .sub { color: var(--text-3); font-size: .82rem; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.meter { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--primary); }
.meter.warn > span { background: var(--warning); }
.meter.full > span { background: var(--danger); }
.w-0 { width: 0; } .w-10 { width: 10%; } .w-20 { width: 20%; } .w-30 { width: 30%; } .w-40 { width: 40%; } .w-50 { width: 50%; }
.w-60 { width: 60%; } .w-70 { width: 70%; } .w-80 { width: 80%; } .w-90 { width: 90%; } .w-100 { width: 100%; }

/* Forms */
label { font-weight: 550; display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { color: var(--text-3); font-size: .82rem; margin-top: 3px; }
.field .error { color: var(--danger); font-size: .85rem; margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date],
input[type=search], input[type=url], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface);
  color: var(--text); font: inherit;
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin-bottom: 8px; }
.check input { margin-top: 4px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 16px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 6px; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.input-prefix { display: flex; }
.input-prefix span { padding: 8px 10px; border: 1px solid var(--border-strong); border-right: 0; border-radius: 6px 0 0 6px; background: var(--surface-2); color: var(--text-2); }
.input-prefix input { border-radius: 0 6px 6px 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; line-height: 1.3; }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: .85rem; }
.btn-link { background: none; border: none; color: var(--primary); padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }
.inline-form { display: inline; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); font-weight: 600; background: var(--surface-2); }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--text-2); }

/* Badges and alerts */
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-info { background: var(--info-soft); color: var(--text); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.banner { padding: 8px 24px; font-size: .9rem; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.banner-info { background: var(--info-soft); }
.banner-warning { background: var(--warning-soft); color: var(--warning); }
.banner-danger { background: var(--danger-soft); color: var(--danger); }

/* Auth pages: split screen (dark red brand panel + sign-in card) */
.auth-body { background: var(--bg); }
.auth-split { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); min-height: 100vh; }
.auth-hero { position: relative; overflow: hidden; display: flex; flex-direction: column; padding: 48px 60px 28px; color: #fff;
  background: var(--hero-grad); }
.hero-copy { margin-top: auto; margin-bottom: auto; position: relative; z-index: 1; max-width: 460px; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; font-weight: 650; color: var(--brand-pale); margin-bottom: 18px; }
.hero-title { font-size: clamp(2.2rem, 3.6vw, 3rem); line-height: 1.12; font-weight: 750; letter-spacing: -.02em; margin: 0 0 22px; }
.hero-rule { display: block; width: 60px; height: 3px; border-radius: 3px; background: linear-gradient(90deg, #ffffff, var(--brand-pale)); margin-bottom: 22px; }
.hero-sub { color: rgba(230, 251, 251, .85); font-size: 1rem; }
.hero-arcs { position: absolute; right: -150px; bottom: -150px; width: 640px; height: 640px; pointer-events: none; }
.hero-arcs .arc-1 { stroke: rgba(255, 255, 255, .13); }
.hero-arcs .arc-2 { stroke: rgba(255, 255, 255, .09); }
.hero-arcs .arc-3 { stroke: rgba(255, 255, 255, .2); }
.hero-foot { position: relative; z-index: 1; margin: 0; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .1); font-size: .78rem; color: rgba(230, 251, 251, .7); }
.auth-side { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px 72px; overflow-y: auto; }
.auth-mobile-logo { display: none; margin-bottom: 22px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card.wide { max-width: 640px; }
.auth-panel { position: relative; padding: 30px 30px 26px; border-radius: 16px; box-shadow: var(--shadow-lg); border-color: transparent; overflow: hidden; }
.auth-panel::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--primary-hover), var(--brand) 55%, var(--brand-light)); }
.auth-panel h1, .auth-title { font-size: 1.6rem; font-weight: 750; letter-spacing: -.01em; margin-top: 4px; }
.auth-lead { color: var(--text-2); margin-bottom: 20px; }
.seg-tabs { display: flex; padding: 4px; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 24px; }
.seg-tabs a, .seg-tabs span { flex: 1; text-align: center; padding: 8px 10px; border-radius: 9px; font-size: .9rem; font-weight: 550; color: var(--text-2); text-decoration: none; }
.seg-tabs a:hover { color: var(--text); }
.seg-tabs .active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 650; }
.auth-panel input:not([type="checkbox"]):not([type="radio"]), .auth-panel select { padding-top: 11px; padding-bottom: 11px; border-radius: 9px; }
.btn-block { width: 100%; justify-content: center; }
.auth-panel .btn-primary { padding: 12px 16px; border-radius: 9px; font-weight: 650; background: linear-gradient(180deg, var(--brand), var(--primary-hover)); border-color: var(--primary-hover); }
.auth-panel .btn-primary:hover { background: var(--primary-hover); }
.auth-links { text-align: center; margin: 16px 0 0; font-size: .9rem; }
.auth-links a { color: var(--text-2); text-decoration: none; }
.auth-links a:hover { color: var(--primary); }
.auth-foot { text-align: center; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--border); }
.auth-theme { position: absolute; right: 18px; bottom: 18px; }
@media (max-width: 900px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-mobile-logo { display: block; }
  .auth-side { justify-content: flex-start; padding-top: 36px; }
  .auth-panel { padding: 24px 20px; }
}
.qr { background: #fff; padding: 8px; border-radius: 8px; display: inline-block; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 16px; font-family: var(--mono); background: var(--surface-2); padding: 12px; border-radius: 6px; }
.choice-list { list-style: none; padding: 0; margin: 0; }
.choice-list li + li { margin-top: 8px; }
.choice { width: 100%; text-align: left; justify-content: space-between; }

/* Wizard */
.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 16px; flex-wrap: wrap; counter-reset: step; }
.steps li { flex: 1; min-width: 110px; padding: 8px 10px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: .85rem; counter-increment: step; }
.steps li::before { content: counter(step) ". "; font-weight: 700; }
.steps li.done { color: var(--success); }
.steps li.current { border-color: var(--primary); color: var(--text); font-weight: 600; background: var(--primary-soft); }

.logo-preview { max-height: 72px; max-width: 220px; border: 1px solid var(--border); border-radius: 6px; padding: 6px; background: #fff; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } }
details summary { cursor: pointer; font-weight: 550; }
.pagination { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

@media print {
  .sidebar, .topbar, .banner, .form-actions, .btn { display: none !important; }
  .shell { display: block; }
  .card { box-shadow: none; border: none; }
}
a.card { display: block; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--primary); }
a.card h3 { color: var(--primary); }
.label-like { display: block; margin-bottom: 4px; }
.steps li a { color: inherit; }
pre { white-space: pre-wrap; word-break: break-word; margin: 4px 0 0; }
h2.mt, .mt { margin-top: 18px; }

/* ---------- Phase 3a: front desk ---------- */
.badge-lg { font-size: .95rem; padding: 4px 12px; }
.status-scheduled { background: var(--info-soft); color: var(--text); }
.status-arrived, .status-waiting { background: var(--warning-soft); color: var(--warning); }
.status-in_consultation { background: var(--primary-soft); color: var(--primary); }
.status-completed { background: var(--success-soft); color: var(--success); }
.status-cancelled, .status-no_show, .status-rescheduled { background: var(--surface-2); color: var(--text-3); }
.alert-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.alert-strip .badge { font-size: .85rem; white-space: normal; }
.alert-panel { border-color: var(--warning); }
.patient-photo { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
ul.plain { list-style: none; padding: 0; margin: 0 0 10px; }
ul.plain li { padding: 4px 0; border-bottom: 1px solid var(--border); }
ul.plain li:last-child { border-bottom: 0; }
.grow { flex: 1; min-width: 0; }

.cal-day { display: grid; gap: 12px; }
.cal-day.cols-1 { grid-template-columns: minmax(0, 520px); }
.cal-day.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cal-day.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cal-day.cols-4, .cal-day.cols-5 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .cal-day[class*="cols-"] { grid-template-columns: 1fr; } }
.slots { list-style: none; margin: 0; padding: 0; }
.slot { display: flex; gap: 8px; align-items: center; padding: 5px 6px; border-bottom: 1px solid var(--border); min-height: 34px; }
.slot-time { font-family: var(--mono); font-size: .85rem; color: var(--text-2); width: 46px; flex: none; }
.slot-past { opacity: .55; }
.slot-booked { background: var(--surface-2); }
.slot-free { text-decoration: none; color: var(--primary); font-size: .85rem; }
.cal-week td { text-align: center; padding: 4px; min-width: 90px; }
.cal-week td.slot-none { background: var(--surface-2); }
.cal-week th.is-today, .cal-cell.is-today { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: .78rem; text-transform: uppercase; color: var(--text-2); padding: 4px; }
.cal-cell { display: flex; flex-direction: column; min-height: 78px; padding: 6px; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; color: var(--text); }
.cal-cell.out { opacity: .45; }
.cal-num { font-weight: 650; }
.slot-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; margin-bottom: 14px; }
.slot-pick { margin: 0; font-weight: 500; }
.slot-pick input { position: absolute; opacity: 0; }
.slot-pick span { display: block; text-align: center; padding: 7px 4px; border: 1px solid var(--border-strong); border-radius: 6px; font-family: var(--mono); cursor: pointer; }
.slot-pick input:checked + span { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.slot-pick input:focus-visible + span { outline: 3px solid var(--focus); }
.slot-pick.slot-booked span, .slot-pick.slot-past span { opacity: .4; cursor: not-allowed; text-decoration: line-through; }

.board { display: grid; gap: 12px; }
.board.cols-1 { grid-template-columns: minmax(0, 640px); }
.board.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.board.cols-3, .board.cols-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1000px) { .board[class*="cols-"] { grid-template-columns: 1fr; } }
.board-col.mine { border-color: var(--primary); }
.board-col h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin-top: 14px; }
.now { padding: 10px; background: var(--surface-2); border-radius: 6px; display: grid; gap: 8px; }
.token { font-family: var(--mono); font-weight: 700; font-size: 1.05rem; display: inline-block; min-width: 42px; }
.queue-list { list-style: none; padding: 0; margin: 0; }
.queue-list li { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.queue-list li.prio-urgent { border-left: 4px solid var(--danger); padding-left: 6px; }
.queue-list li.prio-priority { border-left: 4px solid var(--warning); padding-left: 6px; }

body.tv { background: #0b1013; color: #f2f6f8; min-height: 100vh; }
.tv-head { display: flex; justify-content: space-between; padding: 18px 32px; font-size: 1.6rem; font-weight: 650; border-bottom: 1px solid #23313a; }
.tv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; padding: 28px 32px; }
.tv-card { background: #142027; border-radius: 14px; padding: 22px 26px; }
.tv-card h2 { font-size: 1.6rem; color: #9fd3e6; }
.tv-now { display: flex; align-items: baseline; gap: 16px; margin: 12px 0; }
.tv-now span { font-size: 1.3rem; color: #a9b8c2; }
.tv-now strong { font-size: 5rem; line-height: 1; font-family: var(--mono); color: #fff; }
.tv-next { font-size: 1.6rem; color: #cfe0e8; }
.tv-empty { font-size: 2rem; text-align: center; grid-column: 1 / -1; color: #a9b8c2; }

/* Phase 3b: billing */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-danger { color: var(--danger); }
.grid-bill { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid-bill { grid-template-columns: 1fr; } }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; margin: 12px 0 0 auto; max-width: 420px; font-variant-numeric: tabular-nums; }
.totals dd { margin: 0; text-align: right; }
.totals .strong { font-weight: 650; border-top: 1px solid var(--border); padding-top: 4px; }
.pay-line { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr); gap: 8px; }
.pay-line .input-prefix input { min-width: 0; width: 100%; }
@media (max-width: 600px) { .pay-line { grid-template-columns: 1fr; } }
.badge.bill-paid { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.bill-unpaid, .badge.bill-void { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.bill-partial, .badge.bill-draft { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.row > input, .row > select { width: auto; flex: 0 1 auto; }
.row > input[type=search] { flex: 1 1 240px; }
.row > .field { margin-bottom: 0; }
form.row > label { color: var(--text-2); font-size: .9rem; }

/* Phase 4: clinical */
.grid-emr { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .grid-emr { grid-template-columns: 1fr; } }
.note-section { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px 4px; margin: 0 0 12px; }
.note-section legend { font-weight: 650; padding: 0 6px; }
.note-text { white-space: pre-wrap; font-family: inherit; background: var(--surface-2); border-radius: 6px; padding: 10px 12px; margin: 6px 0; }
.addendum { border-left: 3px solid var(--warning); padding-left: 10px; margin-top: 10px; }
.checks.inline { display: flex; flex-wrap: wrap; gap: 4px 14px; border: 0; padding: 0; margin: 0; }
.checks.inline legend { font-weight: 500; margin-bottom: 4px; padding: 0; }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-bottom: 8px; }
.vgrid .field { margin-bottom: 0; }
table.compact th, table.compact td { padding: 4px 6px; font-size: .88rem; }
tr.struck td { text-decoration: line-through; color: var(--text-3); }
.rx-block { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; }
.rx-block.cancelled { opacity: .65; }
.rx-block.draft { border-style: dashed; }
.rx-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; align-items: end; margin: 10px 0; }
.rx-form .span-2 { grid-column: span 2; }
.rx-form .field { margin-bottom: 0; }
.rx-form .rx-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; padding-top: 4px; border-top: 1px dashed var(--border); margin-top: 4px; }
.btn-add { padding: 9px 18px; font-weight: 650; box-shadow: var(--shadow); }
.btn-add span { font-size: 1.15em; line-height: 1; font-weight: 700; }
@media (max-width: 700px) { .rx-form { grid-template-columns: 1fr; } .rx-form .span-2 { grid-column: auto; } }
.inline-details { display: inline-block; }
.inline-details[open] { display: block; margin: 4px 0; }
.visit-entry { border-bottom: 1px solid var(--border); padding: 8px 0; }
.clin-summary h2 { font-size: 1rem; margin-top: 12px; }
.clin-summary h2:first-child { margin-top: 0; }
.narrow { max-width: 640px; }

/* Phase 5: dental */
.odontogram-wrap { overflow-x: auto; }
.odontogram { width: 100%; min-width: 640px; max-width: 900px; display: block; margin: 0 auto 8px; }
.odontogram .sf { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1; cursor: pointer; }
.odontogram .tooth:not([tabindex]) .sf { cursor: default; }
.odontogram .sf-caries { fill: #d64545; }
.odontogram .sf-filled { fill: #3a78c2; }
.odontogram .sf-sealant { fill: #3fa66b; }
.odontogram .sf.pick { fill: #f2b84b; }
.odontogram .tooth.sel .sf { stroke: var(--primary); stroke-width: 2; }
.odontogram .tooth:focus { outline: none; }
.odontogram .tooth:focus-visible .sf { stroke: var(--primary); stroke-width: 2.5; }
.odontogram .cond-missing .sf { fill: var(--surface-2); stroke-dasharray: 2 2; }
.odontogram .cond-crown .sf, .odontogram .cond-implant .sf, .odontogram .cond-pontic .sf { stroke: #8a5cc2; stroke-width: 2; }
.odontogram .cond-root_canal .sf[data-surface="O"] { fill: #8a5cc2; }
.odontogram .cond-extraction_needed .sf, .odontogram .cond-fractured .sf { stroke: #d64545; stroke-width: 2; }
.odontogram .x { stroke: var(--text-2); stroke-width: 2; }
.odontogram .tn { font-size: 10px; fill: var(--text-2); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; padding: 0; margin: 4px 0 10px; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.legend .sw.sf-caries { background: #d64545; } .legend .sw.sf-filled { background: #3a78c2; } .legend .sw.sf-sealant { background: #3fa66b; }
.finding-form input[size] { width: auto; }
.plan { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }
.plan-cancelled, .plan-completed { opacity: .8; }
.sigpad { width: 100%; max-width: 520px; height: 160px; border: 1px dashed var(--border-strong); border-radius: 6px; background: #fff; touch-action: none; display: block; }
.gallery { display: flex; flex-wrap: wrap; gap: 10px; }
.gallery figure { margin: 0; width: 150px; font-size: .8rem; }
.gallery img { width: 150px; height: 110px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.gallery .pending { width: 150px; height: 110px; display: grid; place-items: center; background: var(--surface-2); border-radius: 6px; }
.w-visit { width: 70px; }

/* Copyable link */
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; font-family: var(--mono); font-size: .85rem; }

/* Sales contact on the sign-in page */
.contact-card { margin-top: 18px; padding: 16px 18px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.contact-card h2 { font-size: .95rem; margin: 0 0 4px; }
.contact-card p { color: var(--text-2); font-size: .86rem; margin-bottom: 12px; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.contact-actions a { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); text-decoration: none; font-size: .86rem; font-weight: 550; }
.contact-actions a:hover { border-color: var(--primary); color: var(--primary); }
.contact-actions a.wa { background: #e7f8ee; border-color: #bfe9cf; color: #146c3a; }
.contact-actions a.wa:hover { background: #d6f3e2; color: #0f5a30; }
.contact-support { margin-top: 10px; font-size: .8rem; color: var(--text-3); }
.contact-support a { color: var(--text-2); }
:root[data-theme="dark"] .contact-actions a.wa { background: #10301f; border-color: #1d5a37; color: #7fe0a6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .contact-actions a.wa { background: #10301f; border-color: #1d5a37; color: #7fe0a6; } }
.card form + h3 { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }
