/* ═══════════════════════════════════════════════════════════
   FCMS Design System — Global CSS
   Font: Cloud (all weights)
   Palette: Ruby Red | Emerald Green | Sapphire Blue | White | Black (Dr. Pat, 11 Oct 2026: only these;
   greys are tints of black, light fills are tints of the three gems; gold stays for the logo, keylines and the
   sign-in / sign-out buttons; no black or dark page backgrounds)
   ═══════════════════════════════════════════════════════════ */

/* ── FONT FACES ─────────────────────────────────────────── */
@font-face { font-family: 'Cloud'; src: url('./fonts/Cloud-Regular.ttf');         font-weight: 100; font-style: normal; }
@font-face { font-family: 'Cloud'; src: url('./fonts/Cloud-Italic.ttf');   font-weight: 100; font-style: italic; }
@font-face { font-family: 'Cloud'; src: url('./fonts/Cloud-Regular.ttf');        font-weight: 300; font-style: normal; }
@font-face { font-family: 'Cloud'; src: url('./fonts/Cloud-Italic.ttf');  font-weight: 300; font-style: italic; }
@font-face { font-family: 'Cloud'; src: url('./fonts/Cloud-Regular.ttf');      font-weight: 400; font-style: normal; }
@font-face { font-family: 'Cloud'; src: url('./fonts/Cloud-Italic.ttf');       font-weight: 400; font-style: italic; }
@font-face { font-family: 'Cloud'; src: url('./fonts/Cloud-SemiBold.ttf');     font-weight: 600; font-style: normal; }
@font-face { font-family: 'Cloud'; src: url('./fonts/Cloud-SemiBoldIta.ttf'); font-weight: 600; font-style: italic; }
@font-face { font-family: 'Cloud'; src: url('./fonts/Cloud-Bold.ttf');         font-weight: 700; font-style: normal; }
@font-face { font-family: 'Cloud'; src: url('./fonts/Cloud-BoldItalic.ttf');   font-weight: 700; font-style: italic; }

/* ── CSS VARIABLES ──────────────────────────────────────── */
:root {
  /* Font — symbol fallbacks ensure Dingbats/checkmarks (✕, ✎, ➤, ✓, ↻) absent from Cloud-*.ttf never render as ▯ boxes */
  --font-primary: 'Cloud', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple Symbols', 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'Noto Sans Symbols', sans-serif;

  /* Ruby Red */
  --ruby:        #E0115F;
  --ruby-light:  #E9588F;
  --ruby-dark:   #A00040;
  --ruby-muted:  #FCE4EE;

  /* Emerald Green */
  --emerald:       #009473;
  --emerald-vivid: #50C878;
  --emerald-dark:  #006B54;
  --emerald-muted: #E0F5EF;

  /* Sapphire Blue */
  --sapphire:      #0F52BA;
  --sapphire-deep: #151667;
  --sapphire-light:#4B7DCB;
  --sapphire-muted:#E8EEFA;

  /* Gem deep tones and page grounds (the Gem colour pages, 23 Oct 2026): the dark partner of each gem for table
     headers and primary buttons, and the tinted ground each gem sits on */
  --ruby-deep:  #9B0E45;
  --pine:       #0C3B30;
  --midnight:   var(--sapphire-deep);
  --ground-ivory:     #FBF6F0;   /* under Ruby */
  --ground-cream:     #F6F4EC;   /* under Emerald */
  --ground-porcelain: #F2F4F8;   /* under Sapphire */

  /* Neutrals */
  --white:  #FFFFFF;
  --black:  #000000;
  /* greys = black at 2 / 4 / 10 / 17 / 35 / 55 / 65 / 75 / 85 / 92 % on white (no blue cast) */
  --gray-50:  #FAFAFA;
  --gray-100: #F5F5F5;
  --gray-200: #E6E6E6;
  --gray-300: #D4D4D4;
  --gray-400: #A6A6A6;
  --gray-500: #737373;
  --gray-600: #595959;
  --gray-700: #404040;
  --gray-800: #262626;
  --gray-900: #141414;

  /* Brand accent (LIFE by Dr. Pat): gold rules / highlights; --gold-dark is gold for text on white (4.5:1).
     --cream is kept as a name only: the page ground is white */
  --gold:       #C9A24B;
  --gold-light: #D4AF37;
  --gold-dark:  #8B7331;
  --gold-shine: #F0D77B;
  --cream:      #FFFFFF;

  /* Semantic roles */
  --color-primary:    var(--sapphire);
  --color-secondary:  var(--emerald);
  --color-danger:     var(--ruby);
  --color-success:    var(--emerald-vivid);
  --color-warning:    var(--ruby);        /* warnings are ruby tints (no amber / yellow) */
  --color-warning-dark: var(--ruby-dark); /* warning as text / thin lines on white (4.5:1 contrast) */
  --color-info:       var(--sapphire-light);

  /* UI surfaces */
  --bg-app:       var(--white);
  --bg-card:      var(--white);
  --bg-sidebar:   var(--sapphire-deep);
  --bg-header:    var(--white);

  /* Text */
  --text-primary:   var(--black);
  --text-secondary: var(--gray-900);
  --text-inverse:   var(--white);
  --text-danger:    var(--ruby);
  --text-success:   var(--emerald-dark);

  /* Borders */
  --border-color: var(--gray-200);
  --border-radius-sm: 6px;
  --border-radius:    10px;
  --border-radius-lg: 16px;
  --border-radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow:    0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Typography scale */
  --text-xs:   12px;
  --text-sm:   14px;
  --text-base: 16px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;
  --text-4xl:  36px;

  /* Sidebar typography hierarchy (Task 3c) */
  --sidebar-heading-size:   16px;
  --sidebar-heading-weight: 700;
  --sidebar-heading-color:  var(--white);
  --sidebar-item-size:      14px;
  --sidebar-item-weight:    400;
  --sidebar-item-indent:    10px;
}

