/*
 * IOI Medical Mission Field Record — application styles.
 *
 * Written locally rather than pulled from a CDN: the field app has to work on
 * an intermittent connection, and cdn.tailwindcss.com is a browser-side JIT
 * compiler that its own documentation marks as unsuitable for production.
 * Keeping styles here also lets the Content-Security-Policy stay locked to
 * 'self'.
 */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #1e293b;
  --muted: #64748b;
  --faint: #94a3b8;
  --inverse: #f8fafc;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;

  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --dark: #0f172a;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.12);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.3; }
p { margin: 0; }
a { color: var(--primary); }

/* Visible focus for keyboard users — the original had none. */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none !important; }

/* Vertical rhythm helper, so views need no inline margin styles. */
.stack > * + * { margin-top: 14px; }
.stack--lg > * + * { margin-top: 20px; }

/* ---------- Icons ---------- */

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.icon--lg { width: 20px; height: 20px; }
.icon--sm { width: 13px; height: 13px; }

/* ---------- Header ---------- */

/*
 * The masthead runs green through teal to blue, left to right.
 * Every foreground colour in here is a light-on-dark override of the app's
 * default dark-on-light scheme. The three stops were picked so white text
 * clears WCAG AA (4.5:1) across the whole bar while staying properly
 * saturated — see the Branding section of README.md before changing them.
 */
