/* Min Lyd design system. Brand roles are shared by patient and clinician. */

:root {
    --ml-teal: var(--ml-action);
    --ml-teal-action: var(--ml-action);
    --ml-teal-deep: var(--ml-action-hover);
    --ml-teal-soft: var(--ml-selected);
    --ml-teal-ring: var(--ml-selected);
    --ml-teal-text: var(--ml-on-selected);
    --ml-indigo: var(--ml-secondary);
    --ml-indigo-deep: var(--ml-secondary);
    --ml-indigo-soft: var(--ml-secondary-soft);
    --ml-indigo-ring: var(--ml-secondary-soft);
    --ml-indigo-text: var(--ml-secondary);
    --ml-gradient: var(--ml-action);
    --ml-gradient-soft: var(--ml-selected);
    --s-accent: var(--ml-action);
    --s-accent-hover: var(--ml-action-hover);
    --s-accent-soft: var(--ml-selected);
    --s-accent-ring: var(--ml-selected);
    --s-accent-text: var(--ml-on-selected);
    --s-red: var(--ml-error);
    --s-red-soft: var(--ml-error-bg);
    --s-red-ring: var(--ml-error-bg);
    --s-green: var(--ml-success);
    --s-green-soft: var(--ml-success-bg);
    --s-green-text: var(--ml-success);
    --s-orange: var(--ml-warning);
    --s-orange-soft: var(--ml-warning-bg);
    --s-orange-text: var(--ml-warning);
    --s-purple: var(--ml-secondary);
    --s-nav: var(--ml-secondary);
    --s-nav-soft: var(--ml-secondary-soft);
    --s-text: var(--ml-text);
    --s-text-secondary: var(--ml-text-secondary);
    --s-text-tertiary: var(--ml-text-secondary);
    --s-bg: var(--ml-background);
    --s-surface: var(--ml-surface);
    --s-surface-2: var(--ml-background);
    --s-border: var(--ml-divider);
    --s-border-light: var(--ml-border);
    --s-hairline: var(--ml-divider);

    /* ---- Radius ---- */
    --s-radius-sm: var(--ml-radius-sm);
    --s-radius:    var(--ml-radius-control);
    --s-radius-lg: var(--ml-radius-card);
    --s-radius-xl: var(--ml-radius-lg);
    --s-pill:      var(--ml-radius-pill);

    /* ---- Shadows (two-stop, diffused) ---- */
    --s-shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 0.5px 1px rgba(0,0,0,0.03);
    --s-shadow:    0 2px 8px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.03);
    --s-shadow-lg: 0 8px 28px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
    --s-shadow-tabbar: 0 -0.5px 0 var(--s-hairline);

    /* ---- Motion ---- */
    --s-transition: var(--ml-transition);
    --s-spring:     var(--ml-spring);

    /* ---- Type ---- */
    --s-font: var(--ml-font);

    /* App column widths */
    --ml-col-phone:  520px;
    --ml-col-tablet: 760px;
    --ml-col-desktop: 1440px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ──────────────────────────────────────────────────────────────
   Reset & base
   ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--s-font);
    color: var(--s-text);
    background: var(--s-bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-size: var(--ml-type-body);
    letter-spacing: 0;
    line-height: var(--ml-line-height);
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img, svg { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--ml-focus); outline-offset: 3px; border-radius: 6px; box-shadow: 0 0 0 3px var(--ml-focus-gap); }
.ml-card :focus-visible, .ml-list :focus-visible { outline-offset: -3px; }
::selection { background: var(--s-accent-soft); }
[hidden] { display: none !important; }

.ml-sr-only {
    position: absolute !important;
    width: 1px !important; height: 1px !important;
    padding: 0 !important; margin: -1px !important;
    overflow: hidden !important; clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important; border: 0 !important;
}
.ml-skip-link {
    position: fixed; top: 8px; left: 8px; z-index: 2000;
    padding: 12px 16px; border-radius: 10px;
    background: var(--s-surface); color: var(--s-text); box-shadow: var(--s-shadow-lg);
    transform: translateY(-160%);
}
.ml-skip-link:focus { transform: translateY(0); }

/* Persistent, non-destructive connectivity feedback. A network loss must never
   silently discard a form or make a stale status look current. */
.ml-connectivity {
    position: sticky;
    top: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 12px 10px;
    padding: 12px 14px;
    border: 2px solid var(--s-orange);
    border-radius: var(--s-radius);
    background: var(--s-orange-soft);
    color: var(--s-text);
    box-shadow: var(--s-shadow-sm);
}
.ml-connectivity__icon {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    place-items: center;
    border-radius: 10px;
    background: var(--s-surface);
    color: var(--s-orange-text);
}
.ml-connectivity__body { flex: 1; min-width: 0; }
.ml-connectivity__body strong { display: block; font-size: .9375rem; }
.ml-connectivity__body span { display: block; color: var(--s-text-secondary); font-size: var(--ml-type-supporting); }
.ml-connectivity .ml-btn { flex: 0 0 auto; }

/* ──────────────────────────────────────────────────────────────
   App shell — centred "device" column. On desktop it reads as the
   mobile app; on a phone it's full-bleed. This is what makes the
   prototype demo as the future iOS/Android app.
   ────────────────────────────────────────────────────────────── */
.ml-app {
    position: relative;
    width: 100%;
    max-width: var(--ml-col-phone);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    background: var(--s-bg);
    display: flex;
    min-width: 0;
    overflow-x: clip;
    flex-direction: column;
}
.ml-app-frame { width: 100%; max-width: 100%; overflow-x: clip; }
.mode-clinician .ml-app { max-width: var(--ml-col-tablet); }
.ml-desktop-sidebar { display: none; }

/* Desktop: float the column with soft shadow so it reads as a device. */
@media (min-width: 800px) {
    body { background: var(--s-bg); padding: 24px 0; }
    .ml-app {
        min-height: calc(100vh - 48px);
        border-radius: 28px;
        box-shadow: var(--s-shadow-lg);
        overflow: hidden;
    }
}

/* The clinical workspace becomes a true desktop application at wide widths.
   Patient pages retain the compact, app-like presentation above. */
@media (min-width: 1024px) {
    body.mode-clinician { padding: 20px; background: var(--s-bg); }
    .mode-clinician .ml-app-frame {
        display: grid;
        grid-template-columns: 264px minmax(0, 1fr);
        width: min(100%, var(--ml-col-desktop));
        min-height: calc(100vh - 40px);
        min-height: calc(100dvh - 40px);
        margin: 0 auto;
        overflow: hidden;
        border: 1px solid var(--s-border);
        border-radius: 24px;
        background: var(--s-bg);
        box-shadow: var(--s-shadow-lg);
    }
    .mode-clinician .ml-app {
        max-width: none;
        min-width: 0;
        min-height: 0;
        border-radius: 0;
        box-shadow: none;
    }
    .mode-clinician .ml-topbar:not(.ml-topbar--bordered) { display: none; }
    .mode-clinician .ml-content {
        padding: 28px clamp(28px, 4vw, 56px) 48px;
    }
    .mode-clinician .ml-tabbar { display: none; }

    .ml-desktop-sidebar {
        display: flex;
        min-width: 0;
        padding: 24px 18px 18px;
        flex-direction: column;
        border-right: 1px solid var(--s-border);
        background: var(--s-surface);
    }
    .ml-desktop-brand {
        display: flex;
        min-height: 52px;
        align-items: center;
        gap: 11px;
        padding: 4px 8px 16px;
    }
    .ml-desktop-brand img { border-radius: 9px; }
    .ml-desktop-brand span, .ml-desktop-profile > span:last-child { display: grid; min-width: 0; }
    .ml-desktop-brand b { font-size: 1.0625rem; letter-spacing: -.02em; }
    .ml-desktop-brand small, .ml-desktop-profile small { color: var(--s-text-secondary); font-size: var(--ml-type-caption); }
    .ml-desktop-nav { display: grid; gap: 4px; margin-top: 14px; }
    .ml-desktop-nav__link,
    .ml-desktop-sidebar__tools a {
        display: grid;
        grid-template-columns: 24px minmax(0, 1fr) auto;
        min-height: 46px;
        align-items: center;
        gap: 10px;
        padding: 8px 11px;
        border: 1px solid transparent;
        border-radius: 10px;
        color: var(--s-text-secondary);
        font-weight: 600;
    }
    .ml-desktop-nav__link:hover,
    .ml-desktop-sidebar__tools a:hover { background: var(--s-surface-2); color: var(--s-text); }
    .ml-desktop-nav__link--active {
        border-color: var(--s-accent-text);
        background: var(--s-accent-soft);
        color: var(--s-accent-text);
    }
    .ml-desktop-nav__link i,
    .ml-desktop-sidebar__tools i { text-align: center; }
    .ml-desktop-nav__count {
        min-width: 24px;
        padding: 2px 7px;
        border-radius: var(--s-pill);
        background: var(--s-red);
        color: var(--ml-on-error);
        font-size: .75rem;
        text-align: center;
    }
    .ml-desktop-sidebar__tools {
        display: grid;
        gap: 2px;
        margin-top: 26px;
    }
    .ml-desktop-sidebar__tools p {
        margin: 0;
        padding: 0 11px 6px;
        color: var(--s-text-secondary);
        font-size: var(--ml-type-caption);
        font-weight: 700;
        letter-spacing: .06em;
        text-transform: uppercase;
    }
    .ml-desktop-sidebar__tools a { min-height: var(--ml-target-min); font-size: .875rem; font-weight: 500; }
    .ml-desktop-profile {
        display: flex;
        min-height: 58px;
        align-items: center;
        gap: 10px;
        margin-top: auto;
        padding: 9px;
        border: 1px solid var(--s-border-light);
        border-radius: 12px;
        background: var(--s-surface-2);
    }
    .ml-desktop-profile b { overflow: hidden; font-size: .8125rem; text-overflow: ellipsis; white-space: nowrap; }
}

