
/* ==========================================================================
   U7Care — theme layer over Bootstrap 5
   Palette and spacing follow the U7Care clinical design system.
   ========================================================================== */

:root {
    color-scheme: light;

    --mh-bg:            oklch(97% 0.004 255);
    --mh-surface:       #ffffff;
    --mh-border:        oklch(90% 0.005 255);
    --mh-border-soft:   oklch(95% 0.003 255);
    --mh-ink:           oklch(22% 0.01 255);
    --mh-muted:         oklch(52% 0.01 255);
    --mh-faint:         oklch(60% 0.01 255);

    --mh-danger:        #c0392b;
    --mh-danger-bg:     oklch(95% 0.04 25);
    --mh-warning:       #b8860b;
    --mh-warning-bg:    oklch(95% 0.05 80);
    --mh-success:       #2e7d32;
    --mh-success-bg:    oklch(95% 0.04 150);
    --mh-info:          #2563eb;
    --mh-info-bg:       oklch(94% 0.03 255);

    /* Per-portal accent, overridden by the [data-accent] hooks below. */
    --mh-accent:        oklch(55% 0.17 255);
    --mh-accent-soft:   oklch(94% 0.03 255);
    --mh-accent-ink:    oklch(35% 0.10 255);
    --mh-sidebar:       oklch(22% 0.035 255);
    --mh-sidebar-label: oklch(60% 0.02 255);

    --mh-radius:        12px;
    --mh-sidebar-w:     264px;
}

[data-accent="green"]  { --mh-accent: oklch(50% 0.14 150); --mh-accent-soft: oklch(96% 0.02 150); --mh-accent-ink: oklch(35% 0.10 150); --mh-sidebar: oklch(22% 0.035 150); --mh-sidebar-label: oklch(60% 0.02 150); }
[data-accent="teal"]   { --mh-accent: oklch(45% 0.13 200); --mh-accent-soft: oklch(95% 0.03 200); --mh-accent-ink: oklch(32% 0.10 200); --mh-sidebar: oklch(24% 0.05 200);  --mh-sidebar-label: oklch(70% 0.02 200); }
[data-accent="pink"]   { --mh-accent: oklch(45% 0.16 350); --mh-accent-soft: oklch(96% 0.03 350); --mh-accent-ink: oklch(40% 0.14 350); --mh-sidebar: oklch(26% 0.07 350);  --mh-sidebar-label: oklch(72% 0.03 350); }
[data-accent="indigo"] { --mh-accent: oklch(50% 0.16 265); --mh-accent-soft: oklch(94% 0.03 265); --mh-accent-ink: oklch(35% 0.12 265); --mh-sidebar: oklch(22% 0.035 255); --mh-sidebar-label: oklch(70% 0.02 255); }
[data-accent="violet"] { --mh-accent: oklch(45% 0.14 300); --mh-accent-soft: oklch(95% 0.04 300); --mh-accent-ink: oklch(35% 0.12 300); --mh-sidebar: oklch(22% 0.035 290); --mh-sidebar-label: oklch(72% 0.02 290); }
[data-accent="slate"]  { --mh-accent: oklch(40% 0.06 255); --mh-accent-soft: oklch(95% 0.01 255); --mh-accent-ink: oklch(30% 0.05 255); --mh-sidebar: oklch(24% 0.02 255);  --mh-sidebar-label: oklch(72% 0.01 255); }
[data-accent="amber"]  { --mh-accent: oklch(52% 0.13 60);  --mh-accent-soft: oklch(96% 0.03 70);  --mh-accent-ink: oklch(38% 0.10 55);  --mh-sidebar: oklch(24% 0.04 55);  --mh-sidebar-label: oklch(72% 0.03 60); }

* { box-sizing: border-box; }

/* Lets a flex or grid child shrink below its content, so .text-truncate and long
   names inside a row wrap or truncate instead of pushing the row off-screen.
   Used throughout the views; Bootstrap has no utility of its own for it. */
.min-width-0 { min-width: 0 !important; }

