/* Country web theme (WEB-1). Design system adapted from the desktop
   wireframe (local_docs/Death_Certificate_Desktop_Wireframe.html): the same
   tokens, cards, tables, buttons, forms and topbar/sidebar shell, applied to
   the country's read-only screens. Overriding the core base template is
   explicitly allowed for branding/layout as long as the i18n hooks stay
   intact (WEB-3). */

:root {
  color-scheme: light dark;

  --background: light-dark(rgb(219 236 250), rgb(16 24 38));
  --foreground: light-dark(rgb(26 28 31), rgb(255 255 255));
  --card: light-dark(rgb(255 255 255), rgb(30 30 33));
  --card-foreground: var(--foreground);
  --popover: light-dark(rgb(255 255 255), rgb(45 45 45));
  --popover-foreground: var(--foreground);
  /* Distinctive orange + light-blue identity: orange is the brand/action
     colour (buttons, brand mark, links, focus), light blue is the accent. */
  --primary: light-dark(rgb(234 88 12), rgb(251 146 60));
  --primary-foreground: light-dark(rgb(255 255 255), rgb(23 12 4));
  --secondary: light-dark(rgb(255 255 255), rgb(54 54 54));
  --secondary-foreground: var(--foreground);
  --muted: color-mix(in srgb, var(--foreground) 8%, transparent);
  --muted-foreground: light-dark(rgb(26 28 31 / 55%), rgb(255 255 255 / 55%));
  --accent: light-dark(rgb(224 242 254), rgb(12 40 61));
  --accent-foreground: light-dark(rgb(3 105 161), rgb(125 211 252));
  --destructive: light-dark(rgb(200 42 30), rgb(255 133 73));
  --success: light-dark(rgb(0 140 66), rgb(64 201 119));
  --warning: light-dark(rgb(147 102 0), rgb(240 195 91));
  --border: light-dark(rgb(26 28 31 / 12%), rgb(255 255 255 / 12%));
  --input: light-dark(rgb(26 28 31 / 14%), rgb(255 255 255 / 16%));
  --ring: light-dark(rgb(234 88 12), rgb(251 146 60 / 76%));

  /* Country-specific field highlight (the wireframe's "Suriname-specific"
     non-WHO-core fields): light blue, to stay distinct from the orange brand. */
  --noncore: light-dark(rgb(56 189 248 / 16%), rgb(56 189 248 / 18%));
  --noncore-border: light-dark(rgb(2 132 199), rgb(56 189 248));

  --font-sans: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-size-base: 14px;
  --font-weight-medium: 500;
  --radius: 10px;
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-2xl: calc(var(--radius) * 1.6);
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px -1px rgb(0 0 0 / 12%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 16px;
  min-height: 100vh;
  color: var(--foreground);
  background: var(--background);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: 1.5;
}

a {
  color: color-mix(in srgb, var(--primary) 85%, var(--foreground) 15%);
  cursor: pointer;
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  text-underline-offset: 2px;
}
a:is(:hover, :focus-visible) { text-decoration: underline; }

h1, h2, h3, h4, p { margin-block: 0; }
h1 { font-size: 1.6rem; font-weight: var(--font-weight-medium); line-height: 1.25; }
h2 { font-size: 1.4rem; font-weight: var(--font-weight-medium); line-height: 1.25; }
h3 { font-size: 1.15rem; font-weight: var(--font-weight-medium); line-height: 1.3; }
b, strong, th { font-weight: var(--font-weight-medium); }

.text-muted { color: var(--muted-foreground); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---- Shell -------------------------------------------------------------- */

.dc-shell {
  max-width: 1180px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.dc-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid color-mix(in srgb, black 14%, var(--primary));
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 82%, black));
  color: var(--primary-foreground);
}

/* The topbar rides the orange brand bar, so its inner text and controls flip
   to the on-primary (light) colour for contrast. */
.dc-topbar .dc-brand-copy strong, .dc-topbar .dc-case strong { color: var(--primary-foreground); }
.dc-topbar .dc-brand-copy span, .dc-topbar .dc-case span {
  color: color-mix(in srgb, var(--primary-foreground) 78%, transparent);
}
.dc-topbar .dc-brand-mark { background: var(--card); color: var(--primary); }
.dc-topbar .dc-status {
  border-color: color-mix(in srgb, var(--primary-foreground) 45%, transparent);
  background: color-mix(in srgb, var(--primary-foreground) 18%, transparent);
  color: var(--primary-foreground);
}
.dc-topbar .btn-ghost { color: color-mix(in srgb, var(--primary-foreground) 85%, transparent); }
.dc-topbar .btn-ghost:not(:disabled):hover {
  color: var(--primary-foreground);
  background: color-mix(in srgb, var(--primary-foreground) 16%, transparent);
}

/* ICD-11 service connectivity light, stacked under the status badge. */
.dc-status-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.dc-conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: var(--font-weight-medium);
  color: color-mix(in srgb, var(--primary-foreground) 82%, transparent);
  cursor: default;
}
.dc-conn-dot {
  width: 9px; height: 9px;
  border-radius: var(--radius-full);
  background: var(--warning);
  transition: background 0.2s, box-shadow 0.2s;
}
.dc-conn[data-state="online"] .dc-conn-dot {
  background: rgb(34 197 94);
  box-shadow: 0 0 7px rgb(34 197 94 / 85%);
}
.dc-conn[data-state="offline"] .dc-conn-dot {
  background: rgb(239 68 68);
  box-shadow: 0 0 7px rgb(239 68 68 / 85%);
}