/* Scroll region. Bottom padding clears the tab bar. */
.ml-content {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0 20px calc(96px + env(safe-area-inset-bottom, 0px));
}
.ml-content--flush { padding-left: 0; padding-right: 0; }
.ml-content--no-tabbar { padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px)); }
.ml-environment-banner {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 12px 10px;
    padding: 9px 12px;
    border: 1px solid var(--s-orange);
    border-inline-start-width: 3px;
    border-radius: 12px;
    background: var(--s-orange-soft);
    color: var(--s-text);
    font-size: 0.8125rem;
    line-height: 1.4;
}
.ml-environment-banner i { color: var(--s-orange-text); margin-top: 2px; }

/* ──────────────────────────────────────────────────────────────
   Top bar — iOS large-title. The big title scrolls with content;
   a compact sticky bar appears for back/actions.
   ────────────────────────────────────────────────────────────── */
.ml-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 52px;
    padding: max(10px, env(safe-area-inset-top, 0px)) 16px 10px;
    background: var(--ml-nav-glass);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.ml-topbar--bordered { box-shadow: 0 0.5px 0 var(--s-hairline); }
.ml-topbar__back {
    display: inline-flex; align-items: center; gap: 3px;
    color: var(--s-accent-text);
    font-size: 1.0625rem; font-weight: 400;
    background: none; border: none; cursor: pointer; padding: 4px 6px 4px 0;
    min-height: 44px;
}
.ml-topbar__back i { font-size: 1.0625rem; }
.ml-topbar__title {
    font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.02em;
    flex: 1; text-align: center;
    min-width: 0; line-height: 1.2; overflow-wrap: anywhere;
}
.ml-topbar__spacer { flex: 1; }
.ml-topbar__action {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    color: var(--s-accent-text);
    font-size: 1.0625rem; font-weight: 400;
    background: none; border: none; cursor: pointer; padding: 4px 2px;
    min-width: 44px; min-height: 44px;
}
.ml-topbar__action--icon { font-size: 1.1875rem; }
.ml-topbar > a:first-child,
.ml-topbar .ml-brand-home,
.ml-topbar a.ml-avatar--sm {
    min-width: var(--ml-target-min);
    min-height: var(--ml-target-min);
    justify-content: center;
}
.ml-topbar a.ml-avatar--sm { width: var(--ml-target-min); height: var(--ml-target-min); }

/* Large title block (lives at top of .ml-content) */
.ml-large-title {
    padding: 4px 0 12px;
}
.ml-large-title h1 {
    margin: 0;
    font-size: 2.125rem; font-weight: 700; letter-spacing: -0.03em;
    line-height: var(--ml-heading-line-height);
}
.ml-large-title p {
    margin: 4px 0 0;
    color: var(--s-text-secondary);
    font-size: 1rem;
    line-height: 1.5;
}
.ml-large-title__row {
    display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px;
}

/* ──────────────────────────────────────────────────────────────
   Bottom tab bar — frosted glass, role-aware accent.
   ────────────────────────────────────────────────────────────── */
.ml-tabbar {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    display: flex;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--ml-surface-glass);
    backdrop-filter: saturate(180%) blur(22px);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    box-shadow: var(--s-shadow-tabbar);
}
.ml-tab {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px; min-height: 58px;
    color: var(--s-text-tertiary);
    font-size: var(--ml-type-caption); font-weight: 600; letter-spacing: 0;
    cursor: pointer;
    transition: color 160ms ease;
}
.ml-tab__icon { font-size: 1.375rem; line-height: 1; height: 26px; display: grid; place-items: center; }
.ml-tab__label { letter-spacing: -0.01em; text-align: center; overflow-wrap: anywhere; }
.ml-tab--active { color: var(--s-accent-text); }
.ml-tab:active { opacity: 0.6; }

/* ──────────────────────────────────────────────────────────────
   Sections & grouped lists (iOS Settings idiom)
   ────────────────────────────────────────────────────────────── */
.ml-section { margin-top: 24px; }
.ml-section:first-child { margin-top: 8px; }
.ml-section__header {
    display: flex; align-items: baseline; justify-content: space-between;
    flex-wrap: wrap; gap: 4px 12px; padding: 0 4px 8px;
}
.ml-section__title {
    font-size: var(--ml-type-caption); font-weight: 700;
    letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--s-text-secondary); margin: 0;
}
.ml-section__action {
    font-size: 0.8125rem; font-weight: 500; color: var(--s-accent-text);
    background: none; border: none; cursor: pointer;
    min-height: 44px; padding: 8px;
}

/* Card */
.ml-card {
    background: var(--s-surface);
    border-radius: var(--s-radius);
    border: 1px solid var(--s-border);
    box-shadow: var(--s-shadow-sm);
    overflow: hidden;
}
.ml-card--lg { border-radius: var(--s-radius-lg); }
.ml-card--pad { padding: 16px; }
.ml-card--pad-lg { padding: 20px; }
.ml-card__header {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
    padding: 14px 16px;
}
.ml-card__title {
    font-size: 1rem; font-weight: 650; letter-spacing: -0.01em;
    display: flex; align-items: center; gap: 8px;
}
.ml-card__title i { color: var(--s-text-tertiary); font-size: 0.875rem; }
.ml-card__divider { height: 1px; background: var(--s-hairline); margin: 0 16px; }

/* Grouped list rows */
.ml-list { background: var(--s-surface); border-radius: var(--s-radius); overflow: hidden; box-shadow: var(--s-shadow-sm); }
.ml-list { border: 1px solid var(--s-border); }
.ml-list--plain { border: 0; box-shadow: none; background: transparent; }
.ml-row {
    display: flex; align-items: center; gap: 12px;
    min-height: 52px;
    padding: 13px 16px;
    position: relative;
    background: var(--s-surface);
    transition: background 140ms ease;
    width: 100%; border: none; text-align: left; cursor: pointer;
    color: inherit; font-family: inherit; font-size: inherit;
}
a.ml-row, button.ml-row { cursor: pointer; }
.ml-row:not(:last-child)::after {
    content: ''; position: absolute; left: 16px; right: 0; bottom: 0;
    height: 1px; background: var(--s-hairline);
}
.ml-row--inset:not(:last-child)::after { left: 52px; }
/* When a list is filtered, JS marks the last visible row so its hairline hides. */
.ml-row--last-visible::after { display: none !important; }
.ml-row:active { background: var(--s-surface-2); }
.ml-row--static { cursor: default; }
.ml-row--static:active { background: var(--s-surface); }
.ml-row__leading {
    width: 30px; height: 30px; border-radius: 8px;
    display: grid; place-items: center;
    background: var(--s-accent-soft); color: var(--s-accent-text);
    font-size: 0.875rem; flex-shrink: 0;
}
.ml-row__leading--green  { background: var(--s-green-soft);  color: var(--s-green-text); }
.ml-row__leading--orange { background: var(--s-orange-soft); color: var(--s-orange-text); }
.ml-row__leading--red    { background: var(--s-red-soft);    color: var(--s-red); }
.ml-row__leading--gray   { background: var(--s-surface-2); color: var(--s-text-secondary); }
.ml-row__leading--lg     { width: 40px; height: 40px; border-radius: 10px; font-size: 1.0625rem; }
.ml-row__body { flex: 1; min-width: 0; }
.ml-row__title { font-size: 0.9375rem; font-weight: 500; overflow-wrap: anywhere; }
.ml-row__subtitle { font-size: var(--ml-type-supporting); color: var(--s-text-secondary); margin-top: 2px; line-height: 1.45; }
.ml-row__value { max-width: 52%; font-size: 0.9375rem; color: var(--s-text-secondary); overflow-wrap: anywhere; text-align: end; }
.ml-row__chevron { color: var(--s-text-tertiary); font-size: 0.8125rem; flex-shrink: 0; }
.ml-row__trailing { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ──────────────────────────────────────────────────────────────
   Stat tiles
   ────────────────────────────────────────────────────────────── */
.ml-stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ml-stat-grid--3 { grid-template-columns: repeat(3, 1fr); }
.ml-stat {
    background: var(--s-surface); border-radius: var(--s-radius);
    padding: 16px; border: 1px solid var(--s-border); box-shadow: var(--s-shadow-sm);
    transition: border-color var(--s-transition), box-shadow var(--s-transition), transform var(--s-transition);
}
.ml-stat__label { font-size: var(--ml-type-caption); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--s-text-tertiary); }
.ml-stat__value { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; line-height: 1; }
.ml-stat__value--sm { font-size: 1.25rem; }
.ml-stat__meta { font-size: 0.8125rem; color: var(--s-text-secondary); margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.ml-stat__meta i { font-size: 0.6875rem; }
.ml-stat--accent { background: var(--ml-gradient); color: var(--ml-on-action); }
.ml-stat--accent .ml-stat__label, .ml-stat--accent .ml-stat__meta { color: var(--ml-on-action); }

@media (hover: hover) and (pointer: fine) {
    a.ml-stat:hover { transform: translateY(-1px); box-shadow: var(--s-shadow); }
    a.ml-row:hover, button.ml-row:hover { background: var(--s-surface-2); }
    .ml-desktop-profile:hover { border-color: var(--s-accent); background: var(--s-accent-soft); }
}

/* ──────────────────────────────────────────────────────────────
   Buttons — pill primary, soft secondary, ghost, danger
   ────────────────────────────────────────────────────────────── */
.ml-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 20px;
    border: 1px solid transparent; border-radius: var(--ml-radius-control);
    font-size: 1rem; font-weight: 600; font-family: var(--s-font);
    letter-spacing: -0.01em; cursor: pointer;
    transition: background var(--s-transition), transform 120ms ease, opacity 160ms ease, box-shadow var(--s-transition);
    -webkit-tap-highlight-color: transparent; min-height: var(--ml-target-min);
}
.ml-btn:active { transform: scale(0.97); }
.ml-btn--primary { background: var(--s-accent); color: var(--ml-on-action); }
.ml-btn--primary:hover { background: var(--s-accent-hover); }
.ml-btn--gradient { background: var(--ml-gradient); color: var(--ml-on-action); }
.ml-btn--gradient:hover { box-shadow: var(--s-shadow); }
.ml-btn--secondary { background: var(--s-accent-soft); color: var(--s-accent-text); }
.ml-btn--secondary:hover { background: var(--s-accent-ring); }
.ml-btn--ghost { background: var(--s-surface); color: var(--s-text); box-shadow: var(--s-shadow-sm); }
.ml-btn--ghost:hover { background: var(--s-surface-2); }
.ml-btn--danger { background: var(--s-red-soft); color: var(--s-red); }
.ml-btn--danger:hover { background: var(--s-red-ring); }
.ml-btn--block { display: flex; width: 100%; }
.ml-btn--lg { padding: 15px 24px; font-size: 1.0625rem; }
.ml-btn--sm { padding: 8px 14px; font-size: 0.875rem; min-height: 44px; }
.ml-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.ml-action-state {
    display: inline-flex;
    align-items: center;
    margin-inline-start: 4px;
    padding: 1px 6px;
    border: 1px solid currentColor;
    border-radius: var(--s-pill);
    font-size: var(--ml-type-caption);
    font-weight: 700;
    line-height: 1.4;
}

