/* Уни Хоспитал – триаж: the work-schedule app's design (Andrei Alexandrov), gathered into one
   stylesheet so the pages need no inline styles (strict Content-Security-Policy).
   Light theme by default (<html data-theme="light">), dark when chosen with the menu's switch
   (static/js/theme-init.js applies it before the page is drawn). Colours are variables below;
   components only use the variables. Haelan teal for structure, bright green only as an accent. */

/* ---- Colours ------------------------------------------------------------------------- */
:root {
  color-scheme: light;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --menu-w: 230px;
  --brand-teal: #024a56;
  --brand-teal-dark: #013640;
  --brand-green: #0bda51;

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --field-border: #cbd5e1;
  --field-bg: #ffffff;
  --text: #024a56;
  --heading: #024a56;
  --muted: #64748b;
  --link: #024a56;
  --link-hover: #036070;
  --link-weight: 500;
  --focus: rgba(2, 74, 86, 0.5);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --glow: rgba(13, 148, 136, 0.09);

  --button-bg: #024a56;
  --button-hover: #036070;
  --button-text: #ffffff;
  --button-ring: none;
  --secondary-bg: #ffffff;
  --secondary-text: #024a56;
  --secondary-border: #024a56;
  --secondary-hover: #f1f5f9;
  --danger-bg: #b42318;
  --danger-text: #ffffff;
  --danger-border: #b42318;
  --danger-hover-bg: #8f1c13;
  --disabled-bg: #e2e8f0;
  --disabled-text: #7c8ba0;

  --ok-bg: #dcfce7; --ok: #166534;
  --warn-bg: #fef3c7; --warn: #92400e;
  --error-bg: #fde2e1; --error: #b42318;
  --info-bg: #dbeafe; --info: #1d4ed8;
  --off-bg: #eef2f6; --off: #64748b;
  /* The response-time signal: pink (warning) and red (overdue), always with a text label */
  --pink-bg: #fce7f3; --pink: #9d174d;
  --red-bg: #fee2e2; --red: #991b1b;
  --medical-bg: #dbeafe; --medical: #1d4ed8;

  --menu-bg: #ffffff;
  --menu-border: #e2e8f0;
  --menu-text: #64748b;
  --menu-strong: #024a56;
  --menu-hover-bg: rgba(2, 74, 86, 0.09);
  --menu-hover-text: #024a56;
  --menu-active-bg: #024a56;
  --menu-active-text: #ffffff;
  --menu-group-bar: #0d9488;
  --menu-button-text: #64748b;
  --menu-button-border: #e2e8f0;
  --menu-scrollbar: #cbd5e1;

  --hero-bg: radial-gradient(120% 140% at 0% 0%, rgba(13, 148, 136, 0.12), transparent 55%), #ffffff;
  --hero-border: #d5e3e8;
  --hero-title: #024a56;
  --hero-lead: #24515b;
  --tile-bg: #f8fbfc;
  --tile-border: #dbe7eb;
  --tile-label: #64748b;
  --tile-number: #024a56;

  --dialog-bg: #ffffff;
  --dialog-text: #024a56;
  --backdrop: rgba(2, 74, 86, 0.35);
  --toast-bg: #ffffff;
  --toast-border: #e2e8f0;
  --toast-text: #0f172a;
  --toast-shadow: 0 12px 32px rgba(2, 74, 86, 0.16);

  --role-admin-bg: #dbeafe; --role-admin: #1d4ed8;
  --role-operator-bg: #ccfbf1; --role-operator: #0f766e;
  --role-uh-bg: #ede9fe; --role-uh: #6d28d9;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #172033;
  --surface-soft: #1b2639;
  --surface-hover: #1e293b;
  --border: #334155;
  --field-border: #334155;
  --field-bg: #1e293b;
  --text: #e2e8f0;
  --heading: #e2e8f0;
  --muted: #94a3b8;
  --link: #94a3b8;
  --link-hover: #e2e8f0;
  --link-weight: 600;
  --focus: rgba(13, 148, 136, 0.8);
  --shadow: none;
  --glow: rgba(20, 184, 166, 0.13);

  --button-bg: #e8b85b;
  --button-hover: #f5cf7e;
  --button-text: #0f172a;
  --button-ring: 0 0 0 3px rgba(232, 184, 91, 0.35);
  --secondary-bg: #1e293b;
  --secondary-text: #e2e8f0;
  --secondary-border: #334155;
  --secondary-hover: #334155;
  --danger-bg: transparent;
  --danger-text: #f87171;
  --danger-border: #ef4444;
  --danger-hover-bg: #b42318;
  --disabled-bg: #334155;
  --disabled-text: #64748b;

  --ok-bg: rgba(22, 163, 74, 0.2); --ok: #86efac;
  --warn-bg: rgba(245, 158, 11, 0.18); --warn: #fcd34d;
  --error-bg: rgba(239, 68, 68, 0.15); --error: #f87171;
  --info-bg: rgba(59, 130, 246, 0.2); --info: #93c5fd;
  --off-bg: #1e293b; --off: #94a3b8;
  --pink-bg: rgba(236, 72, 153, 0.18); --pink: #f9a8d4;
  --red-bg: rgba(239, 68, 68, 0.22); --red: #fca5a5;
  --medical-bg: rgba(59, 130, 246, 0.2); --medical: #93c5fd;

  --menu-bg: #1e293b;
  --menu-border: #0f172a;
  --menu-text: #cbd5e1;
  --menu-strong: #e2e8f0;
  --menu-hover-bg: #0f172a;
  --menu-hover-text: #e8b85b;
  --menu-active-bg: #0f172a;
  --menu-active-text: #e8b85b;
  --menu-group-bar: #2dd4bf;
  --menu-button-text: #94a3b8;
  --menu-button-border: #475569;
  --menu-scrollbar: #475569;

  --hero-bg: radial-gradient(120% 140% at 0% 0%, rgba(20, 184, 166, 0.16), transparent 55%), #111c2e;
  --hero-border: #22344d;
  --hero-title: #f8fafc;
  --hero-lead: #cbd5e1;
  --tile-bg: rgba(15, 23, 42, 0.55);
  --tile-border: #22344d;
  --tile-label: #94a3b8;
  --tile-number: #f1f5f9;

  --dialog-bg: #172033;
  --dialog-text: #e2e8f0;
  --backdrop: rgba(2, 6, 23, 0.65);
  --toast-bg: #1b2740;
  --toast-border: #2b3a52;
  --toast-text: #e2e8f0;
  --toast-shadow: 0 12px 32px rgba(2, 6, 23, 0.45);

  --role-admin-bg: rgba(59, 130, 246, 0.2); --role-admin: #93c5fd;
  --role-operator-bg: rgba(20, 184, 166, 0.18); --role-operator: #5eead4;
  --role-uh-bg: rgba(139, 92, 246, 0.2); --role-uh: #c4b5fd;
}