/* Topbar settings menu: gear trigger + dropdown with theme / language switches. */
.dc-menu { position: relative; display: inline-flex; }
.dc-menu-trigger { padding: 0 8px; list-style: none; cursor: pointer; }
.dc-menu-trigger::-webkit-details-marker { display: none; }
.dc-menu-trigger svg { display: block; }
.dc-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 50;
  min-width: 200px;
  padding: 12px;
  display: grid;
  gap: 12px;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgb(0 0 0 / 20%);
}
.dc-menu-group { display: grid; gap: 6px; }
.dc-menu-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
/* The dropdown is nested inside .dc-case, so the topbar's `.dc-case span` rule
   (the on-orange colour, white in light / near-black in dark) would otherwise
   win over .dc-menu-label by specificity and invert these labels. Scope the
   colour tighter so it beats it: full white on the dark panel, muted grey in
   light. */
.dc-topbar .dc-menu-panel .dc-menu-label {
  color: light-dark(rgb(26 28 31 / 55%), rgb(255 255 255));
}
.dc-seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.dc-seg-btn {
  appearance: none;
  flex: 1;
  border: 0;
  padding: 6px 14px;
  background: var(--secondary);
  color: var(--foreground);
  font: inherit;
  font-size: 0.8rem;
  font-weight: var(--font-weight-medium);
  cursor: pointer;
}
.dc-seg-btn + .dc-seg-btn { border-left: 1px solid var(--border); }
.dc-seg-btn:hover:not([aria-pressed="true"]) { background: var(--muted); }
.dc-seg-btn[aria-pressed="true"] { background: var(--primary); color: var(--primary-foreground); }

.dc-brand, .dc-case { display: flex; align-items: center; gap: 10px; }
.dc-brand { text-decoration: none; color: inherit; }

.dc-brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--primary-foreground);
  background: var(--primary);
  font-weight: var(--font-weight-medium);
}

.dc-brand-copy strong, .dc-case strong { display: block; font-weight: var(--font-weight-medium); }
.dc-brand-copy span, .dc-case span { color: var(--muted-foreground); font-size: 0.85rem; }
.dc-case { text-align: right; }

.dc-workspace {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 560px;
}

.dc-sidebar {
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 55%, transparent);
}

.dc-sidebar-label {
  margin: 0 8px 10px;
  color: var(--muted-foreground);
  font-weight: var(--font-weight-medium);
  font-size: 0.85rem;
}

.dc-nav { display: grid; gap: 6px; margin: 0; padding: 0; }

/* A labelled sidebar sub-category (its own heading + links), e.g. Export. */
.dc-nav-section { display: grid; gap: 6px; margin-top: 18px; }
.dc-nav-section .dc-sidebar-label { margin-bottom: 4px; }

.dc-nav a, .dc-nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--foreground);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.dc-nav a:hover, .dc-nav button:hover { background: var(--accent); color: var(--accent-foreground); }
.dc-nav a[aria-current="page"] { background: var(--primary); color: var(--primary-foreground); }

.dc-sidebar-logout { margin-top: 12px; }
.dc-sidebar-note {
  margin: 18px 8px 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.85rem;
}

.dc-main { min-width: 0; padding: 20px; background: var(--background); }
.dc-screen-head { margin-bottom: 16px; }
.dc-screen-head h2 { margin: 0 0 4px; }
.dc-screen-head p { margin: 0; color: var(--muted-foreground); }
.dc-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

/* ---- Reference number + copy-to-clipboard ------------------------------- */
.dc-ref {
  display: inline-flex; align-items: center; gap: 5px;
  margin-left: 10px; vertical-align: middle;
}
.dc-ref-no {
  font-size: 0.8rem; font-weight: var(--font-weight-medium);
  color: var(--muted-foreground);
  background: var(--muted);
  padding: 2px 8px; border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
}
.dc-copy-btn {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--muted-foreground);
  cursor: pointer; transition: color .15s, border-color .15s;
}
.dc-copy-btn:hover { color: var(--primary); border-color: var(--primary); }
.dc-copy-btn .dc-copy-check { display: none; }
.dc-copy-btn.is-copied { color: var(--success); border-color: var(--success); }
.dc-copy-btn.is-copied .dc-copy-icon { display: none; }
.dc-copy-btn.is-copied .dc-copy-check { display: block; }
.dc-detail-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.dc-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

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

.card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  color: var(--card-foreground);
  background: var(--card);
}
.card + .card { margin-top: 14px; }
.card h3 { margin: 0 0 12px; }

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

.table-responsive { width: 100%; overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  color: var(--foreground);
  text-align: left;
}
.table :is(th, td) {
  padding: 10px 16px 10px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table :is(th, td):last-child { padding-right: 0; }
.table thead th {
  font-weight: 600;
  color: var(--muted-foreground);
  border-bottom-color: color-mix(in srgb, var(--foreground) 20%, transparent);
}
.table tbody tr:last-child :is(th, td) { border-bottom: 0; }
.table .text-end { text-align: right; }

/* ---- Definition grid (detail screen) ------------------------------------ */

.dc-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px 24px;
  margin: 0;
}
.dc-detail-grid > div { min-width: 0; }
.dc-detail-grid dt { color: var(--muted-foreground); font-size: 0.85rem; margin-bottom: 2px; }
.dc-detail-grid dd { margin: 0; overflow-wrap: anywhere; }