body {
    margin: 0;
    background: var(--mh-bg);
    color: var(--mh-ink);
    font-family: -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
    font-size: 14px;
}

a { color: var(--mh-accent); }

/* ----------------------------------------------------------------- shell */

.mh-shell { display: flex; min-height: 100vh; }

.mh-sidebar {
    width: var(--mh-sidebar-w);
    flex-shrink: 0;
    background: var(--mh-sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.mh-sidebar__brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.09);
}

/* U7Care brand mark at the top of every workspace sidebar. */
.mh-sidebar__logo { width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px; }

.mh-sidebar__mark {
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--mh-accent);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 16px;
}

.mh-sidebar__name      { font-size: 17px; font-weight: 700; letter-spacing: .2px; line-height: 1.1; }
.mh-sidebar__workspace { font-size: 9.5px; letter-spacing: 1px; font-weight: 600; color: var(--mh-sidebar-label); }

.mh-nav        { flex: 1; padding: 14px 12px 24px; }
.mh-nav__group { margin-top: 16px; }
.mh-nav__title { font-size: 10.5px; letter-spacing: 1px; font-weight: 700; color: var(--mh-sidebar-label); padding: 0 10px 6px; }

.mh-nav__link {
    width: 100%;
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border: 0; border-radius: 8px;
    background: transparent;
    color: rgba(255,255,255,.72);
    font-size: 13.5px; font-weight: 500;
    text-align: left; text-decoration: none;
    margin-bottom: 1px;
}

