/* ==========================================================================
   PreOpMed design system
   Professional, modern, responsive. No frameworks, no build step.
   ========================================================================== */

:root {
    --color-bg: #f4f6f9;
    --color-surface: #ffffff;
    --color-border: #dde3ea;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-primary: #0e7490;      /* deep teal - medical, serious */
    --color-primary-hover: #0c657e;
    --color-primary-soft: #e0f2f7;
    --color-accent: #16a34a;
    --color-danger: #dc2626;
    --color-danger-soft: #fee2e2;
    --color-warning: #d97706;
    --color-success-soft: #dcfce7;
    --color-success-text: #166534;
    --shadow-card: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --radius: 10px;
    --radius-sm: 7px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win over display classes */
[hidden] { display: none !important; }

/* Screen heights: inside the zoomed body (very wide displays, see the
   "zoom" rules below) Chrome/Edge scale vh units by the zoom too, so a
   plain 100vh came out taller than the window and every page scrolled.
   Divided by the zoom it is the window height again. */
body { --ui-zoom: 1; --screen-h: calc(100vh / var(--ui-zoom)); }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-bg);
    font-size: 15px;
    line-height: 1.5;
    /* Safety net: the page itself must never scroll horizontally, even if
       some element elsewhere has the same min-width:auto grid/flex-item
       quirk just fixed on .wizard-steps below and hasn't been caught yet.
       Anything that legitimately needs to be wider than the viewport
       (tables, the wizard step strip, tab rows) scrolls inside its own
       overflow-x: auto container instead. */
}

/* "clip", not "hidden": hidden on body made it a scroll container of its
   own (one that never scrolls, the window does), and every position:
   sticky element - topbar, sidebar, wizard steps, live indicator - stopped
   sticking. clip cuts the overflow without creating a scroll container. */