.app-header {
  background: linear-gradient(100deg, #047857 0%, #0e7490 52%, #1d4ed8 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  color: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: var(--shadow);
}

.app-header__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

/* Blue focus rings vanish against the gradient. */
.app-header :focus-visible { outline-color: #ffffff; }

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand__text { min-width: 0; }

.brand__mark {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.04em;
  flex: none;
  overflow: hidden;
}
/* Most logos are dark ink on transparency, so they need a light plate. */
.brand__mark--image { background: #fff; border-color: rgba(255, 255, 255, 0.4); padding: 3px; }
.brand__mark img { width: 100%; height: 100%; object-fit: contain; }

.brand__name {
  font-size: 15px;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand__name span { color: #a7f3d0; }

/*
 * No truncation: this was previously clipped to 42ch with an ellipsis, which
 * cut the tagline off mid-sentence. It is short enough to show in full, and it
 * is hidden outright below 860px where the room genuinely runs out.
 */
.brand__tagline {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.03em;
  font-weight: 500;
  line-height: 1.35;
}

/* The connecting words in the tagline are italicised wherever it appears. */
.brand__tagline em,
.letterhead__tagline em {
  font-style: italic;
}

/*
 * Outreach switcher. This sets the context every other screen reads from, so
 * it stays visible in the masthead rather than being buried in a settings page.
 */
.outreach-switch { display: flex; align-items: center; gap: 9px; min-width: 0; }

.outreach-switch__label {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
}

.outreach-switch__select {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.32);
  color: #ffffff;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  max-width: 260px;
  cursor: pointer;
}
/* The native dropdown list renders on a white surface, so its items need
   dark text regardless of the control's own colour. */
.outreach-switch__select option { color: var(--text); background: #ffffff; }

.header-actions { display: flex; align-items: center; gap: 10px; }

.user-chip { text-align: right; line-height: 1.25; }
.user-chip__name { font-size: 12px; font-weight: 700; color: #ffffff; }
.user-chip__role {
  font-size: 10px;
  color: rgba(248, 250, 252, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Controls sitting on the gradient. */
.app-header .btn--ghost {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
  color: #f8fafc;
}
.app-header .btn--ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.24); }

.app-header .conn {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
  color: #eafaf1;
}
.app-header .conn[data-state="offline"] {
  background: rgba(251, 191, 36, 0.22);
  border-color: rgba(251, 191, 36, 0.6);
  color: #fde68a;
}
.app-header .conn[data-state="syncing"] {
  background: rgba(96, 165, 250, 0.22);
  border-color: rgba(96, 165, 250, 0.6);
  color: #bfdbfe;
}

/* ---------- Connection indicator ---------- */

.conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--success);
  background: var(--success-soft);
  color: var(--success);
  white-space: nowrap;
}
.conn[data-state="offline"] {
  border-color: var(--warning);
  background: var(--warning-soft);
  color: var(--warning);
}
.conn[data-state="syncing"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

/* ---------- Layout ---------- */

.app-shell {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px;
  display: flex;
  gap: 20px;
  flex: 1;
  align-items: flex-start;
}

.sidebar {
  width: 232px;
  flex: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: var(--shadow-xs);
  position: sticky;
  top: 80px;
}

.sidebar__group {
  font-size: 10px;
  font-weight: 800;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin: 14px 0 6px;
  padding: 0 10px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-btn + .nav-btn { margin-top: 2px; }
.nav-btn:hover { background: var(--surface-alt); color: var(--text); }
.nav-btn[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.nav-btn[hidden] { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-xs);
}
.card--flush { padding: 0; overflow: hidden; }
.card--dark { background: var(--dark); color: var(--inverse); border-color: var(--dark); }
.card--narrow { max-width: 420px; width: 100%; }

.card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card__subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }

.section-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 12px;
}

/* ---------- Grid ---------- */

.grid { display: grid; gap: 20px; }
.grid--dashboard { grid-template-columns: repeat(12, 1fr); }
.col-3 { grid-column: span 3; display: flex; flex-direction: column; gap: 20px; }
.col-6 { grid-column: span 6; display: flex; flex-direction: column; gap: 14px; }
.grid--thirds { grid-template-columns: repeat(3, 1fr); }
.grid--halves { grid-template-columns: repeat(2, 1fr); }
.grid--form { grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ---------- Stats ---------- */

.stat-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--surface-alt);
}
.stat-row + .stat-row { margin-top: 12px; }
.stat-row:last-child { border-bottom: 0; padding-bottom: 0; }
.stat-row__label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-row__value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-row__value--primary { color: var(--primary); }

.stat-block {
  padding: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-block__label {
  font-size: 10px; font-weight: 700; color: var(--faint);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.stat-block__value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-block__hint { font-size: 9px; color: var(--faint); font-style: italic; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.99); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-xs); }
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-alt); }

.btn--soft { background: var(--surface-alt); color: var(--text); }
.btn--soft:hover:not(:disabled) { background: var(--border); }

.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn--danger:hover:not(:disabled) { background: #fee2e2; }

.btn--link {
  background: none; border: 0; color: var(--muted);
  text-transform: none; letter-spacing: 0; padding: 9px 10px;
}
.btn--link:hover:not(:disabled) { color: var(--text); }

.btn--block { width: 100%; }
.btn--sm { padding: 5px 9px; font-size: 10px; }

.btn-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-row--end { justify-content: flex-end; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 5px; }
.field__label { font-size: 12px; font-weight: 700; }
.field__hint { font-size: 11px; color: var(--muted); }
.field__error { font-size: 11px; color: var(--danger); font-weight: 600; min-height: 0; }

.input,
.select,
.textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}
.input:focus,
.select:focus,
.textarea:focus {
  background: var(--surface);
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.input[aria-invalid="true"],
.select[aria-invalid="true"] { border-color: var(--danger); }
.textarea { resize: vertical; min-height: 72px; }

.form-section + .form-section { margin-top: 22px; }
.form-actions {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
  margin-top: 22px;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-alt);
  color: var(--muted);
  white-space: nowrap;
}
.badge--primary { background: var(--primary-soft); color: var(--primary); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--mono { font-family: var(--mono); text-transform: none; }

/* ---------- Filter pills ---------- */

.filter-row { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-btn {
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.filter-btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Queue ---------- */

.queue-list { display: flex; flex-direction: column; gap: 10px; }

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.queue-item__name { font-weight: 700; font-size: 13px; }
.queue-item__meta { font-size: 11px; color: var(--faint); }
.queue-item__actions { display: flex; align-items: center; gap: 8px; flex: none; }
.queue-item[data-priority="Emergency"] { border-left: 3px solid var(--danger); }
.queue-item[data-priority="Urgent"] { border-left: 3px solid var(--warning); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--surface-alt); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfcfe; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Alerts & empty states ---------- */

.alert {
  padding: 13px 15px;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: 12.5px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.alert--warning { background: var(--warning-soft); border-color: #fde68a; color: #92400e; }
.alert--danger { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.alert--info { background: var(--primary-soft); border-color: #bfdbfe; color: #1e40af; }
.alert__title { font-weight: 700; margin-bottom: 3px; }

.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--faint);
  font-size: 12.5px;
}

.stock-list { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.stock-list li {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 3px 0; font-weight: 500;
}
.stock-list__qty { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Activity feed ---------- */

.feed { display: flex; flex-direction: column; gap: 14px; }
.feed__item { display: flex; gap: 10px; font-size: 12px; }
.feed__dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--primary); }
.feed__dot--success { background: var(--success); }
.feed__dot--warning { background: var(--warning); }
.feed__title { font-weight: 700; color: #f1f5f9; }
.feed__detail { font-size: 11px; color: #94a3b8; }
.feed__time { font-size: 10px; color: #64748b; margin-top: 1px; }

/* ---------- Clinical: vitals, history, prescription rows ---------- */

.vitals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
}

.vital {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 11px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.vital__label {
  font-size: 10px;
  font-weight: 700;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.vital__value { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }

.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item {
  display: flex;
  gap: 12px;
  font-size: 12px;
  padding: 7px 10px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
}
.history-item__date { color: var(--faint); font-weight: 700; white-space: nowrap; }

/* One prescription line: medicine, dose, frequency, days, qty, route, remove. */
.rx-row {
  display: grid;
  grid-template-columns: minmax(170px, 2.2fr) 1fr 1.2fr 72px 72px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.rx-row + .rx-row { margin-top: 8px; }
.rx-row .input,
.rx-row .select {
  background: var(--surface);
  font-size: 12px;
  padding: 7px 9px;
}

@media (max-width: 1100px) {
  .rx-row { grid-template-columns: 1fr 1fr; }
  .rx-row > *:first-child { grid-column: 1 / -1; }
}

/* One admin-managed currency: code, name, symbol, default rate, remove. */
.currency-row {
  display: grid;
  grid-template-columns: 96px 1fr 84px 130px auto;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.currency-row + .currency-row { margin-top: 8px; }
.currency-row .input { background: var(--surface); font-size: 12px; padding: 7px 9px; }

@media (max-width: 720px) {
  .currency-row { grid-template-columns: 1fr 1fr; }
  .currency-row > *:nth-child(2) { grid-column: 1 / -1; }
}

/* ---------- Toasts ---------- */

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
}

.toast {
  padding: 11px 14px;
  border-radius: var(--radius);
  background: var(--dark);
  color: var(--inverse);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 9px;
  animation: toast-in 0.16s ease-out;
}
.toast--success { background: #065f46; }
.toast--error { background: #991b1b; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------- Modal ---------- */

.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 23, 42, 0.5);
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal__panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  padding: 22px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal__title { font-size: 16px; margin-bottom: 6px; }
.modal__body {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
  /* Confirmation text is set with textContent and uses newlines for structure. */
  white-space: pre-line;
}
.modal__body:empty { margin-bottom: 0; }

/* ---------- Login / centered pages ---------- */

.page-centered {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg);
}

/* ---------- Sign-in screen ---------- */

/*
 * One centred card over a full-page backdrop.
 *
 * Deliberately NOT a split screen: a single column stays calm, reads the same
 * at every width, and needs no separate mobile composition. The picture set in
 * System Settings becomes the backdrop; with none set the brand gradient
 * carries it, so the screen never looks unfinished.
 */
.login-page { min-height: 100vh; }

.login-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 15% 15%, rgba(255, 255, 255, 0.14), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(255, 255, 255, 0.10), transparent 45%),
    linear-gradient(145deg, #047857 0%, #0e7490 52%, #1d4ed8 100%);
}

.login-backdrop__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Rendered only when a picture is set — it keeps the card edge and the text
   beneath it legible over an arbitrary photo. */
.login-backdrop__scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.52) 0%, rgba(15, 23, 42, 0.68) 100%);
}

.login-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px 20px;
}

.login-card {
  max-width: 400px;
  width: 100%;
  padding: 34px 32px;
  border-radius: var(--radius-lg);
  border-color: rgba(255, 255, 255, 0.65);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.22);
}

.login-header { text-align: center; margin-bottom: 24px; }

.login-logo {
  display: block;
  max-height: 64px;
  max-width: 210px;
  margin: 0 auto 16px;
  object-fit: contain;
}

.login-mark {
  width: 54px; height: 54px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #047857, #1d4ed8);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 16px;
  letter-spacing: 0.03em;
  margin: 0 auto 16px;
}

.login-title { font-size: 18px; letter-spacing: -0.01em; }
.login-subtitle { font-size: 12px; color: var(--muted); margin-top: 4px; }

.login-tagline { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 8px; }
.login-tagline em { font-style: italic; }

.login-prompt {
  font-size: 10px;
  font-weight: 700;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

/* Contact details and the notice sit under the card, on the backdrop. */
.login-contact {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 1px 6px rgba(15, 23, 42, 0.55);
}
.login-contact span { display: flex; align-items: center; gap: 7px; }
.login-contact .icon { opacity: 0.85; }

.login-legal {
  font-size: 11px;
  text-align: center;
  color: rgba(255, 255, 255, 0.78);
  text-shadow: 0 1px 6px rgba(15, 23, 42, 0.55);
}

@media (max-width: 560px) {
  .login-container { padding: 24px 16px; }
  .login-card { padding: 26px 22px; }
}

/* ---------- Report letterhead ---------- */

.letterhead {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 2px solid var(--border-strong);
  background: var(--surface);
}

.letterhead__logo { max-height: 54px; max-width: 150px; object-fit: contain; flex: none; }
.letterhead__org { flex: 1; min-width: 0; }
.letterhead__name { font-size: 15px; font-weight: 800; letter-spacing: -0.01em; }
/* Not italic as a whole: only the connecting words are emphasised, and
   italic-on-italic would erase the distinction. */
.letterhead__tagline { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.letterhead__contact { font-size: 11px; color: var(--faint); margin-top: 5px; }
.letterhead__meta { text-align: right; flex: none; }
.letterhead__doc { font-size: 12px; font-weight: 700; }
/* Which outreach the report covers — a filed report must not be ambiguous. */
.letterhead__outreach { font-size: 11px; font-weight: 600; color: var(--primary); margin-top: 2px; }
.letterhead__date { font-size: 10.5px; color: var(--faint); margin-top: 2px; }

@media (max-width: 640px) {
  .letterhead { flex-wrap: wrap; }
  .letterhead__meta { text-align: left; width: 100%; }
}

/* Thumbnail of the currently saved image beside its upload field. */
.settings-preview {
  margin-top: 8px;
  max-height: 76px;
  max-width: 100%;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  padding: 6px;
  align-self: flex-start;
}
.settings-preview--logo { background: #fff; }

.error-code { font-size: 40px; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.error-title { font-size: 18px; margin: 6px 0 8px; }
.error-message { font-size: 13px; color: var(--muted); margin-bottom: 20px; }

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .grid--dashboard { grid-template-columns: repeat(6, 1fr); }
  .col-3, .col-6 { grid-column: span 6; }
  .grid--thirds { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; padding: 14px; }
  .sidebar { width: 100%; position: static; }
  .sidebar__nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 4px; }
  .sidebar__group { grid-column: 1 / -1; }
  .nav-btn + .nav-btn { margin-top: 0; }
  .grid--form, .grid--halves { grid-template-columns: 1fr; }
  .brand__tagline { display: none; }
}

@media (max-width: 560px) {
  .app-header__inner { height: auto; padding: 10px 12px; flex-wrap: wrap; }
  .user-chip { display: none; }
  .queue-item { flex-direction: column; align-items: flex-start; }
}

/* ---------- Print (used by the PDF export buttons) ---------- */

@media print {
  .app-header, .sidebar, .btn, .filter-row, .toast-stack, .no-print { display: none !important; }
  body { background: #fff; font-size: 11px; }
  .app-shell { display: block; padding: 0; max-width: none; }
  .card { border: 1px solid #cbd5e1; box-shadow: none; break-inside: avoid; page-break-inside: avoid; }
  .table th { background: #f1f5f9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* The letterhead is the printed report's identity: keep the logo and rules
     rather than letting the browser drop background/colour for economy. */
  .letterhead {
    border-bottom: 2px solid #64748b;
    padding: 0 0 12px;
    margin-bottom: 14px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .letterhead__logo { max-height: 46px; }
  .letterhead__name { font-size: 14px; }

  /* Repeat the column headers when a long report spans pages. */
  thead { display: table-header-group; }
  tr { break-inside: avoid; page-break-inside: avoid; }
}