/* BankID button — recognisable institutional black with the BankID mark */
.ml-btn--bankid { flex-wrap: wrap; background: #39134C; color: #fff; line-height: 1.25; text-align: center; }
.ml-btn--bankid:hover { background: #2c0f3b; }
.ml-bankid-mark {
    display: inline-flex; align-items: center; gap: 2px;
    font-weight: 800; letter-spacing: -0.02em;
}
.ml-bankid-mark b { color: #fff; }
.ml-bankid-mark span { color: #ECA9FF; }

/* ──────────────────────────────────────────────────────────────
   Badges & chips
   ────────────────────────────────────────────────────────────── */
.ml-badge {
    display: inline-flex; align-items: center; gap: 4px;
    flex-shrink: 0; max-width: 100%;
    padding: 2px 9px; border-radius: var(--s-pill);
    font-size: var(--ml-type-caption); font-weight: 650; letter-spacing: 0;
    background: var(--s-surface-2); color: var(--s-text-secondary);
    text-align: center; overflow-wrap: normal;
}
.ml-badge--accent { background: var(--s-accent-soft); color: var(--s-accent-text); }
.ml-badge--green  { background: var(--s-green-soft);  color: var(--s-green-text); }
.ml-badge--orange { background: var(--s-orange-soft); color: var(--s-orange-text); }
.ml-badge--red    { background: var(--s-red-soft);    color: var(--s-red); }
.ml-badge--nav    { background: var(--s-nav-soft);    color: var(--s-nav); }
.ml-badge--dot::before { content:''; width:6px; height:6px; border-radius:50%; background: currentColor; }

.ml-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: var(--s-pill);
    background: var(--s-surface); color: var(--s-text);
    font-size: 0.875rem; font-weight: 500; box-shadow: var(--s-shadow-sm);
    cursor: pointer; transition: all 140ms ease; border: none; min-height: 44px;
}
.ml-chip--active { background: var(--s-accent); color: var(--ml-on-action); }

/* ──────────────────────────────────────────────────────────────
   Segmented control (iOS)
   ────────────────────────────────────────────────────────────── */
.ml-segmented {
    display: inline-flex; padding: 2px; gap: 2px;
    background: var(--s-surface-2); border-radius: 10px; width: 100%;
}
.ml-segmented__option {
    flex: 1; text-align: center;
    padding: 7px 12px; border-radius: 8px;
    font-size: 0.8125rem; font-weight: 600; color: var(--s-text);
    background: transparent; border: none; cursor: pointer;
    transition: background 200ms ease, box-shadow 200ms ease;
    min-height: 44px;
}
.ml-segmented__option--active { background: var(--s-surface); box-shadow: var(--s-shadow-sm); }

/* ──────────────────────────────────────────────────────────────
   Avatar, hero, misc
   ────────────────────────────────────────────────────────────── */
.ml-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--ml-gradient); color: var(--ml-on-action);
    font-weight: 600; font-size: 1rem; flex-shrink: 0;
}
.ml-avatar--lg { width: 64px; height: 64px; font-size: 1.5rem; }
.ml-avatar--sm { width: 32px; height: 32px; font-size: 0.8125rem; }

.ml-gradient-text {
    color: var(--s-accent-text);
}

.ml-hero-card {
    border-radius: var(--s-radius-lg);
    background: var(--ml-gradient); color: var(--ml-on-action);
    padding: 20px; box-shadow: var(--s-shadow-sm);
}
.ml-hero-card--indigo { background: var(--s-accent-soft); color: var(--s-text); box-shadow: var(--s-shadow-sm); }

.ml-note {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 14px; border-radius: var(--s-radius-sm);
    background: var(--s-accent-soft); color: var(--s-text);
    border: 1px solid var(--s-border);
    font-size: var(--ml-type-supporting); line-height: 1.5;
}
.ml-note i { color: var(--s-accent-text); margin-top: 1px; }
.ml-note--nav { background: var(--s-nav-soft); }
.ml-note--nav i { color: var(--s-nav); }

/* Visible feedback mirrors the screen-reader live region. Informational demo
   messages remain until dismissed so users are never forced to read quickly. */
.ml-feedback {
    position: fixed;
    left: 50%;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    z-index: 1200;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 44px;
    width: min(520px, calc(100% - 24px));
    min-height: 56px;
    align-items: center;
    gap: 10px;
    padding: 9px 8px 9px 12px;
    border: 1px solid var(--s-border-light);
    border-radius: var(--s-radius);
    background: var(--s-surface);
    color: var(--s-text);
    box-shadow: var(--s-shadow-lg);
    opacity: 0;
    transform: translate(-50%, 10px);
    transition: opacity 180ms ease, transform var(--s-transition);
}
.ml-feedback--visible { opacity: 1; transform: translate(-50%, 0); }
.ml-feedback__icon {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 9px;
    background: var(--s-accent-soft);
    color: var(--s-accent-text);
}
.ml-feedback__message { min-width: 0; font-size: var(--ml-type-supporting); line-height: 1.45; }
.ml-feedback__close {
    display: grid;
    width: 44px;
    height: 44px;
    cursor: pointer;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--s-text-secondary);
}
.ml-feedback__close:hover { background: var(--s-surface-2); color: var(--s-text); }
.ml-feedback--success .ml-feedback__icon { background: var(--s-green-soft); color: var(--s-green-text); }
.ml-feedback--error .ml-feedback__icon { background: var(--s-red-soft); color: var(--s-red); }

@media (min-width: 1024px) {
    .ml-feedback { bottom: 24px; }
}

/* Empty state */
.ml-empty { text-align: center; padding: 40px 24px; color: var(--s-text-secondary); }
.ml-empty i { font-size: 2rem; color: var(--s-text-tertiary); margin-bottom: 12px; }
.ml-empty h3 { margin: 0 0 4px; font-size: 1rem; color: var(--s-text); }
.ml-empty p { margin: 0; font-size: 0.9375rem; }

/* Trust and provenance patterns used for health data, device state and
   integrations. Status always has text + icon; colour is supplementary. */
.ml-status-panel {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--s-border);
    border-radius: var(--s-radius-lg);
    background: var(--s-surface);
    box-shadow: var(--s-shadow-sm);
}
.ml-status-panel__icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 12px;
    background: var(--s-accent-soft);
    color: var(--s-accent-text);
    font-size: 1.0625rem;
}
.ml-status-panel--warning .ml-status-panel__icon { background: var(--s-orange-soft); color: var(--s-orange-text); }
.ml-status-panel--success .ml-status-panel__icon { background: var(--s-green-soft); color: var(--s-green-text); }
.ml-status-panel--error .ml-status-panel__icon { background: var(--s-red-soft); color: var(--s-red); }
.ml-status-panel__title { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.3; }
.ml-status-panel__body { margin: 4px 0 0; color: var(--s-text-secondary); font-size: var(--ml-type-supporting); line-height: 1.5; }
.ml-status-panel__action { grid-column: 1 / -1; margin-top: 2px; }
.ml-provenance {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--s-hairline);
    color: var(--s-text-secondary);
    font-size: var(--ml-type-supporting);
}
.ml-provenance span { display: inline-flex; align-items: center; gap: 6px; }
.ml-consent-summary {
    display: grid;
    gap: 0;
    margin: 16px 0;
    border: 1px solid var(--s-border);
    border-radius: var(--s-radius);
    overflow: hidden;
}
.ml-consent-summary > div {
    display: grid;
    grid-template-columns: minmax(92px, .7fr) minmax(0, 1.3fr);
    gap: 12px;
    padding: 11px 12px;
    background: var(--s-surface);
}
.ml-consent-summary > div:not(:last-child) { border-bottom: 1px solid var(--s-hairline); }
.ml-consent-summary dt { color: var(--s-text-secondary); font-size: var(--ml-type-caption); font-weight: 700; }
.ml-consent-summary dd { margin: 0; font-size: var(--ml-type-supporting); font-weight: 600; overflow-wrap: anywhere; }