.mh-nav__link:hover        { background: rgba(255,255,255,.07); color: #fff; }
.mh-nav__link.is-active    { background: rgba(255,255,255,.12); color: #fff; font-weight: 700; }
.mh-nav__dot               { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.35); flex-shrink: 0; }
.mh-nav__link.is-active .mh-nav__dot { background: #fff; }
.mh-nav__label             { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mh-nav__badge             { font-size: 10.5px; font-weight: 700; background: rgba(255,255,255,.16); padding: 1px 7px; border-radius: 10px; }

.mh-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.mh-header {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid var(--mh-border);
    position: sticky; top: 0; z-index: 1020;
}

.mh-content { padding: 20px; display: flex; flex-direction: column; gap: 18px; }

/* The header and the selected-patient banner scroll as one. */
.mh-sticky-top { position: sticky; top: 0; z-index: 1020; }
.mh-sticky-top > .mh-header { position: static; }

.mh-context-banner {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 8px 20px;
    font-size: 12.5px;
    background: oklch(96% 0.03 255);
    border-bottom: 2px solid var(--mh-accent);
}
.mh-context-banner__label {
    font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
    color: var(--mh-accent-ink); background: var(--mh-accent-soft); padding: 2px 8px; border-radius: 4px;
}

/* Observations past the currency window must never look like current vitals. */
.mh-stale {
    color: var(--mh-muted); font-style: italic;
    background: repeating-linear-gradient(-45deg, transparent 0 6px, oklch(95% 0.02 80) 6px 12px);
    border-radius: 4px; padding: 0 4px;
}
.mh-stale-banner {
    display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
    color: oklch(40% 0.12 60); background: oklch(95% 0.06 80); border: 1px dashed oklch(70% 0.12 70);
    border-radius: 4px; padding: 1px 6px;
}

/* A pregnant patient's obstetric message leads; NEWS2 sits beneath it as a reference. */
.mh-obstetric {
    border-left: 4px solid var(--mh-danger); background: oklch(97% 0.03 25);
    border-radius: 4px; padding: 6px 10px; font-size: 12px;
}
.mh-obstetric__headline { font-weight: 800; color: var(--mh-danger); font-size: 12.5px; }
.mh-reference { font-size: 11px; color: var(--mh-muted); font-weight: 400; }

/* The four things a doctor takes first, in order. */
.mh-priority { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.mh-priority__item {
    border: 1px solid var(--mh-border); border-radius: var(--mh-radius); background: var(--mh-surface);
    padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.mh-priority__step { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--mh-muted); }

/* A short lifecycle, one pill per step. */
.mh-steps { display: flex; flex-wrap: wrap; gap: 3px; list-style: none; padding: 0; margin: 0; font-size: 10.5px; }
.mh-steps li { padding: 1px 6px; border-radius: 10px; border: 1px solid var(--mh-border-soft); color: var(--mh-muted); }
.mh-steps li.is-done { background: var(--mh-accent-soft); color: var(--mh-accent-ink); }
.mh-steps li.is-current { outline: 2px solid var(--mh-warning); color: var(--mh-ink); font-weight: 700; }

/* --------------------------------------------------------------- surfaces */

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

.mh-card__header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--mh-border-soft);
    font-size: 14px; font-weight: 700;
}

.mh-card__body { padding: 18px; }

.mh-page-title    { font-size: 22px; font-weight: 800; letter-spacing: -.3px; margin: 0; }
.mh-page-subtitle { font-size: 13px; color: var(--mh-muted); margin: 2px 0 0; }

/* Coloured stat / KPI tiles */
.mh-kpi        { background: #fff; border: 1px solid var(--mh-border); border-radius: var(--mh-radius); padding: 16px; height: 100%; }
.mh-kpi__icon  { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; font-size: 15px; }
.mh-kpi__label { font-size: 12px; color: var(--mh-muted); font-weight: 600; }
.mh-kpi__value { font-size: 24px; font-weight: 800; margin-top: 2px; line-height: 1.1; }
.mh-kpi__sub   { font-size: 11.5px; font-weight: 700; margin-top: 3px; }

.tone-danger  { color: var(--mh-danger); }
.tone-warning { color: var(--mh-warning); }
.tone-success { color: var(--mh-success); }
.tone-primary { color: var(--mh-info); }
.tone-pink    { color: #9b3a8f; }
.tone-purple  { color: oklch(58% 0.13 300); }

.bg-tone-danger  { background: var(--mh-danger-bg); }
.bg-tone-warning { background: var(--mh-warning-bg); }
.bg-tone-success { background: var(--mh-success-bg); }
.bg-tone-primary { background: var(--mh-info-bg); }
.bg-tone-pink    { background: oklch(93% 0.05 320); }
.bg-tone-purple  { background: oklch(95% 0.04 300); }

/* Attention strip used by the dashboards */
.mh-attention {
    background: oklch(97% 0.05 25);
    border: 1px solid oklch(85% 0.1 25);
    border-radius: var(--mh-radius);
    padding: 16px 18px;
}

.mh-attention__title { font-size: 14px; font-weight: 800; color: oklch(45% 0.17 25); }
.mh-attention__sub   { font-size: 12.5px; color: oklch(40% 0.05 25); }

.mh-attention__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 10px;
}

.mh-attention__item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; width: 100%;
    border: 1px solid oklch(88% 0.02 25); border-radius: 9px;
    background: #fff; text-align: left; text-decoration: none; color: inherit;
}

.mh-attention__count {
    width: 30px; height: 30px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 800; flex-shrink: 0;
}

/* Patient safety banner */
.mh-safety-banner {
    background: oklch(97% 0.03 40);
    border: 1px solid oklch(85% 0.08 40);
    border-radius: var(--mh-radius);
    padding: 12px 16px;
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    font-size: 12.5px;
}

/* ----------------------------------------------------------------- tables */

.mh-table { width: 100%; margin: 0; font-size: 13px; }

.mh-table thead th {
    font-size: 11px; font-weight: 700; letter-spacing: .3px;
    color: var(--mh-muted); text-transform: uppercase;
    background: oklch(98% 0.003 255);
    border-bottom: 1px solid var(--mh-border);
    padding: 10px 14px; white-space: nowrap;
}

.mh-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--mh-border-soft);
    vertical-align: middle;
}

.mh-table tbody tr:last-child td { border-bottom: 0; }
.mh-table tbody tr.is-clickable:hover { background: oklch(98% 0.004 255); cursor: pointer; }
.mh-table td:first-child, .mh-table th:first-child { font-weight: 600; }

