/* ==========================================================================
   DrVidia Enterprise Clinical Design System
   Calm clinical look: deep slate-navy topbar, medical teal accent, strong flag
   colours, tabular numerals for results, big touch targets, print-safe.
   Fonts are vendored (static/fonts) - nothing loads from the internet.
   Legacy class names (.btn .card .badge .alert .topbar .nav-group) are kept
   so every existing screen picks up the new look without template changes.
   ========================================================================== */

@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/Inter-Regular.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/Inter-Medium.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/Inter-SemiBold.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/Inter-Bold.woff") format("woff"); }

:root {
  /* surfaces */
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  /* text */
  --text: #0f172a;
  --muted: #475569;
  --faint: #94a3b8;
  /* brand */
  --ink: #0b192c;
  --ink-2: #16324f;
  --primary: #0f766e;
  --primary-hover: #0d5e58;
  --primary-soft: #e6f7f5;
  /* semantic */
  --danger: #dc2626;   --danger-soft: #fef2f2;
  --warning: #d97706;  --warning-soft: #fffbeb;
  --success: #16a34a;  --success-soft: #f0fdf4;
  --info: #0284c7;     --info-soft: #f0f9ff;
  /* lab result flags */
  --flag-normal: #15803d;
  --flag-high: #c2410c;
  --flag-low: #0369a1;
  --flag-critical: #b91c1c;
  /* shape + depth */
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-1: 0 1px 3px rgba(15, 23, 42, .05), 0 1px 2px rgba(15, 23, 42, .03);
  --shadow-2: 0 12px 32px rgba(15, 23, 42, .14), 0 2px 6px rgba(15, 23, 42, .06);
  --ring: 0 0 0 3px rgba(15, 118, 110, .25);
  --role-accent: #2dd4bf;
}