/* Utility */
.ml-spacer-sm { height: 8px; } .ml-spacer { height: 16px; } .ml-spacer-lg { height: 28px; }
.ml-muted { color: var(--s-text-secondary); }
.ml-tertiary { color: var(--s-text-tertiary); }
.ml-center { text-align: center; }
.ml-stack { display: flex; flex-direction: column; gap: 12px; }
.ml-stack--sm { gap: 8px; }
.ml-row-flex { display: flex; align-items: center; gap: 10px; }
.ml-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ml-between > * { min-width: 0; }
.ml-grow { flex: 1; min-width: 0; }
.ml-mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ──────────────────────────────────────────────────────────────
   Bottom sheet / modal (BankID consent flow lives here)
   ────────────────────────────────────────────────────────────── */
.ml-sheet-backdrop {
    position: fixed; inset: 0; z-index: 1100;
    background: rgba(0,0,0,0.36);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none; transition: opacity var(--s-transition);
}
.ml-sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.ml-sheet {
    position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 100%);
    width: 100%; max-width: var(--ml-col-phone);
    z-index: 1101;
    background: var(--s-surface);
    border-radius: var(--s-radius-xl) var(--s-radius-xl) 0 0;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.18);
    padding: 8px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    transition: transform var(--s-spring);
    max-height: 92vh; overflow-y: auto;
}
.mode-clinician .ml-sheet { max-width: var(--ml-col-tablet); }
.ml-sheet.open { transform: translate(-50%, 0); }
.ml-sheet__handle { width: 36px; height: 5px; border-radius: 980px; background: var(--s-border); margin: 8px auto 16px; }
.ml-sheet__title { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; }
.ml-sheet__sub { color: var(--s-text-secondary); font-size: 0.9375rem; margin-top: 4px; }

/* Consent line items inside the sheet */
.ml-consent-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; }
.ml-consent-item:not(:last-child) { border-bottom: 1px solid var(--s-hairline); }
.ml-consent-item__icon { width: 32px; height: 32px; border-radius: 8px; background: var(--s-accent-soft); color: var(--s-accent-text); display: grid; place-items: center; flex-shrink: 0; }
.ml-consent-item__title { font-weight: 600; font-size: 0.9375rem; }
.ml-consent-item__desc { font-size: var(--ml-type-supporting); color: var(--s-text-secondary); margin-top: 2px; }

/* BankID processing animation */
.ml-bankid-stage { text-align: center; padding: 24px 0 8px; }
.ml-spinner {
    width: 44px; height: 44px; margin: 0 auto 16px;
    border: 3px solid var(--s-accent-soft); border-top-color: var(--s-accent);
    border-radius: 50%; animation: ml-spin 0.8s linear infinite;
}
@keyframes ml-spin { to { transform: rotate(360deg); } }
.ml-check-pop {
    width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 50%;
    background: var(--s-green); color: var(--ml-on-success); display: grid; place-items: center;
    font-size: 1.5rem; animation: ml-pop var(--s-spring);
}
@keyframes ml-pop { 0% { transform: scale(0); opacity: 0; } 60% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }

/* ──────────────────────────────────────────────────────────────
   Timeline (HA history, request status)
   ────────────────────────────────────────────────────────────── */
.ml-timeline { position: relative; padding-left: 28px; }
.ml-timeline__item { position: relative; padding-bottom: 22px; }
.ml-timeline__item:last-child { padding-bottom: 0; }
.ml-timeline__item::before {
    content: ''; position: absolute; left: -20px; top: 4px;
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--s-surface); border: 2.5px solid var(--s-accent);
}
.ml-timeline__item--done::before { background: var(--s-accent); }
.ml-timeline__item--muted::before { border-color: var(--s-border); }
.ml-timeline__item:not(:last-child)::after {
    content: ''; position: absolute; left: -15px; top: 16px; bottom: 0;
    width: 2px; background: var(--s-hairline);
}
.ml-timeline__time { font-size: var(--ml-type-caption); color: var(--s-text-tertiary); font-weight: 650; }
.ml-timeline__title { font-size: 0.9375rem; font-weight: 500; margin-top: 1px; }
.ml-timeline__desc { font-size: var(--ml-type-supporting); color: var(--s-text-secondary); margin-top: 2px; }

/* ──────────────────────────────────────────────────────────────
   Copy-confirm (inline, no toast — per MediVox silent-feedback rule)
   ────────────────────────────────────────────────────────────── */
.ml-copy { min-height: 44px; padding-block: 10px; transition: background 160ms ease, color 160ms ease; }
.ml-copy.copied { background: var(--s-green) !important; color: var(--ml-on-success) !important; }

/* Table-lite for commission / inventory (mobile-true, scroll-x) */
.ml-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.ml-table th { text-align: left; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--s-text-tertiary); font-weight: 600; padding: 8px 12px; }
.ml-table td { padding: 12px; border-top: 1px solid var(--s-hairline); }
.ml-table tr:first-child td { border-top: none; }
.ml-table__scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--s-radius); }

/* Progress bar */
.ml-progress { height: 8px; border-radius: 980px; background: var(--s-border-light); overflow: hidden; }
.ml-progress__fill { height: 100%; border-radius: 980px; background: var(--s-accent); transition: width var(--s-spring); }
.ml-progress__fill--gradient { background: var(--ml-gradient); }

/* Form fields — used inside sheets (add hearing aid, register receiver, edit period). */
.ml-field { margin-bottom: 14px; }
.ml-field:last-child { margin-bottom: 0; }
.ml-field__label { display: block; font-size: var(--ml-type-supporting); font-weight: 650; color: var(--s-text-secondary); margin-bottom: 6px; }
.ml-field__hint { display: block; margin-top: 6px; color: var(--s-text-secondary); font-size: var(--ml-type-supporting); }
.ml-input, .ml-select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--s-border-light); border-radius: 12px;
  background: var(--s-surface); color: var(--s-text); font-family: var(--s-font); font-size: 1rem;
  line-height: 1.3; -webkit-appearance: none; appearance: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.ml-input:is(textarea) { resize: vertical; min-height: 92px; }
.ml-input:focus-visible, .ml-select:focus-visible {
  outline: 3px solid var(--ml-focus);
  border-color: var(--ml-focus);
  box-shadow: 0 0 0 3px var(--ml-focus-gap);
}
.ml-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238A93A3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 38px;
}

.ml-inline-search {
    width: 100%; min-width: 0; min-height: 44px; border: 0; background: transparent;
    color: inherit; font: inherit; padding: 8px 4px;
}
.ml-patient-link {
    display: inline-flex;
    min-height: var(--ml-target-min);
    align-items: center;
    color: var(--s-accent-text);
    text-decoration: underline;
    text-underline-offset: .18em;
}

/* ──────────────────────────────────────────────────────────────
   Patient appointment flow — calendar is an explicitly labelled demo.
   State is always conveyed with text/symbols as well as colour.
   ────────────────────────────────────────────────────────────── */
.ml-booking-upcoming { margin-top: 12px; }
.ml-booking-upcoming__time { color: var(--s-accent-text); font-size: 0.8125rem; font-weight: 700; }
.ml-booking-upcoming__title { margin-top: 3px; font-size: 1.0625rem; font-weight: 700; }
.ml-booking-upcoming p { margin: 5px 0 0; color: var(--s-text-secondary); }
.ml-booking-upcoming .ml-booking-limit {
    margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--s-hairline);
    color: var(--s-text); font-size: 0.875rem;
}