.mh-pill {
    display: inline-block;
    font-size: 10.5px; font-weight: 700;
    padding: 3px 9px; border-radius: 6px;
    white-space: nowrap;
}

.mh-empty { padding: 36px 16px; text-align: center; color: var(--mh-muted); font-size: 13px; }
.mh-empty__icon { font-size: 28px; display: block; margin-bottom: 8px; opacity: .5; }

/* ------------------------------------------------------------------ forms */

.form-label { font-size: 12px; font-weight: 600; color: oklch(40% 0.01 255); margin-bottom: 5px; }
.form-control, .form-select { font-size: 13.5px; border-color: var(--mh-border); border-radius: 8px; padding: 9px 10px; }
.form-control:focus, .form-select:focus { border-color: var(--mh-accent); box-shadow: 0 0 0 .2rem color-mix(in oklch, var(--mh-accent) 18%, transparent); }
.form-control.is-invalid,
.form-select.is-invalid,
.was-validated .form-control:invalid,
.was-validated .form-select:invalid {
    border-color: var(--mh-danger) !important;
    background-image: none;
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--mh-danger) 15%, transparent);
}
/* Bootstrap widens an invalid field's right padding for its error icon. The icon is not
   shown here, so the padding stays as it was — otherwise a date field's text and calendar
   button jump sideways the moment a validation message appears. */
.form-control.is-invalid,
.was-validated .form-control:invalid { padding-right: 10px; }

/* The dropdown arrow is the select's background image; an invalid select keeps it. */
.form-select.is-invalid,
.was-validated .form-select:invalid {
    background-image: var(--bs-form-select-bg-img) !important;
    padding-right: 2.25rem;
}
.invalid-feedback {
    display: block;
    margin-top: 6px;
    color: var(--mh-danger);
    font-size: 11.5px;
}

.btn { font-size: 13.5px; border-radius: 8px; font-weight: 600; }
.btn-sm { font-size: 12px; padding: .3rem .6rem; }

.btn-accent          {
    background: var(--mh-accent); border-color: var(--mh-accent); color: #fff; font-weight: 700;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.btn-accent:hover,
.btn-accent:focus-visible {
    background: color-mix(in srgb, var(--mh-accent) 82%, #000 18%);
    border-color: color-mix(in srgb, var(--mh-accent) 82%, #000 18%);
    color: #fff;
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--mh-accent) 25%, transparent);
    transform: translateY(-1px);
}
.btn-accent:active { transform: translateY(0); }
.btn-outline-accent  { border-color: var(--mh-border); color: oklch(40% 0.01 255); background: #fff; }
.btn-outline-accent:hover { border-color: var(--mh-accent); color: var(--mh-accent); }

/* Timeline used on task detail */
.mh-timeline        { list-style: none; margin: 0; padding: 0; }
.mh-timeline li     { display: flex; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--mh-border-soft); }
.mh-timeline li:last-child { border-bottom: 0; }
.mh-timeline__dot   { width: 7px; height: 7px; border-radius: 50%; background: var(--mh-accent); flex-shrink: 0; margin-top: 6px; }

/* ------------------------------------------------------------- responsive */

.mh-sidebar-toggle { display: none; }

@media (max-width: 991.98px) {
    .mh-shell { flex-direction: column; }

    /* Sidebar becomes a slide-in drawer */
    .mh-sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: 1045;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 0 0 40px rgba(0,0,0,.3);
    }

    .mh-sidebar.is-open   { transform: translateX(0); }
    .mh-sidebar-toggle    { display: inline-flex; }
    .mh-backdrop          { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1040; }
    .mh-header            { padding: 10px 14px; }
    .mh-content           { padding: 14px; gap: 14px; }
}