/* ── RESET & BASE ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* ── TYPOGRAPHY ─────────────────────────────────────────── */
h1 { font-size: var(--text-4xl); font-weight: 600; line-height: 1.2; color: var(--sapphire-deep); }
h2 { font-size: var(--text-3xl); font-weight: 600; line-height: 1.25; color: var(--sapphire-deep); }
h3 { font-size: var(--text-2xl); font-weight: 600; color: var(--sapphire-deep); line-height: 1.3; }
h4 { font-size: var(--text-xl);  font-weight: 600; color: var(--sapphire-deep); }
h5 { font-size: var(--text-lg);  font-weight: 600; color: var(--sapphire-deep); }
h6 { font-size: var(--text-base);font-weight: 600; color: var(--sapphire-deep); }

.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }
.text-2xl  { font-size: var(--text-2xl); }

.font-thin      { font-weight: 400; }
.font-light     { font-weight: 400; }
.font-regular   { font-weight: 400; }
.font-semibold  { font-weight: 600; }
.font-bold      { font-weight: 700; }

/* ── DEPARTMENT COLOURS (Dr. Pat, 23 Oct 2026) ───────────────────────────────────────────────────────────────
   Every page belongs to one department (app/ui_terms.py DEPARTMENTS / dept_for): medical = emerald, laboratory = ruby,
   office (front desk, pharmacy & supply, finance, growth, management, customer service) = sapphire. life-bar.js and the
   Shell set data-dept on <html>; the sidebar, the page ground, table headers, primary buttons, tabs, focus rings and
   highlight cards read these tokens (journey.css and the module stylesheets). Without data-dept a page is an office page. */
:root, html[data-dept="office"] {
  --dept: var(--sapphire); --dept-deep: var(--sapphire-deep); --dept-tint: var(--sapphire-muted);
  --dept-ground: var(--ground-porcelain); --dept-shadow: rgba(21,22,103,.25); }
html[data-dept="medical"] {
  --dept: var(--emerald); --dept-deep: var(--pine); --dept-tint: var(--emerald-muted);
  --dept-ground: var(--ground-cream); --dept-shadow: rgba(0,148,115,.28); }
html[data-dept="lab"] {
  --dept: var(--ruby); --dept-deep: var(--ruby-deep); --dept-tint: var(--ruby-muted);
  --dept-ground: var(--ground-ivory); --dept-shadow: rgba(224,17,95,.28); }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 20px;
  border-radius: var(--border-radius);
  font-family: var(--font-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* a raised key: an edge of the button's own colour under it, a lift on hover, a press on click (see journey.css) */
  --btn-edge: color-mix(in srgb, var(--dept) 60%, var(--black));
  --btn-glow: var(--dept-shadow);
  box-shadow: 0 3px 0 var(--btn-edge), 0 5px 10px -2px var(--btn-glow), inset 0 1px 0 color-mix(in srgb, var(--white) 30%, transparent);
  transition: transform .09s cubic-bezier(.2,.7,.3,1.3), box-shadow .09s ease, background-color .12s ease, filter .12s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 0 var(--btn-edge), 0 9px 16px -3px var(--btn-glow), inset 0 1px 0 color-mix(in srgb, var(--white) 30%, transparent); }