/* Reassign-reviewer row at the foot of the assigned-practitioner card (FR-17):
   label, practitioner select and action, wrapping on a narrow column. */
.dc-reassign {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.dc-reassign label { color: var(--muted-foreground); font-size: 0.85rem; }
.dc-reassign select {
  flex: 1 1 220px;
  min-width: 0;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  color: var(--foreground);
  background: var(--secondary);
  font: inherit;
}
.dc-reassign select:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: inset 0 0 0 1px var(--ring);
}
.dc-reassign .btn { flex-shrink: 0; }

.dc-review-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.dc-review-item:last-child { border-bottom: 0; }
.dc-review-item span { color: var(--muted-foreground); }
/* Let the text column shrink and wrap instead of the flex row overflowing on a
   long DORIS code chain (NA07.3Y&XC5K&...). */
.dc-review-item > div { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
/* The DORIS status can be a long post-coordinated chain — cap and scroll it. */
#review-doris-status { display: block; max-height: 30vh; overflow-y: auto; }

/* ---- Foldable review sections ------------------------------------------ */
.dc-review-fold { border-bottom: 1px solid var(--border); }
.dc-review-fold:last-child { border-bottom: 0; }
.dc-review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
}
.dc-review-title { font-weight: var(--font-weight-medium); }
.dc-review-summary { padding: 2px 0 14px; display: grid; gap: 6px; }
.dc-review-row {
  display: grid;
  grid-template-columns: minmax(120px, 38%) 1fr;
  gap: 10px;
  font-size: 0.85rem;
}
.dc-review-key { color: var(--muted-foreground); }
.dc-review-val { color: var(--foreground); word-break: break-word; }
.dc-review-empty { color: var(--muted-foreground); font-size: 0.85rem; margin: 0 0 4px; }

/* ---- Status badge ------------------------------------------------------- */