@media (max-width: 767.98px) {
    .mh-page-title { font-size: 19px; }
    .mh-card__body { padding: 14px; }
    .mh-kpi        { padding: 13px; }
    .mh-kpi__value { font-size: 21px; }

    /* Tables restack as labelled rows so nothing is lost off-screen */
    .mh-table--stack thead { display: none; }
    .mh-table--stack tbody tr {
        display: block;
        border: 1px solid var(--mh-border);
        border-radius: 10px;
        padding: 10px 12px;
        margin-bottom: 10px;
        background: #fff;
    }
    .mh-table--stack tbody td {
        display: flex; justify-content: space-between; gap: 14px;
        padding: 5px 0; border: 0; text-align: right;
    }
    .mh-table--stack tbody td::before {
        content: attr(data-label);
        font-size: 10.5px; font-weight: 700; letter-spacing: .3px;
        color: var(--mh-muted); text-transform: uppercase;
        text-align: left; flex-shrink: 0;
    }
    .mh-table--stack tbody td:first-child { font-size: 14px; font-weight: 700; }
    /* A cell's content may shrink and wrap beside its label, never push the card wider. */
    .mh-table--stack tbody td > * { min-width: 0; max-width: 100%; }
    .mh-table--stack tbody td { overflow-wrap: anywhere; }
    .mh-table--stack tbody td > :not(:only-child) { flex-shrink: 1; }
}

/*
 * Adaptive tables (public/js/app.js, "adaptive tables"): a table that does not
 * fit its card at the current width — a phone, a tablet, a narrow column on a
 * desktop — is given .is-stacked and restacks as labelled rows, exactly as on
 * a phone. A table that fits is left as a table.
 */
.mh-table.is-stacked thead { display: none; }
.mh-table.is-stacked tbody tr {
    display: block;
    border: 1px solid var(--mh-border);
    border-radius: 10px;
    padding: 10px 12px;
    margin: 0 10px 10px;
    background: #fff;
}
.mh-table.is-stacked tbody tr:first-child { margin-top: 10px; }
.mh-table.is-stacked tbody td {
    display: flex; justify-content: space-between; gap: 14px;
    padding: 5px 0; border: 0; text-align: right;
    overflow-wrap: anywhere;
}
.mh-table.is-stacked tbody td::before {
    content: attr(data-label);
    font-size: 10.5px; font-weight: 700; letter-spacing: .3px;
    color: var(--mh-muted); text-transform: uppercase;
    text-align: left; flex-shrink: 0; max-width: 45%;
}
.mh-table.is-stacked tbody td[data-label=""]::before { display: none; }
.mh-table.is-stacked tbody td[data-label=""] { justify-content: flex-start; text-align: left; }
.mh-table.is-stacked tbody td > * { min-width: 0; max-width: 100%; }
.mh-table.is-stacked tbody td:first-child { font-size: 14px; font-weight: 700; }
.mh-table.is-stacked .mh-pill { white-space: normal; }
/* A long risk state or missed-visit list wraps inside a My Mothers card instead of running out of it. */
[data-mother-card] .mh-pill { white-space: normal; max-width: 100%; }
.mh-table.is-stacked [data-priority] { display: flex !important; }

/* Long status pills wrap on a phone instead of pushing the page sideways. */
.mh-pill { max-width: 100%; }
@media (max-width: 575.98px) {
    .mh-pill { white-space: normal; overflow-wrap: anywhere; }
}

/* ------------------------------------------------- responsive registers */

/*
 * Clinical priority, applied to columns.
 *
 * A maternity register carries eight to ten columns, and on a tablet at the
 * bedside — which is where it is actually read — they do not fit. The two bad
 * answers are a horizontal scrollbar, which hides the column that matters
 * behind the ones that do not, and a fixed truncation nobody is told about.
 *
 * So every column declares what it is for: priority 1 is the identity and the
 * finding a midwife is triaging on and never leaves the screen; 2 is clinical
 * context; 3 is provenance — who recorded it, when, under which reference.
 * Narrow viewports drop 3 first, then 2, and the register says which ones it
 * dropped rather than letting them vanish. Below the stacking breakpoint
 * nothing is dropped at all, because the rows restack and everything fits.
 */
