/* Laudare design system.
 * --tenant-primary / --tenant-on-primary come from the municipality config (base.html).
 * Every brand shade is derived from it with color-mix(), so each municipality gets a coherent palette. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../vendor/inter/inter-latin-wght-normal.woff2") format("woff2-variations"),
       url("../vendor/inter/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
                 U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../vendor/inter/inter-latin-ext-wght-normal.woff2") format("woff2-variations"),
       url("../vendor/inter/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
                 U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --brand: var(--tenant-primary, #0d6efd);
  --on-brand: var(--tenant-on-primary, #fff);
  --brand-25: color-mix(in srgb, var(--brand) 4%, #fff);
  --brand-50: color-mix(in srgb, var(--brand) 8%, #fff);
  --brand-100: color-mix(in srgb, var(--brand) 16%, #fff);
  --brand-200: color-mix(in srgb, var(--brand) 30%, #fff);
  --brand-600: color-mix(in srgb, var(--brand) 88%, #000);
  --brand-700: color-mix(in srgb, var(--brand) 74%, #000);
  --brand-800: color-mix(in srgb, var(--brand) 58%, #000);
  --brand-900: color-mix(in srgb, var(--brand) 40%, #000);

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cfd6e0;
  --text: #111827;
  --text-2: #374151;
  --muted: #5b6474;      /* 5.9:1 on white, 5.5:1 on --bg */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, .08), 0 2px 6px -2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 16px 32px -8px rgba(16, 24, 40, .16);
  --sidebar-w: 256px;
  --focus: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent);

  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-font-size: .9375rem;
  --bs-body-color: var(--text);
  --bs-body-bg: #fff;  /* components (inputs, modals, dropdowns) inherit this; the page uses --bg below */
  --bs-border-color: var(--border);
  --bs-border-radius: var(--radius-sm);
  --bs-border-radius-lg: var(--radius);
  --bs-secondary-color: var(--muted);
  --bs-link-color: var(--brand-700);
  --bs-link-hover-color: var(--brand-800);
  --bs-focus-ring-color: color-mix(in srgb, var(--brand) 35%, transparent);
}

html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  letter-spacing: -.003em;
}
h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 { color: var(--text); letter-spacing: -.015em; font-weight: 650; }
a { color: var(--brand-700); text-underline-offset: 2px; }
a:hover { color: var(--brand-800); }
.text-muted, .text-body-secondary { color: var(--muted) !important; }
code { color: var(--brand-800); background: var(--brand-50); padding: .1rem .35rem; border-radius: 6px; font-size: .85em; }
::selection { background: var(--brand-100); }

/* Visible keyboard focus everywhere */
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, #fff); outline-offset: 2px; border-radius: 6px; }
.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus {
  box-shadow: var(--focus); border-color: var(--brand); outline: none;
}
.skip-link {
  position: absolute; left: 1rem; top: -100px; z-index: 2000; padding: .6rem 1rem;
  background: var(--brand); color: var(--on-brand); border-radius: var(--radius-sm); font-weight: 600;
}
.skip-link:focus { top: 1rem; color: var(--on-brand); }

