/* Shared design tokens and base primitives for Singular Care Facility (Mozambique).
   Modern clinical aesthetic: calm high-contrast surfaces, emerald primary accent, crisp borders,
   generous touch targets, full light/dark color-scheme support, and interaction-deferred validation. */
:root {
  color-scheme: light dark;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --ink: #14201b;
  --muted: #52635b;
  --line: #d6e0db;
  --line-strong: #b8c8c0;
  --accent: #0b6e4f;
  --accent-hover: #08573e;
  --accent-soft: #e6f4ee;
  --accent-ink: #ffffff;
  --warn: #9a5700;
  --warn-soft: #fef5e7;
  --bad: #b42318;
  --bad-soft: #fef3f2;
  --good: #157347;
  --good-soft: #eaf7f0;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 20, 0.05);
  --shadow-md: 0 4px 14px rgba(16, 24, 20, 0.07);
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  accent-color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #171f1c;
    --surface-2: #1e2824;
    --ink: #ebf1ee;
    --muted: #9eb0a7;
    --line: #293631;
    --line-strong: #3b4d46;
    --accent: #38b889;
    --accent-hover: #4cc99b;
    --accent-soft: rgba(56, 184, 137, 0.14);
    --accent-ink: #071912;
    --warn: #f0b254;
    --warn-soft: rgba(240, 178, 84, 0.14);
    --bad: #f4867c;
    --bad-soft: rgba(244, 134, 124, 0.14);
    --good: #6fd396;
    --good-soft: rgba(111, 211, 150, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { letter-spacing: -0.015em; line-height: 1.25; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }
h3 { font-size: 0.98rem; margin: 0 0 6px; }

button, input, select, textarea { font: inherit; }

button, a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 0.45em 1em;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}
button:hover:not(:disabled), a.button:hover {
  background: var(--surface-2);
  border-color: var(--accent);
}
button:active:not(:disabled), a.button:active { transform: translateY(1px); }

button.primary, a.button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:hover:not(:disabled), a.button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
button.danger {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 45%, var(--line));
}
button.danger:hover:not(:disabled) {
  background: var(--bad-soft);
  border-color: var(--bad);
}
button:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

input, select, textarea {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.5em 0.75em;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent);
  outline-offset: 2px;
}
/* Defer invalid styling until user finishes interacting (Modern Web Guidance). */
:is(input, select, textarea):is(:user-invalid, .user-invalid-fallback) {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px max(20px, env(safe-area-inset-right)) 40px max(20px, env(safe-area-inset-left));
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* Responsive accessible table wrapper with sticky headers. */
.table-wrap {
  overflow: auto;
  max-inline-size: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.table-wrap table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0;
  font-size: 0.92rem;
}
.table-wrap thead th {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--line);
  padding: 0.65rem 0.75rem;
  text-align: left;
  white-space: nowrap;
}
.table-wrap tbody td {
  border-bottom: 1px solid var(--line);
  padding: 0.65rem 0.75rem;
  vertical-align: middle;
}
.table-wrap tbody tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr:hover { background: var(--surface-2); }

.muted { color: var(--muted); }
.ok { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; margin: 0; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