.dc-status {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Per-state colour coding for the certificate lifecycle. Each badge tints its
   text, border and a soft background from one hue so the state reads at a
   glance. Prepared keeps the neutral grey default above. */
.dc-status--draft {
  color: #c2410c;
  border-color: color-mix(in srgb, #ea580c 45%, transparent);
  background: color-mix(in srgb, #ea580c 14%, transparent);
}
.dc-status--prepared {
  color: #4b5563;
  border-color: color-mix(in srgb, #6b7280 45%, transparent);
  background: color-mix(in srgb, #6b7280 14%, transparent);
}
.dc-status--certified {
  color: #1d4ed8;
  border-color: color-mix(in srgb, #2563eb 45%, transparent);
  background: color-mix(in srgb, #2563eb 14%, transparent);
}
.dc-status--reviewed {
  color: #15803d;
  border-color: color-mix(in srgb, #16a34a 45%, transparent);
  background: color-mix(in srgb, #16a34a 14%, transparent);
}
.dc-status--amended {
  color: #b45309;
  border-color: color-mix(in srgb, #f59e0b 50%, transparent);
  background: color-mix(in srgb, #f59e0b 16%, transparent);
}
.dc-status--exported {
  color: #78350f;
  border-color: color-mix(in srgb, #92400e 45%, transparent);
  background: color-mix(in srgb, #92400e 14%, transparent);
}

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

.btn {
  appearance: button;
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  color: var(--secondary-foreground);
  background: var(--secondary);
  font: inherit;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:not(:disabled):hover { background: color-mix(in srgb, var(--foreground) 6%, var(--secondary)); }
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn:disabled { cursor: not-allowed; opacity: 0.4; }

.btn-primary {
  border-color: transparent;
  color: var(--primary-foreground);
  background: var(--primary);
}
.btn-primary:not(:disabled):hover { background: color-mix(in srgb, var(--foreground) 12%, var(--primary)); }

.btn-ghost { border-color: transparent; color: var(--muted-foreground); background: transparent; }
.btn-ghost:not(:disabled):hover { color: var(--foreground); background: var(--muted); }

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

.dc-field { display: grid; gap: 6px; }
.form-label, .dc-field label { font-weight: var(--font-weight-medium); }

.form-control, .form-select {
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  outline: none;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  color: var(--foreground);
  background: var(--secondary);
  font: inherit;
}
.form-control::placeholder { color: var(--muted-foreground); }
.form-control:focus-visible, .form-select:focus-visible {
  border-color: var(--ring);
  box-shadow: inset 0 0 0 1px var(--ring);
}

/* Informational by default (matches the hospital wireframe's `.dc-alert`);
   `.dc-alert-amber` warns and `.dc-alert-danger` is the error style used by the
   sign-in page. */
.dc-alert {
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent);
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-foreground);
  line-height: 1.5;
}
.dc-alert-amber {
  border-color: var(--noncore-border);
  background: var(--noncore);
  color: light-dark(rgb(107 78 9), rgb(255 218 123));
}
.dc-alert-danger {
  border: 1px solid color-mix(in srgb, var(--destructive) 45%, transparent);
  border-left: 3px solid var(--destructive);
  border-radius: 8px;
  background: color-mix(in srgb, var(--destructive) 12%, transparent);
  color: var(--destructive);
}

/* ---- Login -------------------------------------------------------------- */

.dc-login-shell {
  min-height: calc(100vh - 32px);
  display: grid;
  place-items: center;
}
.dc-login-card {
  width: min(100%, 380px);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.dc-login-card .dc-brand { justify-content: center; margin-bottom: 18px; }
.dc-login-card form { display: grid; gap: 14px; margin-top: 18px; }
.dc-login-card .btn { width: 100%; }

/* ---- Pagination --------------------------------------------------------- */

.dc-pagination {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  color: var(--muted-foreground);
}

/* ========================================================================
   New-certificate entry screen — components from the desktop wireframe
   (local_docs/Death_Certificate_Desktop_Wireframe.html), de-scoped from the
   wireframe's #dc-desktop-wireframe root to the #dc-new-certificate page and
   built on the tokens above.
   ======================================================================== */

#dc-new-certificate .dc-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--muted-foreground);
  font-size: 0.85rem;
}
#dc-new-certificate .dc-swatch {
  width: 14px; height: 14px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--card);
  display: inline-block;
}
#dc-new-certificate .dc-swatch.noncore-swatch {
  background: var(--noncore);
  border-color: var(--noncore-border);
}

/* Standalone shell: full-width, with the wireframe's own topbar and numbered
   "Sections" sidebar (base.html renders no app chrome for this page). */
#dc-new-certificate { width: 100%; }
#dc-new-certificate .dc-shell { max-width: none; }
#dc-new-certificate .dc-workspace { grid-template-columns: 210px minmax(0, 1fr); min-height: 760px; }

/* Numbered section steps in the sidebar */
#dc-new-certificate .dc-nav button {
  width: 100%;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--foreground);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
#dc-new-certificate .dc-nav button:hover { background: var(--accent); color: var(--accent-foreground); }
#dc-new-certificate .dc-nav button[aria-selected="true"] { background: var(--primary); color: var(--primary-foreground); }
.dc-step-no {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.8rem;
}
/* A section the user has advanced past is marked done with a green check. */
#dc-new-certificate .dc-nav button.is-complete .dc-step-no {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* Screens */
#dc-new-certificate .dc-screen { display: none; }
#dc-new-certificate .dc-screen.is-active { display: block; }
#dc-new-certificate .dc-screen-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
#dc-new-certificate .dc-screen-head h2 { margin: 0 0 4px; }
#dc-new-certificate .dc-screen-head p { margin: 0; color: var(--muted-foreground); }

/* Layout grids */
.dc-grid-2, .dc-grid-3, .dc-medical-layout, .dc-review-grid { display: grid; gap: 14px; }
.dc-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dc-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dc-medical-layout { grid-template-columns: minmax(0, 1.55fr) minmax(270px, .8fr); align-items: start; }
.dc-review-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dc-card-spacer { margin-top: 14px; }

/* 12-column form grid */
.dc-form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.dc-col-2 { grid-column: span 2; }
.dc-col-3 { grid-column: span 3; }
.dc-col-4 { grid-column: span 4; }
.dc-col-5 { grid-column: span 5; }
.dc-col-6 { grid-column: span 6; }
.dc-col-7 { grid-column: span 7; }
.dc-col-8 { grid-column: span 8; }
.dc-col-9 { grid-column: span 9; }
.dc-col-10 { grid-column: span 10; }
.dc-col-12 { grid-column: span 12; }

/* Helper text and a simple search/toolbar row for the portal screens (the
   guided-form scoped variants live under #dc-new-certificate). */
.dc-help { color: var(--muted-foreground); font-size: 0.85rem; margin: 0 0 12px; }
.dc-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.dc-toolbar .dc-field { flex: 1 1 240px; min-width: 0; }

/* Field, with the non-WHO-core highlight */
#dc-new-certificate .dc-field {
  min-width: 0;
  gap: 6px;
  padding: 9px;
  border: 1px solid transparent;
  border-radius: 8px;
}
#dc-new-certificate .dc-field.noncore {
  background: var(--noncore);
  border-color: color-mix(in srgb, var(--noncore-border) 55%, transparent);
  border-left: 3px solid var(--noncore-border);
}
#dc-new-certificate .dc-field label, #dc-new-certificate .dc-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: var(--font-weight-medium);
}
.dc-tag { font-weight: 400; color: var(--muted-foreground); white-space: nowrap; }

/* WHO-core / country-specific field highlight — shared by the entry screens so the
   preparation form (outside #dc-new-certificate) can mark the same fields. The
   id-scoped rules above win inside the full wireframe; these cover other screens. */
.dc-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted-foreground); font-size: 0.85rem; }
.dc-swatch { width: 14px; height: 14px; border: 1px solid var(--border); border-radius: 3px; background: var(--card); display: inline-block; }
.dc-swatch.noncore-swatch { background: var(--noncore); border-color: var(--noncore-border); }
.dc-field.noncore {
  padding: 9px;
  border: 1px solid color-mix(in srgb, var(--noncore-border) 55%, transparent);
  border-left: 3px solid var(--noncore-border);
  border-radius: 8px;
  background: var(--noncore);
}
.dc-field.noncore label { display: flex; justify-content: space-between; gap: 8px; }

#dc-new-certificate .dc-field textarea { min-height: 76px; resize: vertical; }
textarea.form-control { min-height: 76px; padding: 8px 10px; resize: vertical; }

/* Radio/checkbox choice rows */
.dc-choice-row { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; }
.dc-choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--card);
}
.dc-choice.noncore { background: var(--noncore); border-color: var(--noncore-border); }

/* Sliding on/off switch (checkbox styled as a toggle) */
.dc-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.dc-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dc-switch-track {
  position: relative;
  flex-shrink: 0;
  width: 42px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--input);
  transition: background .15s ease;
}
.dc-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease;
}
.dc-switch input:checked + .dc-switch-track { background: var(--primary); }
.dc-switch input:checked + .dc-switch-track .dc-switch-thumb { transform: translateX(18px); }
.dc-switch input:focus-visible + .dc-switch-track { outline: 2px solid var(--ring); outline-offset: 2px; }
.dc-switch-text { color: var(--foreground); }