.btn:active:not(:disabled) { transform: translateY(3px); filter: brightness(.95); transition-duration: .05s;
  box-shadow: 0 0 0 var(--btn-edge), 0 1px 2px var(--btn-glow), inset 0 2px 5px color-mix(in srgb, var(--black) 22%, transparent); }
.btn:disabled { box-shadow: none; transform: none; }

.btn-primary   { background: var(--dept);      color: var(--white); --btn-edge: color-mix(in srgb, var(--dept) 60%, var(--black)); --btn-glow: var(--dept-shadow); }
.btn-primary:hover { background: var(--dept-deep); --btn-edge: color-mix(in srgb, var(--dept-deep) 60%, var(--black)); }

.btn-secondary { background: var(--emerald);       color: var(--white); --btn-edge: color-mix(in srgb, var(--emerald) 60%, var(--black)); --btn-glow: color-mix(in srgb, var(--emerald) 28%, transparent); }
.btn-secondary:hover { background: var(--emerald-dark); --btn-edge: color-mix(in srgb, var(--emerald-dark) 60%, var(--black)); }

.btn-danger    { background: var(--ruby);          color: var(--white); --btn-edge: color-mix(in srgb, var(--ruby) 60%, var(--black)); --btn-glow: color-mix(in srgb, var(--ruby) 28%, transparent); }
.btn-danger:hover { background: var(--ruby-dark); --btn-edge: color-mix(in srgb, var(--ruby-dark) 60%, var(--black)); }

.btn-ghost {
  background: var(--white);
  color: var(--sapphire);
  border: 1.5px solid var(--sapphire);
  --btn-edge: var(--sapphire);
  --btn-glow: color-mix(in srgb, var(--black) 10%, transparent);
}
.btn-ghost:hover { background: var(--sapphire-muted); }

.btn-sm { padding: 6px 14px; font-size: var(--text-xs); }
.btn-lg { padding: 14px 28px; font-size: var(--text-lg); }

/* ── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}
.card-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
}

/* ── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: var(--text-xs);
  font-weight: 600;
}
.badge-primary  { background: var(--sapphire-muted); color: var(--sapphire); }
.badge-success  { background: var(--emerald-muted);  color: var(--emerald-dark); }
.badge-danger   { background: var(--ruby-muted);     color: var(--ruby-dark); }
.badge-warning  { background: #FEF3C7;               color: #92400E; }
.badge-neutral  { background: var(--gray-100);       color: var(--gray-700); }

/* ── FORM ELEMENTS ──────────────────────────────────────── */
.input, .select, .textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius);
  font-family: var(--font-primary);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--white);
  transition: border-color 0.2s;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--sapphire);
  box-shadow: 0 0 0 3px var(--sapphire-muted);
}
.input.error { border-color: var(--ruby); }
.input.error:focus { box-shadow: 0 0 0 3px var(--ruby-muted); }

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: var(--space-1);
}

/* ── TABLES ─────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th {
  background: var(--sapphire-deep);
  color: var(--white);
  font-weight: 600;
  text-align: left;
  padding: 12px 16px;
}
.table th:first-child { border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm); }
.table th:last-child  { border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0; }
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}
.table tr:hover td { background: var(--sapphire-muted); }
.table tr:last-child td { border-bottom: none; }

/* ── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  background: var(--sapphire-deep);
  color: var(--white);
  width: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar-logo {
  padding: var(--space-6);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-6) 8px calc(var(--space-6) + var(--sidebar-item-indent, 10px));
  color: rgba(255,255,255,0.85);
  font-size: var(--sidebar-item-size, 14px);
  font-weight: var(--sidebar-item-weight, 400);
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.sidebar-nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: var(--white);
}
.sidebar-nav-item.active {
  background: rgba(255,255,255,0.12);
  color: var(--white);
  font-weight: var(--sidebar-item-weight, 400);
  border-left-color: var(--emerald-vivid);
}
.sidebar-section-label {
  padding: var(--space-4) var(--space-6) var(--space-2);
  font-size: var(--sidebar-heading-size, 16px);
  font-weight: var(--sidebar-heading-weight, 700);
  text-transform: none;
  letter-spacing: normal;
  color: var(--sidebar-heading-color, var(--white));
}

/* ── LUXE SIDE PANEL (24 Oct 2026) ───────────────────────
   Dr. Pat: the flat pink panel "is not elegant and luxurious" and should carry the gold logo. The staff sidebar (journey.css,
   class "sidebar luxe-panel") and the home page's panel (dashboard.html) share this: the department colour graded from light at
   the top to its deep tone at the foot, a soft sheen behind the logo, a fading gold hairline on the edge, the gold logo and a
   gold ornament rule. Tokens only; the colour is still --dept / --dept-deep. */