.ml-booking-steps {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px; margin: 0 0 8px; padding: 0; list-style: none;
}
.ml-booking-step {
    min-width: 0; color: var(--s-text-secondary); text-align: center;
    font-size: var(--ml-type-caption); font-weight: 650;
}
.ml-booking-step__number {
    display: grid; place-items: center; width: 32px; height: 32px; margin: 0 auto 5px;
    border: 2px solid var(--s-border-light); border-radius: 50%; background: var(--s-surface);
    color: var(--s-text); font-size: 0.875rem;
}
.ml-booking-step--active { color: var(--s-text); }
.ml-booking-step--active .ml-booking-step__number {
    border-color: var(--s-accent-text); background: var(--s-accent-text);
    box-shadow: inset 0 0 0 2px var(--s-surface);
    color: var(--ml-on-action);
}
.ml-booking-step--complete .ml-booking-step__number { border-color: var(--s-accent-text); color: var(--s-accent-text); }
.ml-booking-step--complete .ml-booking-step__number::after { content: '✓'; }
.ml-booking-step--complete .ml-booking-step__number { font-size: 0; }
.ml-booking-step--complete .ml-booking-step__number::after { font-size: 0.875rem; }
.ml-booking-progress { height: 4px; margin: 0 0 14px; overflow: hidden; border-radius: var(--s-pill); background: var(--s-border); }
.ml-booking-progress > span { display: block; height: 100%; width: 25%; background: var(--s-accent); transition: width var(--s-transition); }
.ml-booking-panel { overflow: visible; }
.ml-booking-title { margin: 0; font-size: 1.375rem; line-height: 1.2; letter-spacing: -0.02em; }
.ml-booking-intro { margin: 7px 0 18px; color: var(--s-text-secondary); }
.ml-booking-fieldset { display: grid; gap: 10px; margin: 0 0 18px; padding: 0; border: 0; }
.ml-booking-choice { position: relative; display: block; cursor: pointer; }
.ml-booking-choice > input {
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}
.ml-booking-choice__body {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
    column-gap: 12px; min-height: 64px; padding: 11px 13px;
    border: 2px solid var(--s-border-light); border-radius: var(--s-radius); background: var(--s-surface);
}
.ml-booking-choice__title { font-weight: 700; }
.ml-booking-choice__detail { grid-column: 1; color: var(--s-text-secondary); font-size: 0.875rem; }
.ml-booking-choice__selected {
    grid-column: 2; grid-row: 1 / span 2; display: none; padding: 3px 8px;
    border: 1px solid currentColor; border-radius: var(--s-pill); color: var(--s-accent-text);
    font-size: var(--ml-type-caption); font-weight: 700;
}
.ml-booking-choice > input:checked + .ml-booking-choice__body {
    border-color: var(--s-accent-text); box-shadow: 0 0 0 1px var(--s-accent-text); background: var(--s-accent-soft);
}
.ml-booking-choice > input:checked + .ml-booking-choice__body .ml-booking-choice__selected { display: inline-flex; }
.ml-booking-choice > input:focus-visible + .ml-booking-choice__body { outline: 3px solid var(--ml-focus); outline-offset: 3px; box-shadow: 0 0 0 3px var(--ml-focus-gap); }
.ml-booking-provider { margin: 0 0 20px; }
.ml-booking-shortcuts { display: grid; grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); gap: 10px; margin-bottom: 16px; }
.ml-booking-shortcuts .ml-btn { min-width: 0; padding-inline: 12px; white-space: normal; }
.ml-booking-shortcuts .ml-btn span { display: block; font-size: var(--ml-type-caption); font-weight: 500; }
.ml-booking-state, .ml-calendar-state {
    min-height: 220px; display: grid; align-content: center; justify-items: center;
    padding: 24px 16px; border: 1px solid var(--s-border-light); border-radius: var(--s-radius);
    background: var(--s-surface-2); text-align: center;
}
.ml-booking-state h3, .ml-calendar-state h3 { margin: 0; font-size: 1.0625rem; }
.ml-booking-state p, .ml-calendar-state p { max-width: 34ch; margin: 6px 0 16px; color: var(--s-text-secondary); }
.ml-booking-state--error, .ml-calendar-state--error { border: 2px solid var(--s-red); background: var(--s-red-soft); }

.ml-calendar { border: 1px solid var(--s-border-light); border-radius: var(--s-radius); overflow: hidden; }
.ml-calendar__header { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; padding: 7px; border-bottom: 1px solid var(--s-hairline); }
.ml-calendar__nav {
    width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--s-accent-soft);
    color: var(--s-accent-text); cursor: pointer; font-size: 1.75rem; line-height: 1;
}
.ml-calendar__nav:disabled { background: transparent; color: var(--s-text-secondary); cursor: not-allowed; opacity: .65; }
.ml-calendar__month { margin: 0; padding-inline: 6px; text-align: center; font-size: 1rem; }
.ml-calendar__grid { width: 100%; table-layout: fixed; border-collapse: collapse; }
.ml-calendar__grid th { height: 36px; color: var(--s-text-secondary); font-size: var(--ml-type-caption); font-weight: 700; }
.ml-calendar__grid abbr { text-decoration: none; }
.ml-calendar__grid td { width: 14.285%; padding: 2px; vertical-align: top; }
.ml-calendar__day {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 1px; width: 100%; min-width: 0; min-height: 54px; padding: 4px 1px;
    border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--s-text);
    cursor: pointer; font: inherit;
}
.ml-calendar__day:disabled { color: var(--s-text-secondary); cursor: not-allowed; }
.ml-calendar__day-number { font-size: 0.875rem; font-weight: 650; }
.ml-calendar__day-state, .ml-calendar__today, .ml-calendar__selected { font-size: 0.5625rem; font-weight: 700; line-height: 1.05; }
.ml-calendar__day-state { color: var(--s-text-secondary); }
.ml-calendar__today { text-decoration: underline; text-underline-offset: 2px; }
.ml-calendar__day--available { border-color: var(--s-accent-text); }
.ml-calendar__day--available .ml-calendar__day-state { color: var(--s-accent-text); text-decoration: underline; }
.ml-calendar__day--booked { border: 2px solid var(--s-text); }
.ml-calendar__day--booked .ml-calendar__day-state { color: var(--s-text); font-weight: 800; }
.ml-calendar__day--blocked { border: 2px dashed var(--s-text-secondary); background: var(--s-surface-2); }
.ml-calendar__day--cancelled { border: 2px dotted var(--s-text-secondary); text-decoration: line-through; }
.ml-calendar__day--selected {
    border: 2px solid var(--s-accent-text); background: var(--s-accent-text); color: var(--ml-on-action);
}
.ml-calendar__day--selected .ml-calendar__day-state,
.ml-calendar__day--selected .ml-calendar__selected { color: var(--ml-on-action); }
.ml-calendar__legend {
    display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 8px 10px 10px; padding: 9px 0 0;
    border-top: 1px solid var(--s-hairline); list-style: none; color: var(--s-text-secondary); font-size: 0.75rem;
}
.ml-calendar__legend-mark { display: inline-grid; width: 17px; height: 17px; place-items: center; border: 1px solid var(--s-border-light); border-radius: 50%; color: var(--s-text); }
.ml-calendar__legend-mark--available { border-color: var(--s-accent-text); color: var(--s-accent-text); }
.ml-calendar__legend-mark--booked { border: 2px solid var(--s-text); color: var(--s-text); }
.ml-calendar__legend-mark--blocked { border: 2px dashed var(--s-text-secondary); border-radius: 3px; }
.ml-calendar__legend-mark--cancelled { border-style: dotted; color: var(--s-red); }
.ml-calendar__legend-mark--selected { background: var(--s-accent-text); color: var(--ml-on-action); }

.ml-booking-times { margin-top: 20px; }
.ml-booking-times h3 { margin: 0; font-size: 1.0625rem; }
.ml-booking-times > p { margin: 4px 0 12px; color: var(--s-text-secondary); }
.ml-time-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ml-time-slot {
    min-width: 0; min-height: 56px; padding: 7px 5px; border: 2px solid var(--s-accent-text);
    border-radius: 10px; background: var(--s-surface); color: var(--s-text); cursor: pointer;
    font: inherit; text-align: center;
}
.ml-time-slot__time { display: block; font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ml-time-slot__label { display: block; margin-top: 2px; font-size: 0.8125rem; font-weight: 700; overflow-wrap: anywhere; }
.ml-time-slot__meta { display: block; margin-top: 2px; color: var(--s-text-secondary); font-size: 0.75rem; overflow-wrap: anywhere; }
.ml-time-slot__state, .ml-time-slot__selected { display: block; color: var(--s-accent-text); font-size: 0.6875rem; font-weight: 700; }
.ml-time-slot--booked { border-style: double; border-width: 3px; border-color: var(--s-text); }
.ml-time-slot--booked .ml-time-slot__state { color: var(--s-text); }
.ml-time-slot--blocked { border-style: dashed; border-color: var(--s-text-secondary); background: var(--s-surface-2); }
.ml-time-slot--blocked .ml-time-slot__state { color: var(--s-text); }
.ml-time-slot--cancelled { border-style: dotted; border-color: var(--s-red); text-decoration: line-through; }
.ml-time-grid--schedule { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ml-time-grid--schedule .ml-time-slot { min-height: 84px; text-align: start; padding: 10px; }
.ml-time-slot--selected { background: var(--s-accent-text); color: var(--ml-on-action); }
.ml-time-slot--selected .ml-time-slot__state,
.ml-time-slot--selected .ml-time-slot__selected,
.ml-time-slot--selected .ml-time-slot__meta { color: var(--ml-on-action); }
.ml-booking-day-empty { display: grid; gap: 2px; padding: 14px; border: 1px solid var(--s-border-light); border-radius: 10px; background: var(--s-surface-2); }
.ml-booking-day-empty span { color: var(--s-text-secondary); font-size: 0.875rem; }
.ml-booking-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.ml-booking-actions .ml-btn { min-width: 112px; }
.ml-booking-actions--stack { display: grid; }
.ml-booking-summary { display: grid; gap: 0; margin: 0 0 20px; border: 1px solid var(--s-border-light); border-radius: var(--s-radius); overflow: hidden; }
.ml-booking-summary > div { display: grid; grid-template-columns: minmax(90px, .8fr) minmax(0, 1.2fr); gap: 12px; padding: 11px 13px; }
.ml-booking-summary > div:not(:last-child) { border-bottom: 1px solid var(--s-hairline); }
.ml-booking-summary dt { color: var(--s-text-secondary); font-size: 0.8125rem; font-weight: 600; }
.ml-booking-summary dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.ml-calendar-detail { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--s-hairline); }
.ml-calendar-detail .ml-booking-summary { margin-bottom: 12px; }
.ml-schedule-boundary { margin-top: 10px; }
.ml-schedule-limit { margin: 0 0 6px; }
.ml-schedule-limit + p { margin: 0; }

/* Clinical schedule workspace ------------------------------------------------
   The desktop week grid is information-dense without reducing target sizes.
   Every state also differs by text and border pattern, never colour alone. */
.ml-schedule-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.ml-schedule-heading h1 { margin: 0; font-size: clamp(2rem, 4vw, 2.75rem); line-height: 1.05; letter-spacing: -.035em; }
.ml-schedule-heading p { margin: 5px 0 0; color: var(--s-text-secondary); }
.ml-schedule-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin: 18px 0;
}
.ml-schedule-view-switcher { width: min(100%, 330px); }
.ml-schedule-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; }
.ml-schedule-shortcuts .ml-btn { gap: 7px; }
.ml-schedule-layout { display: grid; gap: 18px; align-items: start; }
.ml-schedule-calendar-area,
.ml-schedule-inspector { min-width: 0; }
.ml-schedule-calendar-area > section {
    padding: 18px;
    border: 1px solid var(--s-border-light);
    border-radius: var(--s-radius);
    background: var(--s-surface);
}
.ml-schedule-panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}
.ml-schedule-panel-heading h2 { margin: 0; font-size: 1.25rem; }
.ml-schedule-panel-heading p { margin: 2px 0 0; color: var(--s-text-secondary); font-size: .875rem; }
.ml-schedule-inspector { display: grid; gap: 16px; }
.ml-schedule-inspector .ml-card { border: 1px solid var(--s-border-light); box-shadow: none; }
.ml-schedule-selection-summary { margin: 8px 0 12px; }
.ml-schedule-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.ml-schedule-actions .ml-btn { min-width: 0; padding-inline: 10px; }
.ml-schedule-draft-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }

.ml-day-schedule { display: grid; gap: 9px; }
.ml-day-schedule__entry {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 68px;
    padding: 10px 12px;
    border: 2px solid var(--s-border-light);
    border-radius: 11px;
    background: var(--s-surface);
    color: var(--s-text);
    cursor: pointer;
    text-align: start;
}
.ml-day-schedule__entry--available { border-color: var(--s-accent-text); }
.ml-day-schedule__entry--booked { border-style: double; border-width: 4px; }
.ml-day-schedule__entry--blocked {
    border-style: dashed;
    background: repeating-linear-gradient(135deg, var(--s-surface-2), var(--s-surface-2) 8px, var(--s-bg) 8px, var(--s-bg) 16px);
}
.ml-day-schedule__entry[aria-pressed="true"] { outline: 3px solid var(--s-accent-text); outline-offset: 2px; }
.ml-day-schedule__time { font-size: 1.125rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.ml-day-schedule__body { display: grid; min-width: 0; }
.ml-day-schedule__body small { color: var(--s-text-secondary); overflow-wrap: anywhere; }
.ml-day-schedule__status { font-size: var(--ml-type-caption); font-weight: 750; text-decoration: underline; text-underline-offset: 2px; }

.ml-week-calendar__legend { display: flex; flex-wrap: wrap; gap: 7px 12px; color: var(--s-text-secondary); font-size: var(--ml-type-caption); }
.ml-week-calendar__legend span { display: inline-flex; align-items: center; gap: 4px; }
.ml-week-calendar {
    max-width: 100%;
    overflow: auto;
    border: 1px solid var(--s-border);
    border-radius: 12px;
    background: var(--s-surface);
    overscroll-behavior-inline: contain;
}
.ml-week-calendar table { width: 100%; min-width: 840px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.ml-week-calendar thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    height: 64px;
    padding: 7px;
    border-bottom: 1px solid var(--s-border);
    border-left: 1px solid var(--s-hairline);
    background: var(--s-surface);
    text-align: center;
}
.ml-week-calendar thead th:first-child { left: 0; z-index: 4; width: 54px; border-left: 0; }
.ml-week-calendar thead th span,
.ml-week-calendar thead th small { display: block; color: var(--s-text-secondary); font-size: var(--ml-type-caption); }
.ml-week-calendar thead th b { display: block; font-size: 1.125rem; }
.ml-week-calendar tbody th {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 54px;
    padding: 7px;
    border-bottom: 1px solid var(--s-hairline);
    background: var(--s-surface);
    color: var(--s-text-secondary);
    font-size: var(--ml-type-caption);
    font-weight: 600;
    text-align: end;
    vertical-align: top;
}
.ml-week-calendar td {
    height: 86px;
    padding: 4px;
    border-bottom: 1px solid var(--s-hairline);
    border-left: 1px solid var(--s-hairline);
    vertical-align: top;
}
.ml-week-calendar__today { background: var(--s-accent-soft) !important; }
.ml-week-event {
    display: grid;
    width: 100%;
    min-height: 68px;
    margin-bottom: 4px;
    padding: 6px 7px;
    border: 2px solid var(--s-accent-text);
    border-radius: 8px;
    background: var(--s-surface);
    color: var(--s-text);
    cursor: pointer;
    font: inherit;
    line-height: 1.2;
    text-align: start;
}
.ml-week-event b { font-size: var(--ml-type-caption); font-variant-numeric: tabular-nums; }
.ml-week-event span { margin-top: 2px; font-size: var(--ml-type-caption); font-weight: 700; overflow-wrap: anywhere; }
.ml-week-event small { margin-top: 3px; color: var(--s-text-secondary); font-size: var(--ml-type-caption); text-decoration: underline; }
.ml-week-event--booked { border: 3px double var(--s-text); }
.ml-week-event--blocked {
    border-style: dashed;
    border-color: var(--s-text-secondary);
    background: repeating-linear-gradient(135deg, var(--s-surface-2), var(--s-surface-2) 6px, var(--s-bg) 6px, var(--s-bg) 12px);
}
.ml-week-event[aria-pressed="true"] { outline: 3px solid var(--s-accent-text); outline-offset: 2px; }

.ml-working-hours > p { margin: 4px 0 12px; }
.ml-working-hours__presets { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 13px; }
.ml-working-hours fieldset { margin: 0; padding: 0; border: 0; }
.ml-working-hours__day {
    padding: 10px 0;
    border-top: 1px solid var(--s-hairline);
}
.ml-working-hours__day-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.ml-working-hours__day-header > label { display: flex; align-items: center; gap: 7px; min-height: 44px; font-size: .8125rem; font-weight: 700; }
.ml-working-hours__sessions { display: grid; gap: 6px; }
.ml-working-hours__session {
    display: grid;
    grid-template-columns: 42px minmax(72px, 1fr) 12px minmax(72px, 1fr) 44px;
    align-items: center;
    gap: 5px;
}
.ml-working-hours__session > span:first-child { color: var(--s-text-secondary); font-size: .6875rem; }
.ml-working-hours__parity {
    grid-column: 2 / -1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 7px;
}
.ml-working-hours__parity > span { color: var(--s-text-secondary); font-size: .6875rem; font-weight: 650; }
.ml-working-hours__remove {
    grid-column: 5;
    grid-row: 1;
    width: var(--ml-target-min);
    height: var(--ml-target-min);
    border: 1px solid var(--s-border-light);
    border-radius: 50%;
    background: var(--s-surface);
    color: var(--s-red);
    cursor: pointer;
    font-size: 1.25rem;
}
.ml-working-hours__add { margin-top: 7px; }
.ml-working-hours__day > .ml-field__hint { margin: 3px 0 0; }
.ml-working-hours input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--s-accent-text); }
.ml-working-hours input[type="time"],
.ml-working-hours input[type="date"],
.ml-working-hours select {
    width: 100%;
    min-height: var(--ml-target-min);
    padding: 6px 8px;
    border: 1px solid var(--s-border-light);
    border-radius: 8px;
    background: var(--s-surface);
    color: var(--s-text);
    font: inherit;
    font-size: .8125rem;
}
.ml-working-hours__day[data-closed="true"] .ml-working-hours__sessions,
.ml-working-hours__day[data-closed="true"] .ml-working-hours__add { opacity: .55; }
.ml-working-hours__options { display: grid; grid-template-columns: auto minmax(110px, 1fr); align-items: center; gap: 8px 10px; margin: 12px 0; }
.ml-working-hours__options label { font-size: .8125rem; font-weight: 650; }
.ml-working-hours__exceptions { padding-top: 12px; border-top: 1px solid var(--s-hairline); }
.ml-working-hours__exceptions h3 { margin: 0 0 8px; font-size: .875rem; }
.ml-working-hours__exceptions > div { display: grid; grid-template-columns: auto 1fr auto 1fr auto 1fr auto; align-items: center; gap: 7px; }
.ml-working-hours__exceptions > div > label { font-size: var(--ml-type-caption); font-weight: 650; }
.ml-working-hours__exceptions ul { display: grid; gap: 5px; margin: 8px 0 0; padding: 0; list-style: none; }
.ml-working-hours__exceptions li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 9px; border: 1px dashed var(--s-border-light); border-radius: 8px; font-size: var(--ml-type-caption); }
.ml-working-hours__templates { display: grid; gap: 7px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--s-hairline); }
.ml-working-hours__templates > label { font-size: .8125rem; font-weight: 650; }
.ml-working-hours__templates > input { width: 100%; min-height: var(--ml-target-min); padding: 7px 9px; border: 1px solid var(--s-border-light); border-radius: 8px; font: inherit; }
.ml-working-hours__templates > div { display: flex; flex-wrap: wrap; gap: 7px; }
.ml-working-hours__footer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.ml-settings-working-hours { display: grid; gap: 16px; }
.ml-settings-working-hours .ml-schedule-boundary { margin-top: 0; }