/* Cause-of-death table */
.dc-cause-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 9px;
  /* Must stay visible so the ECT results popup can escape the table; the
     rounded look is preserved by rounding the header corner cells below
     (overflow:hidden here would clip the popup, esp. the last row's). */
  overflow: visible;
}
/* Each row (header + a/b/c/d) is its own 3-column grid, stacked in the flex
   column above, so a data row can be dragged as one unit to reorder the chain. */
.dc-cause-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(130px, .34fr);
  border-bottom: 1px solid var(--border);
}
.dc-cause-row:last-child { border-bottom: 0; }
.dc-cause-row > div {
  padding: 9px;
  border-right: 1px solid var(--border);
  min-width: 0;
}
.dc-cause-row > div:last-child { border-right: 0; }
.dc-cause-header > div:first-child { border-top-left-radius: 8px; }
.dc-cause-header > div:last-child { border-top-right-radius: 8px; }
.dc-cause-row.dc-row-dragging { opacity: 0.45; }
.dc-cause-head { background: var(--muted); color: var(--muted-foreground); font-weight: var(--font-weight-medium); }
.dc-cause-line { display: grid; place-items: center; gap: 4px; font-weight: var(--font-weight-medium); }
.dc-drag-handle {
  appearance: none;
  border: 0;
  background: none;
  padding: 2px 4px;
  color: var(--muted-foreground);
  font-size: 1rem;
  line-height: 1;
  cursor: grab;
  border-radius: 5px;
}
.dc-drag-handle:hover { color: var(--foreground); }
.dc-drag-handle:active { cursor: grabbing; }
.dc-drag-handle:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
/* Interval from onset: a magnitude (number) stacked over its unit select. */
.dc-interval { display: grid; gap: 6px; align-content: start; }
.dc-interval .dc-interval-value, .dc-interval .dc-interval-unit { width: 100%; }

/* ICD-11 cause field bound to the WHO Embedded Coding Tool (ECT) */
.dc-icd-field { display: grid; gap: 5px; position: relative; }
.dc-icd-hint { display: flex; align-items: center; gap: 6px; color: var(--muted-foreground); font-size: 0.85rem; }
.dc-icd-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dc-condition-list { display: grid; gap: 8px; }
.dc-condition-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(130px, .3fr); gap: 8px; align-items: start; }
/* The ECT (popupMode) renders its results as an absolutely-positioned card
   (.popupModeResults) with its own white background and shadow. Anchor the
   window to the field but DO NOT clip it — an overflow/max-height here would
   cut off that popup. */
.dc-icd-field .ctw-window { position: absolute; top: 100%; left: 0; right: 0; z-index: 1000; }
/* The ECT is a light-theme widget (text #333); its popup card already paints a
   white background, so its text stays legible on our dark UI. Keep that card
   readable if content lands directly on the (transparent) window too. */
.dc-icd-field .ctw-window .ectComponent { color: #333; }
.dc-icd-field .ctw-window .popupModeResults { max-height: 60vh; overflow: auto; }
/* Entry screen: let the popup escape the rounded app frame and extend the page
   scroll when it runs past the viewport bottom. The shell normally clips to its
   frame (overflow:hidden); re-round the corner cells so it still looks right. */
#dc-new-certificate .dc-shell { overflow: visible; }
#dc-new-certificate .dc-topbar { border-top-left-radius: 13px; border-top-right-radius: 13px; }
#dc-new-certificate .dc-sidebar { border-bottom-left-radius: 13px; }

/* DORIS panel */
.dc-doris { position: sticky; top: 12px; }
.dc-doris-state {
  min-height: 160px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: 9px;
  background: var(--muted);
  color: var(--muted-foreground);
  /* DORIS reports can contain very long post-coordinated code chains with no
     spaces (e.g. NA07.3Y&XC5K&...); break them so they never force overflow. */
  overflow-wrap: anywhere;
  word-break: break-word;
}
.dc-doris-state strong { color: var(--foreground); font-weight: var(--font-weight-medium); display: block; margin-bottom: 5px; }
.dc-doris-state.is-checked {
  border-style: solid;
  background: var(--accent);
  color: var(--accent-foreground);
  /* A completed check can be a wall of text: switch to normal top-aligned flow
     and cap the height with a scrollbar so it stays contained on the page. */
  display: block;
  text-align: left;
  max-height: 60vh;
  overflow-y: auto;
}
.dc-actions { display: flex; align-items: center; gap: 10px; }
.dc-modal {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 22px 24px;
  max-width: 420px;
  width: calc(100% - 32px);
  color: var(--foreground);
  background: var(--background);
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.18);
}
.dc-modal::backdrop { background: rgb(0 0 0 / 0.4); }
.dc-modal h3 { margin: 0 0 8px; }
.dc-modal p { margin: 0 0 12px; color: var(--muted-foreground); }
.dc-modal-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.dc-doris-state ul { margin: 8px 0 0; padding-left: 18px; text-align: left; }
.dc-doris-state li { margin-bottom: 3px; }
/* DORIS rule report: one step (SPn/Mn) per line for readability. */
.dc-doris-report { display: grid; gap: 5px; }
.dc-doris-report span { display: block; }