@media (min-width: 768px) and (max-width: 1399.98px) {
    .mh-table--priority [data-priority="3"] { display: none; }
}

@media (min-width: 768px) and (max-width: 1099.98px) {
    .mh-table--priority [data-priority="2"] { display: none; }
}

.mh-dropped {
    display: none;
    align-items: baseline;
    gap: 6px;
    padding: 7px 14px;
    border-top: 1px dashed var(--mh-border);
    background: oklch(98.5% 0.003 255);
    font-size: 11.5px;
    color: var(--mh-muted);
}

.mh-dropped.is-visible { display: flex; }
.mh-dropped__label { font-weight: 700; text-transform: uppercase; letter-spacing: .3px; font-size: 10.5px; }
.mh-dropped__names { font-weight: 600; color: oklch(40% 0.01 255); }

@media print {
    /* Paper is wide. Nothing is dropped, and the notice is not part of the record. */
    .mh-table--priority [data-priority] { display: table-cell !important; }
    .mh-dropped { display: none !important; }
}

@media print {
    .mh-sidebar, .mh-header, .mh-no-print, .btn { display: none !important; }
    .mh-content { padding: 0; }
    .mh-card { border: 0; }
}

/* --------------------------------------------------- maternity pathway */

/*
 * The episode chain. Reads left to right on a desk and top to bottom at the
 * bedside, because a midwife holding a tablet in one hand should not have to
 * scroll sideways to find out whether the birth was documented.
 */
.mh-chain { display: flex; flex-wrap: wrap; gap: 8px; }

.mh-chain__step {
    flex: 1 1 150px;
    display: flex; align-items: flex-start; gap: 8px;
    padding: 9px 11px;
    border: 1px solid var(--mh-border);
    border-left: 3px solid var(--mh-border);
    border-radius: 9px;
    background: #fff;
    text-decoration: none; color: inherit;
    min-width: 0;
}

.mh-chain__step:hover { border-color: var(--mh-accent); }
.mh-chain__step--done     { border-left-color: var(--mh-success); }
.mh-chain__step--current  { border-left-color: var(--mh-warning); background: oklch(99% 0.02 90); }
.mh-chain__step--declined { border-left-color: var(--mh-danger); }

.mh-chain__mark  { font-size: 13px; font-weight: 700; line-height: 1.3; flex-shrink: 0; }
.mh-chain__body  { display: flex; flex-direction: column; min-width: 0; }
.mh-chain__label { font-size: 12px; font-weight: 700; }
.mh-chain__detail {
    font-size: 11px; color: var(--mh-muted);
    overflow: hidden; text-overflow: ellipsis;
}

@media (max-width: 575.98px) {
    .mh-chain__step { flex: 1 1 100%; }
}

/* Header search: the keyboard-highlighted result, and the live-update toast (public/js/live.js). */
.mh-search-option.is-active,
.mh-search-option:hover { background: var(--mh-accent-soft); }
.mh-live-toast {
    position: fixed; right: 16px; bottom: 16px; z-index: 1090; max-width: min(420px, calc(100vw - 32px));
    display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px;
    background: #fff; border: 1px solid var(--mh-border-soft); box-shadow: 0 6px 24px rgba(0,0,0,.12); font-size: 13px;
}
.mh-live-toast[hidden] { display: none; }
.mh-live-changed { outline: 2px solid var(--mh-accent); outline-offset: 2px; transition: outline-color 1.5s; }