/* ---- Base ------------------------------------------------------------------------------ */
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--link); font-weight: var(--link-weight); }
a:hover { color: var(--link-hover); }
h1 { margin-top: 0; font-size: 1.75rem; line-height: 1.25; color: var(--heading); }
h2 { font-size: 1.2rem; line-height: 1.3; color: var(--heading); }
h3 { font-size: 1rem; color: var(--heading); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.error { color: var(--error); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* ---- Forms and buttons ----------------------------------------------------------------- */
label { display: block; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], select, textarea {
  padding: 8px; border: 1px solid var(--field-border); border-radius: 6px; font: inherit; color: var(--text); background: var(--field-bg);
}
input[type=text], input[type=email], input[type=password], input[type=search], input[type=tel], textarea { width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--button-bg); box-shadow: 0 0 0 2px var(--focus); outline: none; }
.errorlist { color: var(--error); margin: 4px 0; padding-left: 18px; font-size: .9rem; }
button, a.button, summary.button {
  display: inline-block; padding: 8px 16px; border: 1px solid transparent; border-radius: 8px; background: var(--button-bg); color: var(--button-text);
  font: 600 1rem var(--font); text-decoration: none; cursor: pointer;
}
button:hover:not(:disabled), a.button:hover, summary.button:hover { background: var(--button-hover); color: var(--button-text); box-shadow: var(--button-ring); }
button.secondary, a.button.secondary, summary.button.secondary { background: var(--secondary-bg); color: var(--secondary-text); border-color: var(--secondary-border); }
button.secondary:hover:not(:disabled), a.button.secondary:hover, summary.button.secondary:hover { background: var(--secondary-hover); color: var(--secondary-text); box-shadow: none; }
button.danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
button.danger:hover:not(:disabled) { background: var(--danger-hover-bg); color: #fff; box-shadow: none; }
button:disabled { background: var(--disabled-bg); border-color: var(--disabled-bg); color: var(--disabled-text); cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; color: var(--link); font-weight: var(--link-weight); }
button.link:hover:not(:disabled) { background: none; box-shadow: none; text-decoration: underline; color: var(--link-hover); }

/* ---- Cards, tables, badges, messages ---------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 24px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
div.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; margin-bottom: 16px; }
div.grid > .card { margin-bottom: 0; }
.table-wrap { overflow-x: auto; }
table.list { border-collapse: collapse; width: 100%; background: var(--surface); }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: .9rem; vertical-align: top; }
table.list th { font-weight: 600; color: var(--muted); background: var(--surface-soft); }
table.list tbody tr:hover { background: var(--surface-hover); }
table.list td.nowrap, table.list th.nowrap { white-space: nowrap; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--off-bg); color: var(--off); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.error { background: var(--error-bg); color: var(--error); }
.badge.info, .badge.medical { background: var(--medical-bg); color: var(--medical); }
.badge.signal-warning { background: var(--pink-bg); color: var(--pink); }
.badge.signal-overdue { background: var(--red-bg); color: var(--red); }
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { width: fit-content; max-width: 100%; padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; background: var(--ok-bg); color: var(--ok); border-left: 4px solid currentColor; }
.messages li.error { background: var(--error-bg); color: var(--error); }
.messages li.warning { background: var(--warn-bg); color: var(--warn); }
.messages li.info { background: var(--info-bg); color: var(--info); }

/* ---- Layout of the signed-in pages: the menu on the left, the page on the right ---------- */
body.has-sidebar { display: grid; grid-template-columns: var(--menu-w) minmax(0, 1fr); min-height: 100vh; }
body.has-sidebar > main { width: 100%; max-width: 1200px; padding: 24px 32px 48px; }
/* A faint teal glow in the top-left corner of the page and in the window's bottom-right corner */
body.has-sidebar > main::before {
  content: ""; position: absolute; z-index: -1; top: 0; left: var(--menu-w); width: min(760px, 70vw); height: 460px;
  background: radial-gradient(ellipse at 0 0, var(--glow), transparent 70%); pointer-events: none;
}
body.has-sidebar::after {
  content: ""; position: fixed; z-index: -1; right: 0; bottom: 0; width: min(760px, 70vw); height: 460px;
  background: radial-gradient(ellipse at 100% 100%, var(--glow), transparent 70%); pointer-events: none;
}

/* ---- Page header card (templates/_page_hero.html) ---------------------------------------- */
.page-hero {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 28px; margin: 0 0 18px;
  padding: 22px 26px; border: 1px solid var(--hero-border); border-radius: 16px; background: var(--hero-bg); box-shadow: var(--shadow);
}
.page-hero h1 { margin: 0 0 6px; font-size: 1.75rem; line-height: 1.15; color: var(--hero-title); }
.page-hero-lead { margin: 0; font-size: .88rem; line-height: 1.5; color: var(--hero-lead); }
.page-hero-main { min-width: 0; }
.page-hero-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.page-hero-stats > div { min-width: 96px; padding: 10px 14px; border: 1px solid var(--tile-border); border-radius: 12px; background: var(--tile-bg); text-align: center; }
.page-hero-stats dt { margin: 0; font-size: .7rem; font-weight: 600; color: var(--tile-label); }
.page-hero-stats dd { margin: 2px 0 0; font-size: 1.35rem; font-weight: 700; color: var(--tile-number); }

/* ---- The menu (templates/_sidebar.html) -------------------------------------------------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  padding: 20px 14px 16px; font: 14px var(--font); color: var(--menu-strong); background: var(--menu-bg);
  border-right: 1px solid var(--menu-border); scrollbar-width: thin; scrollbar-color: var(--menu-scrollbar) transparent;
}
.nav-check { position: absolute; opacity: 0; pointer-events: none; }
.sidebar svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-top { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; padding: 0 6px; }
.sidebar-brand { order: 1; display: inline-flex; align-items: center; text-decoration: none; }
/* The white Haelan logo, cropped to the lettering; drawn in teal in the light theme (mask) */
.sidebar-brand img.brand-logo { display: block; width: 100px; height: 50px; object-fit: cover; object-position: center; margin: -2px 0 -2px -3px; }
html:not([data-theme="dark"]) .sidebar-brand img.brand-logo {
  background: var(--brand-teal); object-position: -9999px 0;
  -webkit-mask: url("../img/haelan-logo-white.0824528cee51.png") center / 100% auto no-repeat;
  mask: url("../img/haelan-logo-white.0824528cee51.png") center / 100% auto no-repeat;
}
button.theme-switch {
  order: 2; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; margin-left: auto; padding: 0;
  background: transparent; color: var(--menu-button-text); border: 1px solid var(--menu-button-border); border-radius: 8px;
}
button.theme-switch:hover:not(:disabled), button.theme-switch:focus-visible { background: var(--menu-hover-bg); color: var(--menu-hover-text); box-shadow: none; }
.sidebar button.theme-switch svg { width: 17px; height: 17px; }
.theme-switch span { display: inline-flex; }
.theme-switch .to-light { display: none; }
html[data-theme="dark"] .theme-switch .to-light { display: inline-flex; }
html[data-theme="dark"] .theme-switch .to-dark { display: none; }
.nav-toggle { order: 3; display: none; margin: 0; padding: 6px; border-radius: 8px; cursor: pointer; color: var(--menu-strong); }
.nav-toggle svg { width: 24px; height: 24px; }
.app-name { order: 4; flex-basis: 100%; margin: 4px 0 0; color: var(--menu-text); font-size: 12px; font-weight: 600; letter-spacing: .01em; }
/* Who is signed in: always in view, at the top of the menu (and in the top bar on narrow screens) */
.sidebar-identity { order: 5; flex-basis: 100%; min-width: 0; margin: 16px 0 0; padding: 10px 12px; border: 1px solid var(--menu-button-border); border-radius: 10px; }
.identity-name { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 14px; color: var(--menu-strong); }
.identity-role { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 4px 0 0; font-size: 12px; color: var(--menu-text); }
.role-badge { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.role-badge.role-admin { background: var(--role-admin-bg); color: var(--role-admin); }
.role-badge.role-operator { background: var(--role-operator-bg); color: var(--role-operator); }
.role-badge.role-uh_staff { background: var(--role-uh-bg); color: var(--role-uh); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; margin-top: 20px; flex: 1; }
.nav-group { display: flex; align-items: flex-start; gap: 8px; margin: 20px 4px 8px 12px; font-size: 11px; font-weight: 700; line-height: 1.35;
             letter-spacing: .05em; text-transform: uppercase; color: var(--menu-strong); }
.nav-group::before { content: ""; flex: none; width: 3px; height: 12px; margin-top: 1px; border-radius: 2px; background: var(--menu-group-bar); }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; color: var(--menu-text); font-size: 13px; font-weight: 500;
            line-height: 1.3; text-decoration: none; transition: background-color .15s, color .15s; }
.nav-link:hover, .nav-link:focus-visible { background: var(--menu-hover-bg); color: var(--menu-hover-text); }
.nav-link.active, .nav-link.active:hover { background: var(--menu-active-bg); color: var(--menu-active-text); }
.sidebar-user { margin-top: 20px; padding: 14px 6px 0; border-top: 1px solid var(--menu-button-border); }
.sidebar-user form { margin: 0; }
button.sidebar-logout {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 8px 12px;
  background: transparent; color: var(--menu-button-text); border: 1px solid var(--menu-button-border); border-radius: 8px; font: 500 13px var(--font);
}
button.sidebar-logout:hover:not(:disabled), button.sidebar-logout:focus-visible { background: var(--error-bg); border-color: var(--error); color: var(--error); box-shadow: none; }

/* Phones and tablets in portrait: the menu becomes a top bar. The signed-in person's name and
   role stay in the bar, next to the logo; the links open with the menu button. */
@media (max-width: 900px) {
  body.has-sidebar { display: block; }
  body.has-sidebar > main { padding: 16px 16px 40px; }
  body.has-sidebar > main::before { left: 0; }
  .sidebar { position: sticky; z-index: 10; height: auto; max-height: 100vh; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--menu-border); }
  .sidebar-top { flex-wrap: nowrap; padding: 0; }
  .sidebar-brand img.brand-logo { width: 72px; height: 36px; }
  .app-name { display: none; }
  .sidebar-identity { order: 2; flex: 1 1 auto; margin: 0 4px; padding: 2px 8px; border: 0; }
  .identity-role { margin-top: 0; }
  button.theme-switch { order: 3; margin-left: 0; }
  .nav-toggle { order: 4; display: inline-flex; }
  .sidebar nav, .sidebar-user { display: none; }
  .nav-check:checked ~ nav { display: flex; margin-top: 12px; }
  .nav-check:checked ~ .sidebar-user { display: block; }
  .nav-check:focus-visible ~ .sidebar-top .nav-toggle { outline: 3px solid var(--focus); }
}
@media (max-width: 600px) {
  .card { padding: 16px; }
  div.grid { grid-template-columns: 1fr; }
  .identity-org { display: none; }
}
@media print { .sidebar, body.has-sidebar > main::before, body.has-sidebar::after { display: none; } body.has-sidebar { display: block; } }

/* ---- Sign-in pages (templates/public.html): the teal background with the green Haelan line ---- */
body.login-page { min-height: 100vh; background: linear-gradient(135deg, #024a56 0%, #013640 100%); color: #f1f5f9; }
.bg-wrapper { position: relative; overflow: hidden; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.bg-wrapper::before, .bg-wrapper::after { content: ""; position: absolute; border-radius: 50%; filter: blur(90px); pointer-events: none; z-index: 0; }
.bg-wrapper::before { width: 360px; height: 360px; background: rgba(11, 218, 81, 0.32); top: -70px; left: 16%; }
.bg-wrapper::after { width: 420px; height: 420px; background: rgba(20, 184, 166, 0.28); bottom: -110px; right: 12%; }
.bg-decoration { position: absolute; bottom: -150px; left: -10%; width: 120%; height: auto; opacity: 0.6; pointer-events: none; user-select: none; }
@keyframes drawIn { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: no-preference) { .bg-decoration { animation: drawIn 3s ease-out 0.3s both; } }
.bg-content { position: relative; z-index: 1; width: 100%; max-width: 380px; }
.login-card {
  position: relative; width: 100%; padding: 1.75rem 2.25rem 2rem; text-align: center; color: #f1f5f9;
  background: rgba(10, 26, 31, 0.75); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10), 0 8px 24px rgba(0, 0, 0, 0.35), 0 24px 64px rgba(0, 0, 0, 0.45);
}
.login-logo { display: block; width: 150px; height: 150px; margin: -0.5rem auto -0.75rem; object-fit: contain; }
.platform-name { margin: 0 0 1.5rem; font-size: 1.4rem; font-weight: 700; letter-spacing: 0.01em; color: #ffffff; }
.login-card h1 { margin: 0 0 0.5rem; font-size: 1.2rem; color: #f1f5f9; }
.login-card p { margin: 0 0 1.25rem; font-size: 0.9rem; color: rgba(255, 255, 255, 0.75); }
.login-card a:not(.button) { color: var(--brand-green); }
.login-card .error { color: #fca5a5; }
.login-card .login-notice {
  display: flex; align-items: center; gap: 0.5rem; text-align: left; padding: 0.625rem 0.875rem; font-size: 0.8125rem; line-height: 1.4;
  color: #fde68a; background: rgba(245, 158, 11, 0.10); border: 1px solid rgba(245, 158, 11, 0.28); border-radius: 10px;
}
.login-card .login-notice::before {
  content: ""; flex: none; width: 16px; height: 16px; background: #fbbf24;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E") center / contain no-repeat;
}
.login-form { text-align: left; }
.login-form label { margin: 1rem 0 0.375rem; font-size: 0.875rem; font-weight: 500; color: rgba(255, 255, 255, 0.82); }
.login-form input[type=text], .login-form input[type=password] {
  padding: 0.5rem 0.7rem; font-size: 0.9rem; color: #f1f5f9; background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 0.5rem;
}
.login-form input:focus { border-color: var(--brand-green); background: rgba(255, 255, 255, 0.12); box-shadow: 0 0 0 3px rgba(11, 218, 81, 0.18); }
.login-form input:-webkit-autofill { -webkit-text-fill-color: #f1f5f9; -webkit-box-shadow: 0 0 0 1000px rgba(16, 33, 39, 0.98) inset; caret-color: #f1f5f9; }
.login-card a.button, .login-card button[type=submit] {
  display: flex; align-items: center; justify-content: center; width: 100%; margin-top: 1.5rem; padding: 0.7rem 0.875rem;
  font: 700 0.9rem var(--font); letter-spacing: 0.01em; color: #04282e; background: var(--brand-green); border: 0; border-radius: 0.5rem;
}
.login-card a.button:hover, .login-card button[type=submit]:hover { background: #16a34a; color: #fff; box-shadow: none; }
.login-card .login-hint { margin: 1.25rem 0 0; font-size: 0.78rem; color: rgba(255, 255, 255, 0.55); }
.login-card :focus-visible { outline-color: rgba(11, 218, 81, 0.65); }

/* ---- Dialogs: confirmations (static/js/confirm.js) and the session warning (session.js) -- */
.confirm-dialog {
  width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--dialog-bg); color: var(--dialog-text);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35); font: 15px var(--font);
}
.confirm-dialog::backdrop { background: var(--backdrop); }
.confirm-dialog[open] { animation: confirm-in .14s ease-out; }
@keyframes confirm-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.confirm-dialog form { margin: 0; padding: 22px 24px 18px; }
.confirm-title { margin: 0 0 6px; font-size: 1.05rem; font-weight: 700; }
.confirm-message { margin: 0 0 22px; color: var(--muted); line-height: 1.45; white-space: pre-line; }
.confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.confirm-dialog .confirm-actions button { padding: 8px 18px; font-size: .95rem; }
.confirm-dialog .confirm-ok { background: #dc2626; border-color: #dc2626; color: #fff; }
.confirm-dialog .confirm-ok:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; color: #fff; box-shadow: none; }
.confirm-dialog .confirm-ok.plain { background: var(--button-bg); border-color: var(--button-bg); color: var(--button-text); }
.confirm-dialog .confirm-ok.plain:hover:not(:disabled) { background: var(--button-hover); border-color: var(--button-hover); color: var(--button-text); }
.confirm-dialog .confirm-reason { display: block; margin: -8px 0 20px; font-size: .9rem; font-weight: 600; }
.confirm-dialog .confirm-reason textarea { display: block; margin-top: 6px; resize: vertical; }
.confirm-dialog.session-dialog { padding: 22px 24px 18px; }
.session-countdown { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--dialog-text); }

/* ---- Toasts (static/js/toasts.js): Django's messages as small cards at the top centre ---- */
.toast-stack { position: fixed; top: 16px; left: 50%; z-index: 2000; display: flex; flex-direction: column; align-items: center; gap: 10px;
               width: min(520px, calc(100vw - 32px)); transform: translateX(-50%); pointer-events: none; }
.toast { position: relative; display: flex; align-items: flex-start; gap: 12px; width: fit-content; max-width: 100%; padding: 12px 12px 12px 14px;
         border: 1px solid var(--toast-border); border-radius: 12px; background: var(--toast-bg); color: var(--toast-text); box-shadow: var(--toast-shadow);
         font-size: .9rem; font-weight: 500; line-height: 1.45; overflow: hidden; pointer-events: auto; opacity: 0; transform: translateY(-12px);
         transition: opacity .2s ease, transform .25s ease; }
.toast.is-in { opacity: 1; transform: none; }
.toast.is-out { opacity: 0; transform: translateY(-12px); }
.toast-icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-top: 1px;
              border-radius: 50%; color: #0f172a; font-size: .8rem; font-weight: 800; }
.toast-text { flex: 1; min-width: 0; padding-top: 1px; overflow-wrap: anywhere; }
.toast-text a { color: inherit; text-decoration: underline; }
.toast-line + .toast-line { margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(148, 163, 184, .18); }
button.toast-close { position: relative; flex: none; width: 24px; height: 24px; margin: -1px -2px 0 4px; padding: 0; border: 0; border-radius: 6px;
                     background: transparent; color: var(--muted); box-shadow: none; }
.toast-close::before, .toast-close::after { content: ""; position: absolute; top: 50%; left: 50%; width: 11px; height: 2px; margin: -1px 0 0 -5.5px;
                                            border-radius: 1px; background: currentColor; }
.toast-close::before { transform: rotate(45deg); }
.toast-close::after { transform: rotate(-45deg); }
button.toast-close:hover:not(:disabled), button.toast-close:focus-visible { background: var(--surface-hover); color: var(--text); box-shadow: none; }
.toast-timer { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; transform-origin: left; opacity: .85; }
.toast.success .toast-icon, .toast.success .toast-timer { background: #22c55e; }
.toast.info .toast-icon, .toast.info .toast-timer, .toast.debug .toast-icon { background: #38bdf8; }
.toast.warning .toast-icon { background: #f59e0b; }
.toast.error .toast-icon { background: #ef4444; color: #fff; }
.toast.success { border-color: rgba(34, 197, 94, .45); }
.toast.warning { border-color: rgba(245, 158, 11, .55); }
.toast.error { border-color: rgba(239, 68, 68, .6); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media (max-width: 600px) { .toast-stack { left: 16px; right: 16px; width: auto; transform: none; align-items: stretch; } .toast { width: auto; } }

/* ---- htmx: its own indicator styles are switched off (no inline styles), so they live here ---- */
.htmx-indicator { opacity: 0; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; transition: opacity 200ms ease-in; }

/* ---- Pages ------------------------------------------------------------------------------- */
.placeholder .phase { display: inline-block; margin-bottom: 8px; }
.audit-value { max-width: 260px; overflow-wrap: anywhere; }
.page-actions { margin: 0 0 16px; }
/* „Опашка“: „Нов триаж“ and „Отвори казус №“ under the header card */
.queue-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin: 0 0 16px; }
.open-case { display: flex; align-items: center; gap: 8px; margin: 0; }
.open-case label { margin: 0; font-weight: 600; white-space: nowrap; }
.open-case input[type=text] { width: 6.5em; }
.notice { padding: 10px 14px; border-radius: 8px; border-left: 4px solid currentColor; }
.notice-error { background: var(--error-bg); color: var(--error); }

/* Status, type and signal badges (always with words, never colour alone) */
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; }
.badge-row .badge { font-size: .85rem; padding: 4px 12px; }
.badge.type-medical { background: var(--medical-bg); color: var(--medical); }
.badge.type-administrative { background: var(--off-bg); color: var(--off); }
.badge.status-waiting { background: var(--warn-bg); color: var(--warn); }
.badge.status-answered { background: var(--info-bg); color: var(--info); }
.badge.status-called { background: var(--ok-bg); color: var(--ok); }
.badge.status-closed { background: var(--off-bg); color: var(--off); }
.badge.status-annulled { background: var(--error-bg); color: var(--error); }

/* ---- „Нов триаж“ (templates/triage/new.html) ---------------------------------------------- */
.triage-form { max-width: 880px; }
.form-card h2 { margin: 0 0 14px; font-size: 1.05rem; }
.form-errors { padding: 10px 14px; border-radius: 8px; background: var(--error-bg); color: var(--error); font-weight: 600; }
.field { margin: 0 0 16px; }
.field:last-child { margin-bottom: 0; }
.field > label, .field > legend { display: block; margin: 0 0 6px; padding: 0; font-weight: 600; font-size: .92rem; color: var(--heading); }
fieldset.field { min-width: 0; border: 0; padding: 0; }
.required { color: var(--error); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 20px; }
.field textarea { min-height: 72px; resize: vertical; }
.field input[type=number] { width: 120px; }
.field-error { margin: 6px 0 0; color: var(--error); font-size: .85rem; font-weight: 600; }
.field-warning { margin: 6px 0 0; padding: 5px 10px; border-radius: 6px; background: var(--warn-bg); color: var(--warn); font-size: .85rem; }
.field-hint { margin: 6px 0 0; color: var(--muted); font-size: .82rem; }
.has-error input, .has-error textarea { border-color: var(--error); }
.age-computed { margin: 0; padding: 8px 0; font-weight: 700; font-size: 1.05rem; }
/* The two branches show only once the type is chosen; the other branch's answers are dropped on saving */
.triage-form .branch { display: none; }
.triage-form:has(input[name="case_type"][value="medical"]:checked) .branch-medical,
.triage-form:has(input[name="case_type"][value="administrative"]:checked) .branch-administrative { display: block; }
/* Single choices as buttons; the real radio stays focusable for the keyboard */
.choice-group { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-list { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.choice-pill {
  position: relative; display: inline-flex; align-items: center; gap: 10px; margin: 0; padding: 8px 16px;
  border: 1px solid var(--field-border); border-radius: 999px; background: var(--field-bg); color: var(--text);
  font-weight: 500; line-height: 1.35; cursor: pointer;
}
.choice-list .choice-pill { border-radius: 10px; }
.choice-pill input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.choice-pill:hover { border-color: var(--button-bg); }
.choice-pill:has(input:checked) { background: var(--button-bg); border-color: var(--button-bg); color: var(--button-text); }
.choice-pill:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.type-choice .choice-pill { padding: 12px 24px; font-size: 1.05rem; font-weight: 600; }
.score { display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--off-bg); color: var(--off); font-weight: 700; font-size: .85rem; }
.choice-pill:has(input:checked) .score { background: rgba(255, 255, 255, .2); color: inherit; }
button.clear-choice { margin-top: 8px; font-size: .85rem; }
.form-actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px;
  margin: 0 -8px; padding: 14px 8px; background: linear-gradient(to bottom, transparent, var(--bg) 35%);
}
.form-keys { margin: 0 auto 0 0; font-size: .82rem; }

/* ---- Filters as chips (from the work-schedule app's _filter_bar.html) ------------------------- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 32px; margin: 0 0 16px; }
.filter-group-title { margin: 0 0 6px; font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
a.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--field-border); border-radius: 999px;
  background: var(--surface); color: var(--text); font-size: .8rem; font-weight: 500; line-height: 1.4; text-decoration: none;
}
a.filter-chip:hover, a.filter-chip:focus-visible { border-color: var(--button-bg); color: var(--text); }
a.filter-chip.selected { background: var(--button-bg); border-color: var(--button-bg); color: var(--button-text); font-weight: 700; }
.chip-count { display: inline-block; min-width: 1.4em; padding: 0 5px; border-radius: 999px; background: var(--off-bg); color: var(--off); font-size: .72rem; text-align: center; }
a.filter-chip.selected .chip-count { background: rgba(255, 255, 255, .25); color: inherit; }

/* ---- „Опашка“: the list of open cases --------------------------------------------------------- */
.queue-card { padding: 8px 0; overflow: hidden; }
.queue-card > .muted { padding: 12px 24px; margin: 0; }
.queue-list td, .queue-list th { padding: 10px 12px; }
.queue-list td a { font-weight: 600; text-decoration: none; }
.queue-list td a:hover { text-decoration: underline; }
.queue-list .numeric { font-variant-numeric: tabular-nums; }
.queue-status { display: flex; flex-wrap: wrap; gap: 4px; }
.queue-patient { display: block; margin-top: 2px; color: var(--muted); font-size: .8rem; white-space: nowrap; }
/* The response-time signal also as a bar at the start of the row (the badge says it in words) */
.queue-list tr.row-warning td:first-child { box-shadow: inset 4px 0 0 var(--pink); }
.queue-list tr.row-overdue td:first-child { box-shadow: inset 4px 0 0 var(--red); }

/* ---- New-answer notices (Phase 4) ------------------------------------------------------------- */
.nav-badge-slot { display: inline-flex; margin-left: auto; }
.nav-badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: #dc2626; color: #fff;
             font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; }
.badge.new-answer { background: #dc2626; color: #fff; }

/* ---- Search and filter forms (archive, report, audit log) ------------------------------------- */
.search-form { padding: 16px 20px; }
.search-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 16px; }
.search-grid .field { margin-bottom: 10px; }
.search-grid label { margin: 0 0 4px; font-weight: 600; font-size: .85rem; color: var(--heading); }
.search-grid input, .search-grid select { width: 100%; }
.search-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 6px; }
label.checkbox { display: inline-flex; align-items: center; gap: 8px; margin: 0 auto 0 0; font-weight: 600; font-size: .9rem; }
.list-caption { margin: 0; padding: 8px 16px 10px; color: var(--muted); font-size: .85rem; }
.list-empty { padding: 4px 16px 12px; margin: 0; }
.report-table .number { text-align: right; font-variant-numeric: tabular-nums; }
.report-table tfoot th { color: var(--text); border-top: 2px solid var(--border); }
.pager { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px 4px; }
.settings-form { max-width: 880px; }
.settings-form label.checkbox { margin: 4px 0 12px; }
summary.button.danger-outline { color: var(--error); border-color: var(--error); }

/* ---- Case page (templates/triage/case.html) ------------------------------------------------ */
.notice-off { background: var(--off-bg); color: var(--off); }
.case-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; margin: 0 0 16px; }
.case-actions > form { margin: 0; }
/* A button that opens a small form below it (a reason to give), without JavaScript */
details.action-panel > summary { list-style: none; cursor: pointer; }
details.action-panel > summary::-webkit-details-marker { display: none; }
details.action-panel[open] > summary { margin-bottom: 10px; }
details.action-panel > form {
  width: min(460px, calc(100vw - 48px)); padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow);
}
details.action-panel > form label { margin: 0 0 6px; font-weight: 600; font-size: .9rem; }
details.action-panel > form textarea { margin-bottom: 10px; }
details.action-panel.inline { margin-top: 12px; }
details.action-panel > summary.link { display: inline; color: var(--link); font-weight: var(--link-weight); font-size: .9rem; }
.case-answer .answer-text, .comment-text { white-space: normal; overflow-wrap: anywhere; line-height: 1.55; }
.case-answer .answer-text { padding: 12px 14px; border-left: 4px solid var(--info); border-radius: 6px; background: var(--info-bg); color: var(--text); }
.meta { margin: 6px 0 0; color: var(--muted); font-size: .85rem; }
details.history { margin: 12px 0 0; }
details.history > summary { cursor: pointer; color: var(--link); font-weight: var(--link-weight); font-size: .9rem; }
details.history ol { margin: 10px 0 0; padding-left: 20px; }
details.history li { margin-bottom: 10px; }
details.history .answer-text { background: var(--surface-soft); border-left-color: var(--border); }
.answer-form, .comment-form { margin-top: 14px; }
.answer-form label, .comment-form label { margin: 0 0 6px; font-weight: 600; font-size: .9rem; }
.answer-form button, .comment-form button { margin-top: 10px; }
.comment { padding: 10px 0; border-top: 1px solid var(--border); }
.comment:first-of-type { border-top: 0; padding-top: 0; }
.comment .meta { margin: 0 0 4px; }
.timeline-list { margin: 0; padding: 0; list-style: none; }
.timeline-list li { position: relative; padding: 0 0 12px 18px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline-list li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--button-bg); }
.timeline-list li:last-child { padding-bottom: 0; }
.timeline-list .meta { margin: 0; }
.timeline-detail { margin: 2px 0 0; overflow-wrap: anywhere; font-size: .9rem; }
.case-grid { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(320px, 2fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.case-grid > .card { margin-bottom: 0; }
.case-summary dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.case-summary dt { color: var(--muted); font-weight: 600; }
.case-summary dd { margin: 0; overflow-wrap: anywhere; }
.case-answers dl { margin: 0; }
.case-answers dt { margin: 14px 0 0; font-weight: 600; color: var(--heading); }
.case-answers dt:first-child { margin-top: 0; }
.case-answers dd { margin: 4px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
@media (max-width: 900px) { .case-grid { grid-template-columns: 1fr; } }

/* ---- Users and invitations (Phase 5) ---- */
.user-list td { vertical-align: middle; }
.user-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-form { display: flex; align-items: center; gap: 6px; margin: 0; }
.inline-form select { padding: 5px 8px; font-size: .85rem; }
.user-actions button { padding: 5px 12px; font-size: .85rem; white-space: nowrap; }
.badge.invitation-active { background: var(--ok-bg); color: var(--ok); }
.badge.invitation-used { background: var(--info-bg); color: var(--info); }
.badge.invitation-revoked { background: var(--error-bg); color: var(--error); }
.badge.invitation-expired { background: var(--off-bg); color: var(--off); }
.invitation-form { max-width: 880px; }
.invite-share { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px 24px; }
/* The QR code stays black on white in the dark theme too, so that phones can read it. */
.invite-qr { flex: none; padding: 8px; border-radius: 8px; background: #fff; line-height: 0; }
.invite-text { flex: 1 1 260px; min-width: 0; }
.invite-text label { margin: 14px 0 6px; font-weight: 600; font-size: .9rem; }
.invite-code-label { margin: 0; color: var(--muted); font-size: .85rem; font-weight: 600; }
.invite-code { margin: 2px 0 0; font: 700 1.6rem/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .08em; color: var(--heading); }
.invite-actions { margin: 16px 0 0; }

/* The invitation pages on the dark sign-in card. */
.login-card .login-divider { margin: 1.25rem 0 0; font-size: .8rem; color: rgba(255, 255, 255, 0.55); }
.login-card a.button.secondary-on-dark { margin-top: .75rem; color: #f1f5f9; background: transparent; border: 1px solid rgba(255, 255, 255, 0.35); }
.login-card a.button.secondary-on-dark:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.login-card code { padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.12); color: #fff; font-weight: 700; letter-spacing: .05em; white-space: nowrap; }