/* Conditional notes / disclosure */
.dc-conditional-note {
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted-foreground);
  background: var(--muted);
}
.dc-hidden { display: none !important; }
#dc-new-certificate details { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
#dc-new-certificate summary { cursor: pointer; font-weight: var(--font-weight-medium); margin-bottom: 10px; }
#dc-new-certificate .dc-help, #dc-new-certificate .dc-caption { color: var(--muted-foreground); font-size: 0.85rem; }

/* Section actions row */
.dc-section-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Cancel sits flush left while the save/continue buttons stay right. */
.dc-section-actions .dc-cancel {
  margin-right: auto;
}

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

@media (max-width: 1040px) {
  .dc-medical-layout { grid-template-columns: 1fr; }
  .dc-doris { position: static; }
  .dc-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  body { padding: 8px; }
  .dc-topbar { flex-direction: column; align-items: stretch; }
  .dc-case { text-align: left; }
  .dc-workspace { grid-template-columns: 1fr; }
  .dc-sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .dc-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dc-sidebar-note { display: none; }
  #dc-new-certificate .dc-workspace { grid-template-columns: 1fr; min-height: 0; }
  #dc-new-certificate .dc-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #dc-new-certificate .dc-topbar { flex-direction: column; align-items: stretch; }
  #dc-new-certificate .dc-case { justify-content: flex-start; text-align: left; }
  #dc-new-certificate .dc-screen-head { flex-direction: column; align-items: stretch; }
  .dc-grid-2, .dc-grid-3, .dc-review-grid { grid-template-columns: 1fr; }
  .dc-col-2, .dc-col-3, .dc-col-4, .dc-col-5, .dc-col-6,
  .dc-col-7, .dc-col-8, .dc-col-9, .dc-col-10 { grid-column: span 12; }
  .dc-cause-row { grid-template-columns: 30px minmax(0, 1fr); }
  .dc-cause-row > div { border-right: 0; }
  .dc-cause-row .dc-interval { grid-column: 2; }
  .dc-cause-row .dc-interval-head { display: none; }
}

/* ========================================================================
   Hospital portal components — from the Hospital Death Certificate Portal
   wireframe (local_docs/Hospital_Death_Certificate_Portal_Wireframe.html),
   rebuilt on the shared tokens above (blue brand kept for one coherent theme;
   the wireframe's green `--dc-*` palette is intentionally NOT re-introduced).
   Only classes NOT already defined earlier are added here — the shell, `.card`,
   `.table`, forms, `.dc-cause-table`, `.dc-doris*`, `.dc-choice*`, `.btn*`,
   `.dc-status`, `.dc-detail-grid` and layout grids are reused as-is.

   Note on markup mapping: the wireframe's asymmetric `.dc-grid-2` (main + aside)
   maps to `.dc-grid-main-aside` here, because this file's `.dc-grid-2` is the
   symmetric 2-column grid used by the entry form.
   ======================================================================== */

/* ---- Page head (h1 + lead + actions) ------------------------------------ */
.dc-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.dc-page-head h1 { margin: 0 0 6px; font-size: 1.55rem; line-height: 1.2; letter-spacing: -0.02em; }
.dc-page-head p { margin: 0; color: var(--muted-foreground); }

/* ---- Buttons (wireframe vocabulary; complements the shared `.btn*`) ------ */
.dc-button {
  appearance: button;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  color: var(--foreground);
  background: var(--secondary);
  font: inherit;
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.dc-button:not(:disabled):hover { border-color: var(--primary); }
.dc-button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.dc-button:disabled { cursor: not-allowed; opacity: 0.4; }
.dc-button-primary { border-color: transparent; color: var(--primary-foreground); background: var(--primary); }
.dc-button-primary:not(:disabled):hover { background: color-mix(in srgb, var(--foreground) 12%, var(--primary)); }
.dc-button-danger { color: var(--destructive); }
.dc-button-small { min-height: 0; padding: 7px 10px; font-size: 0.8rem; }

/* ---- Stat tiles --------------------------------------------------------- */
.dc-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.dc-stat {
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.dc-stat-label { color: var(--muted-foreground); font-size: 0.8rem; }
.dc-stat-value { margin-top: 6px; font-size: 1.7rem; font-weight: var(--font-weight-medium); line-height: 1.1; }
.dc-stat-note { margin-top: 4px; color: var(--muted-foreground); font-size: 0.75rem; }

/* ---- Panel card with header/body (distinct from the plain `.card`) ------ */
.dc-grid-main-aside {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(270px, 0.75fr);
  gap: 18px;
  align-items: start;
}
.dc-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.dc-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--border);
}
.dc-card-head h2 { margin: 0; font-size: 1rem; }
.dc-card-head a { font-size: 0.8rem; }
.dc-card-body { padding: 18px; }