/* role accent: colours the current user's home pill and header underline */
body.role-reception    { --role-accent: #6cc4f5; }
body.role-technician   { --role-accent: #7ee0c3; }
body.role-pathologist  { --role-accent: #8fe388; }
body.role-radiologist, body.role-radiographer { --role-accent: #c3a6ff; }
body.role-phlebotomist { --role-accent: #ff9fb0; }
body.role-accountant   { --role-accent: #ffd66b; }
body.role-manager      { --role-accent: #6cc4f5; }
body.role-owner        { --role-accent: #ffd66b; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", "Nirmala UI", "Noto Sans Devanagari", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
  font-feature-settings: "kern", "calt";
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.3rem;  font-weight: 700; }
h3 { font-size: 1.08rem; font-weight: 600; }
h4 { font-size: 0.98rem; font-weight: 600; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
small, .text-muted { color: var(--muted); }
code, kbd, .mono { font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace; font-size: 0.9em; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ---------- Header / navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 900;
  background: linear-gradient(90deg, #0b192c 0%, #0f2537 100%);
  color: #fff;
  padding: 0 1.25rem;
  min-height: 60px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem;
  border-bottom: 3px solid var(--role-accent);
  box-shadow: 0 3px 12px rgba(11, 25, 44, .22);
}
.topbar a { color: #f1f5f9; text-decoration: none; font-weight: 600; }
.brand-wrap { display: inline-flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em; color: #fff !important; }
.brand-logo-img {
  height: 34px; max-width: 110px; object-fit: contain;
  background: #ffffff; border-radius: 6px; padding: 2px 5px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.brand-mark-dv {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  display: inline-grid; place-items: center; color: #fff;
  box-shadow: 0 2px 6px rgba(20, 184, 166, .35);
}
.brand-monogram {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  display: inline-grid; place-items: center; font-size: 0.78rem; font-weight: 800; color: #fff;
  letter-spacing: 0.03em;
}
.brand-sub { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 0.98rem; font-weight: 700; color: #ffffff; }
.brand-meta { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.7rem; color: #94a3b8; font-weight: 600; }
.platform-pill {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.14rem 0.5rem; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  background: rgba(20, 184, 166, .16); color: #5eead4; border: 1px solid rgba(94, 234, 212, .28);
}
.lab-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.18rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, .18); border-radius: 999px;
  font-size: 0.74rem; font-weight: 700; color: #e2e8f0; background: rgba(255, 255, 255, .07);
}
.mode-chip { padding: 0.14rem 0.5rem; border-radius: 999px; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.06em; }
.mode-chip.test { background: #fbbf24; color: #451a03; }
.mode-chip.live { background: #22c55e; color: #052e16; }
.exit-console-btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.24rem 0.65rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700;
  background: rgba(251, 191, 36, .16); color: #fde68a !important;
  border: 1px solid rgba(251, 191, 36, .4);
  transition: background .15s;
}
.exit-console-btn:hover { background: rgba(251, 191, 36, .28); }

.topbar-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.35rem; font-size: 0.86rem; }
.topbar-nav > a, .nav-group summary {
  padding: 0.45rem 0.68rem; border-radius: 7px; color: #e2e8f0; font-weight: 600;
  display: inline-flex; align-items: center; gap: 0.35rem;
  transition: background .12s, color .12s;
}
.topbar-nav > a:hover, .nav-group summary:hover { background: rgba(255, 255, 255, .11); color: #fff; }
.nav-home {
  color: var(--role-accent) !important;
  background: rgba(255, 255, 255, .08);
  border: 1px solid color-mix(in srgb, var(--role-accent) 40%, transparent);
}
.nav-group { position: relative; display: inline-block; }
.nav-group summary { cursor: pointer; list-style: none; user-select: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group[open] summary { background: rgba(255, 255, 255, .18); color: #fff; }
.nav-group-menu {
  position: absolute; top: calc(100% + 8px); left: 0;
  background: var(--surface); color: var(--text);
  min-width: 240px; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-2); padding: 0.4rem; z-index: 1000;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-group:last-of-type .nav-group-menu { left: auto; right: 0; }
.nav-menu-label {
  padding: 0.35rem 0.65rem 0.2rem; font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint);
}
.nav-group-menu a {
  color: var(--text) !important; padding: 0.48rem 0.7rem; border-radius: 6px;
  font-weight: 500; font-size: 0.86rem; display: flex; align-items: center; gap: 0.45rem;
  white-space: nowrap; text-decoration: none;
}
.nav-group-menu a:hover { background: var(--primary-soft); color: var(--primary) !important; }
.nav-menu-divider { border-top: 1px solid var(--border); margin: 0.25rem 0; }
.user-pill {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.2rem 0.55rem 0.2rem 0.25rem;
  border-radius: 999px; background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14); margin: 0 0.2rem 0 0.4rem;
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 999px;
  background: var(--primary); color: #fff;
  display: inline-grid; place-items: center;
  font-size: 0.72rem; font-weight: 800; text-transform: uppercase;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.1; }
.nav-user { font-size: 0.8rem; font-weight: 600; color: #f8fafc; margin: 0; }
.nav-role { font-size: 0.65rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.04em; }
.topbar .btn-outline { background: transparent; color: #fff !important; border-color: rgba(255, 255, 255, .28); padding: 0.3rem 0.65rem; min-height: 32px; font-size: 0.8rem; }
.topbar .btn-outline:hover { background: rgba(255, 255, 255, .14); }
.ico { width: 15px; height: 15px; flex: 0 0 15px; opacity: 0.85; }

/* ---------- Enterprise Login Shell ---------- */
.login-shell {
  min-height: calc(100vh - 130px);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem 0.75rem;
}
.login-card {
  width: 100%; max-width: 440px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-2); overflow: hidden;
}
.login-header {
  background: linear-gradient(135deg, #0b192c 0%, #13314c 100%);
  color: #fff; padding: 1.5rem 1.75rem; text-align: center;
  border-bottom: 3px solid #14b8a6;
}
.login-brand-logo {
  height: 54px; max-width: 160px; object-fit: contain;
  background: #fff; border-radius: 10px; padding: 5px 10px;
  margin-bottom: 0.75rem; box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
}
.login-emblem {
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  display: inline-grid; place-items: center; margin: 0 auto 0.75rem;
  box-shadow: 0 4px 14px rgba(20, 184, 166, .35);
}
.login-header h1 { color: #fff; font-size: 1.25rem; margin: 0; font-weight: 700; }
.login-header .login-sub { color: #cbd5e1; font-size: 0.82rem; margin-top: 0.3rem; line-height: 1.4; }
.login-body { padding: 1.5rem 1.75rem 1.25rem; }
.login-trust-footer {
  background: var(--surface-2); border-top: 1px solid var(--border);
  padding: 0.75rem 1.5rem; text-align: center;
  font-size: 0.74rem; color: var(--muted); font-weight: 500;
}

.mode-banner {
  background: repeating-linear-gradient(135deg, #fff4dc, #fff4dc 14px, #ffeab8 14px, #ffeab8 28px);
  color: #6b4500; text-align: center; font-size: 0.8rem; font-weight: 700;
  padding: 0.35rem 1rem; border-bottom: 1px solid #f1d28b; letter-spacing: 0.03em;
}

/* ---------- Layout ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.page-header h1, .page-header h2 { margin: 0; }
.page-header .sub { color: var(--muted); font-size: 0.9rem; margin-top: 0.15rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.stack > * + * { margin-top: 0.75rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.1rem 1.15rem; margin-bottom: 1rem; box-shadow: var(--shadow-1);
}
.card h2, .card h3 { margin-top: 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0.9rem 1rem; box-shadow: var(--shadow-1); }
.stat .num { font-size: 1.7rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .lbl { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 1rem; min-height: 38px;
  border-radius: var(--radius); border: 1px solid transparent;
  background: var(--primary); color: #fff !important;
  font: inherit; font-weight: 600; font-size: 0.9rem; line-height: 1.2;
  cursor: pointer; text-decoration: none; transition: background .12s, box-shadow .12s, transform .05s;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--ink) !important; }
.btn-outline:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary) !important; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a61e1e; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #226f32; }
.btn-warning { background: #f08c00; color: #3b2400 !important; }
.btn-sm { min-height: 30px; padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-lg { min-height: 48px; padding: 0.7rem 1.4rem; font-size: 1rem; }

/* ---------- Forms ---------- */
label { font-weight: 600; font-size: 0.85rem; color: var(--ink-2); }
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select, textarea {
  width: 100%; padding: 0.5rem 0.65rem; min-height: 38px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: #fff; color: var(--text); font: inherit; font-size: 0.95rem;
}
input[type=checkbox], input[type=radio] { width: 1.05rem; height: 1.05rem; accent-color: var(--primary); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--faint); }
.help { color: var(--muted); font-size: 0.8rem; margin-top: 0.2rem; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
th, td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
thead th, th {
  background: var(--surface-2); color: var(--muted); font-size: 0.74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
tbody tr:hover { background: #f4fafb; }
tr:last-child td { border-bottom: 0; }

/* ---------- Badges, flags, alerts ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.12rem 0.6rem; border-radius: 999px;
  font-size: 0.74rem; font-weight: 700; background: #e8edf1; color: var(--ink-2); letter-spacing: 0.01em;
}
.badge-danger  { background: var(--danger-soft);  color: #8f1f1f; }
.badge-success { background: var(--success-soft); color: #1d6a2e; }
.badge-warning { background: var(--warning-soft); color: #7a4800; }
.badge-info    { background: var(--info-soft);    color: #174f9e; }
.flag { font-weight: 800; font-variant-numeric: tabular-nums; }
.flag-H  { color: var(--flag-high); }
.flag-L  { color: var(--flag-low); }
.flag-CH, .flag-CL, .flag-A { color: #fff; background: var(--flag-critical); padding: 0.05rem 0.4rem; border-radius: 4px; }
.flag-N  { color: var(--flag-normal); }

.alert {
  padding: 0.7rem 0.95rem; border-radius: var(--radius); margin-bottom: 0.75rem;
  border: 1px solid var(--border); border-left-width: 4px; background: var(--surface);
}
.alert-error, .alert-danger { background: var(--danger-soft);  border-color: #f3b4b4; border-left-color: var(--danger);  color: #7d1b1b; }
.alert-success              { background: var(--success-soft); border-color: #b7e0c0; border-left-color: var(--success); color: #1b5a29; }
.alert-warning              { background: var(--warning-soft); border-color: #f1d28b; border-left-color: #f08c00;       color: #6b4500; }
.alert-info                 { background: var(--info-soft);    border-color: #b9d0f1; border-left-color: var(--info);    color: #174580; }

/* ---------- Small screens, touch, motion, print ---------- */
@media (max-width: 760px) {
  .topbar { padding: 0.4rem 0.6rem; }
  .lab-chip { display: none; }
  .nav-group-menu { position: fixed; left: 0.5rem; right: 0.5rem; top: 56px; min-width: 0; max-height: 70vh; overflow-y: auto; }
  .container { padding: 0.8rem 0.6rem 3rem; }
}
@media (max-width: 480px) {
  .card { padding: 0.8rem; }
  th, td { padding: 0.4rem 0.45rem; font-size: 0.82rem; }
}
@media (pointer: coarse) {
  .btn { min-height: 46px; }
  input:not([type=checkbox]):not([type=radio]), select { min-height: 46px; }
  .nav-group-menu a { padding: 0.75rem 0.9rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .topbar, .mode-banner, .btn, .no-print, form button { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .card, .table-scroll { box-shadow: none; border-color: #999; }
  .container { max-width: none; padding: 0; }
}