/* ---------- buttons ---------- */
.btn { font-weight: 550; border-radius: 10px; padding: .5rem .95rem; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; }
.btn-sm { padding: .35rem .7rem; font-size: .84rem; border-radius: 8px; }
.btn-lg { padding: .7rem 1.2rem; font-size: 1rem; }
.btn .bi { font-size: 1.05em; line-height: 1; }
.btn-primary {
  --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-color: var(--on-brand);
  --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600); --bs-btn-hover-color: var(--on-brand);
  --bs-btn-active-bg: var(--brand-700); --bs-btn-active-border-color: var(--brand-700); --bs-btn-active-color: var(--on-brand);
  --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); --bs-btn-disabled-color: var(--on-brand);
  box-shadow: var(--shadow-xs);
}
.btn-soft {
  --bs-btn-bg: var(--brand-50); --bs-btn-color: var(--brand-800); --bs-btn-border-color: var(--brand-100);
  --bs-btn-hover-bg: var(--brand-100); --bs-btn-hover-color: var(--brand-900); --bs-btn-hover-border-color: var(--brand-200);
  --bs-btn-active-bg: var(--brand-200); --bs-btn-active-color: var(--brand-900);
}
.btn-white, .btn-outline-secondary {
  --bs-btn-bg: #fff; --bs-btn-color: var(--text-2); --bs-btn-border-color: var(--border-strong);
  --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: #b8c1cd;
  --bs-btn-active-bg: #eef2f6; --bs-btn-active-color: var(--text); --bs-btn-active-border-color: #b8c1cd;
  box-shadow: var(--shadow-xs);
}
.btn-success { --bs-btn-bg: #047857; --bs-btn-border-color: #047857; --bs-btn-hover-bg: #065f46; --bs-btn-hover-border-color: #065f46; }
.btn-danger { --bs-btn-bg: #b42318; --bs-btn-border-color: #b42318; --bs-btn-hover-bg: #912018; --bs-btn-hover-border-color: #912018; }
.btn-warning { --bs-btn-bg: #b54708; --bs-btn-border-color: #b54708; --bs-btn-color: #fff; --bs-btn-hover-bg: #93370d; --bs-btn-hover-border-color: #93370d; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; }
.btn-outline-danger { --bs-btn-color: #b42318; --bs-btn-border-color: #f1b3ad; --bs-btn-hover-bg: #fef3f2; --bs-btn-hover-color: #912018; --bs-btn-hover-border-color: #e88b83; --bs-btn-bg: #fff; }
.btn-outline-success { --bs-btn-color: #047857; --bs-btn-border-color: #a6e2cb; --bs-btn-hover-bg: #ecfdf3; --bs-btn-hover-color: #065f46; --bs-btn-hover-border-color: #6fcea8; --bs-btn-bg: #fff; }
.btn-icon { width: 2.25rem; height: 2.25rem; padding: 0; border-radius: 10px; }
.btn-icon.btn-sm { width: 2rem; height: 2rem; }
.btn-ghost { --bs-btn-color: var(--muted); --bs-btn-hover-bg: var(--brand-50); --bs-btn-hover-color: var(--brand-800); --bs-btn-bg: transparent; --bs-btn-border-color: transparent; --bs-btn-hover-border-color: transparent; }

/* ---------- forms ---------- */
.form-label { font-weight: 550; font-size: .84rem; color: var(--text-2); margin-bottom: .35rem; }
.form-control, .form-select { border-color: var(--border-strong); border-radius: 10px; padding: .55rem .8rem; box-shadow: var(--shadow-xs); }
.form-control-sm, .form-select-sm { padding: .4rem .65rem; font-size: .875rem; border-radius: 8px; }
.form-control::placeholder { color: #8a93a3; }
.form-check-input { border-color: #98a2b3; width: 1.1em; height: 1.1em; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-text { color: var(--muted); }
.input-icon { position: relative; }
.input-icon > .bi { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon > .form-control { padding-left: 2.3rem; }

/* ---------- app shell ---------- */
.app-shell { min-height: 100vh; }
.sidebar, .sidebar.offcanvas-lg {
  background: var(--surface) !important;  /* Bootstrap makes offcanvas-lg transparent on desktop */
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
@media (min-width: 992px) {
  .sidebar.offcanvas-lg {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1030;
    visibility: visible !important; transform: none !important;
  }
  .app-main { margin-left: var(--sidebar-w); }
  .topbar { display: none !important; }
}
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { width: min(86vw, 300px); }
}
.sidebar .offcanvas-body { display: flex; flex-direction: column; padding: 0; height: 100%; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.25rem 1rem; text-decoration: none; color: var(--text); }
.sidebar-brand:hover { color: var(--text); }
.sidebar-brand img { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; background: #fff; border: 1px solid var(--border); padding: 3px; flex-shrink: 0; }
.sidebar-brand .t-name { font-weight: 650; font-size: .88rem; line-height: 1.25; }
.sidebar-brand .t-unit { font-size: .76rem; color: var(--muted); line-height: 1.25; margin-top: .1rem; }
.sidebar-section { padding: .25rem .75rem; }
.sidebar-label { font-size: .7rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: .9rem .6rem .4rem; }
.nav-side .nav-link {
  display: flex; align-items: center; gap: .7rem; color: var(--text-2); font-weight: 550; font-size: .9rem;
  padding: .55rem .7rem; border-radius: 10px; margin-bottom: 2px; position: relative;
}
.nav-side .nav-link .bi { font-size: 1.1rem; color: var(--muted); width: 1.25rem; text-align: center; }
.nav-side .nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-side .nav-link.active { background: var(--brand-50); color: var(--brand-800); }
.nav-side .nav-link.active .bi { color: var(--brand-700); }
.nav-side .nav-link.active::before {
  content: ""; position: absolute; left: -.75rem; top: .45rem; bottom: .45rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border); padding: .9rem 1rem; display: flex; align-items: center; gap: .7rem; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: var(--brand-100); color: var(--brand-800); font-weight: 650; font-size: .85rem;
}
.sidebar-footer .u-name { font-weight: 600; font-size: .85rem; line-height: 1.2; }
.sidebar-footer .u-role { font-size: .76rem; color: var(--muted); }
.sidebar-product { font-size: .72rem; color: var(--muted); padding: 0 1.25rem .9rem; }

.topbar {
  position: sticky; top: 0; z-index: 1020; background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .6rem; padding: .55rem .9rem;
}
.topbar img { width: 32px; height: 32px; object-fit: contain; }
.topbar .t-name { font-weight: 650; font-size: .88rem; line-height: 1.2; min-width: 0; }

.app-content { padding: 1.75rem 2rem 3rem; max-width: 1480px; }
@media (max-width: 991.98px) { .app-content { padding: 1.25rem 1rem 2.5rem; } }

/* ---------- page header ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-title { font-size: 1.5rem; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.page-subtitle { color: var(--muted); margin: .25rem 0 0; font-size: .92rem; }
.breadcrumb-back { display: inline-flex; align-items: center; gap: .35rem; font-size: .84rem; font-weight: 550; color: var(--muted); text-decoration: none; margin-bottom: .5rem; }
.breadcrumb-back:hover { color: var(--brand-700); }
@media (max-width: 575.98px) { .page-title { font-size: 1.3rem; } }

/* ---------- cards ---------- */
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); background: var(--surface); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); padding: .9rem 1.25rem; font-weight: 650; display: flex; align-items: center; gap: .5rem; }
.card-header .bi { color: var(--brand-700); }
.card-body { padding: 1.25rem; }
.card-title-sm { font-size: .78rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 0 0 .75rem; }

/* key/value lists */
.kv { display: grid; grid-template-columns: minmax(104px, 38%) minmax(0, 1fr); gap: .55rem 1rem; margin: 0; }
.kv code { word-break: break-all; background: transparent; padding: 0; color: var(--text-2); }
.kv dt { font-weight: 500; color: var(--muted); font-size: .86rem; }
.kv dd { margin: 0; font-weight: 500; color: var(--text); overflow-wrap: anywhere; }
@media (min-width: 992px) {
  .kv-wide { grid-template-columns: 130px minmax(0, 1fr) 130px minmax(0, 1fr); }
}

/* ---------- stats ---------- */
.stat-card { display: flex; flex-direction: row; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .84rem; font-weight: 500; }
.tone-amber { background: #fff4e5; color: #b54708; }
.tone-blue { background: #eaf2ff; color: #1d4ed8; }
.tone-green { background: #e7f8ef; color: #047857; }
.tone-brand { background: var(--brand-50); color: var(--brand-700); }
@media (max-width: 575.98px) {
  .stat-card { padding: .75rem .8rem; flex-direction: column; align-items: flex-start; gap: .45rem; }
  .stat-icon { width: 30px; height: 30px; font-size: .95rem; border-radius: 8px; }
  .stat-value { font-size: 1.3rem; }
  .stat-label { font-size: .74rem; line-height: 1.25; }
}

/* ---------- status pills & tags ---------- */
.status-pill {
  display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap;
  padding: .2rem .6rem .2rem .48rem; border-radius: 999px; font-size: .76rem; font-weight: 600; border: 1px solid transparent;
}
.status-pill .bi { font-size: .85rem; }
.status-aguardando_laudo { background: #fff6e8; color: #93370d; border-color: #fbd9a6; }
.status-em_laudo { background: #eaf2ff; color: #1e40af; border-color: #bcd3fb; }
.status-laudado { background: #e9f8f0; color: #05603a; border-color: #a9e5c8; }
.status-entregue { background: #f0f2f5; color: #364152; border-color: #d3d9e2; }
.status-pill.lg { font-size: .85rem; padding: .32rem .8rem .32rem .65rem; }
.tag {
  display: inline-flex; align-items: center; padding: .12rem .45rem; border-radius: 6px; font-size: .74rem; font-weight: 650;
  letter-spacing: .03em; background: var(--brand-50); color: var(--brand-800); border: 1px solid var(--brand-100);
}
.tag + .tag { margin-left: .25rem; }
.tag-neutral { background: #f1f4f8; color: #364152; border-color: #dfe5ec; }
.badge-soft { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.badge-soft.ok { background: #e9f8f0; color: #05603a; }
.badge-soft.off { background: #f0f2f5; color: #4a5565; }

/* ---------- tables ---------- */
.table-card { overflow: hidden; }
.table-app { margin: 0; --bs-table-bg: transparent; font-size: .875rem; }
.table-app > thead th {
  background: var(--surface-2); color: var(--muted); font-size: .7rem; font-weight: 650; letter-spacing: .05em;
  text-transform: uppercase; border-bottom: 1px solid var(--border); padding: .65rem .8rem; white-space: nowrap;
}
.table-app > thead th:first-child, .table-app > tbody td:first-child { padding-left: 1.25rem; }
.table-app > thead th:last-child, .table-app > tbody td:last-child { padding-right: 1.25rem; }
.table-app > tbody td { padding: .75rem .8rem; border-color: var(--border); vertical-align: middle; color: var(--text-2); }
.table-app > tbody tr:last-child td { border-bottom: 0; }
.table-app > tbody tr { transition: background-color .12s ease; }
.table-app > tbody tr:hover > td { background: var(--brand-25); }
.row-link { cursor: pointer; }
.row-link:hover > td { background: var(--brand-50) !important; }
.patient-link { color: var(--text); font-weight: 600; text-decoration: none; }
.patient-link:hover, .patient-link:focus { color: var(--brand-800); text-decoration: none; }
.cell-sub { display: block; color: var(--muted); font-size: .8rem; margin-top: .1rem; font-weight: 450; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.actions { display: inline-flex; gap: .3rem; justify-content: flex-end; }

/* Worklist turns into cards on phones (same markup, no duplicated rows) */
@media (max-width: 767.98px) {
  .table-cards > thead { display: none; }
  .table-cards, .table-cards > tbody { display: block; }
  .table-cards > tbody > tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .6rem;
    padding: .9rem 1rem; border-bottom: 1px solid var(--border);
  }
  .table-cards > tbody > tr:last-child { border-bottom: 0; }
  .table-cards > tbody > tr > td,
  .table-cards > tbody > tr.row-link:hover > td { display: block; padding: 0 !important; border: 0; background: transparent !important; }
  .table-cards > tbody > tr.row-link:hover { background: var(--brand-25); }
  .table-cards .c-name { order: 1; flex: 1 1 100%; min-width: 0; font-size: .98rem; }
  .table-cards .c-date { order: 2; flex: 1 1 auto; color: var(--muted); font-size: .82rem; margin: .35rem 0 .2rem; }
  .table-cards .c-status { order: 3; margin-left: auto; }
  .table-cards .c-date .cell-sub { display: inline; margin-left: .3rem; font-size: inherit; }
  .table-cards > tbody > tr > td.c-mod { display: none !important; }  /* shown inside the description cell on phones */
  .table-cards .c-desc { order: 5; flex: 1 1 100%; min-width: 0; font-size: .86rem; color: var(--text-2); }
  .table-cards .c-count { order: 6; font-size: .8rem; color: var(--muted); }
  .table-cards .c-count::before { content: attr(data-label) ": "; font-weight: 600; }
  .table-cards .c-actions { order: 7; margin-left: auto; }
  .table-cards .c-empty { flex-basis: 100%; }
}

/* generic tables collapse into stacked rows on phones */
@media (max-width: 767.98px) {
  .table-stack > thead { display: none; }
  .table-stack, .table-stack > tbody, .table-stack > tbody > tr, .table-stack > tbody > tr > td { display: block; width: 100%; }
  .table-stack > tbody > tr { padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
  .table-stack > tbody > tr > td { border: 0; padding: .15rem 0; }
  .table-stack > tbody > tr > td[data-label]:not(.c-main)::before {
    content: attr(data-label); display: inline-block; min-width: 8.5rem; color: var(--muted); font-weight: 550; font-size: .8rem;
  }
  .table-stack .c-main { font-weight: 600; font-size: .98rem; margin-bottom: .25rem; }
  .table-stack .c-actions { padding-top: .5rem !important; text-align: left !important; }
}

/* ---------- filters ---------- */
.filter-card .card-body { padding: 1rem 1.25rem; }
.filters-grid { display: grid; gap: .85rem; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.filters-grid .f-name, .filters-grid .f-actions { grid-column: 1 / -1; }
.filters-grid .f-actions { display: flex; gap: .5rem; }
.filters-grid .f-actions .btn-primary { flex: 1; }
@media (min-width: 768px) {
  .filters-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters-grid .f-name { grid-column: span 2; }
  .filters-grid .f-actions { grid-column: auto; }
}
@media (min-width: 1200px) {
  /* 1366px (hospital PCs): two balanced rows */
  .filters-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .filters-grid .f-name { grid-column: span 2; }
  .filters-grid .f-actions { grid-column: auto; }
}
@media (min-width: 1600px) {
  /* wide screens: a single row */
  .filters-grid { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr) minmax(150px, 1.1fr) minmax(150px, 1.1fr) minmax(110px, .9fr) minmax(160px, 1.2fr) auto; }
  .filters-grid .f-name { grid-column: auto; }
  .filters-grid .f-actions .btn-primary { flex: none; }
}
.filter-toggle { display: none; }
@media (max-width: 767.98px) {
  .filter-toggle { display: flex; }
  .filter-card .card-body { padding: .9rem; }
}

/* ---------- pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .8rem 1rem; border-top: 1px solid var(--border); background: var(--surface-2); }
.pager .info { color: var(--muted); font-size: .85rem; }
.pagination { --bs-pagination-color: var(--text-2); --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand);
  --bs-pagination-active-color: var(--on-brand); --bs-pagination-hover-bg: var(--brand-50); --bs-pagination-hover-color: var(--brand-800);
  --bs-pagination-focus-box-shadow: var(--focus); --bs-pagination-border-radius: 8px; margin: 0; gap: .25rem; }
.pagination .page-link { border-radius: 8px !important; min-width: 2.1rem; text-align: center; }

/* ---------- empty states ---------- */
.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-state .icon {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 1rem;
  background: var(--brand-50); color: var(--brand-700); font-size: 1.7rem;
}
.empty-state h2 { font-size: 1.05rem; margin-bottom: .35rem; }
.empty-state p { color: var(--muted); margin: 0 auto; max-width: 420px; }

/* ---------- alerts / callouts ---------- */
.callout { display: flex; gap: .75rem; padding: .9rem 1rem; border-radius: var(--radius-sm); border: 1px solid; font-size: .9rem; }
.callout .bi { font-size: 1.15rem; line-height: 1.3; flex-shrink: 0; }
.callout-warning { background: #fffaeb; border-color: #fedf89; color: #7a2e0e; }
.callout-danger { background: #fef3f2; border-color: #fecdca; color: #7a271a; }
.callout-info { background: #eff6ff; border-color: #c7dcfe; color: #1e3a8a; }
.callout-neutral { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }

/* ---------- toasts ---------- */
.toast-stack { position: fixed; top: 1rem; right: 1rem; z-index: 1090; display: flex; flex-direction: column; gap: .6rem; width: min(400px, calc(100vw - 2rem)); }
.app-toast { display: flex; gap: .7rem; align-items: flex-start; background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: .85rem .9rem .85rem 1rem; font-size: .9rem; color: var(--text-2); }
.app-toast.hide { display: none; }
.app-toast .t-icon { font-size: 1.2rem; line-height: 1.25; }
.app-toast .t-body { flex: 1; min-width: 0; }
.app-toast.toast-success .t-icon { color: #047857; }
.app-toast.toast-danger .t-icon { color: #b42318; }
.app-toast.toast-warning .t-icon { color: #b54708; }
.app-toast.toast-info .t-icon { color: #1d4ed8; }
.app-toast.toast-danger { border-left: 4px solid #d92d20; }
.app-toast.toast-success { border-left: 4px solid #12b76a; }
.app-toast.toast-warning { border-left: 4px solid #f79009; }
.app-toast.toast-info { border-left: 4px solid #2e90fa; }

/* ---------- modal ---------- */
.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 0; padding: 1.25rem 1.5rem .25rem; }
.modal-body { padding: .5rem 1.5rem 1rem; color: var(--text-2); }
.modal-footer { border-top: 0; padding: .5rem 1.5rem 1.25rem; gap: .5rem; }
.modal-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 1.3rem; margin-bottom: .75rem; }

/* ---------- login ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-brand {
  position: relative; overflow: hidden; color: var(--on-brand); padding: 3rem 3.5rem; display: flex; flex-direction: column;
  background: radial-gradient(1200px 600px at -10% -20%, color-mix(in srgb, var(--brand) 70%, #fff) 0%, transparent 60%),
              linear-gradient(150deg, var(--brand-600) 0%, var(--brand-800) 100%);
}
.auth-brand::after {
  content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%;
  border: 60px solid color-mix(in srgb, var(--on-brand) 8%, transparent);
}
.auth-brand .logo-box { width: 84px; height: 84px; border-radius: 20px; background: #fff; display: grid; place-items: center; box-shadow: var(--shadow-lg); }
.auth-brand .logo-box img { width: 64px; height: 64px; object-fit: contain; }
.auth-brand h2 { color: inherit; font-size: 1.9rem; font-weight: 700; margin: 2rem 0 .5rem; max-width: 480px; line-height: 1.2; }
.auth-brand .unit { opacity: .9; font-size: 1.05rem; }
.auth-brand .features { list-style: none; padding: 0; margin: 2.5rem 0 0; display: grid; gap: .9rem; max-width: 420px; }
.auth-brand .features li { display: flex; gap: .75rem; align-items: flex-start; opacity: .95; }
.auth-brand .features .bi { font-size: 1.15rem; margin-top: .05rem; }
.auth-brand .foot { margin-top: auto; font-size: .82rem; opacity: .8; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; }
.auth-form .inner { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: .35rem; }
.auth-mobile-brand { display: none; }
@media (max-width: 991.98px) {
  .auth-page { grid-template-columns: 1fr; background: var(--bg); }
  .auth-brand { display: none; }
  .auth-form { align-items: flex-start; padding-top: 3rem; }
  .auth-form .inner { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 1.75rem 1.5rem; }
  .auth-mobile-brand { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.5rem; }
  .auth-mobile-brand img { width: 48px; height: 48px; object-fit: contain; }
  .auth-mobile-brand .t-name { font-weight: 650; font-size: .95rem; line-height: 1.25; }
  .auth-mobile-brand .t-unit { color: var(--muted); font-size: .8rem; }
}

/* ---------- exam detail ---------- */
.exam-hero { padding: 1.4rem 1.5rem; }
.exam-hero h1 { font-size: 1.45rem; font-weight: 700; margin: 0; letter-spacing: -.02em; overflow-wrap: anywhere; }
.exam-hero .meta { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; color: var(--muted); font-size: .88rem; margin-top: .45rem; }
.exam-hero .meta span { display: inline-flex; align-items: center; gap: .35rem; }
.exam-hero .actions-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; padding-top: 1.1rem; border-top: 1px solid var(--border); }
@media (max-width: 575.98px) {
  .exam-hero { padding: 1.1rem; }
  .exam-hero h1 { font-size: 1.2rem; }
  .exam-hero .actions-bar > .btn, .exam-hero .actions-bar > form { flex: 1 1 auto; }
  .exam-hero .actions-bar > form .btn { width: 100%; }
}
.report-state { display: flex; gap: .85rem; align-items: flex-start; }
.report-state .state-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 1.15rem; flex-shrink: 0; }
.version-list { list-style: none; margin: 0; padding: 0; }
.version-list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--border); font-size: .88rem; }
.version-list li:first-child { border-top: 0; }

.series-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; }
@media (max-width: 575.98px) { .series-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; } }
.series-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-xs);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.series-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand-200); }
.series-thumb { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: contain; background: #0b0f14; }
.series-card .s-body { padding: .65rem .8rem .75rem; font-size: .84rem; }
.series-card .s-title { font-weight: 600; color: var(--text); display: flex; align-items: center; gap: .4rem; }
.series-card .s-sub { color: var(--muted); font-size: .8rem; }

/* ---------- report editor ---------- */
.editor-patientbar {
  position: sticky; top: 0; z-index: 1010; background: rgba(255, 255, 255, .95); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: .8rem 1.1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.25rem; margin-bottom: 1.25rem;
}
@media (max-width: 991.98px) { .editor-patientbar { top: 57px; } }
.editor-patientbar .p-name { font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.editor-patientbar .p-meta { display: flex; flex-wrap: wrap; gap: .25rem .9rem; color: var(--muted); font-size: .84rem; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.25rem; align-items: start; }
.editor-layout.templates-collapsed { grid-template-columns: minmax(0, 1fr); }
.editor-layout.templates-collapsed .templates-panel { display: none; }
@media (max-width: 1199.98px) { .editor-layout { grid-template-columns: minmax(0, 1fr); } }
.doc-sheet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); overflow: hidden; }
.doc-sheet .ql-toolbar.ql-snow {
  position: sticky; top: 0; z-index: 5; background: var(--surface-2); border: 0; border-bottom: 1px solid var(--border);
  padding: .55rem .75rem; font-family: inherit;
}
.doc-sheet .ql-container.ql-snow { border: 0; font-family: inherit; font-size: 1.02rem; }
.doc-sheet .ql-editor { min-height: 58vh; padding: 2.25rem clamp(1.25rem, 5vw, 3.5rem); line-height: 1.7; color: var(--text); }
/* extra specificity: quill.snow.css is loaded after this file */
.doc-sheet .ql-container .ql-editor h2, .template-form-editor .ql-container .ql-editor h2 { font-size: 1.15rem; font-weight: 700; margin: 1.1rem 0 .4rem; }
.doc-sheet .ql-container .ql-editor h3, .template-form-editor .ql-container .ql-editor h3 { font-size: 1.02rem; font-weight: 650; margin: 1rem 0 .35rem; }
.doc-sheet .ql-container .ql-editor h2:first-child { margin-top: 0; }
/* Quill's paragraph-style picker in Portuguese */
/* "body" raises specificity above quill.snow.css, which is loaded after this file */
body .ql-snow .ql-picker.ql-header { width: 112px; }
body .ql-snow .ql-picker.ql-header .ql-picker-label::before, body .ql-snow .ql-picker.ql-header .ql-picker-item::before { content: "Texto"; }
body .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before, body .ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before { content: "Título"; }
body .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before, body .ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before { content: "Subtítulo"; }
.doc-sheet .ql-editor.ql-blank::before { left: clamp(1.25rem, 5vw, 3.5rem); color: #8a93a3; font-style: normal; }
.ql-snow .ql-stroke { stroke: var(--text-2); }
.ql-snow .ql-fill { fill: var(--text-2); }
.ql-snow.ql-toolbar button:hover .ql-stroke, .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--brand-700); }
.ql-snow.ql-toolbar button:hover .ql-fill, .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--brand-700); }
.ql-snow.ql-toolbar button:hover, .ql-snow.ql-toolbar button.ql-active, .ql-snow .ql-picker-label:hover, .ql-snow .ql-picker-label.ql-active { color: var(--brand-700); }
.ql-snow.ql-toolbar button { border-radius: 6px; }
.ql-snow.ql-toolbar button:hover, .ql-snow.ql-toolbar button.ql-active { background: var(--brand-50); }
.editor-actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem;
  padding: .8rem 1rem; background: rgba(255, 255, 255, .96); border-top: 1px solid var(--border);
}
.autosave { font-size: .84rem; color: var(--muted); display: inline-flex; align-items: center; gap: .35rem; }
.templates-panel { position: sticky; top: 92px; }
.template-item { width: 100%; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: .6rem .75rem; display: flex; align-items: center; gap: .6rem; font-size: .88rem; color: var(--text-2); }
.template-item:hover { border-color: var(--brand-200); background: var(--brand-25); color: var(--text); }
.template-item .bi { color: var(--brand-700); }
.template-group-label { font-size: .72rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: .9rem 0 .45rem; }
.template-group-label:first-child { margin-top: 0; }

/* rendered report (version page) */
.report-body { line-height: 1.7; font-size: 1rem; color: var(--text); }
.report-body h1, .report-body h2, .report-body h3 { font-size: 1.1rem; font-weight: 700; margin: 1.1rem 0 .4rem; }
.report-doc { padding: 2.25rem clamp(1.25rem, 5vw, 3.5rem); }
.signature { border-top: 1px solid var(--border); padding: 1.1rem clamp(1.25rem, 5vw, 3.5rem); background: var(--surface-2); font-size: .88rem; color: var(--text-2); }

/* ---------- error pages ---------- */
.error-wrap { min-height: 60vh; display: grid; place-items: center; }
.error-card { text-align: center; max-width: 480px; padding: 2.5rem 2rem; }
.error-card .code { font-size: .8rem; font-weight: 700; letter-spacing: .12em; color: var(--brand-700); text-transform: uppercase; }
.error-card .icon { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 1.25rem; font-size: 2rem; }
.error-card h1 { font-size: 1.4rem; margin: .5rem 0; }
.error-card p { color: var(--muted); }

/* ---------- settings ---------- */
.form-control-color { width: 3.25rem; height: 2.6rem; padding: .3rem; flex-shrink: 0; }
.logo-current { width: 72px; height: 72px; border: 1px solid var(--border); border-radius: 12px; display: grid; place-items: center; background: #fff; flex-shrink: 0; }
.logo-current img { max-width: 60px; max-height: 60px; object-fit: contain; }
/* order follows the request: Identidade, Aparência, Laudo/PDF (Aparência beside both on wide screens) */
.settings-grid { display: grid; gap: 1.5rem; align-items: start; grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "identity" "look" "pdf"; }
.settings-grid .s-identity { grid-area: identity; }
.settings-grid .s-look { grid-area: look; }
.settings-grid .s-pdf { grid-area: pdf; }
@media (min-width: 1200px) {
  .settings-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); grid-template-areas: "identity look" "pdf look"; }
}
.settings-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem;
  margin-top: 1.5rem; padding: .85rem 1rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
}
@media (min-width: 768px) { .settings-actions { position: sticky; bottom: .75rem; z-index: 5; } }
@media (max-width: 767.98px) { .settings-actions .btn { flex: 1 1 100%; } .settings-actions .small { display: none; } }
/* live preview: brand tokens recomputed from the color being edited */
.brand-preview {
  --pv-primary: var(--brand); --pv-on: var(--on-brand);
  --pv-50: color-mix(in srgb, var(--pv-primary) 8%, #fff);
  --pv-700: color-mix(in srgb, var(--pv-primary) 74%, #000);
  --pv-800: color-mix(in srgb, var(--pv-primary) 58%, #000);
  display: grid; grid-template-columns: 170px minmax(0, 1fr); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--bg); min-height: 150px;
}
.brand-preview .pv-side { background: #fff; border-right: 1px solid var(--border); padding: .75rem .6rem; display: flex; flex-direction: column; gap: 4px; }
.brand-preview .pv-brand { display: flex; align-items: center; gap: .45rem; margin-bottom: .5rem; min-width: 0; }
.brand-preview .pv-brand img { width: 28px; height: 28px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: #fff; padding: 2px; flex-shrink: 0; }
.brand-preview .pv-name { font-size: .72rem; font-weight: 650; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.brand-preview .pv-item { font-size: .76rem; font-weight: 550; color: var(--text-2); padding: .35rem .45rem; border-radius: 7px; display: flex; gap: .4rem; align-items: center; }
.brand-preview .pv-item.active { background: var(--pv-50); color: var(--pv-800); box-shadow: inset 3px 0 0 var(--pv-primary); }
.brand-preview .pv-main { padding: .9rem; display: flex; flex-direction: column; align-items: flex-start; gap: .6rem; }
.brand-preview .pv-title { font-weight: 650; font-size: .85rem; }
.brand-preview .pv-btn { display: inline-flex; gap: .4rem; align-items: center; background: var(--pv-primary); color: var(--pv-on); font-weight: 600; font-size: .84rem; border-radius: 9px; padding: .45rem .85rem; }
.brand-preview .pv-link { color: var(--pv-700); text-decoration: underline; font-size: .82rem; }
@media (max-width: 420px) { .brand-preview { grid-template-columns: 1fr; } .brand-preview .pv-side { border-right: 0; border-bottom: 1px solid var(--border); } }

/* misc */
.divider { height: 1px; background: var(--border); margin: 1rem 0; }
.min-w-0 { min-width: 0; }
.fw-semibold { font-weight: 600 !important; }
.report-editor { min-height: 320px; }
.template-form-editor .ql-toolbar.ql-snow { border-radius: 10px 10px 0 0; border-color: var(--border-strong); background: var(--surface-2); }
.template-form-editor .ql-container.ql-snow { border-radius: 0 0 10px 10px; border-color: var(--border-strong); font-family: inherit; font-size: 1rem; }
.template-form-editor .ql-editor { min-height: 320px; line-height: 1.65; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