.ml-calendar-dialog {
    width: min(620px, calc(100% - 32px));
    max-height: min(820px, calc(100dvh - 32px));
    padding: 0;
    overflow: auto;
    border: 1px solid var(--s-border);
    border-radius: 18px;
    background: var(--s-surface);
    color: var(--s-text);
    box-shadow: var(--s-shadow-lg);
}
.ml-calendar-dialog::backdrop { background: rgba(20, 20, 28, .48); backdrop-filter: blur(2px); }
.ml-calendar-dialog form { padding: 22px; }
.ml-calendar-dialog__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ml-calendar-dialog__header h2 { margin: 6px 0 0; font-size: 1.5rem; }
.ml-calendar-dialog__close {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border: 1px solid var(--s-border-light);
    border-radius: 50%;
    background: var(--s-surface-2);
    color: var(--s-text);
    cursor: pointer;
    font-size: 1.5rem;
}
.ml-calendar-dialog__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.ml-calendar-dialog__availability,
.ml-calendar-dialog__conflict { margin-top: 14px; padding: 11px 12px; border: 1px solid var(--s-border-light); border-radius: 10px; background: var(--s-surface-2); }
.ml-calendar-dialog__conflict { display: grid; gap: 2px; border: 2px solid var(--s-red); background: var(--s-red-soft); }
.ml-calendar-dialog__actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

@media (min-width: 1180px) {
    .ml-schedule-inspector {
        grid-template-columns: minmax(0, 1fr);
        align-items: start;
    }
}

@media (max-width: 639px) {
    .ml-connectivity { align-items: flex-start; flex-wrap: wrap; }
    .ml-connectivity .ml-btn { width: 100%; }
    .ml-consent-summary > div { grid-template-columns: 1fr; gap: 3px; }
    .ml-schedule-calendar-area > section { padding: 13px; }
    .ml-schedule-toolbar { align-items: stretch; }
    .ml-schedule-view-switcher { width: 100%; }
    .ml-schedule-shortcuts { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
    .ml-day-schedule__entry { grid-template-columns: 52px minmax(0, 1fr); }
    .ml-day-schedule__status { grid-column: 2; }
    .ml-working-hours__session { grid-template-columns: 40px minmax(72px, 1fr) 10px minmax(72px, 1fr) 44px; }
    .ml-working-hours__options { grid-template-columns: 1fr; }
    .ml-working-hours__exceptions > div { grid-template-columns: 1fr 1fr; }
    .ml-working-hours__exceptions > div .ml-btn { grid-column: 1 / -1; }
    .ml-working-hours__footer-actions { grid-template-columns: 1fr; }
    .ml-calendar-dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); }
    .ml-calendar-dialog form { padding: 16px; }
    .ml-calendar-dialog__grid { grid-template-columns: 1fr; }
    .ml-calendar-dialog__actions { display: grid; grid-template-columns: 1fr; }
}

/* Give action-oriented rows enough room before the emergency 320px reflow
   breakpoint. This prevents names and clinical metadata being squeezed into
   narrow columns beside a large action button. */
@media (max-width: 520px) {
    .ml-card--pad > .ml-between { align-items: flex-start; flex-wrap: wrap; }
    .ml-card--pad > .ml-between > .ml-row-flex { flex: 1 1 220px; min-width: 0; }
    .ml-card--pad > .ml-between > .ml-row-flex > div:last-child { min-width: 0; overflow-wrap: anywhere; }
    .ml-device-actions { display: grid; grid-template-columns: 1fr; }
    .ml-device-actions .ml-btn { width: 100%; min-width: 0; }
    .ml-row--action { align-items: flex-start; flex-wrap: wrap; }
    .ml-row--action > .ml-row__body { flex: 1 1 calc(100% - 44px); }
    .ml-row--action > .ml-btn {
        width: auto;
        flex: 1 1 100%;
        margin-inline-start: 42px;
        white-space: normal;
    }
    .ml-row--action > .ml-row__trailing {
        width: auto;
        flex: 1 1 100%;
        margin-inline-start: 42px;
        align-items: center !important;
        justify-content: flex-end;
        flex-direction: row !important;
        flex-wrap: wrap;
    }
}

@media (min-width: 640px) {
    .ml-schedule-calendar-card [data-calendar-state="ready"] {
        display: grid;
        grid-template-columns: minmax(0, 1.2fr) minmax(240px, .8fr);
        align-items: start;
        gap: 0 20px;
    }
    .ml-schedule-calendar-card .ml-calendar { grid-column: 1; grid-row: 1 / span 2; }
    .ml-schedule-calendar-card .ml-booking-times { grid-column: 2; margin-top: 0; }
    .ml-schedule-calendar-card .ml-calendar-detail { grid-column: 2; }
    .ml-schedule-calendar-card .ml-time-grid--schedule { grid-template-columns: 1fr; }
}

@media (prefers-contrast: more) {
    :root {
        --s-text-secondary: var(--s-text);
        --s-text-tertiary: var(--s-text);
        --s-hairline: var(--s-text);
    }
    .ml-card, .ml-list, .ml-btn, .ml-chip, .ml-badge { border: 1px solid currentColor; }
    .ml-booking-step__number, .ml-calendar, .ml-calendar__day, .ml-time-slot, .ml-booking-summary { border-color: currentColor; }
}

@media (forced-colors: active) {
    .ml-btn, .ml-chip, .ml-badge, .ml-card, .ml-list { border: 1px solid ButtonText; }
    .ml-progress__fill, .ml-progress__fill--gradient { background: Highlight; }
    .ml-check-pop { forced-color-adjust: auto; }
    .ml-booking-step--active .ml-booking-step__number,
    .ml-calendar__day--selected,
    .ml-time-slot--selected { border-color: Highlight; background: Highlight; color: HighlightText; }
    .ml-booking-choice > input:checked + .ml-booking-choice__body { border-color: Highlight; }
}