/* ---- Data table (wireframe styling; complements the shared `.table`) ----- */
.dc-table-wrap { width: 100%; overflow-x: auto; }
.dc-table { width: 100%; border-collapse: collapse; min-width: 690px; }
.dc-table th {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 55%, transparent);
  color: var(--muted-foreground);
  font-size: 0.7rem;
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.dc-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  vertical-align: middle;
}
.dc-table tr:last-child td { border-bottom: 0; }
.dc-patient { font-weight: var(--font-weight-medium); }
.dc-id { display: block; margin-top: 3px; color: var(--muted-foreground); font-size: 0.72rem; }

/* ---- Badges ------------------------------------------------------------- */
.dc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: var(--radius-full);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
}
.dc-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.dc-badge-green { color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); }
.dc-badge-blue { color: var(--primary); background: var(--accent); }
.dc-badge-red { color: var(--destructive); background: color-mix(in srgb, var(--destructive) 14%, transparent); }
.dc-badge-amber { color: var(--warning); background: color-mix(in srgb, var(--warning) 16%, transparent); }

/* ---- Quick-action cards ------------------------------------------------- */
.dc-quick-actions { display: grid; gap: 10px; }
.dc-quick-action {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 11px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: color-mix(in srgb, var(--muted) 45%, transparent);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.dc-quick-action:hover { border-color: var(--primary); }
.dc-quick-icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-foreground);
  font-weight: var(--font-weight-medium);
}
.dc-quick-title { display: block; font-weight: var(--font-weight-medium); }
.dc-quick-copy { display: block; margin-top: 3px; color: var(--muted-foreground); font-size: 0.75rem; }

/* ---- Filter bar + inputs (wireframe vocabulary) ------------------------- */
.dc-filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--border);
}
.dc-input, .dc-select, .dc-textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  outline: none;
  border: 1px solid var(--input);
  border-radius: 9px;
  color: var(--foreground);
  background: var(--secondary);
  font: inherit;
}
.dc-input::placeholder, .dc-textarea::placeholder { color: var(--muted-foreground); }
.dc-input:focus-visible, .dc-select:focus-visible, .dc-textarea:focus-visible {
  border-color: var(--ring);
  box-shadow: inset 0 0 0 1px var(--ring);
}
.dc-textarea { min-height: 80px; resize: vertical; }
.dc-filterbar .dc-input { max-width: 300px; }
.dc-filterbar .dc-select { max-width: 190px; }

/* ---- Guided form: step nav + progress + sections ------------------------ */
.dc-form-shell {
  display: grid;
  grid-template-columns: 205px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.dc-step-nav {
  position: sticky;
  top: 16px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
}
.dc-step-button {
  width: 100%;
  padding: 11px;
  border: 0;
  border-radius: 9px;
  color: var(--muted-foreground);
  background: transparent;
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}
.dc-step-button.is-active { color: var(--primary); background: var(--accent); font-weight: var(--font-weight-medium); }
.dc-progress { height: 6px; margin: 15px 10px 8px; border-radius: var(--radius-full); background: var(--muted); overflow: hidden; }
.dc-progress span { display: block; height: 100%; background: var(--primary); }
.dc-progress-copy { padding: 0 10px 9px; color: var(--muted-foreground); font-size: 0.72rem; }
.dc-form-section { display: none; }
.dc-form-section.is-active { display: block; }

/* ---- Section head + field grid ------------------------------------------ */
.dc-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.dc-section-head h2 { margin: 0 0 4px; font-size: 1.1rem; }
.dc-section-head p { margin: 0; color: var(--muted-foreground); font-size: 0.8rem; }
.dc-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
  padding: 20px;
}
.dc-field-full { grid-column: 1 / -1; }
.dc-fields .dc-field label { font-size: 0.8rem; font-weight: var(--font-weight-medium); }
.dc-fields .dc-field small { color: var(--muted-foreground); font-size: 0.72rem; }
.dc-field-extra {
  padding: 11px;
  border: 1px solid var(--noncore-border);
  border-radius: 10px;
  background: var(--noncore);
}
.dc-extra-tag {
  color: var(--noncore-border);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---- Inline radio pills -------------------------------------------------- */
.dc-radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.dc-radio {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  font-size: 0.8rem;
}
.dc-radio input { margin-right: 6px; }

/* ---- Cause table cells + ICD fields (extends the shared `.dc-cause-table`) */
.dc-cause-cell { font-size: 0.8rem; }
.dc-icd-input { width: 100%; border: 0; background: transparent; color: var(--foreground); outline: 0; font: inherit; }
.dc-icd-code { color: var(--primary); font-size: 0.72rem; font-family: var(--font-mono); font-weight: 600; }

/* ---- Form action bar ---------------------------------------------------- */
.dc-form-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 45%, transparent);
}