/* Header alert feed: never wider than the screen, and long alerts wrap instead of being cut off. */
.mh-alerts-menu {
    width: 330px; max-width: calc(100vw - 24px);
    max-height: min(380px, 70vh); overflow-y: auto; overflow-x: hidden;
}
.mh-alerts-menu__text { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
@media (max-width: 575.98px) {
    /* On a phone the panel spans the screen under the header, whatever Popper computes. */
    .mh-alerts-menu.show {
        position: fixed !important; inset: 60px 12px auto 12px !important;
        transform: none !important; width: auto; max-width: none;
    }
}

/* Doctor dashboard "Decisions Due": one row per decision that wraps rather than overflows —
   what is asked, then who, then the owner and the action, which drop to a second line when space runs out. */
.mh-decision {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
    border-left: 4px solid var(--tone, var(--mh-border)); 
}
.mh-decision__what  { flex: 1 1 280px; min-width: 0; overflow-wrap: anywhere; }
.mh-decision__who   { flex: 0 1 220px; min-width: 0; }
.mh-decision__owner { flex: 0 1 auto; min-width: 0; max-width: 100%; }
.mh-decision > form, .mh-decision > .btn { flex: 0 0 auto; margin-left: auto; }
@media (max-width: 575.98px) {
    .mh-decision__who { flex-basis: 100%; }
}

/* Record dialog: each field keeps one line for its validation message whether or not one is
   showing, so validating never shifts the form (or a native date picker anchored to a field). */
.mh-record-body .invalid-feedback { min-height: 1.4em; margin-top: 3px; line-height: 1.4; }

/* A grid (role × portal) stays a grid and scrolls; its first column stays put so each row keeps its name. */
.mh-table--matrix th:first-child,
.mh-table--matrix td:first-child { position: sticky; left: 0; z-index: 1; background: var(--mh-surface); box-shadow: 1px 0 0 var(--mh-border-soft); }
.mh-table--matrix thead th:first-child { background: oklch(98% 0.003 255); }

/*
 * Handover is read at shift change on the tablet the midwife is carrying, so
 * it never drops a column ("not shown at this width"). Below desktop width
 * every row becomes a stacked card carrying every field — SBAR, Escalate If,
 * carried-forward items and sign-off included.
 */
@media (max-width: 1199.98px) {
    .mh-table--handover thead { display: none; }
    .mh-table--handover, .mh-table--handover tbody { display: block; width: 100%; }
    .mh-table--handover tbody tr {
        display: block;
        border: 1px solid var(--mh-border);
        border-radius: 10px;
        padding: 10px 12px;
        margin: 10px;
        background: #fff;
    }
    .mh-table--handover tbody td {
        display: flex !important; justify-content: space-between; gap: 14px;
        padding: 5px 0; border: 0; text-align: right; overflow-wrap: anywhere;
    }
    .mh-table--handover tbody td::before {
        content: attr(data-label);
        font-size: 10.5px; font-weight: 700; letter-spacing: .3px;
        color: var(--mh-muted); text-transform: uppercase;
        text-align: left; flex-shrink: 0; max-width: 45%;
    }
    .mh-table--handover tbody td > * { min-width: 0; max-width: 100%; }
    .mh-table--handover tbody td:first-child { font-size: 14px; font-weight: 700; }
    .mh-table--handover tbody td[colspan] { display: block !important; text-align: left; }
}

/* In a stacked row, a value too wide to sit beside its label drops beneath it instead of overflowing the card. */
.mh-table.is-stacked tbody td { flex-wrap: wrap; }
.mh-table.is-stacked tbody td > * { flex-shrink: 1; }
.mh-table.is-stacked .btn.text-nowrap { white-space: normal; }
@media (max-width: 767.98px) {
    .mh-table--stack tbody td { flex-wrap: wrap; }
    .mh-table--stack .btn.text-nowrap { white-space: normal; }
}
/* Stacked, the table is a plain block at its card's width; as a table it would still size to its widest content. */
.mh-table.is-stacked, .mh-table.is-stacked tbody { display: block; width: 100%; }
@media (max-width: 767.98px) {
    .mh-table--stack, .mh-table--stack tbody { display: block; width: 100%; }
}

/* Phones: the header search gets its own full-width row under the menu, alerts and profile. */
@media (max-width: 575.98px) {
    .mh-header { flex-wrap: wrap; row-gap: 8px; }
    .mh-header [data-header-search] { order: 10; flex: 1 1 100%; max-width: none !important; }
    .mh-header > .dropdown { margin-left: auto; }
    .mh-header > .dropdown + .dropdown { margin-left: 0; }
}