.luxe-panel {
  background:
    radial-gradient(120% 44% at 50% 0%, color-mix(in srgb, var(--white) 26%, transparent) 0%, transparent 72%),
    linear-gradient(172deg, var(--dept) 0%, color-mix(in srgb, var(--dept) 52%, var(--dept-deep)) 46%, var(--dept-deep) 100%);
  color: var(--white);
  box-shadow: 10px 0 30px -14px color-mix(in srgb, var(--black) 55%, transparent);
}
.luxe-panel::after {
  content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 1.5px; pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, var(--gold-shine) 16%, var(--gold) 50%, var(--gold-shine) 84%, transparent 100%);
}
.luxe-brand { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 4px 0 2px; }
.luxe-brand img {
  width: var(--luxe-logo, 88px); height: auto; display: block;
  filter: drop-shadow(0 1px 2px color-mix(in srgb, var(--black) 30%, transparent));
}
.luxe-brand small {
  display: block; margin-top: 8px; font-family: var(--font-primary); font-weight: 600; font-size: 10.5px; line-height: 1.5;
  letter-spacing: .18em; text-transform: uppercase; color: var(--white); opacity: .92;
}
.luxe-brand .orn { display: block; position: relative; align-self: stretch; height: 9px; margin-top: 12px; }
.luxe-brand .orn::before {
  content: ''; position: absolute; left: 4%; right: 4%; top: 4px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold) 26%, var(--gold-shine) 50%, var(--gold) 74%, transparent);
}
.luxe-brand .orn::after {
  content: ''; position: absolute; left: 50%; top: 0; width: 7px; height: 7px; margin-left: -3.5px; transform: rotate(45deg);
  background: var(--gold-shine); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dept) 48%, var(--dept-deep));
}
.luxe-brand .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── STATUS INDICATORS ──────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-pending    { background: #F59E0B; }
.status-active     { background: var(--emerald-vivid); }
.status-resulted   { background: var(--sapphire); }
.status-verified   { background: var(--emerald-dark); }
.status-cancelled  { background: var(--ruby); }
.status-critical   { background: var(--ruby); animation: pulse 1.5s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── ALERTS ─────────────────────────────────────────────── */
.alert {
  padding: var(--space-4);
  border-radius: var(--border-radius);
  font-size: var(--text-sm);
  border-left: 4px solid;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.alert-danger  { background: var(--ruby-muted);     border-color: var(--ruby);    color: var(--ruby-dark); }
.alert-success { background: var(--emerald-muted);  border-color: var(--emerald); color: var(--emerald-dark); }
.alert-info    { background: var(--sapphire-muted); border-color: var(--sapphire);color: var(--sapphire); }
.alert-warning { background: #FEF3C7; border-color: #F59E0B; color: #92400E; }

/* ── LAYOUT UTILITIES ───────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-6); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }

/* ── SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--sapphire-light); }

/* No stylus handwriting in text fields — typing only, on the on-screen keyboard (Dr. Pat, 9 Nov 2026: the Xiaomi Pad 7
   must not accept handwriting). Android starts stylus handwriting on a field only when its touch-action allows both
   pan-x and pan-y; pan-y + pinch-zoom keeps vertical scrolling and zoom but no handwriting — and stays off under the
   proposed standard `handwriting` keyword (w3c/pointerevents #516), which this list does not include. Signature pads
   are canvases, not text fields, so they are not affected. */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]),
textarea, select, [contenteditable]:not([contenteditable=false]) {
  touch-action: pan-y pinch-zoom;
}

/* Printed / exported pages: Cloud Regular throughout, no bold (Dr. Pat, 16 Nov 2026: "does not need to be all bold. it scream
   too much attention" … "use regular cloud font not the light or thin one"). The PDFs follow the same rule. Labels and the
   accounting documents keep their own weights. */
@media print {
  body, body * { font-weight: 400 !important; }
  body { line-height: 1.55; }
}