/* ---- Doctor review: main + sticky aside --------------------------------- */
.dc-review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  align-items: start;
}
.dc-review-aside { position: sticky; top: 16px; display: grid; gap: 14px; }

/* ---- Key/value detail list ---------------------------------------------- */
.dc-detail-list { display: grid; gap: 11px; }
.dc-detail-row { display: flex; justify-content: space-between; gap: 15px; font-size: 0.8rem; }
.dc-detail-row span:first-child { color: var(--muted-foreground); }

/* ---- DORIS result item -------------------------------------------------- */
.dc-doris-item {
  margin-top: 9px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.dc-doris-item strong { display: block; font-size: 0.8rem; }
.dc-doris-item p { margin: 5px 0 0; color: var(--muted-foreground); font-size: 0.72rem; line-height: 1.45; }

/* ---- Tabs --------------------------------------------------------------- */
.dc-tabs { display: flex; gap: 4px; padding: 0 17px; border-bottom: 1px solid var(--border); }
.dc-tab {
  padding: 13px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted-foreground);
  font: inherit;
  font-size: 0.8rem;
  font-weight: var(--font-weight-medium);
  cursor: pointer;
}
.dc-tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- Legend dots (page-head classification key) ------------------------- */
.dc-legend-dot { display: inline-block; width: 10px; height: 10px; border: 1px solid var(--border); border-radius: 3px; background: var(--card); }
.dc-legend-dot-extra { background: var(--noncore); border-color: var(--noncore-border); }

/* ---- Sidebar nav icon/text spans (role portal sidebar) ------------------ */
.dc-nav-icon { width: 22px; text-align: center; font-weight: 700; }
.dc-nav-text { min-width: 0; }

/* ---- Centred modal-style form + developer handoff note ------------------ */
.dc-modal-card { max-width: 720px; margin: 0 auto; }
.dc-dev-note {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 11px;
  color: var(--muted-foreground);
  font-size: 0.72rem;
  line-height: 1.55;
}

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 1040px) {
  .dc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dc-grid-main-aside, .dc-review-layout { grid-template-columns: 1fr; }
  .dc-review-aside { position: static; }
}
@media (max-width: 760px) {
  .dc-page-head { flex-direction: column; }
  .dc-stats { grid-template-columns: 1fr 1fr; }
  .dc-form-shell { grid-template-columns: 1fr; }
  .dc-step-nav { position: static; display: flex; overflow-x: auto; }
  .dc-step-button { white-space: nowrap; }
  .dc-progress, .dc-progress-copy { display: none; }
  .dc-fields { grid-template-columns: 1fr; }
  .dc-field-full { grid-column: auto; }
  .dc-filterbar .dc-input, .dc-filterbar .dc-select { max-width: none; }
}

/* ---- Public-health statistics portal ------------------------------------ */
/* Fixed-height wrapper so the Chart.js canvas (maintainAspectRatio: false)
   has room without growing unbounded. */
.dc-chart { position: relative; height: 320px; }
.dc-chart canvas { max-width: 100%; }

.dc-report-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 8px;
}
.dc-report-toolbar h3 { margin: 0; }
.dc-report-actions { display: flex; gap: 8px; }
.dc-report-filter {
  display: flex; align-items: end; gap: 12px; flex-wrap: wrap;
  margin: 12px 0 4px;
}
.dc-report-filter label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.78rem; color: var(--muted-foreground);
}
.dc-report-filter input[type="date"] {
  padding: 7px 9px; border: 1px solid var(--input);
  border-radius: var(--radius-sm); background: var(--card); color: var(--foreground);
}

/* ---- Printable report --------------------------------------------------- */
.dc-print { max-width: 900px; margin: 24px auto; padding: 0 20px; }
.dc-print-head h1 { margin: 0 0 4px; font-size: 1.4rem; }
.dc-print-head p { margin: 0 0 12px; color: var(--muted-foreground); }
@media print {
  .dc-print-hide { display: none !important; }
  .dc-print { margin: 0; max-width: none; }
  .table thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---- Flash message toasts ----------------------------------------------- */
/* Server messages surface as a stack of auto-dismissing toasts pinned to the
   top-right of the viewport (above the app chrome) instead of pushing the page
   content down. Dismissal is driven by the script in base.html. */
.dc-messages {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}
.dc-message {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px 11px 14px;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted-foreground);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px rgb(0 0 0 / 20%);
  font-size: 0.86rem;
  line-height: 1.35;
  animation: dc-toast-in 0.22s ease-out;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.dc-message.is-leaving { opacity: 0; transform: translateX(16px); }
.dc-message-text { flex: 1; min-width: 0; }
.dc-message-close {
  flex: none;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 1.15rem;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.dc-message-close:hover { color: var(--foreground); }
.dc-message.success { border-left-color: var(--success); }
.dc-message.error { border-left-color: var(--destructive); }
.dc-message.warning { border-left-color: var(--warning); }
.dc-message.info, .dc-message.debug { border-left-color: var(--accent-foreground); }
@keyframes dc-toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
@media print { .dc-messages { display: none !important; } }