/* ── Audiogram import ─────────────────────────────────────────────── */
.ml-content--wide { width: 100%; max-width: 1180px; min-width: 0; margin-inline: auto; }
.ml-import-steps { margin: 14px 0 22px; }
.ml-import-steps ol { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; padding: 0; list-style: none; }
.ml-import-steps li { display: flex; min-width: 0; align-items: center; gap: 9px; color: var(--s-text-secondary); font-size: var(--ml-type-supporting); }
.ml-import-steps li > span { display: grid; width: 30px; height: 30px; flex: 0 0 30px; place-items: center; border: 1.5px solid var(--s-border-light); border-radius: 50%; background: var(--s-surface); font-weight: 750; }
.ml-import-steps li.is-current { color: var(--s-text); }
.ml-import-steps li.is-current > span { border-color: var(--s-accent); background: var(--s-accent); color: var(--s-on-accent); }
.ml-import-steps li.is-complete > span { border-color: var(--s-green); background: var(--s-green-soft); color: var(--s-green-text); }
.ml-source-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 0 0 16px; padding: 0; border: 0; }
.ml-source-grid legend { grid-column: 1 / -1; margin-bottom: 6px; }
.ml-source-option { position: relative; display: flex; min-height: 138px; cursor: pointer; flex-direction: column; gap: 10px; padding: 16px; border: 1.5px solid var(--s-border-light); border-radius: var(--ml-radius-card); background: var(--s-surface); box-shadow: var(--s-shadow-sm); }
.ml-source-option:has(input:checked) { border-color: var(--s-accent); background: var(--s-accent-soft); box-shadow: 0 0 0 2px color-mix(in srgb, var(--s-accent) 25%, transparent); }
.ml-source-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ml-source-option:has(input:focus-visible) { outline: 3px solid var(--ml-focus); outline-offset: 3px; }
.ml-source-option__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; background: var(--s-accent-soft); color: var(--s-accent); }
.ml-source-option b, .ml-source-option small { display: block; }
.ml-source-option small { margin-top: 4px; color: var(--s-text-secondary); font-size: var(--ml-type-caption); line-height: 1.4; }
.ml-source-option__check { position: absolute; top: 12px; right: 12px; color: var(--s-accent); opacity: 0; }
.ml-source-option:has(input:checked) .ml-source-option__check { opacity: 1; }
.ml-import-input { margin-top: 0; }
.ml-file-input { width: 100%; min-height: var(--ml-target-comfortable); padding: 10px; border: 1px solid var(--s-border); border-radius: var(--ml-radius-control); background: var(--s-bg); color: var(--s-text); font: inherit; }
.ml-textarea { width: 100%; min-height: 110px; resize: vertical; padding: 12px 14px; border: 1px solid var(--s-border); border-radius: var(--ml-radius-control); background: var(--s-surface); color: var(--s-text); font: inherit; line-height: 1.5; }
.ml-alert { display: flex; align-items: flex-start; gap: 10px; margin: 12px 0; padding: 13px 15px; border: 1px solid var(--s-border-light); border-radius: var(--ml-radius-control); background: var(--s-surface); font-size: var(--ml-type-supporting); line-height: 1.5; }
.ml-alert ul { margin: 6px 0 0; padding-left: 20px; }
.ml-alert--error { border-color: var(--s-red); background: var(--s-red-soft); color: var(--s-red); }
.ml-alert--warning { border-color: var(--s-orange); background: var(--s-orange-soft); color: var(--s-text); }
.ml-import-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.ml-import-workspace > * { min-width: 0; }
.ml-original-panel { min-width: 0; }
.ml-original-image, .ml-original-frame { width: 100%; height: 480px; margin-top: 14px; border: 1px solid var(--s-border-light); border-radius: var(--ml-radius-control); background: white; object-fit: contain; }
.ml-original-text { max-height: 480px; overflow: auto; margin: 14px 0 0; padding: 14px; border: 1px solid var(--s-border-light); border-radius: var(--ml-radius-control); background: var(--s-bg); color: var(--s-text); font: 500 var(--ml-type-supporting)/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.ml-disclosure { margin-top: 12px; }
.ml-disclosure summary { min-height: var(--ml-target-min); cursor: pointer; color: var(--s-accent); font-weight: 700; }
.ml-import-chart { min-height: 360px; margin-top: 12px; padding: 10px; border: 1px solid var(--s-border-light); border-radius: var(--ml-radius-control); background: var(--s-surface); }
.ml-import-chart svg { width: 100%; height: auto; overflow: visible; }
.ml-chart-grid { stroke: var(--s-hairline); stroke-width: 1; }
.ml-chart-label, .ml-chart-axis { fill: var(--s-text-secondary); font: 600 13px var(--s-font); }
.ml-chart-line { stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ml-chart-line--right { stroke: var(--ml-audiogram-right); }
.ml-chart-line--left { stroke: var(--ml-audiogram-left); }
.ml-chart-point { fill: var(--s-surface); stroke-width: 3; }
.ml-chart-point--right { stroke: var(--ml-audiogram-right); }
.ml-chart-point--left { fill: none; stroke: var(--ml-audiogram-left); stroke-width: 3; }
.ml-chart-bone { fill: var(--s-surface); stroke-width: 3; }
.ml-chart-bone--right { stroke: var(--ml-audiogram-right); }
.ml-chart-bone--left { stroke: var(--ml-audiogram-left); }
.ml-chart-legend { margin-top: 8px; color: var(--s-text-secondary); font-size: var(--ml-type-caption); font-weight: 650; }
.ml-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ml-static-field { display: flex; min-height: var(--ml-target-comfortable); flex-direction: column; justify-content: center; padding: 9px 12px; border: 1px solid var(--s-border-light); border-radius: var(--ml-radius-control); background: var(--s-bg); }
.ml-static-field span { color: var(--s-text-secondary); font-size: var(--ml-type-caption); }
.ml-card__header { padding: 18px 20px; border-bottom: 1px solid var(--s-hairline); }
.ml-card__header p { margin: 4px 0 0; }
.ml-table-scroll { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; }
.ml-import-table { width: 100%; min-width: 1040px; border-collapse: collapse; }
.ml-import-table th { padding: 10px 8px; color: var(--s-text-secondary); font-size: var(--ml-type-caption); text-align: left; }
.ml-import-table td { position: relative; padding: 8px; border-top: 1px solid var(--s-hairline); vertical-align: middle; }
.ml-import-table td .ml-input, .ml-import-table td .ml-select { min-width: 100px; }
.ml-import-table tr.is-uncertain { background: var(--s-orange-soft); }
.ml-import-table .ml-unit { display: block; margin-top: 3px; color: var(--s-text-secondary); font-size: var(--ml-type-caption); }
.ml-check-cell { text-align: center; }
.ml-check-cell input { width: 24px; height: 24px; accent-color: var(--s-accent); }
.ml-source-locator { display: block; max-width: 150px; color: var(--s-text-secondary); font-size: var(--ml-type-caption); overflow-wrap: anywhere; }
.ml-icon-button { display: inline-grid; width: var(--ml-target-min); height: var(--ml-target-min); cursor: pointer; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--s-red); }
.ml-form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.ml-check-list { display: grid; gap: 10px; margin: 14px 0; padding: 0; list-style: none; }
.ml-check-list li { position: relative; padding-left: 28px; }
.ml-check-list li::before { position: absolute; left: 0; content: '✓'; color: var(--s-green-text); font-weight: 800; }
.ml-choice-list { display: grid; gap: 9px; margin: 16px 0; padding: 0; border: 0; }
.ml-choice-list legend { margin-bottom: 8px; font-weight: 750; }
.ml-choice-list label, .ml-confirm-check { display: flex; min-height: var(--ml-target-comfortable); cursor: pointer; align-items: flex-start; gap: 12px; padding: 13px; border: 1px solid var(--s-border-light); border-radius: var(--ml-radius-control); }
.ml-choice-list input, .ml-confirm-check input { width: 22px; height: 22px; flex: 0 0 22px; accent-color: var(--s-accent); }
.ml-choice-list small { display: block; margin-top: 2px; color: var(--s-text-secondary); font-size: var(--ml-type-caption); }
.ml-result-panel { max-width: 600px; margin: clamp(30px, 8vh, 80px) auto; text-align: center; }
.ml-result-panel h1 { margin: 18px 0 8px; }
.ml-result-panel > p { color: var(--s-text-secondary); font-size: 1.05rem; line-height: 1.55; }
.ml-result-panel .ml-note { margin: 22px 0; text-align: left; }
.ml-history-item { border-bottom: 1px solid var(--s-hairline); }
.ml-history-item:last-child { border-bottom: 0; }
.ml-history-item summary { display: flex; min-height: 64px; cursor: pointer; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.ml-history-item summary small { display: block; margin-top: 3px; color: var(--s-text-secondary); font-size: var(--ml-type-caption); }
.ml-compact-table { width: 100%; border-collapse: collapse; font-size: var(--ml-type-supporting); }
.ml-compact-table th, .ml-compact-table td { padding: 9px 12px; border-top: 1px solid var(--s-hairline); text-align: left; }
.ml-compact-table th { color: var(--s-text-secondary); font-size: var(--ml-type-caption); }
@media (max-width: 920px) {
    .ml-source-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ml-import-workspace { grid-template-columns: 1fr; }
    .ml-original-image, .ml-original-frame { height: min(65vh, 520px); }
}
@media (max-width: 560px) {
    .ml-import-steps ol { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .ml-import-steps li { justify-content: center; }
    .ml-import-steps li b { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .ml-source-grid, .ml-form-grid { grid-template-columns: 1fr; }
    .ml-source-option { min-height: 96px; flex-direction: row; align-items: center; }
    .ml-import-chart { min-height: 250px; padding: 4px; }
    .ml-form-actions { flex-direction: column-reverse; }
    .ml-form-actions .ml-btn { width: 100%; }
}

/* WCAG 2.2 reflow target: remain usable at a 320 CSS-pixel viewport. */
@media (max-width: 359px) {
    .ml-content { padding-left: 12px; padding-right: 12px; }
    .ml-topbar { padding-left: 12px; padding-right: 12px; }
    .ml-environment-banner { margin-left: 8px; margin-right: 8px; }
    .ml-topbar__title { min-width: 0; font-size: 0.9375rem; }
    .ml-large-title h1 { font-size: 1.875rem; overflow-wrap: anywhere; }
    .ml-card--pad { padding: 14px; }
    .ml-stat-grid, .ml-stat-grid--3 { grid-template-columns: 1fr; }
    .ml-row { align-items: flex-start; flex-wrap: wrap; }
    .ml-row__body { flex: 1 1 160px; }
    .ml-row__trailing { flex-wrap: wrap; }
    .ml-row > .ml-btn { flex: 1 1 100%; margin-inline-start: 42px; white-space: normal; }
    .ml-badge { white-space: normal; }

    .ml-card--pad > .ml-between {
        align-items: flex-start;
        flex-wrap: wrap;
    }
    .ml-card--pad > .ml-between > .ml-row-flex {
        flex: 1 1 190px;
        min-width: 0;
    }
    .ml-card--pad > .ml-between > .ml-row-flex > div:last-child {
        min-width: 0;
        overflow-wrap: anywhere;
    }
    .ml-card--pad > .ml-row-flex {
        flex-wrap: wrap;
    }
    .ml-card--pad > .ml-row-flex > .ml-btn {
        flex: 1 1 100% !important;
        white-space: normal;
    }
    .ml-row__value { max-width: 45%; }
    .ml-booking-panel { padding: 16px; }
    .ml-booking-step { font-size: var(--ml-type-caption); }
    .ml-booking-step__number { width: 28px; height: 28px; }
    .ml-booking-shortcuts { grid-template-columns: 1fr; }
    .ml-calendar__grid td { padding: 1px; }
    .ml-calendar__day { min-height: 50px; border-radius: 7px; }
    .ml-calendar__day-number { font-size: 0.8125rem; }
    .ml-time-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ml-time-grid--schedule { grid-template-columns: 1fr; }
    .ml-booking-actions { display: grid; grid-template-columns: 1fr; }
    .ml-booking-actions .ml-btn { width: 100%; min-width: 0; }
    .ml-booking-summary > div { grid-template-columns: 1fr; gap: 3px; }
}

/* Brand assets remain vector-based; the wordmark is not recreated with a UI font. */
.ml-brand-logo { display: block; width: 176px; max-width: 100%; flex-shrink: 0; }
.ml-brand-logo img { display: block; width: 100%; height: auto; }
.ml-brand-logo--welcome { width: 280px; margin: 0 auto 20px; }
.ml-brand-logo--compact { width: 144px; }
.ml-brand-home { display: inline-flex; align-items: center; min-height: 44px; }
.ml-desktop-brand { flex-wrap: wrap; }
.ml-desktop-brand .ml-brand-logo img { width: 100%; height: auto; border-radius: 0; }
.ml-desktop-brand small { color: var(--s-text-secondary); font-size: .875rem; }
@media (prefers-color-scheme: dark) {
    .ml-bankid-mark b, .ml-bankid-mark span { color: var(--s-text) !important; }
    .ml-btn--bankid .ml-bankid-mark b { color: #fff !important; }
    .ml-btn--bankid .ml-bankid-mark span { color: #ECA9FF !important; }
}