body { overflow-x: clip; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Guest (auth) layout
   -------------------------------------------------------------------------- */

.guest-body {
    min-height: var(--screen-h);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.guest-card-wrap {
    width: 100%;
    max-width: 460px;
}

.guest-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.guest-brand-logo {
    display: block;
    height: 84px;
    width: auto;
}

.guest-brand-tag {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.guest-card { padding: 28px; }

.guest-footer {
    text-align: center;
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 18px;
}

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

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.card-title {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 650;
}

.card-subtitle {
    margin: 0 0 20px;
    font-size: 14px;
    color: var(--color-text-muted);
}

.card-alt-action {
    margin: 18px 0 0;
    font-size: 14px;
    text-align: center;
    color: var(--color-text-muted);
}

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

.field { margin-bottom: 16px; }

.field-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.field-inline-link {
    font-size: 14px;
    color: var(--color-primary);
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 560px) {
    .field-row { grid-template-columns: 1fr; }
}

.label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.input, select.input, textarea.input {
    width: 100%;
    padding: 10px 12px;
    font-size: 15px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.input-error { border-color: var(--color-danger); }

.field-error {
    margin: 6px 0 0;
    font-size: 13px;
    color: var(--color-danger);
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover { background: var(--color-primary-hover); }

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary:hover { background: var(--color-bg); }

.btn-link {
    background: none;
    color: var(--color-text-muted);
    border: none;
}

.btn-block { width: 100%; }

.mt-2 { margin-top: 10px; }

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */

.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-success {
    background: var(--color-success-soft);
    color: var(--color-success-text);
}

.alert-danger {
    background: var(--color-danger-soft);
    color: var(--color-danger);
}

/* --------------------------------------------------------------------------
   App shell: topbar
   -------------------------------------------------------------------------- */

/* Topbar + the rest of the screen: the app area takes whatever height the
   topbar leaves (no "100vh minus N px" guess - the topbar's real height
   depends on its content, and a wrong guess made every page scroll) */
.app-body { min-height: var(--screen-h); display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 58px;
    padding: 0 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.topbar-brand {
    display: flex;
    align-items: center;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: .4px;
    color: var(--color-primary);
}

.topbar-brand:hover { text-decoration: none; }

.topbar-brand-logo { display: block; height: 32px; width: auto; }

@media (max-width: 640px) {
    .topbar-brand-logo { height: 26px; }
}

.topbar-right { display: flex; align-items: center; gap: 18px; }

.topbar-balance {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.15;
}

.topbar-balance:hover { text-decoration: none; }

.topbar-balance-label {
    font-size: 11px;
    color: var(--color-text-muted);
}

.topbar-balance-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
}

.topbar-account {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    font: inherit;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    padding: 8px 4px;
}

.caret {
    width: 0; height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid currentColor;
    opacity: .55;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
}

.icon-bars, .icon-bars::before, .icon-bars::after {
    content: "";
    display: block;
    width: 16px; height: 2px;
    background: var(--color-text);
    border-radius: 2px;
    position: relative;
}

.icon-bars::before { position: absolute; top: -5px; }
.icon-bars::after { position: absolute; top: 5px; }

/* Dropdown */
.dropdown { position: relative; }

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 190px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
    padding: 6px;
}

.dropdown.open .dropdown-menu { display: block; }

.dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    font-size: 14px;
    color: var(--color-text);
    border-radius: 6px;
}

.dropdown-item:hover {
    background: var(--color-bg);
    text-decoration: none;
}

.dropdown-item-btn {
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   App shell: sidebar + content
   -------------------------------------------------------------------------- */

.app-wrap {
    display: flex;
    flex: 1 0 auto;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #1e2836;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: margin-left .18s ease;
}

.sidebar-collapsed .sidebar { margin-left: -220px; }

/* The dark column keeps the page's full height; its links stick below the
   topbar while the content scrolls */
.sidebar-inner {
    position: sticky;
    top: 72px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    display: block;
    padding: 11px 14px;
    color: #cbd5e1;
    font-size: 14.5px;
    font-weight: 500;
    border-radius: 8px;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
    text-decoration: none;
}

.sidebar-link.active {
    background: rgba(255, 255, 255, .08);
    color: #fff;
    border-left-color: var(--color-primary);
}

.content {
    flex: 1;
    padding: 24px;
    min-width: 0;
}

@media (max-width: 860px) {
    /* Below this width the sidebar becomes an off-canvas drawer, closed by
       default - a DIFFERENT class than desktop's .sidebar-collapsed on
       purpose. That flag is a persisted "I collapsed it" preference; reusing
       it here made a desktop collapse-toggle reopen as a stuck-open mobile
       drawer on the next visit (and vice versa) once localStorage carried
       the same value across breakpoints. .sidebar-open is set by JS per
       click and is never persisted, so every page load starts closed. */
    .sidebar {
        position: fixed;
        top: 58px;
        bottom: 0;
        z-index: 40;
        margin-left: -220px;
    }
    .sidebar-open .sidebar { margin-left: 0; }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 58px 0 0 0;
        background: rgba(15, 23, 42, .45);
        z-index: 39;
    }
    .sidebar-open .sidebar-backdrop { display: block; }

    .content { padding: 16px; }
}

/* --------------------------------------------------------------------------
   Dashboard
   -------------------------------------------------------------------------- */

.page-grid-dashboard {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    align-items: start;
}

/* Grid items default to min-width: auto, so the recent-reports table
   (min-width: 560px, scrolling inside its own .table-scroll wrapper) would
   otherwise force this card - and its column track - wider than available
   space instead of letting .table-scroll do the scrolling. Same fix as
   .wizard-steps and .index-layout above. */
.page-grid-dashboard > * { min-width: 0; }

@media (max-width: 1080px) {
    .page-grid-dashboard { grid-template-columns: 1fr; }
}

.stats-card, .recent-card { padding: 22px; }

.section-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 650;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.section-head .section-title { margin: 0; }

.stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.stat:last-child { margin-bottom: 0; }

.stat-value {
    display: block;
    font-size: 34px;
    font-weight: 700;
    line-height: 1.1;
}

.stat-blue { color: #2563eb; }
.stat-green { color: #16a34a; }
.stat-orange { color: #ea580c; }

.stat-label {
    font-size: 13px;
    color: var(--color-text-muted);
}

.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    flex-shrink: 0;
}

.stat-icon .icon { width: 22px; height: 22px; }

.stat-icon-blue { background: #eff6ff; color: #60a5fa; }
.stat-icon-green { background: #f0fdf4; color: #6ee7b7; }
.stat-icon-orange { background: #fff7ed; color: #fdba74; }

.btn-pill { border-radius: 999px; padding: 9px 20px; }

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14.5px;
}

.table th {
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    padding: 10px 12px;
    border-bottom: 2px solid var(--color-border);
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--color-border);
}

.table tbody tr:hover { background: #fafbfc; }

.table-actions-col { text-align: right; }
.table-actions { text-align: right; white-space: nowrap; }
/* Icon-only buttons (history) next to text buttons: inline-flex buttons
   line up by their text baseline, and an icon has none - all to the
   middle, at one height */
.table-actions .btn { vertical-align: middle; min-height: 32px; }
.table-actions .btn .icon { width: 16px; height: 16px; }

/* --------------------------------------------------------------------------
   Empty states (ROADMAP 2.17: no bare grey tables)
   -------------------------------------------------------------------------- */

.empty-state {
    padding: 36px 20px;
    text-align: center;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
}

.empty-state-title {
    margin: 0 0 6px;
    font-weight: 650;
}

.empty-state-text {
    margin: 0;
    font-size: 14px;
    color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   Page head + list pages
   -------------------------------------------------------------------------- */

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.page-title {
    margin: 0;
    font-size: 21px;
    font-weight: 650;
}

.list-card { padding: 18px; }

.list-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.list-search { flex: 1; min-width: 220px; }

/* "select.input" (width: 100%) outranks a single class, which left the
   page-size select stretched across a whole row of its own. */
.list-toolbar select.list-per-page { width: 84px; flex: 0 0 auto; }
.list-toolbar .btn { flex: 0 0 auto; }

/* Page size, search button and the extras always travel together, so
   when the filters wrap they stay on one line. */
.list-toolbar-end {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 0 0 auto;
}

.inline-form { display: inline; }

.btn-sm { padding: 6px 12px; font-size: 13.5px; }

.btn-danger {
    background: var(--color-surface);
    color: var(--color-danger);
    border-color: var(--color-border);
}

.btn-danger:hover { background: var(--color-danger-soft); }

.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 999px;
    vertical-align: middle;
}

.badge-muted {
    background: var(--color-bg);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.pagination-wrap { margin-top: 14px; }

/* --------------------------------------------------------------------------
   Modal (native dialog)
   -------------------------------------------------------------------------- */

.modal {
    width: min(680px, calc(100vw - 32px));
    border: none;
    border-radius: var(--radius);
    padding: 0;
    box-shadow: 0 20px 60px rgba(16, 24, 40, .25);
}

.modal::backdrop { background: rgba(15, 23, 42, .45); }

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.modal-title { margin: 0; font-size: 17px; font-weight: 650; }

.modal-close {
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
}

.modal-body { padding: 20px; }

.modal-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-top: 1px solid var(--color-border);
    background: #fafbfc;
    border-radius: 0 0 var(--radius) var(--radius);
}

.modal-hint { font-size: 13px; color: var(--color-text-muted); }

.modal-foot-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.req { color: var(--color-danger); }

.field-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

@media (max-width: 640px) {
    .field-row-3 { grid-template-columns: 1fr; }
}

.doc-row {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 8px;
}

.expand-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px dashed var(--color-border);
    border-radius: 999px;
    padding: 7px 16px;
    font: inherit;
    font-size: 13.5px;
    color: var(--color-text-muted);
    cursor: pointer;
    margin: 4px 0 14px;
}

.expand-toggle:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* --------------------------------------------------------------------------
   Settings
   -------------------------------------------------------------------------- */

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 18px;
    border-bottom: 2px solid var(--color-border);
    flex-wrap: wrap;
}

.tab {
    padding: 10px 16px;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab:hover { text-decoration: none; color: var(--color-text); }

.tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.form-card { padding: 24px; max-width: 980px; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.form-actions-split { justify-content: space-between; }

.logo-preview {
    display: block;
    max-height: 64px;
    margin-bottom: 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 6px;
    background: #fff;
}

.address-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 12px;
}

@media (max-width: 720px) {
    .address-grid { display: block; }
}

.toggle-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    cursor: pointer;
}

.toggle-row:hover { border-color: var(--color-primary); }

.toggle-row input[type="checkbox"] { margin-top: 4px; }

.toggle-body { display: flex; flex-direction: column; gap: 2px; }
.toggle-title { font-weight: 600; font-size: 14.5px; }
.toggle-desc { font-size: 13px; color: var(--color-text-muted); }

.preset-row {
    display: grid;
    grid-template-columns: 120px 180px 1fr auto auto;
    gap: 10px;
    align-items: start;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

@media (max-width: 720px) {
    .preset-row { grid-template-columns: 1fr; }
}

.preset-active { white-space: nowrap; padding-top: 10px; }

/* --------------------------------------------------------------------------
   Report wizard
   -------------------------------------------------------------------------- */

.wizard-patient {
    padding: 12px 18px;
    margin-bottom: 16px;
    font-size: 14.5px;
}

.wizard-body {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 18px;
    align-items: start;
}

/* Wizard on mobile: horizontal step strip, sticky nav. */
@media (max-width: 900px) {
    .wizard-body { grid-template-columns: 1fr; min-width: 0; }
    /* min-width: 0 is the fix, not overflow-x alone: a grid/flex ITEM
       defaults to min-width: auto (sized to fit its content), so 13
       nowrap step buttons forced this row - and everything sharing its
       grid container - wider than the viewport, dragging the whole page
       (even the sticky topbar) into horizontal scroll. overflow-x: auto
       never got the chance to contain anything because the box itself
       had already grown to match the content instead of the viewport. */
    .wizard-steps {
        position: static !important; /* the sticky rule below comes later */
        flex-direction: row !important;
        overflow-x: auto;
        min-width: 0;
        gap: 6px;
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
    }
    .wizard-panels { min-width: 0; }
    .wizard-step { padding: 8px 10px; }
    .wizard-step-label { font-size: 13px; }
    .wizard-nav {
        position: sticky;
        bottom: 0;
        background: var(--color-bg);
        padding: 10px 0;
        z-index: 20;
        border-top: 1px solid var(--color-border);
    }
    .indicator { position: static; margin-top: 14px; }
}

.wizard-steps {
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Steps stay in view while a long panel scrolls (desktop; on narrow
       screens they become a horizontal strip, see the media query above) */
    position: sticky;
    top: 76px;
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 14px;
    color: var(--color-text-muted);
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}

.wizard-step:hover { background: var(--color-primary-soft); }

.wizard-step.active {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
}

.wizard-step.done { color: var(--color-primary); }

.wizard-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 2px solid currentColor;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.wizard-panels { padding: 24px; min-height: 420px; }

.wizard-panel { display: none; }
.wizard-panel.active { display: block; }

.wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
}

.wizard-save-state {
    font-size: 13px;
    color: var(--color-text-muted);
}

.subsection-title {
    margin: 18px 0 10px;
    font-size: 14.5px;
    font-weight: 650;
}

.radio-row { display: flex; gap: 18px; padding-top: 8px; }

.check-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 20px;
    margin-bottom: 16px;
}

@media (max-width: 720px) {
    .check-grid { grid-template-columns: 1fr; }
}

.field-hint { font-size: 13px; margin: 6px 0 0; }

.bleeding-alert {
    color: var(--color-danger);
    font-weight: 600;
}

.bmi-box {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    transition: background-color .15s, border-color .15s;
}

.bmi-value { font-size: 16px; font-weight: 700; }
.bmi-label { font-size: 13px; color: var(--color-text-muted); }

/* Colored like the risk index indicators once height+weight are known -
   WHO adult BMI bands (green/yellow/orange/red), not a flat gray box. */
.bmi-box[data-bmi-band="green"] { background: #f0fdf4; border-color: #bbf7d0; }
.bmi-box[data-bmi-band="green"] .bmi-value { color: #16a34a; }

.bmi-box[data-bmi-band="yellow"] { background: #fefce8; border-color: #fde68a; }
.bmi-box[data-bmi-band="yellow"] .bmi-value { color: #ca8a04; }

.bmi-box[data-bmi-band="orange"] { background: #fff7ed; border-color: #fed7aa; }
.bmi-box[data-bmi-band="orange"] .bmi-value { color: #ea580c; }

.bmi-box[data-bmi-band="red"] { background: #fef2f2; border-color: #fecaca; }
.bmi-box[data-bmi-band="red"] .bmi-value { color: #dc2626; }

/* Fact rows + point badges */

.index-layout {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .index-layout { grid-template-columns: 1fr; }
    .index-layout > * { min-width: 0; }
}

.fact-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 720px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14.5px;
}

/* Rows inside a "choose one" group sit on a white card so they read as
   distinct from the group's own tinted background. Declared before
   :hover below on purpose - same specificity, and :hover must win the
   cascade so hovering a row inside a group still shows feedback. */
.fact-group .fact-row { background: var(--color-surface); }

/* A composite item's own criteria (e.g. Goldman's "poor general status"),
   nested right under the parent checkbox they instantly drive. */
.fact-subgroup {
    max-width: 720px;
    margin: 2px 0 8px 26px;
    padding: 4px 8px;
    border-left: 2px solid var(--color-border);
}

.fact-subgroup .fact-row { font-size: 13.5px; padding: 6px 10px; }

.fact-row:hover { background: var(--color-bg); }

.fact-row input { margin-top: 3px; }

.fact-label { flex: 1; }

.fact-row.checked .fact-label { font-weight: 600; }

.point-badge {
    display: inline-block;
    min-width: 42px;
    text-align: center;
    padding: 2px 8px;
    font-size: 12.5px;
    font-weight: 700;
    border-radius: 999px;
    background: var(--color-bg);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.fact-row.checked .point-badge {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.fact-group {
    max-width: 720px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin: 12px 0;
    background: var(--color-bg);
}

.fact-group-title {
    font-size: 13.5px;
    font-weight: 650;
    padding: 0 6px;
    /* A <legend> straddles its <fieldset>'s border by default; without
       its own opaque background here, the fieldset's gray fill shows
       through/behind it right where the border gap is, reading as a
       line cutting across the title. */
    background: var(--color-surface);
    margin-left: 6px;
    border-radius: 4px;
}

/* "Choose one" cue (radio group) vs. plain checkbox rows above/below -
   same visual language as the group's tinted background, spelled out so
   it doesn't rely on noticing the circle-vs-square input shape alone. */
.fact-group-title::after {
    content: " " attr(data-hint);
    font-weight: 400;
    font-size: 12px;
    color: var(--color-text-muted);
}

.fact-group .fact-row { background: var(--color-surface); }

/* Live indicator: segmented bar */

.indicator {
    position: sticky;
    top: 76px;
    padding: 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}

.indicator-compact { position: static; margin-top: 14px; }

.indicator-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 10px;
}

.indicator-title {
    font-size: 13px;
    font-weight: 650;
    color: var(--color-text-muted);
}

.indicator-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    padding: 0;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--color-text-muted);
    cursor: pointer;
}

.indicator-info-btn:hover { color: var(--color-primary); background: var(--color-primary-soft); }

.indicator-info-btn .icon { width: 15px; height: 15px; }

.indicator-bar {
    display: flex;
    gap: 3px;
    height: 14px;
    margin-bottom: 10px;
}

.indicator-seg {
    flex: 1;
    border-radius: 4px;
    opacity: .25;
    transition: opacity .25s, transform .25s;
}

.indicator-seg.active {
    opacity: 1;
    transform: scaleY(1.35);
}

.seg-green { background: #16a34a; }
.seg-yellow { background: #ca8a04; }
.seg-orange { background: #ea580c; }
.seg-red { background: #dc2626; }

.indicator-result {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.indicator-band { font-size: 17px; font-weight: 700; }
.indicator-points { font-size: 13.5px; color: var(--color-text-muted); }
.indicator-risk { font-size: 13px; color: var(--color-text-muted); }

.indicator-delta {
    position: absolute;
    top: 10px; right: 12px;
    font-size: 14px;
    font-weight: 700;
    animation: floatUp 1.1s ease-out;
}

.delta-up { color: var(--color-danger); }
.delta-down { color: var(--color-accent); }

@keyframes floatUp {
    from { opacity: 1; transform: translateY(6px); }
    to { opacity: 0; transform: translateY(-8px); }
}

/* VTE three-column layout */

.vte-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

@media (max-width: 1100px) {
    .vte-grid { grid-template-columns: 1fr; }
}

/* Conclusion presets */

.preset-options { display: flex; flex-direction: column; gap: 8px; }

.preset-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    cursor: pointer;
    font-size: 14.5px;
}

.preset-option input { margin-top: 3px; }

.preset-green { background: #f0fdf4; border-color: #bbf7d0; }
.preset-yellow { background: #fefce8; border-color: #fde68a; }
.preset-red { background: #fef2f2; border-color: #fecaca; }

/* Final summary */

.final-summary { margin-bottom: 16px; }

.summary-list {
    margin: 0;
    padding-left: 18px;
    font-size: 14.5px;
}

.summary-list li { margin-bottom: 6px; }

.disclaimer {
    font-size: 12.5px;
    color: var(--color-text-muted);
    font-style: italic;
    border-top: 1px solid var(--color-border);
    padding-top: 12px;
}

/* Patient picker + report badges */

.picker-results {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
}

.picker-result {
    display: block;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    color: var(--color-text);
}

.picker-result:hover {
    background: var(--color-primary-soft);
    text-decoration: none;
}

.picker-empty {
    padding: 11px 12px;
    color: var(--color-text-muted);
    font-size: 14px;
}

.badge-signed { background: var(--color-success-soft); color: var(--color-success-text); }
.badge-saved { background: #e0f2fe; color: #075985; }
.badge-draft { background: #fef9c3; color: #854d0e; }

/* Wallet */

.balance-line { font-size: 16px; }
.balance-amount { font-size: 22px; color: var(--color-primary); }

.package-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin: 18px 0;
}

.package-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.package-exclusive { border-color: var(--color-primary); }

.package-title { font-weight: 650; font-size: 15px; }
.package-credit { font-size: 14px; }
.package-bonus {
    font-size: 13px;
    color: var(--color-success-text);
    background: var(--color-success-soft);
    border-radius: 999px;
    padding: 2px 10px;
    align-self: flex-start;
}

.package-form { margin-top: auto; padding-top: 8px; }

.tariff-list { font-size: 14px; padding-left: 18px; }
.tariff-list li { margin-bottom: 6px; }

.amount-neg { color: var(--color-danger); }
.amount-pos { color: var(--color-success-text); }

.btn-sign {
    background: var(--color-accent);
    color: #fff;
}

.btn-sign:hover { background: #12813b; }

/* Onboarding (ROADMAP 2.17) */

.welcome-card {
    padding: 22px 24px;
    margin-bottom: 20px;
    border-left: 4px solid var(--color-primary);
}

.welcome-title { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.welcome-sub { margin: 0 0 14px; font-size: 14.5px; color: var(--color-text-muted); }

.onboarding-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.onboarding-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14.5px;
}

.onboarding-item.done { color: var(--color-text-muted); }
.onboarding-item.done > a, .onboarding-item.done > span:not(.onboarding-check) {
    text-decoration: line-through;
}

.onboarding-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    font-size: 12px;
    font-weight: 700;
    color: var(--color-accent);
    text-decoration: none;
    flex-shrink: 0;
}

.onboarding-item.done .onboarding-check { border-color: var(--color-accent); }

.onboarding-dismiss { margin-top: 12px; }
.onboarding-dismiss .btn { padding: 8px 16px; font-size: 13px; }

/* Pulsing CTA until the first real report (subtle, professional) */

.btn-pulse {
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(14, 116, 144, .45); }
    50% { box-shadow: 0 0 0 9px rgba(14, 116, 144, 0); }
}

/* --------------------------------------------------------------------------
   Admin console
   -------------------------------------------------------------------------- */

.admin-tag {
    font-size: 11px;
    font-weight: 700;
    background: var(--color-danger-soft);
    color: var(--color-danger);
    border-radius: 999px;
    padding: 2px 8px;
    vertical-align: middle;
}

.admin-nav { display: flex; gap: 4px; margin-right: 14px; }

.admin-nav a {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-muted);
}

.admin-nav a:hover { text-decoration: none; background: var(--color-bg); }
.admin-nav a.active { color: var(--color-primary); background: var(--color-primary-soft); }

.admin-content { max-width: 1200px; margin: 0 auto; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.kpi-card { padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--color-primary); }
.kpi-label { font-size: 12.5px; color: var(--color-text-muted); }

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}

.chart-card { padding: 18px; }

.bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 150px;
    border-bottom: 1px solid var(--color-border);
}

/* each bar: its value on top; a zero keeps its place (empty slot) */
.bar-wrap { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; text-decoration: none; border-radius: 3px 3px 0 0; }
.bar-wrap:hover { text-decoration: none; background: var(--color-bg); }
.bar-value { font-size: 10.5px; font-weight: 600; color: var(--color-text); line-height: 1.4; white-space: nowrap; }

.bar {
    display: block;
    width: 100%;
    max-height: calc(100% - 16px);
    background: var(--color-primary);
    border-radius: 2px 2px 0 0;
    min-height: 3px;
    opacity: .85;
}

.bar-wrap:hover .bar { opacity: 1; }
.bar-axis { display: flex; gap: 2px; margin-top: 4px; }
.bar-axis span { flex: 1 1 0; min-width: 0; font-size: 10px; color: var(--color-text-muted); text-align: center; white-space: nowrap; overflow: visible; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.chart-total { font-weight: 700; font-size: 15px; }
.kpi-link { color: inherit; text-decoration: none; transition: box-shadow .15s, transform .15s; }
.kpi-link:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 22px rgba(16, 24, 40, .1); }
.metric-back { display: inline-block; margin-bottom: 6px; font-size: 14px; }
.metric-bar { height: 8px; border-radius: 4px; background: var(--color-primary); opacity: .8; min-width: 2px; }

.credit-form { display: flex; gap: 6px; justify-content: flex-end; }
.input-xs { width: 110px; padding: 6px 8px; font-size: 13px; }

/* --------------------------------------------------------------------------
   Index details in settings (bands + reference)
   -------------------------------------------------------------------------- */

.toggle-block { margin-bottom: 10px; }
.toggle-block .toggle-row { margin-bottom: 0; }

.index-details-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--color-primary-soft);
    border: 1px solid transparent;
    color: var(--color-primary);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    padding: 6px 12px;
    border-radius: 999px;
    transition: background .15s, border-color .15s;
    align-self: center;
}

.index-details-toggle:hover {
    background: #cdeaf2;
}

.index-details-toggle .chevron {
    width: 14px;
    height: 14px;
    transition: transform .2s ease;
}

.index-details-toggle.open .chevron { transform: rotate(180deg); }

.index-details {
    margin-top: -2px;
    border: 1px solid var(--color-border);
    border-top: none;
    border-left: 3px solid var(--color-primary);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    padding: 16px 18px;
    background: linear-gradient(180deg, #fafcfd 0%, #f4f8fa 100%);
}

.index-detail-card + .index-detail-card {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--color-border);
}

.index-details-subtitle {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* One grid for all rows (rows are display: contents): the range column is
   as wide as its longest text - e.g. ACP's "up to 15 pts and 2 or more
   low-risk variables" - instead of a fixed width it overflowed */
.band-rows {
    display: grid;
    grid-template-columns: 220px auto 1fr;
    align-items: center;
    gap: 6px 16px;
    margin-bottom: 12px;
    font-size: 13px;
}

.band-row { display: contents; }

@media (max-width: 720px) {
    .band-rows { grid-template-columns: 1fr; gap: 2px; }
    .band-risk { margin-bottom: 8px; }
}

.band-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 650;
    color: #fff;
    text-align: center;
}

.band-chip-green { background: #16a34a; }
.band-chip-yellow { background: #ca8a04; }
.band-chip-orange { background: #ea580c; }
.band-chip-red { background: #dc2626; }

.band-range {
    color: var(--color-text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.band-risk { color: var(--color-text-muted); }

.index-reference {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--color-text-muted);
}

.index-reference .icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--color-primary);
}

.reference-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    margin-left: 6px;
    white-space: nowrap;
}

.reference-link svg { width: 12px; height: 12px; }

/* Abbreviation tooltips */

abbr[title] {
    text-decoration: underline dotted;
    text-underline-offset: 2px;
    cursor: help;
}

/* Unit affix inputs (unit inside the field, not in the label) */

.input-affix {
    display: flex;
    align-items: stretch;
}

.input-affix .input {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    border-right: none;
    flex: 1;
    min-width: 0;
}

.input-affix .affix {
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    font-size: 13px;
    color: var(--color-text-muted);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    white-space: nowrap;
}

.input-affix-sm { max-width: 220px; }

.fact-number-row { margin: 10px 0; }

/* --------------------------------------------------------------------------
   Exam grids (vitals + extra exam sets)
   -------------------------------------------------------------------------- */

.vitals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.exam-set {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin: 0 0 14px;
}

.exam-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.exam-field-wide { grid-column: 1 / -1; }

.exam-set-option { display: flex; padding: 7px 2px; }

/* --------------------------------------------------------------------------
   Rich text mini editor
   -------------------------------------------------------------------------- */

.richtext-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.snippet-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}

/* Higher specificity than the base "select.input" rule on purpose - a
   plain .snippet-select class lost that fight silently, which is why an
   earlier size pass here never actually took effect. These are a
   secondary/occasional utility (saved-text snippets), not a primary
   form field, so they read as a compact toolbar, not a full-size input
   and button. */
select.snippet-select {
    width: 150px;
    padding: 4px 8px;
    font-size: 12.5px;
    color: var(--color-text-muted);
}

.snippet-controls .btn {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 4px 10px;
    font-size: 12.5px;
    background: none;
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

.snippet-controls .btn:hover { color: var(--color-text); border-color: var(--color-text-muted); }

.richtext {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
}

.richtext:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.richtext-toolbar {
    display: flex;
    gap: 2px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--color-border);
    background: #fafbfc;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.richtext-toolbar button {
    min-width: 32px;
    height: 28px;
    background: none;
    border: 1px solid transparent;
    border-radius: 5px;
    font-size: 13px;
    cursor: pointer;
    color: var(--color-text);
}

.richtext-toolbar button:hover {
    background: var(--color-surface);
    border-color: var(--color-border);
}

.richtext-sep {
    width: 1px;
    background: var(--color-border);
    margin: 3px 5px;
}

.richtext-area {
    min-height: 84px;
    padding: 10px 12px;
    font-size: 14.5px;
    outline: none;
}

.richtext-area ul, .richtext-area ol { margin: 6px 0; padding-left: 22px; }

/* --------------------------------------------------------------------------
   Inline conclusion preset editing
   -------------------------------------------------------------------------- */

.preset-pick {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    width: 100%;
}

.preset-pick input { margin-top: 3px; }

.preset-edit {
    display: grid;
    grid-template-columns: 1fr 130px auto;
    gap: 8px;
    align-items: start;
    width: 100%;
}

@media (max-width: 720px) {
    .preset-edit { grid-template-columns: 1fr; }
}

.preset-edit-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

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

.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    vertical-align: -3px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 11px;
}

.sidebar-link .icon { opacity: .8; }
.sidebar-link.active .icon { opacity: 1; }

.tabs .tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.tabs .tab .icon { width: 16px; height: 16px; }

.admin-nav a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.admin-nav .icon { width: 16px; height: 16px; }

/* --------------------------------------------------------------------------
   Topbar with icons
   -------------------------------------------------------------------------- */

.topbar-balance {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    border-radius: 999px;
    background: var(--color-surface-alt, #f3f4f6);
    transition: background .15s;
}

.topbar-balance:hover { background: var(--color-bg); }

.topbar-balance-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary-soft);
    flex-shrink: 0;
}

.topbar-balance-icon {
    width: 18px;
    height: 18px;
    color: var(--color-primary);
}

.topbar-balance-text {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.15;
}

.topbar-balance-label {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.topbar-balance-info {
    width: 12px;
    height: 12px;
    color: var(--color-text-muted);
    opacity: .8;
}

.icon-btn-accent {
    color: #16a34a;
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.icon-btn-accent:hover { background: #dcfce7; }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 9px;
}

.dropdown-item .icon {
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   Conclusion presets: pencil editing
   -------------------------------------------------------------------------- */

.preset-option {
    position: relative;
    padding-right: 46px;
}

.preset-pencil {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, .7);
    border: 1px solid var(--color-border);
    border-radius: 7px;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: color .15s, border-color .15s, background .15s;
}

.preset-pencil:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: #fff;
}

.preset-pencil .icon { width: 15px; height: 15px; }

.preset-edit {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.preset-edit-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.preset-edit-row .preset-color-select { width: 130px; }

/* --------------------------------------------------------------------------
   Rich text editor: palettes and tables
   -------------------------------------------------------------------------- */

.rt-palette-wrap { position: relative; display: inline-flex; }

.rt-palette {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 24px);
    gap: 5px;
    padding: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 20px rgba(16, 24, 40, .14);
}

.rt-palette button {
    width: 24px;
    height: 24px;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 5px;
    cursor: pointer;
    min-width: 0;
    padding: 0;
}

.rt-palette button:hover { transform: scale(1.12); }

.rt-color-glyph {
    font-weight: 700;
    border-bottom: 3px solid #dc2626;
    line-height: 1.1;
}

.rt-highlight-glyph {
    font-weight: 700;
    background: #fef08a;
    padding: 0 3px;
    border-radius: 2px;
}

.richtext-toolbar button svg { width: 15px; height: 15px; }

/* --------------------------------------------------------------------------
   Template editor (badge tokens)
   -------------------------------------------------------------------------- */

.stock-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.stock-template-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}

.stock-template-card.active { border-color: var(--color-primary); }

.stock-template-card .icon {
    width: 28px;
    height: 28px;
    color: var(--color-primary);
}

.stock-template-name { font-weight: 650; font-size: 14px; }

.template-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 16px;
    align-items: start;
}

@media (max-width: 960px) {
    .template-layout { grid-template-columns: 1fr; }
}

.template-area { min-height: 420px; }

.token-panel {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    background: #fafbfc;
    max-height: 520px;
    overflow-y: auto;
}

.token-group-title {
    margin: 12px 0 6px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--color-text-muted);
}

.token-list { display: flex; flex-wrap: wrap; gap: 6px; }

.token-chip-btn {
    background: var(--color-primary-soft);
    color: var(--color-primary);
    border: 1px solid transparent;
    border-radius: 999px;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
}

.token-chip-btn:hover { border-color: var(--color-primary); }
.token-chip-btn.required { background: #fef3c7; color: #92400e; }

.tpl-token {
    display: inline-block;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    border: 1px solid #a5d8e6;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 650;
    padding: 1px 9px;
    margin: 0 1px;
    white-space: nowrap;
    cursor: default;
    user-select: all;
}

/* --------------------------------------------------------------------------
   Guided tour (coach marks)
   -------------------------------------------------------------------------- */

.tour-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    z-index: 200;
    /* Defensive: these live outside <body> (see tour.js) specifically to
       avoid the >=1800px "body { zoom }" rule below, but reset it
       explicitly too in case zoom is ever set closer to the root. */
    zoom: normal;
}

.tour-highlight {
    position: relative;
    z-index: 210 !important;
    box-shadow: 0 0 0 4px var(--color-primary), 0 0 0 9px rgba(14, 116, 144, .35);
    border-radius: 8px;
    background: var(--color-surface);
}

.tour-tooltip {
    position: fixed;
    z-index: 220;
    zoom: normal;
    /* Width is set inline by tour.js using document.documentElement.
       clientWidth, not vw units - vw includes the scrollbar's width in
       most browsers, which made this render wider than the actual
       visible area whenever a scrollbar was present. This is a fallback
       for the instant before JS positions it. */
    width: 320px;
    max-width: calc(100% - 24px);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: 0 18px 50px rgba(15, 23, 42, .35);
    padding: 16px 18px;
}

.tour-step-count {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: .5px;
    margin-bottom: 4px;
}

.tour-tooltip h3 { margin: 0 0 6px; font-size: 15.5px; }
.tour-tooltip p { margin: 0 0 12px; font-size: 13.5px; color: var(--color-text-muted); }

.tour-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.referral-earned {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 18px;
    background: var(--color-success-soft);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    max-width: 320px;
}

.onboarding-dismiss {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.richtext-compact .richtext-toolbar { padding: 4px 6px; }
.richtext-compact .richtext-toolbar button { min-width: 26px; height: 24px; font-size: 12px; }
.richtext-area-sm { min-height: 56px; padding: 8px 10px; font-size: 14px; }

.richtext-area table {
    border-collapse: collapse;
    margin: 8px 0;
    width: 100%;
}

.richtext-area td, .richtext-area th {
    border: 1px solid var(--color-border);
    padding: 6px 9px;
    min-width: 40px;
}

/* --------------------------------------------------------------------------
   Responsive: mobile-first fixes and ultra-wide support
   -------------------------------------------------------------------------- */

/* Ultra-wide: keep content readable, centered */
.content {
    width: 100%;
    max-width: 1480px;
    margin: 0 auto;
}

@media (min-width: 1800px) {
    .content { max-width: 1640px; }
}

/* Very large/wide displays: scale the whole UI proportionally so text
   never looks tiny (zoom scales px-based components too; supported by
   Chrome/Edge/Safari and Firefox 126+). */
@media (min-width: 1800px) {
    body { zoom: 1.1; --ui-zoom: 1.1; }
}

@media (min-width: 2300px) {
    body { zoom: 1.25; --ui-zoom: 1.25; }
}

@media (min-width: 3000px) {
    body { zoom: 1.45; }
}

/* Tables scroll horizontally instead of breaking the layout - scoped to
   a wrapper around just the <table>, not the whole card, so the search/
   filter toolbar above it never scrolls out of reach along with it. */
.table-scroll { overflow-x: auto; }
.table { min-width: 560px; }

/* Mobile topbar: compact brand, hide account name and balance label */
@media (max-width: 640px) {
    .topbar { padding: 0 10px; }
    .topbar-brand { font-size: 16px; }
    .topbar-right { gap: 8px; }
    /* Balance pill collapses to just the wallet icon on mobile - the label
       and value text would otherwise force the topbar wider than the
       viewport alongside the logo, help, and account controls. */
    .topbar-balance { padding: 6px; gap: 0; }
    .topbar-balance-text { display: none; }
    .topbar-account-name { display: none; }
    .content { padding: 12px; }
    .page-title { font-size: 18px; }
    .page-head { flex-wrap: wrap; }
    .form-card, .wizard-panels { padding: 16px; }
    .modal { width: calc(100vw - 20px); }
    .modal-body { max-height: calc(var(--screen-h) * .7); overflow-y: auto; }

    /* Settings has 8 tabs; wrapping them (the default) stacks 3-4 rows of
       tabs above the fold before any actual settings are visible. A
       horizontal-scrolling single row (same pattern as .wizard-steps
       below) keeps it to one line. */
    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
    }
    .tabs .tab { flex-shrink: 0; }

    .date-range-fields { flex-wrap: wrap; }

    /* Staff admin topbar: icon, 3 nav links (icon+label) and a logout
       button all had to share one non-wrapping row - same treatment as
       the tenant topbar's balance/account text (icon-only nav here). */
    .admin-nav { gap: 0; margin-right: 6px; }
    .admin-nav a { padding: 8px; }
    .admin-nav a span { display: none; }
    .admin-tag { display: none; }
}

@media (max-width: 560px) {
    .field-row-3, .field-row { grid-template-columns: 1fr; }
    .vitals-grid { grid-template-columns: 1fr 1fr; }
    .exam-grid { grid-template-columns: 1fr; }
    .check-grid { grid-template-columns: 1fr; }
    .vte-grid { grid-template-columns: 1fr; }
    .richtext-head { flex-direction: column; align-items: flex-start; }
    .snippet-controls { width: 100%; }
    .snippet-select { flex: 1; width: auto; }
    .list-toolbar { flex-direction: column; align-items: stretch; }
    .list-search { min-width: 0; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .chart-grid { grid-template-columns: 1fr; }
    .credit-form { flex-wrap: wrap; }
    .package-grid { grid-template-columns: 1fr; }
    .table-actions .btn { margin-bottom: 4px; }
}

/* Very wide wizard: give the index panels breathing room */
@media (min-width: 1800px) {
    .index-layout { grid-template-columns: 1fr 300px; }
    .wizard-body { grid-template-columns: 240px 1fr; }
    .page-grid-dashboard { grid-template-columns: 380px 1fr; }
}

/* --------------------------------------------------------------------------
   Help center
   -------------------------------------------------------------------------- */

.help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    color: var(--color-text-muted);
    cursor: pointer;
    vertical-align: middle;
    margin-left: 8px;
}

.help-btn:hover { color: var(--color-primary); border-color: var(--color-primary); }
.help-btn .icon { width: 15px; height: 15px; }

.page-title-row { display: flex; align-items: center; }

/* Rich-text help article body (shared by the contextual modal and the
   help center's article pane). */
.help-article-body h4 { margin: 16px 0 6px; font-size: 14px; }
.help-article-body h4:first-child { margin-top: 0; }
.help-article-body p { margin: 0 0 10px; line-height: 1.55; }
.help-article-body ol, .help-article-body ul { margin: 0 0 12px; padding-left: 20px; line-height: 1.6; }
.help-article-body li { margin-bottom: 4px; }

.help-center-modal { width: min(720px, calc(100vw - 32px)); }

.help-center-layout {
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 20px;
    align-items: start;
}

.help-center-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-right: 1px solid var(--color-border);
    padding-right: 12px;
}

.help-center-nav-item {
    text-align: left;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 13.5px;
    color: var(--color-text);
    cursor: pointer;
}

.help-center-nav-item:hover { background: var(--color-surface-alt, #f3f4f6); }
.help-center-nav-item.active { background: var(--color-primary); color: #fff; }

.help-center-article { min-height: 220px; }

.help-center-foot { flex-wrap: wrap; gap: 10px; }
.help-center-contact { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 640px) {
    .help-center-layout { grid-template-columns: 1fr; }
    .help-center-nav {
        flex-direction: row;
        flex-wrap: wrap;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        padding-right: 0;
        padding-bottom: 10px;
    }
}

/* --------------------------------------------------------------------------
   Column visibility config (reports/patients lists)
   -------------------------------------------------------------------------- */

.column-config { position: relative; display: inline-block; }

.column-config-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 30;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 26px rgba(16, 24, 40, .14);
    padding: 10px 14px;
    min-width: 160px;
}

.column-config-panel label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 13.5px;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Wallet statement / list filters
   -------------------------------------------------------------------------- */

.date-range-fields {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* --------------------------------------------------------------------------
   Two-factor authentication (settings security tab)
   -------------------------------------------------------------------------- */

.recovery-codes-alert { display: block; }

.recovery-codes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.recovery-codes-grid code {
    display: block;
    text-align: center;
    padding: 8px 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    letter-spacing: .03em;
}

.catalog-field { position: relative; }

.catalog-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 2px);
    z-index: 25;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 26px rgba(16, 24, 40, .14);
    max-height: 240px;
    overflow-y: auto;
}

.catalog-suggestions button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
    cursor: pointer;
}

.catalog-suggestions button:last-child { border-bottom: none; }
.catalog-suggestions button:hover { background: var(--color-surface-alt, #f3f4f6); }

/* Search + badges share one bordered box (matches .richtext's footprint
   next door) instead of a bare input floating over empty space. */
.med-field {
    min-height: 116px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
}

.med-field:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.med-search-input {
    display: block;
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    font-size: 14.5px;
    padding: 3px 2px;
}

.med-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.med-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 4px 10px;
    background: var(--color-surface-alt, #f3f4f6);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 13px;
    line-height: 1.4;
}

.med-badge button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--color-text-muted);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.med-badge button:hover { background: rgba(0, 0, 0, .08); color: var(--color-text); }

.danger-zone {
    border: 1px solid #fecaca;
}

.danger-zone .section-title {
    color: #b91c1c;
}

.qr-code-wrap {
    display: flex;
    justify-content: center;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    max-width: 260px;
    margin: 0 0 16px;
}

.manual-key {
    display: inline-block;
    padding: 10px 14px;
    background: var(--color-surface-alt, #f3f4f6);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    letter-spacing: .06em;
}

.two-factor-confirm-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}

.two-factor-confirm-form .input {
    max-width: 240px;
}

.date-range-fields .input { width: 150px; }

/* Wizard final step: print-on-save option above the save buttons */
.finalize-print { margin: 12px 0 4px; }
.alert a { font-weight: 600; margin-left: 8px; }

/* Settings: layout preview dialog */
.template-preview-modal { width: min(960px, 96vw); max-width: 96vw; }
.template-preview-modal .modal-body { padding: 0; }
.template-preview-modal iframe {
    display: block;
    width: 100%;
    height: min(calc(var(--screen-h) * .72), 900px);
    border: 0;
    background: var(--color-bg);
}
.template-preview-modal .modal-foot { gap: 10px; }
.template-preview-modal .modal-hint { margin-right: auto; }
.stock-template-card .btn-link .icon { width: 16px; height: 16px; vertical-align: -3px; }

/* Settings: integration token with its copy button */
.token-copy-row { display: flex; gap: 10px; }
.token-copy-row .input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.token-copy-row .btn { flex: 0 0 auto; }

/* Error pages */
.error-code {
    margin: 0 0 4px;
    font-size: 40px;
    font-weight: 700;
    line-height: 1;
    color: var(--color-primary);
}
.error-support { margin-top: 16px; margin-bottom: 0; }

.alert-warning {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
}

/* Signup: doctors-only notice and the professional data block */
.signup-doctors-only { margin-bottom: 18px; font-size: 14px; line-height: 1.45; }
.guest-card .subsection-title { margin: 20px 0 12px; }
.guest-card .checkbox-label { align-items: flex-start; line-height: 1.4; }
.guest-card .checkbox-label input { margin-top: 3px; }

/* Embeddable signup form (/registro/embed): no page chrome, sits on
   whatever background the host page has. */
.embed-html, .embed-body { margin: 0; background: transparent; }
.embed-card { max-width: 520px; margin: 0 auto; padding: 4px 2px 8px; }
.embed-card .subsection-title { margin: 20px 0 12px; }
.embed-card .checkbox-label { align-items: flex-start; line-height: 1.4; }
.embed-card .checkbox-label input { margin-top: 3px; }
.embed-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Legal documents (/legal): public reading pages */
.legal-body { background: var(--color-bg); }
.legal-header {
    display: flex; align-items: center; gap: 16px 28px; flex-wrap: wrap;
    padding: 14px 24px; background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.legal-brand img { display: block; height: 38px; width: auto; }
.legal-nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 14px; }
.legal-nav-link { color: var(--color-text-muted); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.legal-nav-link:hover { color: var(--color-primary); }
.legal-nav-link.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }
.legal-wrap { max-width: 860px; margin: 0 auto; padding: 28px 16px 40px; }
.legal-missing { margin-bottom: 16px; font-size: 14px; }
.legal-doc { padding: 36px 44px; font-size: 15px; line-height: 1.65; }
.legal-doc-head { position: relative; margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--color-border); }
.legal-doc-head h1 { margin: 0 0 4px; font-size: 26px; line-height: 1.25; padding-right: 110px; }
.legal-doc-meta { margin: 0; font-size: 13px; color: var(--color-text-muted); }
.legal-print { position: absolute; top: 0; right: 0; }
.legal-doc h2 { margin: 30px 0 10px; font-size: 18px; }
.legal-doc h3 { margin: 20px 0 8px; font-size: 15.5px; }
.legal-doc p { margin: 0 0 12px; }
.legal-doc ul, .legal-doc ol { margin: 0 0 14px; padding-left: 22px; }
.legal-doc li { margin-bottom: 6px; }
.legal-doc a { color: var(--color-primary); }
.legal-nowrap { white-space: nowrap; }
.legal-table-wrap { overflow-x: auto; margin: 0 0 14px; }
.legal-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
.legal-table th, .legal-table td { border: 1px solid var(--color-border); padding: 8px 10px; text-align: left; vertical-align: top; }
.legal-table th { background: var(--color-bg); font-weight: 600; }
.legal-index { list-style: none; margin: 0; padding: 0 !important; }
.legal-index li { padding: 14px 0; border-bottom: 1px solid var(--color-border); margin: 0; }
.legal-index li:last-child { border-bottom: 0; }
.legal-index a { font-size: 17px; font-weight: 600; text-decoration: none; }
.legal-index p { margin: 4px 0 0; color: var(--color-text-muted); font-size: 14px; }
.legal-footer { margin-top: 20px; text-align: center; font-size: 13px; line-height: 1.6; color: var(--color-text-muted); }
.legal-footer p { margin: 0 0 8px; }
.legal-footer a { color: var(--color-primary); }
.guest-footer a { color: inherit; }
.signup-legal { margin: 0 0 14px; font-size: 13px; line-height: 1.45; color: var(--color-text-muted); }
.signup-legal a { color: var(--color-primary); }
@media (max-width: 640px) {
    .legal-doc { padding: 22px 18px; }
    .legal-doc-head h1 { font-size: 22px; padding-right: 0; }
    .legal-print { position: static; margin-top: 10px; }
}
@media print {
    .legal-header, .legal-print, .legal-missing, .legal-footer p:last-child { display: none !important; }
    .legal-body { background: #fff; }
    .legal-wrap { max-width: none; padding: 0; }
    .legal-doc { border: 0; box-shadow: none; padding: 0; font-size: 11.5pt; }
}

/* Staff console > Clientes: filters, last access, account actions */
.tenant-filters select.tenant-filter-status { width: 190px; flex: 0 0 auto; }
.tenant-filter-inactive { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--color-text-muted); white-space: nowrap; }
.tenant-filter-inactive .input { width: 76px; }
.cell-sub { font-size: 12.5px; color: var(--color-text-muted); margin-top: 2px; white-space: nowrap; }
.tenant-actions { display: flex; gap: 6px; justify-content: flex-end; }
.tenant-actions form { margin: 0; }
.table-empty { text-align: center; color: var(--color-text-muted); padding: 28px 12px; }

/* Support calls: staff banner */
.support-call-alert { margin-bottom: 14px; }

/* Procedure suggestions: the account's own (saved) procedures, before the catalog */
.catalog-suggestions button.catalog-history { font-weight: 600; border-left: 3px solid var(--color-primary); }

/* Page links of paginated lists (partials/pagination) */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.pager-info { margin: 0; font-size: 13.5px; color: var(--color-text-muted); }
.pager-list { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }
.pager-link {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px; padding: 0 10px;
    border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    background: var(--color-surface); color: var(--color-text);
    font-size: 14px; text-decoration: none;
}
a.pager-link:hover { border-color: var(--color-primary); color: var(--color-primary); text-decoration: none; }
.pager-link.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; font-weight: 600; }
.pager-link.disabled { color: var(--color-text-muted); opacity: .55; }
.pager-gap { display: inline-flex; align-items: center; height: 34px; padding: 0 4px; color: var(--color-text-muted); }
@media (max-width: 600px) {
    .pager { justify-content: center; }
    .pager-info { width: 100%; text-align: center; }
}

/* Staff console > E-mails */
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.email-tabs { margin-bottom: 10px; }
.email-kind-help { margin: 0 0 14px; }
.email-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.email-form .form-card { margin-bottom: 16px; }
.email-editor-area { background: #fff; }
.email-editor-area img { max-width: 100%; height: auto; }
.email-editor-html { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.email-editor .richtext-toolbar button.active { background: var(--color-primary-soft); color: var(--color-primary); }
.email-radio-row { display: flex; gap: 8px 22px; flex-wrap: wrap; margin-bottom: 12px; }
.email-filters { margin-top: 6px; }
.email-picker .input { margin-bottom: 8px; }
.email-pick-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 6px 10px; }
.email-pick-list .checkbox-label { display: flex; padding: 4px 0; }
.email-recipient-count { margin: 12px 0 0; font-weight: 600; }
.email-test-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.input-auto { width: auto; }
.input-color { width: 72px; height: 40px; padding: 4px; }
.email-layout-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.email-preview { width: 100%; height: 520px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: #f4f6f9; }
@media (max-width: 1000px) { .email-layout-grid { grid-template-columns: 1fr; } }
.email-filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.email-filter-row .checkbox-label { min-width: 210px; }
.email-filter-row.is-off > span, .email-filter-row.is-off .input { opacity: .45; }
.email-editor .richtext-toolbar { flex-wrap: wrap; row-gap: 4px; }
.email-editor .rt-select { height: 30px; padding: 0 6px; border: 1px solid var(--color-border); border-radius: 6px; background: #fff; font: inherit; font-size: 13px; }
.email-editor .rt-icons { display: grid; grid-template-columns: repeat(6, 30px); gap: 2px; width: auto; }
.email-editor .rt-icons button { width: 30px; height: 30px; font-size: 17px; line-height: 1; background: none; border: 0; border-radius: 6px; }
.email-editor .rt-icons button:hover { background: var(--color-primary-soft); transform: none; }
.email-editor-area table { border-collapse: collapse; }
.email-editor-area td, .email-editor-area th { min-width: 40px; }
.guest-corner { position: fixed; top: 16px; right: 16px; z-index: 10; }

/* Toast (layouts/app): bottom-right, above everything, fades out */
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 1000; display: flex; align-items: center; gap: 12px; max-width: min(420px, calc(100vw - 32px)); padding: 12px 14px 12px 16px; border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(15, 23, 42, .18); font-size: 14px; animation: toast-in .25s ease-out; transition: opacity .3s, transform .3s; }
.toast-success { background: var(--color-success-soft); color: var(--color-success-text); border: 1px solid currentColor; }
.toast-danger { background: var(--color-danger-soft); color: var(--color-danger); border: 1px solid currentColor; }
.toast.is-leaving { opacity: 0; transform: translateY(10px); }
.toast-close { background: none; border: 0; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px; opacity: .7; }
.toast-close:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) { .toast { left: 16px; right: 16px; bottom: 16px; max-width: none; } }

/* Staff console > E-mails > History */
.email-log-filters { flex-wrap: wrap; gap: 10px; align-items: center; }
.email-log-date { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--color-text-muted); }
.email-log-date .input { width: auto; }
.email-log-meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.email-log-meta dt { color: var(--color-text-muted); }
.email-log-meta dd { margin: 0; word-break: break-word; }
.email-log-frame { width: 100%; min-height: 640px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: #fff; }
.email-log-text { white-space: pre-wrap; font-size: 13px; margin: 0; }
td.nowrap { white-space: nowrap; }

/* Wallet > Pix QR code (Mercado Pago) */
.pix-card { max-width: 520px; }
.pix-amount { font-size: 16px; margin: 0 0 6px; }
.pix-qr { display: block; width: 240px; max-width: 100%; height: auto; margin: 16px auto; image-rendering: pixelated; border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.pix-copy { display: flex; gap: 8px; margin-bottom: 16px; }
.pix-copy .input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 12px; }
.pix-waiting { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; font-weight: 600; }
.pix-spinner { width: 16px; height: 16px; border: 2px solid var(--color-border); border-top-color: var(--color-primary); border-radius: 50%; animation: pix-spin .9s linear infinite; }
@keyframes pix-spin { to { transform: rotate(360deg); } }

/* Vouchers: staff console list, and the "I have a voucher" box on the wallet */
.voucher-code { font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: .04em; }
.voucher-code-input { text-transform: uppercase; font-family: ui-monospace, monospace; }
.voucher-note-field { grid-column: span 2; }
.voucher-form { margin: 4px 0 18px; }
.voucher-row { display: flex; gap: 8px; max-width: 420px; }
.voucher-row .input { flex: 1; min-width: 0; text-transform: uppercase; }
@media (max-width: 720px) { .voucher-note-field { grid-column: auto; } }

/* Sidebar: WhatsApp help pinned to the bottom of the menu */
/* (a little less than the visible height: never makes the page scroll) */
.sidebar-inner { min-height: calc(var(--screen-h) - 120px); }
.sidebar-whatsapp { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 13px; font-weight: 400; color: #94a3b8; }
.sidebar-whatsapp .icon { width: 16px; height: 16px; opacity: .7; }
.sidebar-whatsapp:hover { color: #e2e8f0; background: rgba(255, 255, 255, .05); }
.sidebar-whatsapp:hover .icon { color: #4ade80; opacity: 1; }
@media (max-width: 860px) {
    .sidebar-inner { position: static; min-height: 0; flex: 1; }
}

/* Settings: legal documents at the bottom of the page */
.settings-legal { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--color-border); }
.settings-legal-title { font-size: 14px; font-weight: 600; color: var(--color-text-muted); margin: 0 0 10px; }
.settings-legal-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 14px; }
.settings-legal-links a { display: inline-flex; align-items: center; gap: 6px; }
.settings-legal-links .icon { width: 16px; height: 16px; }

/* Risk-index item answered elsewhere (Procedure > Type of surgery) */
.fact-row-readonly { cursor: default; opacity: .85; }
.fact-row-readonly input { cursor: not-allowed; }
.fact-source { font-size: 12px; color: var(--color-text-muted); margin-left: 4px; }

/* Support calls: banner on the client's screen, booking page, staff hours */
.support-banner { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--color-primary-soft); border: 1px solid var(--color-border); font-size: 14px; }
.support-banner.is-live { background: var(--color-success-soft); color: var(--color-success-text); border-color: currentColor; }
.support-banner-icon .icon { width: 18px; height: 18px; }
.support-banner-text { flex: 1; min-width: 200px; font-weight: 600; }
.support-banner-link { font-size: 13px; }
.support-intro { margin-bottom: 16px; }
.support-booked-when { font-size: 16px; font-weight: 600; margin: 4px 0 14px; }
.support-booked-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.support-day { margin-bottom: 12px; }
.support-day-title { font-size: 13px; font-weight: 600; color: var(--color-text-muted); margin-bottom: 6px; text-transform: capitalize; }
.support-slots { display: flex; flex-wrap: wrap; gap: 6px; }
.support-slot { min-width: 64px; font-variant-numeric: tabular-nums; }
.support-hours { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; max-width: 520px; }
.support-hours-row { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 10px; }
.support-hours-day { font-weight: 600; font-size: 14px; }
.support-dashboard { margin-bottom: 16px; }
.support-dashboard-list { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }

/* Report layout editor: richer toolbar, HTML source, what the PDF draws */
.template-toolbar { flex-wrap: wrap; row-gap: 4px; }
.template-area img { max-width: 100%; height: auto; }
.template-area table { border-collapse: collapse; }
.template-area td, .template-area th { border: 1px solid #cbd5e1; padding: 4px 6px; min-width: 40px; }
.template-area hr { border: 0; border-top: 1px solid #cbd5e1; }
.template-html-source { width: 100%; min-height: 420px; font-family: ui-monospace, monospace; font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; }

/* E-mail automations: "accounts with between N and Y reports" */
.email-report-range { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; }
.email-report-range .input { width: 110px; }

/* Risk-index badges: a coefficient that lowers the risk (NSQIP-MICA), and a
   note next to a number field ("+0.02 / year") */
.point-badge-negative { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.point-badge-note { margin-left: 6px; font-weight: 500; }

/* Risk-index number shown, not typed (age from the birth date) */
.input-readonly { background: var(--color-bg); color: var(--color-text-muted); cursor: not-allowed; }

/* Read-only number (age from the birth date): one line - label, value, badge */
.fact-number-row-inline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.fact-number-row-inline .label { margin: 0; }
.fact-number-row-inline .input-affix { order: 2; width: auto; }
.fact-number-row-inline .input-affix .input { width: 64px; padding: 4px 8px; height: 32px; }
.fact-number-row-inline .point-badge-note { order: 3; margin-left: 0; }

/* --------------------------------------------------------------------------
   Conclusion step: risk summary, suggestion, recommendations, preview
   -------------------------------------------------------------------------- */

.concl-summary {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    padding: 12px 14px;
    margin-bottom: 18px;
}
.concl-summary-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.concl-summary-head .subsection-title { margin: 0; }
.concl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.concl-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    font-size: 13px;
}
.concl-chip small { color: var(--color-text-muted); font-size: 12px; }
.concl-chip-green { background: #f0fdf4; border-color: #bbf7d0; }
.concl-chip-green strong { color: #15803d; }
.concl-chip-yellow { background: #fefce8; border-color: #fde68a; }
.concl-chip-yellow strong { color: #a16207; }
.concl-chip-orange { background: #fff7ed; border-color: #fed7aa; }
.concl-chip-orange strong { color: #c2410c; }
.concl-chip-red { background: #fef2f2; border-color: #fecaca; }
.concl-chip-red strong { color: #b91c1c; }
.concl-chip-gray { color: var(--color-text-muted); }
.concl-alerts {
    margin: 10px 0 0;
    padding-left: 18px;
    color: #b45309;
    font-size: 13.5px;
}

.preset-drag {
    display: inline-flex;
    align-items: center;
    cursor: grab;
    padding-top: 1px;
}
.preset-drag .icon { width: 14px; height: 18px; }
.preset-option.dragging { opacity: .5; }
.preset-suggested,
.concl-rec-auto {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    vertical-align: 1px;
}
.concl-mismatch {
    margin: 8px 0 0;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    font-size: 13.5px;
}

.concl-recs { display: flex; flex-direction: column; gap: 6px; }
.concl-rec {
    position: relative;
    padding: 8px 46px 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
}
.concl-rec.checked { border-color: var(--color-primary); background: #f5fbfd; }
.concl-rec .preset-pencil { top: 50%; transform: translateY(-50%); width: 28px; height: 28px; }
.concl-rec-pick { align-items: flex-start; width: 100%; }
.concl-rec-pick input { margin-top: 3px; }

.concl-preview {
    margin-top: 18px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
}
.concl-preview-head {
    padding: 6px 12px;
    border-bottom: 1px dashed var(--color-border);
    color: var(--color-text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.concl-preview-body { padding: 10px 14px; font-size: 14px; }
.concl-preview-body p { margin: 0 0 6px; }
.concl-preview-body ul { margin: 4px 0; padding-left: 22px; }

/* --------------------------------------------------------------------------
   Report wizard: patient in the left pane, above the steps
   -------------------------------------------------------------------------- */

.wizard-body { grid-template-columns: 220px 1fr; }
.wizard-side {
    position: sticky;
    top: 76px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}
/* the side pane is the sticky one now */
.wizard-side .wizard-steps { position: static; }

.wizard-patient {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 4px 12px;
    margin: 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
}
.wizard-patient-info { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.wizard-patient-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--color-text-muted);
    font-size: 12.5px;
}
.wizard-patient-name {
    font-size: 15px;
    text-transform: uppercase;
    /* long names wrap to a second line, then are cut */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.wizard-patient-age { color: var(--color-text-muted); font-size: 12.5px; }
.wizard-patient-info .badge { align-self: flex-start; margin-top: 4px; }
.wizard-patient-link {
    flex: none;
    display: inline-flex;
    color: var(--color-text-muted);
    padding: 4px;
    border-radius: 6px;
}
.wizard-patient-link:hover { color: var(--color-primary); background: var(--color-primary-soft); }
.wizard-patient-link svg { width: 18px; height: 18px; }

@media (max-width: 900px) {
    .wizard-body { grid-template-columns: 1fr; }
    .wizard-side { position: static; }
}

/* Wizard help button: top-right corner of the panel */
.wizard-panels { position: relative; }
.wizard-help { position: absolute; top: 14px; right: 14px; z-index: 2; }
.wizard-help .help-btn { margin-left: 0; width: 30px; height: 30px; border: none; }
.wizard-help .help-btn svg { width: 22px; height: 22px; }
/* keeps the index's live indicator clear of the help button */
.wizard-panels .index-layout > .indicator { margin-top: 32px; }

/* Risk summary without a title: chips on the left, the insert button right */
.concl-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.concl-summary .concl-chips { flex: 1; min-width: 0; order: 1; }
.concl-summary .concl-summary-head { order: 2; margin: 0; }
.concl-summary .concl-alerts { order: 3; flex-basis: 100%; margin-top: 0; }

/* --------------------------------------------------------------------------
   Verdict cards (Conclusion step)
   -------------------------------------------------------------------------- */

.verdict-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
    flex-direction: initial;
}
.verdict-card {
    padding: 12px 40px 12px 14px;
    border-width: 1.5px;
    transition: opacity .15s, box-shadow .15s, border-color .15s;
    cursor: default;
}
.verdict-card.editing { grid-column: 1 / -1; padding-right: 14px; }
.verdict-pick { flex-direction: column; gap: 4px; cursor: pointer; }
/* the card is the button: the radio stays for the keyboard, unseen */
.verdict-radio { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.verdict-head { display: flex; align-items: center; gap: 7px; font-size: 14.5px; }
.verdict-icon {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}
.preset-green .verdict-icon { background: #16a34a; }
.preset-green .verdict-icon::before { content: "\2713"; }
.preset-yellow .verdict-icon { background: #ca8a04; }
.preset-yellow .verdict-icon::before { content: "!"; }
.preset-red .verdict-icon { background: #dc2626; }
.preset-red .verdict-icon::before { content: "\2715"; }
.verdict-text {
    color: var(--color-text-muted);
    font-size: 13px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.verdict-card .preset-suggested {
    position: absolute;
    top: -9px;
    right: 12px;
    margin: 0;
    background: var(--color-primary);
    color: #fff;
}
/* pencil only on hover (always on touch screens) */
.verdict-card .preset-pencil { top: 8px; right: 8px; width: 26px; height: 26px; opacity: 0; }
.verdict-card:hover .preset-pencil,
.verdict-card .preset-pencil:focus-visible { opacity: 1; }
@media (hover: none) { .verdict-card .preset-pencil { opacity: 1; } }

.verdict-card:has(.verdict-radio:focus-visible) { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.verdict-card.selected.preset-green { border-color: #16a34a; box-shadow: 0 0 0 1px #16a34a; }
.verdict-card.selected.preset-yellow { border-color: #ca8a04; box-shadow: 0 0 0 1px #ca8a04; }
.verdict-card.selected.preset-red { border-color: #dc2626; box-shadow: 0 0 0 1px #dc2626; }
.verdict-card.selected .verdict-text { color: var(--color-text); }
.verdict-cards.has-pick .verdict-card:not(.selected):not(.editing) { opacity: .55; }
.verdict-cards.has-pick .verdict-card:not(.selected):hover { opacity: 1; }

/* reorder handle: inside the editor only */
.verdict-card .preset-drag { cursor: grab; color: var(--color-text-muted); padding: 4px; }

.verdict-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 78px;
    border: 1.5px dashed var(--color-border);
    border-radius: var(--radius-sm);
    background: none;
    color: var(--color-text-muted);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}
.verdict-add:hover { border-color: var(--color-primary); color: var(--color-primary); }
.verdict-add:hover .icon { color: var(--color-primary); }

/* the warning: one discreet line, not a box */
.concl-mismatch {
    margin: 8px 0 0;
    padding: 0;
    background: none;
    border: none;
    color: #b45309;
    font-size: 13px;
}
.concl-mismatch::before { content: "\26A0\FE0E  "; }

@media (max-width: 720px) {
    .verdict-cards { grid-template-columns: 1fr; }
}

/* Exam step on a computer: number fields sized for a few digits, not the
   whole row (on phones they stay full width) */
@media (min-width: 641px) {
    .biometrics-row { grid-template-columns: 150px 150px minmax(220px, 340px); }
    .vitals-grid { grid-template-columns: repeat(auto-fill, 165px); }
}

/* --------------------------------------------------------------------------
   Physical exam: compact metrics, discreet bleeding alert
   -------------------------------------------------------------------------- */

.exam-metrics { display: flex; flex-wrap: wrap; column-gap: 40px; }
.exam-metrics-group { min-width: 0; }
.exam-metrics .vitals-grid { margin-bottom: 10px; }
@media (min-width: 641px) {
    .biometrics-row { grid-template-columns: 130px 130px minmax(200px, 260px); }
    .exam-metrics .vitals-grid { grid-template-columns: 210px repeat(3, 125px); }
}
@media (max-width: 640px) {
    .exam-metrics { display: block; }
}

/* systolic / diastolic in one field */
.bp-pair .input { border-radius: 0; border-right: none; text-align: center; padding-left: 6px; padding-right: 6px; }
.bp-pair .input:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.bp-pair .input + .bp-sep + .input { border-left: none; }
.bp-sep {
    display: inline-flex;
    align-items: center;
    padding: 0 2px;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}
.bp-pair .input:first-child { border-right: none; }

/* the medication box no taller than its content */
.med-field .med-badges:empty { display: none; }

.bleeding-alert {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 6px;
    color: #b45309;
    font-weight: 500;
    font-size: 13px;
}
.bleeding-alert::before { content: "\26A0\FE0E"; }

/* --------------------------------------------------------------------------
   Recommendations: a plain checklist, no boxes
   -------------------------------------------------------------------------- */

.concl-recs { gap: 0; }
.concl-rec {
    padding: 5px 36px 5px 2px;
    border: none;
    border-radius: 6px;
    background: none;
}
.concl-rec:hover { background: var(--color-bg); }
.concl-rec.checked { border: none; background: none; }
.concl-rec.checked:hover { background: var(--color-bg); }
.concl-rec-pick { font-size: 14px; }
.concl-rec .preset-pencil { opacity: 0; width: 26px; height: 26px; right: 4px; border-color: transparent; background: none; }
.concl-rec:hover .preset-pencil,
.concl-rec .preset-pencil:focus-visible { opacity: 1; }
@media (hover: none) { .concl-rec .preset-pencil { opacity: 1; } }
.concl-rec .preset-edit { padding: 4px 0; }
.concl-recs + .preset-edit-actions { margin-top: 6px; }

/* verdict "Sugerida" tag on the left of the top edge, clear of the pencil */
.verdict-card .preset-suggested { right: auto; left: 12px; }

/* Recommendations title with a small "+ Agregar" next to it */
.concl-recs-head { display: flex; align-items: center; gap: 10px; margin: 22px 0 8px; }
.concl-recs-head .subsection-title { margin: 0; line-height: 1.3; }
.link-add {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin: 0;
    padding: 2px 8px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--color-primary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.link-add .icon { width: 14px; height: 14px; color: currentColor; }
.link-add:hover { background: var(--color-primary-soft); }

/* Medications and allergies: two boxes of the same height (the taller
   one sets it) */
.meds-row { align-items: stretch; }
.meds-row > .field { display: flex; flex-direction: column; margin-bottom: 0; }
.meds-row .med-field { flex: 1; }
.meds-row .richtext { flex: 1; display: flex; flex-direction: column; }
.meds-row .richtext-area { flex: 1; }
.meds-row + .bleeding-alert { margin-top: 8px; }

/* Verdict cards a bit larger; the add card a narrow column at the end */
.verdict-cards { display: flex; flex-wrap: wrap; gap: 10px; }
.verdict-card { flex: 1 1 260px; min-width: 0; min-height: 110px; padding: 14px 42px 14px 16px; }
.verdict-card.editing { flex-basis: 100%; }
.verdict-text { -webkit-line-clamp: 4; font-size: 13.5px; }
.verdict-add {
    flex: 0 0 110px;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    padding: 8px;
    font-size: 12.5px;
    line-height: 1.25;
    text-align: center;
}
@media (max-width: 720px) {
    .verdict-card { flex-basis: 100%; }
    .verdict-add { flex: 1 1 100%; flex-direction: row; padding: 10px; }
}

/* Saved snippets inside the editor toolbar, pushed to the right */
.richtext-toolbar { flex-wrap: wrap; align-items: center; }
.richtext-toolbar .snippet-controls { margin-left: auto; gap: 6px; }
.richtext-toolbar .snippet-controls .btn { min-width: 0; height: 28px; border: 1px solid var(--color-border); background: var(--color-surface); }
.richtext-toolbar select.snippet-select { height: 28px; background-color: var(--color-surface); }
@media (max-width: 560px) {
    .richtext-toolbar .snippet-controls { margin-left: 0; width: 100%; }
}

/* Final step: the report text, editable */
.final-text { position: relative; }
.final-text-head {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.final-text-head .field-hint { margin: 0; }
.final-text .richtext-area { min-height: 360px; line-height: 1.5; }
.final-text .richtext-area table { border-collapse: collapse; max-width: 100%; }
.final-text .richtext-area img { max-width: 100%; height: auto; }
.final-text .richtext-area h1, .final-text .richtext-area h2,
.final-text .richtext-area h3, .final-text .richtext-area h4 { margin: 10px 0 6px; }
@media (max-width: 640px) {
    .final-text-head { position: static; justify-content: flex-end; margin-bottom: 4px; }
}

/* Conclusion title with "+ Inserir resumo na conclusão" next to it */
.concl-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 14px; padding-right: 36px; }
.concl-title-row .section-title { margin: 0; }

/* Risk box: chips on top, then a footer (alerts left, insert button right) */
.concl-summary { display: block; }
.concl-summary .concl-chips { flex: none; }
.concl-summary-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border);
}
.concl-summary-foot .concl-alerts { margin: 0; flex: 1; min-width: 0; }
.concl-summary-foot .concl-alerts[hidden] + .link-add { margin-left: auto; }
.concl-summary-foot .link-add { flex: none; }

/* Final step: layout picker on the right of the editor toolbar */
.richtext-toolbar .template-pick { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.richtext-toolbar .template-pick .btn { height: 28px; padding: 4px 10px; font-size: 12.5px; display: inline-flex; align-items: center; }
.richtext-toolbar .template-pick select.snippet-select { width: 170px; height: 28px; background-color: var(--color-surface); }
@media (max-width: 560px) {
    .richtext-toolbar .template-pick { margin-left: 0; width: 100%; }
}

/* Points-group heading inside a long index list (Caprini) */
.fact-points-heading {
    margin: 14px 0 4px;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.fact-points-heading:first-child { margin-top: 0; }

/* Thrombotic / bleeding step: Caprini block, then Padua / IMPROVE columns */
.vte-block-hint { margin: -6px 0 12px; }
.vte-grid-2 { grid-template-columns: repeat(2, 1fr); }
.vte-grid-1 { grid-template-columns: 1fr; max-width: 640px; }
.vte-grid-after {
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid var(--color-border);
}
.vte-col {
    display: flex;
    flex-direction: column;
    padding: 14px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
}
.vte-col .subsection-title { margin-top: 0; }
.vte-col .indicator { margin-top: auto; position: static; }
@media (max-width: 1100px) {
    .vte-grid-2 { grid-template-columns: 1fr; }
}

/* Age options (from the birth date): shown, not answered */
.fact-group-readonly .fact-row { cursor: default; }
.fact-group-readonly input[disabled] { cursor: not-allowed; }

/* "Mostrar mais recomendações": under the list, small */
.concl-recs-more { margin: 6px 0 0 2px; font-weight: 500; }

/* Small pencil next to the patient (edit the record) */
.wizard-patient-edit {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
}
.wizard-patient-edit:hover { color: var(--color-primary); background: var(--color-primary-soft); }
.wizard-patient-edit .icon { width: 15px; height: 15px; color: currentColor; }

/* Font size (px) in the report layout editor */
.template-toolbar .rt-select { height: 30px; padding: 0 6px; border: 1px solid var(--color-border); border-radius: 6px; background: #fff; font: inherit; font-size: 13px; cursor: pointer; }

/* Final report text: the whole document toolbar (wraps on narrow screens) */
.richtext-full .richtext-toolbar { flex-wrap: wrap; row-gap: 4px; }
.richtext-full .rt-select { height: 28px; padding: 0 6px; border: 1px solid var(--color-border); border-radius: 6px; background: #fff; font: inherit; font-size: 13px; cursor: pointer; }
.richtext-full .richtext-toolbar button[data-rt-html].active { background: var(--color-primary-soft); border-color: var(--color-primary); }
.richtext-full .richtext-toolbar button:disabled, .richtext-full .rt-select:disabled { opacity: .4; cursor: default; }
.richtext-full .richtext-area img { max-width: 100%; height: auto; }
.richtext-full .richtext-area table { border-collapse: collapse; }
.richtext-full .richtext-area td, .richtext-full .richtext-area th { border: 1px solid #cbd5e1; padding: 4px 6px; min-width: 40px; }
.richtext-full .richtext-area hr { border: 0; border-top: 1px solid #cbd5e1; }
.richtext-full .template-html-source { min-height: 420px; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

/* Editor menus with text items (final report text: style, alignment) */
.rt-palette.rt-menu { display: flex; flex-direction: column; gap: 2px; padding: 6px; min-width: 190px; }
.rt-palette.rt-menu button { width: auto; height: auto; min-height: 30px; padding: 4px 10px; border: 1px solid transparent; border-radius: 5px; background: none; text-align: left; font-size: 13px; color: var(--color-text); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.rt-palette.rt-menu button:hover { transform: none; background: var(--color-primary-soft); }
.rt-menu-icon { display: inline-block; min-width: 22px; text-align: center; color: var(--color-text-muted); }
.rt-menu-sep { height: 1px; background: var(--color-border); margin: 4px 2px; }
.rt-menu-btn { display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; }
.rt-caret { font-size: 10px; color: var(--color-text-muted); }

/* Integration documentation for partners (/integracao) */
.dev-doc code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 4px; padding: 1px 5px; word-break: break-word; }
.dev-doc pre { margin: 0 0 16px; padding: 14px 16px; background: #0f172a; color: #e2e8f0; border-radius: 8px; overflow-x: auto; font-size: 12.5px; line-height: 1.55; }
.dev-doc pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; word-break: normal; white-space: pre; }
.dev-doc .dev-steps { counter-reset: step; list-style: none; padding-left: 0 !important; }
.dev-doc .dev-steps > li { counter-increment: step; position: relative; padding-left: 38px; margin-bottom: 12px; }
.dev-doc .dev-steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--color-primary-soft); color: var(--color-primary); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.dev-doc .dev-toc { columns: 2; column-gap: 32px; margin-bottom: 8px; }
.dev-doc .dev-note { padding: 12px 14px; border-left: 3px solid var(--color-primary); background: var(--color-primary-soft); border-radius: 0 6px 6px 0; margin: 0 0 16px; font-size: 14px; }
@media (max-width: 640px) { .dev-doc .dev-toc { columns: 1; } }

/* Focus mode (integration, focus=true): no top bar, no side menu - the
   sticky parts of the report sit at the top of the window */
.focus-mode .wizard-side, .focus-mode .wizard-steps, .focus-mode .indicator { top: 12px; }
.focus-mode .content { max-width: none; }

/* Country of this system and switch to the others (partials.country-switch) */
.country-switch { position: relative; display: inline-flex; font-size: 13.5px; color: var(--color-text); }
.country-switch summary { list-style: none; display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-surface); cursor: pointer; user-select: none; white-space: nowrap; }
.country-switch summary::-webkit-details-marker { display: none; }
.country-switch summary:hover { border-color: var(--color-primary); }
.country-switch-static { align-items: center; gap: 7px; padding: 5px 10px; border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-surface); }
.country-flag { width: 20px; height: 14px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); object-fit: cover; flex: none; }
.country-flag-code { display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; background: var(--color-bg); color: var(--color-text-muted); }
.country-caret { font-size: 10px; color: var(--color-text-muted); }
.country-switch-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; min-width: 230px; padding: 8px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(16, 24, 40, .12); }
.country-switch-note { margin: 2px 6px 8px; font-size: 12.5px; line-height: 1.4; color: var(--color-text-muted); white-space: normal; }
.country-switch-item { display: flex; align-items: center; gap: 9px; padding: 8px 8px; border-radius: 6px; color: var(--color-text); text-decoration: none; }
.country-switch-item:hover { background: var(--color-bg); text-decoration: none; }
.country-switch-more { color: var(--color-primary); font-weight: 600; border-top: 1px solid var(--color-border); border-radius: 0 0 6px 6px; margin-top: 4px; }
.guest-country { display: flex; justify-content: center; margin: 0 0 12px; }
.country-suggestion { display: flex; align-items: flex-start; gap: 10px; max-width: 440px; margin: 0 auto 14px; font-size: 14px; }
.country-suggestion .country-flag { margin-top: 3px; }
.embed-country { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.settings-country { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 10px; font-size: 14px; color: var(--color-text-muted); }

/* Tutorials (sidebar > Tutoriais) */
.tutorial-head { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; }
.page-subtitle { margin: 4px 0 0; color: var(--color-text-muted); font-size: 14.5px; }
.tutorial-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.tutorial-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; color: inherit; text-decoration: none; transition: box-shadow .15s, transform .15s; }
.tutorial-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 10px 28px rgba(16, 24, 40, .12); }
.tutorial-card-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; object-position: top left; background: var(--color-bg); border-bottom: 1px solid var(--color-border); }
.tutorial-card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tutorial-card-title { margin: 0; font-size: 16px; color: var(--color-text); }
.tutorial-card-text { margin: 0; font-size: 14px; color: var(--color-text-muted); flex: 1; }
.tutorial-card-meta { font-size: 12.5px; font-weight: 600; color: var(--color-primary); }
.tutorial-back { display: inline-block; margin-bottom: 6px; font-size: 14px; }
.tutorial-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; max-width: 920px; }
.tutorial-step, .tutorial-done { padding: 18px 20px; }
.tutorial-step-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.tutorial-step-num { flex: none; width: 34px; height: 34px; border-radius: 50%; background: #ea580c; color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.tutorial-step-title { margin: 3px 0 4px; font-size: 17px; }
.tutorial-step-text { margin: 0; font-size: 15px; line-height: 1.5; }
.tutorial-step-shot { display: inline-block; max-width: 100%; vertical-align: top; border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; cursor: zoom-in; }
.tutorial-step-shot img { display: block; max-width: 100%; height: auto; } /* 2x images, shown at their real size */
.tutorial-tip { margin: 14px 0 0; padding: 10px 14px; border-radius: var(--radius-sm); background: #fef3c7; border: 1px solid #fcd34d; color: #78350f; font-size: 14px; }
.tutorial-done { max-width: 920px; margin-top: 18px; }
.tutorial-done p { margin: 0; }
.tutorial-more { margin-top: 8px !important; font-size: 14px; color: var(--color-text-muted); }

/* Sortable column titles (admin > clients) */
.th-sort { color: inherit; text-decoration: none; white-space: nowrap; }
.th-sort:hover { color: var(--color-primary); text-decoration: none; }
.th-sort.active { color: var(--color-primary); }

/* Admin > Integrations > Metrics tokens */
.dev-code { margin: 0 0 14px; padding: 14px 16px; background: #0f172a; color: #e2e8f0; border-radius: 8px; overflow-x: auto; font-size: 12.5px; line-height: 1.55; white-space: pre; }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.metrics-token-new { border-color: var(--color-primary); }
