/* Medications — UI 2026
   Responsive, mobile-first, dark mode automatique.
*/

:root {
    color-scheme: light dark;
    --bg: #f3f6fb;
    --bg-elevated: rgba(255,255,255,.78);
    --surface: rgba(255,255,255,.88);
    --surface-solid: #ffffff;
    --surface-soft: #f7f9fc;
    --surface-hover: #eef4ff;
    --text: #111827;
    --text-soft: #475569;
    --text-muted: #7b8797;
    --border: rgba(148,163,184,.22);
    --border-strong: rgba(148,163,184,.38);


    --blue: #0062cc;
    --blue-strong: #004fa6;
    --blue-soft: #E8F1FF;
    --green: #23b26d;
    --green-soft: #e8f8f0;
    --amber: #f4a51c;
    --amber-soft: #fff4d8;
    --red: #ef5350;
    --red-soft: #ffe8e7;
    --violet: #7567f8;
    --violet-soft: #efecff;
    --shadow-soft: 0 18px 45px rgba(37, 54, 86, .09);
    --shadow-card: 0 8px 24px rgba(30, 41, 59, .06);
    --radius-xl: 26px;
    --radius-lg: 20px;
    --radius-md: 15px;
    --radius-sm: 11px;
    --focus: 0 0 0 3px rgba(0,98,204,.18);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 70% -20%, rgba(96,165,250,.18), transparent 34rem),
        radial-gradient(circle at 10% 120%, rgba(52,211,153,.12), transparent 32rem),
        var(--bg);
    color: var(--text);
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

a {
    color: inherit;
    text-decoration: none;
}

img,
svg {
    display: block;
}

button {
    cursor: pointer;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

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

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

/* ---------- Auth ---------- */

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-wrap {
    width: min(100%, 470px);
}

.auth-panel {
    border: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: blur(18px);
    border-radius: 28px;
    padding: 28px;
    box-shadow: var(--shadow-soft);
}

.auth-panel h1 {
    margin-bottom: 7px;
    font-size: 1.8rem;
    letter-spacing: -.03em;
}

.auth-subtitle {
    color: var(--text-soft);
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 17px;
}

.form-group label {
    display: block;
    margin-bottom: 7px;
    font-weight: 700;
    font-size: .93rem;
}

.input-wrap {
    position: relative;
}


.password-field .form-control {
    padding-right: 58px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 0;
    background: transparent;
    color: var(--icon-accent);
    padding: 0;
    border-radius: 10px;
    transition: background-color .16s ease, color .16s ease, transform .10s ease;
}

.password-toggle:hover {
    background: color-mix(in srgb, var(--icon-accent) 10%, transparent);
    color: var(--icon-accent);
}

.password-toggle:active {
    background: color-mix(in srgb, var(--blue) 16%, transparent);
}

.password-toggle .password-eye-icon {
    width: 22px;
    height: 22px;
    filter: drop-shadow(0 0 5px color-mix(in srgb, var(--blue) 20%, transparent));
}

.password-toggle [hidden] {
    display: none !important;
}

.primary-btn,
.secondary-btn {
    border: 0;
    min-height: 44px;
    border-radius: 13px;
    padding: 10px 15px;
    font-weight: 800;
}

.primary-btn {
    box-shadow: 0 10px 22px rgba(var(--primary-button-rgb),.24);
}


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


.full-btn {
    width: 100%;
}

.alert {
    margin-bottom: 16px;
    padding: 12px 13px;
    border-radius: 13px;
    border: 1px solid rgba(239,83,80,.25);
    background: var(--red-soft);
    color: #b3312f;
}

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

.app-shell {
    min-height: 100vh;
}

.sidebar {
    display: none;
}

.main-area {
    min-width: 0;
}

.topbar {
    z-index: 30;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(16px);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 850;
}

.top-search {
    display: none;
}


.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #c7d2fe, #dbeafe 50%, #bbf7d0);
    color: #30415a;
    font-weight: 900;
    border: 1px solid var(--border);
}

.user-name-desktop {
    display: none;
}

.page {
    width: min(100%, var(--page-max));
    margin: 0 auto;
    padding: 20px 14px 94px;
}

.hero {
    padding: 4px 2px 18px;
}

.eyebrow {
    margin-bottom: 6px;
    color: var(--text-soft);
    font-size: .94rem;
}

.hero h1 {
    margin-bottom: 9px;
    font-size: clamp(1.8rem, 6vw, 2.55rem);
    line-height: 1.06;
    letter-spacing: -.045em;
}

.hero p {
    margin-bottom: 0;
    max-width: 650px;
    color: var(--text-muted);
}

/* ---------- Mobile tabs ---------- */

/* ---------- Sections ---------- */

.section-shell {
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--surface);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 14px;
}

.section-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-icon {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 13px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 1.2rem;
}

.section-heading h2 {
    margin-bottom: 2px;
    font-size: 1.15rem;
    letter-spacing: -.02em;
}

.section-heading p {
    margin: 0;
    color: var(--text-muted);
    font-size: .86rem;
}

.desktop-actions {
    display: none;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-solid);
    color: var(--text-soft);
}

/* ---------- Medication list ---------- */

.med-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.med-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 14px;
    font-size: 1.18rem;
    background: var(--blue-soft);
    color: var(--blue);
}

.med-icon.green {
    background: var(--green-soft);
    color: var(--green);
}

.med-icon.amber {
    background: var(--amber-soft);
    color: var(--amber);
}

.med-icon.violet {
    background: var(--violet-soft);
    color: var(--violet);
}

.med-name {
    margin-bottom: 3px;
    font-weight: 820;
    letter-spacing: -.01em;
}

.med-meta {
    color: var(--text-muted);
    font-size: .85rem;
}

.med-cell {
    display: none;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 820;
    white-space: nowrap;
}

.status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.status.stable {
    color: #13884f;
    background: var(--green-soft);
}

.status.watch {
    color: #b97708;
    background: var(--amber-soft);
}

.status.low {
    color: #c63734;
    background: var(--red-soft);
}

.progress {
    width: 100%;
    height: 7px;
    border-radius: 999px;
    background: #e8edf4;
    overflow: hidden;
    margin-top: 7px;
}

.progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
}

.progress.green > span {
    background: var(--green);
}

.progress.amber > span {
    background: var(--amber);
}

.progress.red > span {
    background: var(--red);
}

/* ---------- Overview ---------- */

.overview-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 14px;
}

.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 17px 18px 12px;
}

.panel-heading h3 {
    margin: 0;
    font-size: 1rem;
}

.link-btn {
    border: 0;
    background: transparent;
    color: var(--blue);
    font-weight: 780;
    padding: 6px 0;
}

.stock-content {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 8px 18px 18px;
}

.donut {
    width: 104px;
    height: 104px;
    flex: 0 0 104px;
    border-radius: 50%;
    position: relative;
    background: transparent;
}

.donut-chart {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.stock-overview-card { position: relative; }
.stock-chart-tooltip {
    position: absolute; z-index: 10; pointer-events: none;
    max-width: min(240px, calc(100% - 16px)); padding: 9px 12px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface-solid); color: var(--text);
    box-shadow: var(--shadow-soft); font-size: .85rem; line-height: 1.4;
    overflow-wrap: anywhere;
}
.stock-chart-tooltip[hidden] { display: none; }
.donut-chart:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; border-radius: 50%; }
.legend-dot-neutral { background: var(--blue); }
.dashboard-medication-link { color: inherit; text-decoration: none; }
.dashboard-medication-link:hover { text-decoration: underline; }

.dashboard-medications-all {
    display: flex; align-items: center; justify-content: flex-end; gap: 9px;
    padding: 16px 20px; border-top: 1px solid var(--border); color: var(--blue);
    font-weight: 700; text-decoration: none;
}
.dashboard-medications-all:hover { background: var(--surface-soft); }
.dashboard-medications-all .ui-icon { width: 18px; height: 18px; flex: none; }
.dashboard-stock-activity { --activity-teal: #26d8d8; --activity-blue: #40a1ff; --activity-purple: #5848d4; margin: 0 0 20px; padding: 0; }
.stock-activity-heading {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    flex-wrap: wrap; padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.stock-activity-heading h2 { margin: 0; font-size: 1.1rem; }
.stock-activity-heading p { margin: 4px 0 0; color: var(--text-soft); font-size: .85rem; }
.stock-activity-range { display: flex; align-items: center; gap: 8px; color: var(--text-soft); font-size: .85rem; }
.stock-activity-range > .app-select,
.stock-activity-range > select { width: 120px; flex: 0 0 120px; }
.stock-activity-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 18px 20px 0; }
.stock-activity-stats > div { min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); text-align: center; }
.stock-activity-stats span { display: block; color: var(--text-soft); font-size: .8rem; }
.stock-activity-stats strong { display: block; margin-top: 5px; font-size: 1.35rem; }
.stock-activity-mobile-label,
.stock-activity-series-total,
.stock-activity-stats .stock-activity-mobile-label { display: none; }
.stock-activity-chart { position: relative; height: 285px; min-width: 0; margin: 18px 18px 0; overflow-x: auto; overflow-y: hidden; }
.stock-activity-plot { position: relative; height: calc(100% - 16px); min-width: 0; }
.stock-activity-is-year .stock-activity-plot { min-width: 640px; }
.stock-activity-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 20px; padding: 12px 18px; }
.stock-activity-legend button { display: inline-flex; align-items: center; gap: 7px; border: 0; padding: 6px 0; background: transparent; color: var(--text-soft); font: inherit; font-size: .8rem; cursor: pointer; }
.stock-activity-legend button[aria-pressed="false"] { opacity: .55; text-decoration: line-through; }
.stock-activity-dot { display: inline-block; width: 10px; height: 10px; flex: none; border-radius: 2px; }
.stock-activity-dot-0 { background: var(--activity-teal); }
.stock-activity-dot-1 { background: var(--activity-blue); }
.stock-activity-dot-2 { background: var(--activity-purple); }
.stock-activity-note { margin: 0; padding: 0 20px 16px; color: var(--text-soft); font-size: .8rem; }
@media (max-width: 899px) {
    .stock-activity-heading {
        display: grid; grid-template-columns: minmax(0, 1fr) 120px;
        align-items: center; padding: 16px; gap: 12px;
    }
    .stock-activity-heading > div { min-width: 0; width: auto; }
    .stock-activity-range { width: auto; justify-content: flex-end; }
    .stock-activity-range > span {
        position: absolute; width: 1px; height: 1px; padding: 0;
        margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
    }
    .stock-activity-stats { display: block; padding: 0; border-bottom: 1px solid var(--border); }
    .stock-activity-stats > div { display: none; }
    .stock-activity-stats > .stock-activity-total {
        display: flex; align-items: baseline; gap: 7px; padding: 12px 16px;
        border: 0; border-radius: 0; background: transparent; text-align: left;
    }
    .stock-activity-stats strong { margin-top: 0; }
    .stock-activity-desktop-label,
    .stock-activity-stats .stock-activity-desktop-label { display: none; }
    .stock-activity-mobile-label,
    .stock-activity-series-total,
    .stock-activity-stats .stock-activity-mobile-label { display: inline; }
    .stock-activity-chart { height: 241px; margin: 12px 0 0; }
    .stock-activity-is-month .stock-activity-plot { min-width: 760px; }
    .stock-activity-legend {
        display: grid; grid-template-columns: minmax(0, 1fr);
        justify-content: stretch; gap: 0; padding: 8px 16px 12px;
    }
    .stock-activity-legend button { min-height: 44px; width: 100%; text-align: left; }
    .stock-activity-series-total { margin-left: auto; font-variant-numeric: tabular-nums; }
}
@media (max-width: 599px) {
    .dashboard-medications-all { justify-content: center; padding: 15px; }
}
@media (pointer: coarse) {
    .stock-activity-legend button { min-height: 44px; }
}

.donut-label {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    place-items: center;
    text-align: center;
    font-size: .75rem;
    color: var(--text-muted);
    pointer-events: none;
}

.donut-label strong {
    display: block;
    font-size: 1.45rem;
    color: var(--text);
    line-height: 1;
    margin-bottom: 3px;
}

.legend {
    flex: 1;
    display: grid;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-soft);
    font-size: .88rem;
}

.legend-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.timeline {
    padding: 6px 18px 16px;
}

.timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: 12px 1fr auto;
    gap: 12px;
    padding: 10px 0 14px;
}

.timeline-item.timeline-empty { grid-template-columns: 1fr; }

.timeline-item:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 28px;
    bottom: -2px;
    width: 1px;
    background: var(--border-strong);
}

.timeline-dot {
    width: 10px;
    height: 10px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--blue);
    position: relative;
    z-index: 1;
}

.timeline-dot.violet {
    background: var(--violet);
}

.timeline-dot.red {
    background: var(--red);
}

.timeline-kicker {
    margin-bottom: 2px;
    color: var(--blue);
    font-size: .78rem;
    font-weight: 800;
}

.timeline-title {
    margin-bottom: 2px;
    font-weight: 820;
}

.timeline-meta {
    color: var(--text-muted);
    font-size: .84rem;
}

.quick-actions {
    padding: 8px 18px 18px;
    display: grid;
    gap: 10px;
}

.quick-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface-solid);
    color: var(--text);
    font-weight: 750;
}


/* ---------- Bottom navigation ---------- */

.bottom-nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
    backdrop-filter: blur(18px);
    box-shadow: 0 16px 40px rgba(15,23,42,.16);
}

.bottom-link {
    min-height: 52px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 2px;
    border-radius: 14px;
    color: var(--text-muted);
    font-weight: 750;
}

.bottom-link.active {
    background: var(--blue-soft);
    color: var(--blue);
}

.bottom-icon {
    font-size: 1.1rem;
    line-height: 1;
}

/* ---------- Desktop ---------- */

@media (min-width: 900px) {
    .sidebar {
        display: flex;
        flex-direction: column;
        border-right: 1px solid var(--border);
        backdrop-filter: blur(20px);
    }

    .brand {
        display: flex;
        align-items: center;
        font-weight: 900;
        letter-spacing: -.025em;
    }

    .nav-list {
        display: grid;
    }

    .nav-link {
        display: flex;
        align-items: center;
        color: var(--text-soft);
    }

    .nav-link:hover {
        background: var(--surface-soft);
    }


    .nav-icon {
        text-align: center;
    }

    .nav-badge {
        margin-left: auto;
        min-width: 22px;
        height: 22px;
        padding: 0 6px;
        display: grid;
        place-items: center;
        border-radius: 999px;
        background: var(--blue);
        color: #fff;
        font-size: .72rem;
    }

    .sidebar-foot {
        overflow: hidden;
        background: linear-gradient(180deg, rgba(30,64,175,.08), rgba(16,185,129,.08)), linear-gradient(145deg, #eaf3ff, #edfdf6);
    }


    .sidebar-foot small {
        color: #64748b;
    }


    .mobile-logo {
        display: none;
    }

    .top-search {
        display: flex;
        align-items: center;
        gap: 9px;
        width: min(520px, 45vw);
        padding: 0 13px;
        border: 1px solid var(--border);
        border-radius: 13px;
        background: var(--surface);
        color: var(--text-muted);
    }

    .top-search input {
        flex: 1;
        min-width: 0;
        border: 0;
        outline: 0;
        background: transparent;
        color: var(--text);
    }

    .user-name-desktop {
        color: var(--text-soft);
    }

    .page {
        padding: 28px 24px 46px;
    }

    .hero {
        padding: 8px 8px 22px;
    }

    .hero h1 {
        font-size: clamp(2.1rem, 3vw, 3.2rem);
    }


    .section-heading {
        padding: 20px 22px 16px;
    }

    .desktop-actions {
        display: flex;
    }

    .med-cell {
        display: block;
        min-width: 0;
        color: var(--text-soft);
        font-size: .9rem;
    }


    .row-menu {
        display: grid;
        place-items: center;
        width: 34px;
        height: 34px;
        border: 0;
        background: transparent;
        color: var(--text-muted);
        border-radius: 9px;
        font-size: 1.2rem;
    }

    .overview-grid {
        grid-template-columns: 1fr 1.1fr .9fr;
        gap: 16px;
        margin-top: 16px;
    }

    .bottom-nav {
        display: none;
    }
}

/* ---------- Large desktop ---------- */

@media (min-width: 1250px) {

    .page {
        padding-left: 30px;
        padding-right: 30px;
    }
}

/* ---------- Dark mode ---------- */

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1218;
        --bg-elevated: rgba(21,28,36,.82);
        --surface: rgba(20,27,35,.88);
        --surface-solid: #151c24;
        --surface-soft: #18212b;
        --surface-hover: #1f2d3f;
        --text: #edf2f7;
        --text-soft: #c3ceda;
        --text-muted: #8d9aaa;
        --border: rgba(148,163,184,.16);
        --border-strong: rgba(148,163,184,.28);


    --blue: #0062cc;
        --blue-strong: #004fa6;
        --blue-soft: #15243A;

        --green: #52d28c;
        --green-soft: #163326;
        --amber: #f7b94b;
        --amber-soft: #3a2e17;
        --red: #ff7773;
        --red-soft: #3b1d1e;
        --violet: #a097ff;
        --violet-soft: #29264e;

        --shadow-soft: 0 18px 50px rgba(0,0,0,.28);
        --shadow-card: 0 8px 24px rgba(0,0,0,.18);
    }

    .alert {
        color: #ffb8b6;
    }

    .progress {
        background: #293442;
    }

    .sidebar-foot {
        background:
            linear-gradient(180deg, rgba(59,130,246,.12), rgba(16,185,129,.09)),
            #18212b;
        color: #d5e0ea;
    }

    .sidebar-foot small {
        color: #92a0af;
    }

    .status.stable {
        color: #69dfa0;
    }

    .status.watch {
        color: #f3c05d;
    }

    .status.low {
        color: #ff8d89;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important;
    }
}


/* ==========================================================
   CRUD Médicaments
   ========================================================== */

.page-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.page-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}


.page-toolbar p {
    margin-bottom: 0;
    color: var(--text-muted);
}

.action-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border-radius: 13px;
    padding: 10px 15px;
    font-weight: 800;
}

.action-link.primary {
    box-shadow: 0 10px 22px rgba(var(--primary-button-rgb),.20);
}

.action-link.secondary {
    border: 1px solid var(--border);
    background: var(--surface-solid);
    color: var(--text);
}

.real-med-primary {
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 0;
}

.real-med-info {
    min-width: 0;
}

.real-med-title {
    margin-bottom: 3px;
    font-weight: 850;
    letter-spacing: -.015em;
    word-break: break-word;
}

.real-med-subtitle {
    color: var(--text-muted);
    font-size: .86rem;
}

.detail-label {
    display: block;
    margin-bottom: 3px;
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 780;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.inline-form {
    display: inline;
    margin: 0;
}

.empty-state {
    padding: 48px 22px;
    text-align: center;
}

.empty-state-icon {
    width: 62px;
    height: 62px;
    margin: 0 auto 15px;
    border-radius: 20px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 1.5rem;
}

.empty-state h2 {
    margin-bottom: 7px;
    font-size: 1.18rem;
}

.empty-state p {
    max-width: 520px;
    margin: 0 auto 18px;
    color: var(--text-muted);
}

.flash-message {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 13px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.flash-message.success {
    border-color: color-mix(in srgb, var(--green) 35%, var(--border));
    background: var(--green-soft);
    color: var(--green);
}

.flash-message.error {
    border-color: color-mix(in srgb, var(--red) 35%, var(--border));
    background: var(--red-soft);
    color: var(--red);
}

/* ---------- Formulaire médicament ---------- */

.med-form {
    display: grid;
    gap: 16px;
}

.form-section {
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--surface);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-card);
    padding: 18px;
}

.form-section-heading {
    margin-bottom: 17px;
}

.form-section-heading h2 {
    margin-bottom: 4px;
    font-size: 1.08rem;
}

.form-section-heading p {
    margin-bottom: 0;
    color: var(--text-muted);
    font-size: .88rem;
}

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

.field {
    min-width: 0;
}

.field.full {
    grid-column: 1 / -1;
}

.field label,
.field-label {
    display: block;
    margin-bottom: 7px;
    font-size: .88rem;
    font-weight: 800;
}

.field-help {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: .78rem;
}

.form-control,
.form-select,
.form-textarea {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: 13px;
    background: var(--surface-solid);
    color: var(--text);
    padding: 11px 12px;
}

.form-control,
.form-select {
    min-height: 46px;
}

.form-textarea {
    min-height: 105px;
    resize: vertical;
}

.form-error-summary {
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--red-soft);
    color: var(--red);
    border: 1px solid color-mix(in srgb, var(--red) 30%, transparent);
}

.form-error-summary ul {
    margin: 8px 0 0 18px;
    padding: 0;
}

.mode-choice {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.mode-option {
    position: relative;
}

.mode-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mode-option label {
    display: block;
    min-height: 76px;
    margin: 0;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-solid);
    cursor: pointer;
}

.mode-option input:checked + label {
    border-color: var(--blue);
    background: var(--blue-soft);
}

.mode-option strong {
    display: block;
    margin-bottom: 3px;
}

.mode-option span {
    color: var(--text-muted);
    font-size: .82rem;
}

.schedule-list {
    display: grid;
    gap: 12px;
}

.schedule-row {
    position: relative;
    display: grid;
    gap: 13px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface-solid);
}

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

.schedule-row-title {
    font-weight: 850;
}

.remove-schedule {
    border: 0;
    background: transparent;
    color: var(--red);
    padding: 6px 8px;
    border-radius: 9px;
    font-weight: 800;
}

.schedule-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.weekday-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0,1fr));
    gap: 6px;
}

.day-check {
    position: relative;
}

.day-check input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.day-check label {
    display: grid;
    place-items: center;
    min-height: 38px;
    margin: 0;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--text-soft);
    font-size: .76rem;
    font-weight: 850;
    cursor: pointer;
}

.day-check input:checked + label {
    border-color: var(--blue);
    background: var(--blue-soft);
    color: var(--blue);
}

.schedule-actions {
    margin-top: 12px;
}

.form-footer {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-card);
}

.form-footer .primary-btn,
.form-footer .secondary-btn {
    min-width: 0;
}

.stock-readonly {
    display: flex;
    align-items: baseline;
    gap: 7px;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px dashed var(--border-strong);
    border-radius: 13px;
    background: var(--surface-soft);
}

.stock-readonly strong {
    font-size: 1.2rem;
}

.stock-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text-soft);
    font-weight: 800;
    font-size: .82rem;
}

@media (min-width: 700px) {
    .field-grid.two {
        grid-template-columns: repeat(2, minmax(0,1fr));
    }

    .field-grid.three {
        grid-template-columns: repeat(3, minmax(0,1fr));
    }

    /* Aligner les champs du stock dès le passage à trois colonnes. */
    .stock-alert-fields > .field {
        display: grid;
        align-self: stretch;
        grid-row: span 3;
        grid-template-rows: subgrid;
        row-gap: 0;
    }

    .mode-choice {
        grid-template-columns: repeat(2, minmax(0,1fr));
    }

    .schedule-fields {
        grid-template-columns: minmax(130px,.55fr) minmax(120px,.5fr) minmax(0,1.4fr);
    }
}

@media (min-width: 900px) {

    .form-section {
        padding: 22px;
    }
}

@media (max-width: 620px) {
    .page-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .page-toolbar-actions {
        width: 100%;
    }

    .page-toolbar-actions .action-link {
        flex: 1;
    }

    .form-footer .primary-btn,
    .form-footer .secondary-btn {
        flex: 1;
    }

    .weekday-grid {
        grid-template-columns: repeat(4, minmax(0,1fr));
    }
}


/* Prises régulières : heure + dose + consommation de stock */
.schedule-fields-detailed {
    grid-template-columns: 1fr;
}

@media (min-width: 760px) {
    .schedule-fields-detailed {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        align-items: start;
    }

    /* Partager les lignes libellé / champ / aide, même si un libellé se replie. */
    .schedule-fields-detailed > .field:not(.full) {
        display: grid;
        align-self: stretch;
        grid-row: span 3;
        grid-template-rows: subgrid;
        row-gap: 0;
    }

    .schedule-fields-detailed .field.full {
        grid-column: 1 / -1;
    }
}


/* ==========================================================
   Stocks, historique, rappels et paramètres
   ========================================================== */

.stock-layout {
    display: grid;
    gap: 16px;
}

.stock-action-panel {
    align-self: start;
}

.stock-list {
    border-top: 1px solid var(--border);
}

.stock-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 17px 18px;
    border-bottom: 1px solid var(--border);
}

.stock-row[hidden] { display:none; }
.stock-pagination { display:flex; justify-content:center; align-items:center; flex-wrap:wrap; gap:8px; margin-top:20px; }
.stock-pagination a { display:inline-flex; align-items:center; justify-content:center; box-sizing:border-box; min-width:44px; height:44px; padding:8px 12px; text-decoration:none; }
.stock-pagination a[aria-current="page"] { background:var(--primary-button-bg); color:#fff; }
.stock-pagination a[aria-disabled="true"] { opacity:.4; cursor:default; }
.stock-pagination .ui-icon { width:18px; height:18px; }
.stock-page-status { margin:16px 0 0; padding:0 16px 20px; text-align:center; color:var(--text-soft); font-size:.85rem; }

.stock-row:last-child {
    border-bottom: 0;
}

.stock-number {
    display: flex;
    align-items: baseline;
    gap: 7px;
}

.stock-number strong {
    font-size: 1.35rem;
    letter-spacing: -.03em;
}

.stock-number span,
.stock-last {
    color: var(--text-muted);
    font-size: .86rem;
}

.stock-last {
    display: grid;
    gap: 3px;
}


/* L’ancre des pages reste sous la barre fixe sur Desktop. */
#history-movements { scroll-margin-top: 12px; }
@media (min-width: 900px) {
    #history-movements { scroll-margin-top: calc(var(--desktop-topbar-height, 68px) + 12px); }
}

.history-list {
    display: grid;
}

.history-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.history-row:last-child {
    border-bottom: 0;
}

.history-row > div:first-child {
    display: grid;
    gap: 3px;
}

.history-row > div:first-child > span {
    color: var(--text-muted);
    font-size: .8rem;
}

.history-row-full {
    align-items: flex-start;
    padding: 16px 18px;
}

.history-main {
    display: flex !important;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.history-icon {
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--surface-soft);
    color: var(--text-soft);
    font-weight: 900;
}

.history-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-weight: 850;
}

.history-meta {
    color: var(--text-muted);
    font-size: .82rem;
}

.history-note {
    color: var(--text-soft);
}

.history-amount {
    flex: 0 0 auto;
}

.movement-delta {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 5px 9px;
    border-radius: 999px;
    font-weight: 850;
    font-size: .84rem;
}

.movement-delta.positive {
    background: var(--green-soft);
    color: var(--green);
}

.movement-delta.negative {
    background: var(--amber-soft);
    color: var(--amber);
}

.history-filters {
    position: relative;
    z-index: 5;
    margin-bottom: 16px;
}

.history-filter-toggle { display: none; }
.history-filter-form[hidden] { display: none; }
@media (max-width: 899px) {
    .history-filter-toggle:not([hidden]) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 22px;
        align-items: center;
        gap: 4px 12px;
        width: 100%;
        min-height: 44px;
        padding: 0;
        border: 0;
        background: transparent;
        color: var(--text);
        font: inherit;
        text-align: left;
        cursor: pointer;
    }
    .history-filter-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 5px; border-radius: 6px; }
    .history-filter-toggle-label { font-weight: 700; }
    .history-filter-summary { grid-column: 1; color: var(--text-soft); font-size: .85rem; overflow-wrap: anywhere; }
    .history-filter-toggle .ui-icon { grid-column: 2; grid-row: 1 / 3; width: 22px; height: 22px; color: var(--blue); }
    .history-filter-toggle[aria-expanded="true"] .ui-icon { transform: rotate(180deg); }
    .history-filter-toggle[aria-expanded="true"] + .history-filter-form { margin-top: 16px; }
}

.history-filter-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.history-filter-actions {
    display: flex;
    gap: 8px;
    align-items: end;
}


.settings-grid {
    display: grid;
    gap: 16px;
}

.settings-list {
    display: grid;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.settings-row:first-child {
    padding-top: 0;
}

.settings-row:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.settings-row > div {
    display: grid;
    gap: 4px;
}

.settings-row span:not(.stock-pill) {
    color: var(--text-muted);
    font-size: .82rem;
}

.bottom-link {
    font-size: .66rem;
}

/* Préférence manuelle : clair */
html[data-theme="light"] {
    color-scheme: light;

    --bg: #f3f6fb;
    --bg-elevated: rgba(255,255,255,.78);
    --surface: rgba(255,255,255,.88);
    --surface-solid: #ffffff;
    --surface-soft: #f7f9fc;
    --surface-hover: #eef4ff;
    --text: #111827;
    --text-soft: #475569;
    --text-muted: #7b8797;
    --border: rgba(148,163,184,.22);
    --border-strong: rgba(148,163,184,.38);


    --blue: #0062cc;
    --blue-strong: #004fa6;
    --blue-soft: #E8F1FF;
    --green: #23b26d;
    --green-soft: #e8f8f0;
    --amber: #f4a51c;
    --amber-soft: #fff4d8;
    --red: #ef5350;
    --red-soft: #ffe8e7;
    --violet: #7567f8;
    --violet-soft: #efecff;
    --shadow-soft: 0 18px 45px rgba(37,54,86,.09);
    --shadow-card: 0 8px 24px rgba(30,41,59,.06);
}

/* Préférence manuelle : sombre */
html[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0d1218;
    --bg-elevated: rgba(21,28,36,.82);
    --surface: rgba(20,27,35,.88);
    --surface-solid: #151c24;
    --surface-soft: #18212b;
    --surface-hover: #1f2d3f;
    --text: #edf2f7;
    --text-soft: #c3ceda;
    --text-muted: #8d9aaa;
    --border: rgba(148,163,184,.16);
    --border-strong: rgba(148,163,184,.28);


    --blue: #0062cc;
    --blue-strong: #004fa6;
    --blue-soft: #15243A;
    --green: #52d28c;
    --green-soft: #163326;
    --amber: #f7b94b;
    --amber-soft: #3a2e17;
    --red: #ff7773;
    --red-soft: #3b1d1e;
    --violet: #a097ff;
    --violet-soft: #29264e;
    --shadow-soft: 0 18px 50px rgba(0,0,0,.28);
    --shadow-card: 0 8px 24px rgba(0,0,0,.18);
}

html[data-theme="dark"] .alert {
    color: #ffb8b6;
}

html[data-theme="dark"] .progress {
    background: #293442;
}

html[data-theme="dark"] .sidebar-foot {
    background: linear-gradient(180deg, rgba(59,130,246,.12), rgba(16,185,129,.09)), #18212b;
}

html[data-theme="dark"] .sidebar-foot small {
    color: #92a0af;
}

@media (min-width: 720px) {
    .history-filter-form {
        grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto;
        align-items: end;
    }


}

@media (min-width: 1080px) {
    .stock-layout {
        grid-template-columns: minmax(0,1.7fr) minmax(310px,.8fr);
        align-items: start;
    }

    .stock-row {
        grid-template-columns: minmax(240px,1fr) minmax(150px,.45fr) minmax(180px,.65fr);
        align-items: center;
    }
}

@media (max-width: 420px) {
    .bottom-link {
        font-size: .61rem;
    }

    .bottom-icon {
        font-size: 1rem;
    }

    .history-row-full {
        flex-direction: column;
    }

    .history-amount {
        padding-left: 50px;
    }
}


/* Correctif CSP : aucune couleur via attribut style="" */

.legend-dot-green {
    background: var(--green);
}

/* ==========================================================
   Refonte visuelle — alignement mockup 2026
   ========================================================== */

:root {
    --sidebar-open: 258px;
    --sidebar: var(--sidebar-open);
    --desktop-topbar-height: 68px;
    --page-max: 1560px;
}


[hidden] { display: none !important; }

.ui-icon {
    width: 1.15em;
    height: 1.15em;
    flex: 0 0 auto;
}

.brand-logo {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    flex: 0 0 32px;
}

.app-logo-svg {
    width: 100%;
    height: 100%;
}

/* Sidebar */
@media (min-width: 900px) {

    .sidebar {
        background: color-mix(in srgb, var(--surface-solid) 96%, transparent);
    }

    .sidebar-head {
        display: flex;
        align-items: center;
        gap: 8px;
        min-height: 48px;
        margin-bottom: 16px;
    }

    .brand {
        min-width: 0;
        flex: 1;
    }

    .brand-text {
        white-space: nowrap;
        overflow: hidden;
        transition: opacity .15s ease, width .22s ease;
    }

    .nav-link {
        position: relative;
        border-radius: 14px;
        transition: background .15s ease, color .15s ease;
    }

    .nav-icon {
        display: grid;
        place-items: center;
    }


    .nav-link.active {
        background: var(--blue-soft);
        color: var(--blue);
    }

    .sidebar-foot {
        background: linear-gradient(180deg, #eaf3ff 0%, #e7f3f6 60%, #dceff0 100%);
        color: #334155;
    }

    .sidebar-foot strong {
        z-index: 2;
    }

    .sidebar-foot-line {
        z-index: 2;
        left: 18px;
        top: 92px;
        background: rgba(24,62,118,.55);
    }

    .sidebar-foot small {
        z-index: 2;
        left: 18px;
        bottom: 14px;
    }

}

/* Topbar */
.topbar-inner {
    min-height: 66px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.topbar-spacer { display: none; }

.top-icon-btn {
    border: 0;
    background: transparent;
    color: var(--text-soft);
}

.top-icon-btn {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
}

.top-icon-btn:hover {
    background: var(--surface-soft);
}

.popover-wrap { position: relative; }

.top-popover {
    position: absolute;
    right: 0;
    top: calc(100% + 9px);
    z-index: 100;
    width: 250px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface-solid);
    box-shadow: 0 18px 48px rgba(15,23,42,.16);
}

.top-popover button,
.popover-link {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--text);
    text-align: left;
}

.top-popover button:hover,
.popover-link:hover { background: var(--surface-soft); }


.user-popover small {
    color: var(--text-muted);
}

.user-popover-head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 9px 12px;
    margin-bottom: 5px;
    border-bottom: 1px solid var(--border);
}

.user-popover-head > span:last-child { display: grid; gap: 2px; }
.avatar-large { width: 40px; height: 40px; }
.danger-link { color: var(--red) !important; }

@media (min-width: 900px) {
    .topbar-inner {
        display: grid;
        grid-template-columns: minmax(120px,1fr) minmax(360px,600px) minmax(250px,1fr);
        align-items: center;
        gap: 22px;
        padding: 12px 28px;
    }

    .topbar-spacer { display: block; }

    .top-search {
        width: 100%;
        max-width: 600px;
        justify-self: center;
        min-height: 44px;
        background: color-mix(in srgb, var(--surface-solid) 82%, transparent);
    }

    .top-search-icon { display: grid; place-items: center; }
    .top-search-icon .ui-icon { width: 17px; height: 17px; }
    .topbar-actions { justify-self: end; }
    .user-name-desktop { display: inline; font-weight: 760; }
}

/* Theme trigger follows effective theme */


/* Hero */
.hero-dashboard {
    position: relative;
    overflow: hidden;
    margin-bottom: 18px;
    padding: 28px 24px 30px;
    border-radius: 0 0 24px 24px;
    background: linear-gradient(100deg, rgba(255,255,255,.08), rgba(99,160,255,.08)), color-mix(in srgb, var(--blue-soft) 54%, var(--bg));
}

.hero-copy { position: relative; z-index: 2; }
.hero-dashboard h1 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}
.hero-leaf { color: var(--green); display: inline-grid; place-items: center; }
.hero-mantra {
    display: none;
    position: absolute;
    z-index: 2;
    right: 30px;
    top: 42px;
    text-align: right;
    color: var(--text-soft);
    font-size: .84rem;
    font-weight: 700;
    line-height: 1.35;
}
.hero-mantra span { display: block; }
.hero-mantra i {
    display: block;
    width: 26px;
    height: 2px;
    margin: 10px 0 0 auto;
    background: var(--blue);
    border-radius: 999px;
}

@media (min-width: 1120px) {
    .hero-mantra { display: block; }
}

/* General cards and headings */
.page { padding-top: 24px; }
.section-shell,
.panel,
.form-section {
    border-color: color-mix(in srgb, var(--border) 78%, transparent);
    box-shadow: 0 10px 28px rgba(30,41,59,.045);
}
.section-shell { border-radius: 24px; }
.panel { border-radius: 18px; }
.section-icon,
.empty-state-icon,
.med-icon,
.settings-section-icon {
    display: grid;
    place-items: center;
}
.section-icon .ui-icon,
.empty-state-icon .ui-icon,
.med-icon .ui-icon,
.settings-section-icon .ui-icon {
    width: 22px;
    height: 22px;
}
.section-icon-blue { background: var(--blue-soft); color: var(--blue); }

.action-link,
.primary-btn,
.secondary-btn,
.quick-action {
    gap: 8px;
}
.action-link .ui-icon,
.primary-btn .ui-icon,
.secondary-btn .ui-icon,
.quick-action .ui-icon { width: 18px; height: 18px; }

.refined-toolbar { align-items: center; }
.page-kicker {
    color: var(--blue) !important;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .08em;
}

/* Filter popover */
.filter-menu { position: relative; }
.filter-menu summary { list-style: none; cursor: pointer; }
.filter-menu summary::-webkit-details-marker { display: none; }
.filter-popover {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 60;
    width: 220px;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-solid);
    box-shadow: 0 18px 42px rgba(15,23,42,.14);
}
.filter-popover a {
    display: block;
    padding: 9px 10px;
    border-radius: 9px;
    color: var(--text-soft);
    font-size: .88rem;
    font-weight: 700;
}
.filter-popover a:hover,
.filter-popover a.active { background: var(--blue-soft); color: var(--blue); }

/* Medication table */
.medication-dashboard-table { border-top: 1px solid var(--border); }
.medication-dashboard-head { display: none; }
.medication-dashboard-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
}
.medication-dashboard-row:last-child { border-bottom: 0; }
.medication-dashboard-row .med-cell { display: none; }
.med-row-actions { display: flex; align-items: center; gap: 4px; }
.row-menu {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
}
.row-menu:hover { background: var(--surface-soft); color: var(--text); }
.row-menu-danger:hover { color: var(--red); }
.row-menu .ui-icon { width: 18px; height: 18px; }
.med-stock-cell strong { margin-right: 4px; color: var(--text); }
.med-stock-cell > span { color: var(--text-muted); font-size: .82rem; }
.med-posology { line-height: 1.35; }
.med-days-cell { font-weight: 760; color: var(--text); }

.status.neutral { color: var(--text-muted); background: var(--surface-soft); }
.status.out { color: #64748b; background: #eef2f7; }
.progress-stable > span { background: var(--green); }
.progress-watch > span { background: var(--amber); }
.progress-low > span { background: var(--red); }
.progress-out > span { background: #94a3b8; }
.progress-w-10 { width: 10%; }
.progress-w-25 { width: 25%; }
.progress-w-50 { width: 50%; }
.progress-w-75 { width: 75%; }
.progress-w-100 { width: 100%; }

@media (min-width: 900px) {
    .medication-dashboard-head,
    .medication-dashboard-row {
        grid-template-columns: minmax(240px,1.35fr) minmax(230px,1.25fr) minmax(150px,.75fr) minmax(120px,.65fr) minmax(135px,.72fr) 52px;
        gap: 16px;
    }

    .medication-dashboard-head {
        display: grid;
        padding: 10px 22px;
        background: var(--surface-soft);
        color: var(--text-muted);
        font-size: .76rem;
        font-weight: 800;
    }

    .medication-dashboard-row { padding: 15px 22px; }
    .medication-dashboard-row .med-cell { display: block; }
    .med-row-actions { justify-content: flex-end; }
}

.dashboard-empty-state {
    display: grid;
    place-items: center;
    align-content: center;
}
.dashboard-empty-state > * { margin-left: auto; margin-right: auto; }

/* Accueil : cartes dans leur ordre mobile naturel. Sur desktop, la
   section médicaments occupe la première rangée de la grille. */
.dashboard-overview-grid {
    align-items: stretch;
    margin-top: 0;
}

@media (min-width: 900px) {
    .dashboard-overview-grid > .dashboard-medications {
        grid-column: 1 / -1;
        grid-row: 1;
    }
}
.panel-title-with-icon { display: flex; align-items: center; gap: 9px; }
.panel-title-icon { color: var(--blue); display: grid; place-items: center; }
.panel-title-icon .ui-icon { width: 18px; height: 18px; }
.panel-footer-link {
    min-height: 48px;
    margin: 0 16px 16px;
    padding: 11px 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
    font-size: .84rem;
    font-weight: 750;
}
.panel-footer-link .ui-icon { width: 17px; height: 17px; }
.legend-dot-amber { background: var(--amber); }
.legend-dot-red { background: var(--red); }
.legend-dot-gray { background: var(--text-muted); }
.timeline-arrow { align-self: center; color: var(--text-muted); }
.timeline-arrow .ui-icon { width: 18px; height: 18px; }
.quick-action-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.quick-action > .ui-icon { flex: 0 0 auto; }
.health-card {
    min-height: 88px;
    margin: 0 18px 18px;
    padding: 15px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 14px;
    background: linear-gradient(115deg, #5b9bd3, #86bed9 58%, #dcefdc);
    color: #fff;
}
.health-card > div { position: relative; z-index: 2; }
.health-card strong { display: block; line-height: 1.25; }
.health-card > div span { display: block; width: 25px; height: 2px; margin-top: 10px; background: rgba(255,255,255,.85); }
.health-card svg { width: 150px; height: 82px; margin-right: -12px; }
.health-leaf-stem {
    fill: none;
    stroke-width: 3;
}

/* Refined page extras */
.heading-with-icon { display: flex; gap: 12px; align-items: flex-start; }
.settings-section-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 13px;
    background: var(--blue-soft);
    color: var(--blue);
}
.icon-text-btn { display: inline-flex; align-items: center; gap: 8px; }
.icon-text-btn .ui-icon { width: 17px; height: 17px; }

/* Mobile */
@media (max-width: 899px) {
    .theme-trigger { width: 38px; height: 38px; }
    .user-name-desktop {
        display: none;
    }
    .top-popover { position: fixed; top: 68px; right: 12px; }
    .hero-dashboard { margin: -20px -14px 16px; border-radius: 0 0 22px 22px; padding: 26px 18px 28px; }
    .page-toolbar-actions { flex-wrap: wrap; }
    .filter-menu { flex: 1; }
    .filter-menu summary { justify-content: center; }
    .filter-popover { left: 0; right: auto; }
}

/* Dark refinements */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .sidebar-foot {
        background: linear-gradient(180deg, #162437, #173039);
        color: #dbe8f5;
    }
}
html[data-theme="dark"] .sidebar-foot {
    background: linear-gradient(180deg, #162437, #173039);
    color: #dbe8f5;
}
html[data-theme="dark"] .status.out { color: #b4c0ce; background: #202a35; }
.bottom-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ==========================================================
   Ajustements visuels v5 — densité, focus, toggle, sidebar
   ========================================================== */

/* La sidebar doit rester au-dessus du contenu pour que les infobulles
   du mode replié ne passent jamais sous les cartes. */
@media (min-width: 900px) {
    .main-area {
        position: relative;
        z-index: 1;
        min-width: 0;
    }
}

/* Recherche : le focus appartient au conteneur, pas au champ lui-même.
   Cela évite la grande lisière bleue de Firefox autour de l'input. */
.top-search {
    transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
    position: relative;
    overflow: visible;
}

.top-search:focus-within {
    border-color: color-mix(in srgb, var(--blue) 32%, var(--border-strong));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--blue) 8%, transparent);
    background: var(--surface-solid);
}

.top-search input,
.top-search input:hover,
.top-search input:focus,
.top-search input:focus-visible {
    appearance: none;
    -webkit-appearance: none;
    outline: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

/* Toggle clair / sombre : uniquement deux états, sans menu. */
.theme-trigger {
    border: 1px solid transparent;
    transition: background .14s ease, border-color .14s ease, transform .14s ease;
}

.theme-trigger:hover {
    border-color: var(--border);
}

.theme-trigger:active {
    transform: scale(.96);
}


/* Titres plus discrets, sur le tableau de bord comme dans les autres onglets. */
.hero-dashboard {
    min-height: 132px;
    padding-top: 23px;
    padding-bottom: 24px;
}

.hero-dashboard .eyebrow {
    font-size: .91rem;
    margin-bottom: 5px;
}

.hero-dashboard h1 {
    max-width: 820px;
    font-size: clamp(1.72rem, 2.35vw, 2.28rem);
    line-height: 1.08;
    letter-spacing: -.038em;
    font-weight: 820;
}


.page-toolbar {
    margin-bottom: 15px;
}

.page-toolbar h1 {
    margin-bottom: 5px;
    font-size: clamp(1.55rem, 2.15vw, 2.05rem);
    line-height: 1.1;
    letter-spacing: -.032em;
    font-weight: 820;
}

.page-toolbar p {
    font-size: .91rem;
}

.page-kicker {
    margin-bottom: 4px !important;
    font-size: .71rem;
}

.section-heading h2,
.form-section-heading h2 {
    letter-spacing: -.018em;
}

/* Bloc médicaments légèrement moins haut lorsqu'il est vide. */
.dashboard-empty-state {
    min-height: 292px;
}

/* Les trois cartes du bas reprennent la densité du mockup :
   mêmes dimensions et beaucoup moins d'espace vide. */
@media (min-width: 900px) {
    .dashboard-overview-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 16px;
        align-items: stretch;
    }

    .dashboard-overview-grid > .panel {
        height: 292px;
        min-height: 292px;
        display: flex;
        flex-direction: column;
    }

    .dashboard-overview-grid .panel-heading {
        flex: 0 0 auto;
        padding: 14px 16px 9px;
    }

    .dashboard-overview-grid .panel-heading h3 {
        font-size: .94rem;
        letter-spacing: -.015em;
    }

    .stock-overview-card .stock-content {
        flex: 0 0 auto;
        gap: 14px;
        padding: 4px 16px 8px;
    }

    .stock-overview-card .donut {
        width: 92px;
        height: 92px;
        flex: 0 0 92px;
    }


    .stock-overview-card .donut-label {
        font-size: .68rem;
    }

    .stock-overview-card .donut-label strong {
        font-size: 1.28rem;
    }

    .stock-overview-card .legend {
        gap: 6px;
    }

    .stock-overview-card .legend-item {
        font-size: .81rem;
    }

    .stock-overview-card .panel-footer-link {
        min-height: 41px;
        margin: auto 14px 14px;
        padding: 8px 11px;
        font-size: .8rem;
    }

    .reminders-card .timeline {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        padding: 0 16px 10px;
    }

    .reminders-card .timeline-item {
        gap: 10px;
        padding: 7px 0 9px;
    }

    .reminders-card .timeline-item:not(:last-child)::after {
        top: 24px;
        bottom: -1px;
    }

    .reminders-card .timeline-kicker {
        font-size: .72rem;
    }

    .reminders-card .timeline-title {
        font-size: .88rem;
        line-height: 1.2;
    }

    .reminders-card .timeline-meta {
        font-size: .76rem;
        line-height: 1.25;
    }

    .quick-actions-card .quick-actions {
        flex: 0 0 auto;
        gap: 7px;
        padding: 2px 14px 8px;
    }

    .quick-actions-card .quick-action {
        min-height: 41px;
        padding: 7px 10px;
        border-radius: 11px;
        font-size: .82rem;
        line-height: 1.15;
    }

    .quick-actions-card .quick-action .ui-icon {
        width: 16px;
        height: 16px;
    }

    .quick-actions-card .health-card {
        height: 72px;
        min-height: 72px;
        margin: auto 14px 14px;
        padding: 10px 13px;
        border-radius: 12px;
    }

    .quick-actions-card .health-card strong {
        font-size: .88rem;
    }

    .quick-actions-card .health-card svg {
        width: 122px;
        height: 67px;
    }
}

@media (min-width: 1120px) {
    .hero-copy {
        padding-right: 225px;
    }
}

@media (max-width: 899px) {
    .hero-dashboard {
        min-height: 122px;
        padding-top: 22px;
        padding-bottom: 23px;
    }


    .page-toolbar h1 {
        font-size: clamp(1.45rem, 7vw, 1.9rem);
    }

    .dashboard-empty-state {
        min-height: 265px;
    }
}

/* Outil temporaire de données de démonstration */

.danger-outline {
    color: var(--red);
    border: 1px solid color-mix(in srgb, var(--red) 28%, var(--border));
}

/* ==========================================================
   Ajustements visuels v6
   - cartes dashboard fidèles au mockup
   - autocomplétion recherche
   - logo gélules croisées
   - profil non cliquable sauf chevron
   - photo de profil
   ========================================================== */

/* Recherche : aucun halo interne Firefox, bouton X et suggestions */

.top-search input::-webkit-search-decoration,
.top-search input::-webkit-search-cancel-button,
.top-search input::-webkit-search-results-button,
.top-search input::-webkit-search-results-decoration {
    display: none;
}

.search-clear {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    display: grid;
    place-items: center;
    margin-right: -3px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
}

.search-clear:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.search-clear .ui-icon {
    width: 16px;
    height: 16px;
}

.search-suggestions {
    position: absolute;
    z-index: 220;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    max-height: 330px;
    overflow: auto;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: var(--surface-solid);
    box-shadow: 0 18px 45px rgba(15,23,42,.16);
}

.search-suggestion {
    display: grid;
    gap: 2px;
    padding: 10px 11px;
    border-radius: 10px;
}

.search-suggestion:hover,
.search-suggestion.active {
    background: var(--surface-hover);
}

.search-suggestion-main {
    overflow: hidden;
    color: var(--text);
    font-weight: 780;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-suggestion-meta {
    overflow: hidden;
    color: var(--text-muted);
    font-size: .78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Logo de l’application. */
.brand-logo {
    filter: drop-shadow(0 7px 13px rgba(67,145,222,.13));
}

/* Profil : avatar et prénom purement informatifs. Seul le chevron est un bouton. */
.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
}

.avatar-static {
    cursor: default;
    user-select: none;
}

.avatar img,
.avatar-preview img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: inherit;
    object-fit: cover;
}

.user-menu-arrow {
    width: 28px;
    height: 34px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
}

.user-menu-arrow:hover,
.user-menu-arrow[aria-expanded="true"] {
    background: var(--surface-soft);
    color: var(--text);
}

.user-menu-arrow .ui-icon {
    width: 15px;
    height: 15px;
}

.user-arrow-wrap {
    display: grid;
    place-items: center;
}

.user-arrow-wrap .user-popover {
    right: 0;
    top: calc(100% + 10px);
}

/* Les trois cartes : même gabarit, contenu proche du mockup.
   Le donut retrouve une vraie présence visuelle. */
@media (min-width: 1180px) {
    .dashboard-overview-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: stretch;
    }

    .dashboard-overview-grid > .panel {
        display: flex;
        flex-direction: column;
    }


    .dashboard-overview-grid .panel-heading h3 {
        letter-spacing: -.018em;
    }

    .stock-overview-card .stock-content {
        flex: 1 1 auto;
        align-items: center;
        min-height: 0;
    }

    .stock-overview-card .donut-label {
        font-size: .73rem;
        line-height: 1.22;
    }

    .stock-overview-card .donut-label strong {
        margin-bottom: 5px;
        font-size: 1.72rem;
    }

    .donut-caption {
        display: block;
    }

    .stock-overview-card .legend-item strong {
        min-width: 18px;
        text-align: right;
    }

    .stock-overview-card .legend-dot {
        width: 9px;
        height: 9px;
    }

    .stock-overview-card .panel-footer-link {
        min-height: 46px;
        margin: 0 18px 17px;
        padding: 9px 13px;
        font-size: .84rem;
    }

    .reminders-card .timeline {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        padding: 0 20px 11px;
    }

    .reminders-card .timeline-item {
        min-height: 65px;
        gap: 11px;
        padding: 8px 0 10px;
    }

    .reminders-card .timeline-item:not(:last-child)::after {
        top: 26px;
        bottom: -2px;
    }

    .reminders-card .timeline-kicker {
        font-size: .75rem;
    }

    .reminders-card .timeline-title {
        line-height: 1.18;
    }

    .reminders-card .timeline-meta {
        line-height: 1.22;
    }

    .quick-actions-card .quick-actions {
        flex: 0 0 auto;
        padding: 2px 18px 10px;
    }

    .quick-actions-card .quick-action {
        padding: 8px 12px;
        border-radius: 12px;
        font-size: .84rem;
        line-height: 1.16;
    }

}

@media (min-width: 900px) and (max-width: 1179px) {
    .dashboard-overview-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-overview-grid > .panel {
        min-height: 260px;
    }
}

/* Réglages photo de profil */
.avatar-settings {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.avatar-preview {
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: linear-gradient(135deg, #c7d2fe, #dbeafe 50%, #bbf7d0);
    color: #30415a;
    font-weight: 900;
}

.avatar-preview-large {
    width: 96px;
    height: 96px;
    flex: 0 0 96px;
    font-size: 1.75rem;
}

.avatar-settings-actions {
    display: grid;
    gap: 10px;
    min-width: min(100%, 310px);
}

.avatar-settings-actions form {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
    margin: 0;
}

.avatar-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.avatar-file-label {
    cursor: pointer;
}

.avatar-save-btn:disabled {
    opacity: .48;
    cursor: not-allowed;
}

@media (max-width: 899px) {


    .search-suggestions {
        position: fixed;
        left: 12px;
        right: 12px;
        top: 64px;
    }
}


/* ==========================================================
   Harmonisation v7
   ========================================================== */

/* Tableau de bord : le titre repose directement sur le fond général. */
.hero-dashboard-plain {
    min-height: 0;
    margin: 0 0 14px;
    padding: 10px 4px;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.hero-dashboard-plain .hero-copy {
    padding-right: 0;
}

.hero-dashboard-plain .hero-mantra {
    top: 24px;
    right: 8px;
}

.hero-dashboard-plain h1 {
    font-size: clamp(1.4rem, 2vw, 1.7rem);
    max-width: none;
    justify-content: center;
    text-align: center;
}

@media (max-width: 899px) {
    .hero-dashboard-plain {
        min-height: auto;
    }
}

/* Sidebar : footer intégré au fond du menu, sans carte ni paysage. */
@media (min-width: 900px) {
    .sidebar-foot {
        position: relative;
        min-height: 132px;
        margin-top: auto;
        padding: 20px 12px 10px;
        border: 0;
        border-radius: 0;
        background: transparent !important;
        box-shadow: none;
        color: var(--text-soft);
        isolation: auto;
    }

    .sidebar-foot strong {
        position: static;
        display: block;
        max-width: 165px;
        color: var(--text-soft);
    }

    .sidebar-foot-line {
        position: static;
        display: block;
        width: 28px;
        height: 2px;
        margin-top: 18px;
        background: color-mix(in srgb, var(--blue) 62%, transparent);
        border-radius: 999px;
    }

    .sidebar-foot-meta {
        position: absolute;
        left: 12px;
        right: 12px;
        bottom: 9px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }

    .sidebar-foot small {
        position: static;
        color: var(--text-muted);
        font-size: .68rem;
        line-height: 1;
    }

}

html[data-theme="dark"] .sidebar-foot {
    background: transparent !important;
}

/* Cartes du dashboard : même largeur/hauteur, titre stock sur une ligne. */
@media (min-width: 1180px) {


    .dashboard-overview-grid .panel-heading {
        padding-left: 17px;
        padding-right: 17px;
    }


    .stock-overview-card .panel-heading h3 {
        letter-spacing: -.024em;
    }


    .stock-overview-card .donut {
        flex-basis: 142px;
    }


}

/* Tables médicaments : réserve assez d'espace au statut complet. */
@media (min-width: 900px) {

    .medication-full-table .status {
        max-width: 100%;
    }
}

/* Page Rappels */
.reminder-engine-card {
    min-height: auto;
    margin-bottom: 16px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.reminder-engine-main {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.reminder-engine-icon {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--blue-soft);
    color: var(--blue);
}

.reminder-engine-icon .ui-icon {
    width: 22px;
    height: 22px;
}

.reminder-engine-main h2 {
    margin: 0 0 4px;
    font-size: 1rem;
    letter-spacing: -.015em;
}

.reminder-engine-main p {
    max-width: 720px;
    margin: 0;
    color: var(--text-muted);
    font-size: .84rem;
    line-height: 1.42;
}

.reminder-engine-status {
    flex: 0 0 auto;
}

.reminder-treatment-list {
    display: grid;
    border-top: 1px solid var(--border);
}

.reminder-treatment-row {
    min-height: 78px;
    padding: 13px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--border);
}

.reminder-treatment-row:last-child {
    border-bottom: 0;
}

.reminder-treatment-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.reminder-treatment-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.reminder-treatment-copy strong {
    overflow: hidden;
    color: var(--text);
    font-size: .96rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reminder-treatment-copy span {
    overflow: hidden;
    color: var(--text-muted);
    font-size: .82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reminder-treatment-side {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    flex-wrap: wrap;
}

.reminder-threshold {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text-soft);
    font-size: .78rem;
    font-weight: 780;
    white-space: nowrap;
}

/* Historique : lignes plus denses + icônes SVG. */
.history-row-full {
    padding-top: 12px;
    padding-bottom: 12px;
}

.history-icon {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
}

.history-icon .ui-icon {
    width: 17px;
    height: 17px;
}

.history-icon.positive {
    background: var(--green-soft);
    color: var(--green);
}

.history-icon.negative {
    background: var(--amber-soft);
    color: var(--amber);
}

.history-icon.correction {
    background: var(--blue-soft);
    color: var(--blue);
}

.history-meta,
.history-note {
    margin-top: 2px;
}

.history-note {
    font-size: .78rem;
}

/* Paramètres : un peu plus dense sans modifier la structure. */
.settings-grid-refined {
    gap: 14px;
}

.settings-grid-refined .form-section {
    padding: 18px 20px;
}

.settings-grid-refined .form-section-heading {
    margin-bottom: 14px;
}

.settings-grid-refined .settings-row {
    padding-top: 11px;
    padding-bottom: 11px;
}

.settings-grid-refined .avatar-preview-large {
    width: 84px;
    height: 84px;
    flex-basis: 84px;
}

@media (max-width: 720px) {
    .reminder-engine-card,
    .reminder-treatment-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .reminder-treatment-side {
        justify-content: flex-start;
        padding-left: 58px;
    }

    .reminder-treatment-copy strong,
    .reminder-treatment-copy span {
        white-space: normal;
    }
}


/* ==========================================================
   Ajustements v8 — desktop ouvert/replié et actions par icônes
   ========================================================== */

/* Les colonnes d'actions utilisent toujours de vraies icônes SVG. */
.dashboard-row-actions,
.medication-full-table .med-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    min-width: 0;
}

.dashboard-row-actions .row-menu,
.medication-full-table .row-menu {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
}

.dashboard-row-actions .row-menu .ui-icon,
.medication-full-table .row-menu .ui-icon {
    width: 17px;
    height: 17px;
}

/* Tableau de bord : le statut et les deux actions restent visibles même
   lorsque la sidebar est ouverte. */
@media (min-width: 900px) {
    .dashboard-medications .medication-dashboard-head,
    .dashboard-medications .medication-dashboard-row {
        grid-template-columns:
            minmax(190px, 1.25fr)
            minmax(150px, .92fr)
            minmax(132px, .72fr)
            minmax(108px, .58fr)
            minmax(145px, .78fr)
            70px;
        gap: 11px;
    }

    .medication-full-table .medication-dashboard-head,
    .medication-full-table .medication-dashboard-row {
        grid-template-columns:
            minmax(190px, 1.25fr)
            minmax(150px, .92fr)
            minmax(135px, .72fr)
            minmax(108px, .58fr)
            minmax(150px, .8fr)
            72px;
        gap: 11px;
    }

    .dashboard-medications .status,
    .medication-full-table .status {
        white-space: nowrap;
    }
}

/* Gabarit du mockup : Stocks et Rappels ont un peu plus de largeur que
   Actions rapides. Cela évite surtout l'effet tassé sidebar ouverte. */
@media (min-width: 1180px) {

    .dashboard-overview-grid .panel-heading {
        min-height: 50px;
        padding: 14px 16px 8px;
    }

    .dashboard-overview-grid .panel-heading h3 {
        font-size: .94rem;
        line-height: 1.15;
    }

    .stock-overview-card .panel-heading h3 {
        white-space: nowrap;
    }

    .stock-overview-card .stock-content {
        padding: 5px 18px 9px;
    }

    .quick-actions-card .health-card {
        margin-left: 16px;
        margin-right: 16px;
        margin-bottom: 20px;
    }
}

/* Sur les largeurs desktop intermédiaires on conserve les 3 cartes tant
   qu'elles disposent d'une vraie largeur utile. */
@media (min-width: 1100px) and (max-width: 1179px) {

    .dashboard-overview-grid > .panel {
        min-height: 300px;
        height: 300px;
    }

    .stock-overview-card .donut {
        width: 136px;
        height: 136px;
        flex: 0 0 136px;
    }


    .stock-overview-card .legend-item {
        font-size: .79rem;
    }
}

/* Le titre Actions rapides reprend l'icône éclair du mockup. */
.quick-actions-card .panel-title-icon .ui-icon {
    width: 19px;
    height: 19px;
}


/* ==========================================================
   Sidebar fixe + proportions finales du dashboard
   ========================================================== */

/* La navigation desktop reste fixe ; la barre supérieure reste collée en haut. */
@media (min-width: 900px) {
    .app-shell {
        display: block;
        min-height: 100vh;
        transition: none;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--sidebar) !important;
        height: 100vh;
        padding: 18px 12px 16px !important;
        z-index: 90;
        overflow: visible;
        transition: none;
    }

    .main-area {
        margin-left: var(--sidebar);
    }

    .topbar {
        position: sticky;
        top: 0;
        width: auto;
        min-height: var(--desktop-topbar-height);
        z-index: 80;
    }

    .sidebar-head {
        justify-content: flex-start;
    }

    .sidebar-head .brand {
        flex: 1 1 auto;
        padding-right: 8px;
    }
}

/*
 * Répartition voulue :
 *  - Vue d'ensemble des stocks : la plus large
 *  - Prochains rappels : intermédiaire
 *  - Actions rapides : la plus compacte
 */
@media (min-width: 1180px) {
    .dashboard-overview-grid {
        grid-template-columns:
            minmax(350px, 1.16fr)
            minmax(235px, .92fr)
            minmax(220px, .92fr) !important;
        gap: 14px;
    }

    .dashboard-overview-grid > .panel {
        height: 300px;
        min-height: 300px;
    }

    /* Plus d'air autour du donut et de la légende. */
    .stock-overview-card .stock-content {
        gap: 26px;
        padding-left: 22px;
        padding-right: 22px;
    }

    .stock-overview-card .donut {
        width: 146px;
        height: 146px;
        flex: 0 0 146px;
    }

    .stock-overview-card .legend {
        flex: 1 1 auto;
        min-width: 126px;
        gap: 10px;
    }

    .stock-overview-card .legend-item {
        gap: 12px;
        font-size: .84rem;
    }

    /* La carte rappels reste lisible malgré sa largeur plus contenue. */
    .reminders-card .timeline {
        padding-left: 16px;
        padding-right: 16px;
    }

    .reminders-card .timeline-title {
        font-size: .89rem;
    }

    .reminders-card .timeline-meta {
        font-size: .76rem;
    }

    /* Actions rapides : zone illustration un peu moins haute,
       avec une vraie marge sous l'illustration. */
    .quick-actions-card .quick-actions {
        padding-left: 15px;
        padding-right: 15px;
        gap: 7px;
    }

    .quick-actions-card .quick-action {
        min-height: 44px;
    }

    .quick-actions-card .health-card {
        height: 70px;
        min-height: 70px;
        margin: auto 15px 18px;
        padding: 8px 13px;
        border-radius: 13px;
    }

    .quick-actions-card .health-card strong {
        font-size: .86rem;
        line-height: 1.12;
        white-space: nowrap;
    }

    .quick-actions-card .health-card > div span {
        margin-top: 7px;
    }

    .quick-actions-card .health-card svg {
        width: 118px;
        height: 64px;
        margin-right: -9px;
    }
}

/* Desktop un peu moins large : on conserve trois cartes mais on
   privilégie déjà clairement la carte des stocks. */
@media (min-width: 1100px) and (max-width: 1179px) {
    .dashboard-overview-grid {
        grid-template-columns:
            minmax(320px, 1.18fr)
            minmax(245px, .94fr)
            minmax(225px, .88fr) !important;
        gap: 12px;
    }

    .stock-overview-card .stock-content {
        gap: 18px;
        padding-left: 16px;
        padding-right: 16px;
    }

    .quick-actions-card .health-card {
        height: 68px;
        min-height: 68px;
        margin-bottom: 18px;
        padding-top: 7px;
        padding-bottom: 7px;
    }

    .quick-actions-card .health-card strong {
        white-space: nowrap;
        line-height: 1.1;
    }
}


/* ==========================================================
   Sidebar plus compacte
   ========================================================== */

@media (min-width: 900px) {
    :root {
        --sidebar: 215px;
    }


    .brand {
        gap: 9px;
        padding: 4px 8px 17px;
        font-size: .98rem;
        cursor: default;
        user-select: none;
    }

    .brand-logo {
        flex: 0 0 auto;
    }

    .nav-list {
        gap: 4px;
    }

    .nav-link {
        gap: 10px;
        min-height: 42px;
        padding: 8px 10px;
        font-size: .88rem;
        font-weight: 700;
    }


    .sidebar-foot {
        padding-left: 10px;
        padding-right: 10px;
    }

    .sidebar-foot strong {
        font-size: .90rem;
        line-height: 1.28;
    }

    .sidebar-foot-meta small {
        font-size: .72rem;
    }
}

/* ==========================================================
   Dimensions des icônes de navigation desktop
   ========================================================== */
@media (min-width: 900px) {
    .nav-icon {
        width: 27px;
        height: 27px;
        flex: 0 0 27px;
    }

    .nav-icon .ui-icon {
        width: 25px;
        height: 25px;
        stroke-width: 1.8;
    }
}

/* ==========================================================
   Bouton de thème clair / sombre
   Visuel CSS ; le JavaScript existant ne sert qu'à appliquer
   et mémoriser le thème entre les pages.
   ========================================================== */
.theme-trigger.theme-switch {
    position: relative;
    display: block;
    width: 78px;
    height: 34px;
    min-width: 78px;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 34px;
    background: #ebebeb;
    color: #5f6670;
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, .40),
        inset 0 -1px 3px rgba(255, 255, 255, .40);
    cursor: pointer;
    transition: background-color .3s ease, box-shadow .3s ease, transform .14s ease;
}

.theme-trigger.theme-switch::after {
    content: "";
    position: absolute;
    z-index: 1;
    top: 2px;
    left: 2px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(180deg, #ffcc89, #d8860b);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .20);
    transform: translateX(0);
    transition: left .3s ease, transform .3s ease, width .18s ease, background .3s ease;
}

.theme-trigger.theme-switch:hover {
    border-color: transparent;
    background: #e5e5e5;
}

.theme-trigger.theme-switch:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--blue) 34%, transparent);
    outline-offset: 3px;
}

.theme-trigger.theme-switch:active {
    transform: scale(.98);
}

.theme-trigger.theme-switch:active::after {
    width: 38px;
}

.theme-switch-icon {
    position: absolute;
    z-index: 2;
    top: 8px;
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    pointer-events: none;
    transition: color .3s ease;
}

.theme-switch-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

.theme-switch-sun {
    left: 8px;
    color: #ffffff;
}

.theme-switch-sun svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
}

.theme-switch-moon {
    right: 8px;
    color: #565b63;
}

.theme-switch-moon svg {
    fill: none;
    stroke: currentColor;
}

html[data-theme="dark"] .theme-trigger.theme-switch {
    background: #242424;
    color: #ffffff;
}

html[data-theme="dark"] .theme-trigger.theme-switch:hover {
    background: #2a2a2a;
}

html[data-theme="dark"] .theme-trigger.theme-switch::after {
    left: 76px;
    transform: translateX(-100%);
    background: linear-gradient(180deg, #777777, #3a3a3a);
}

html[data-theme="dark"] .theme-switch-sun {
    color: #777777;
}

html[data-theme="dark"] .theme-switch-moon {
    color: #ffffff;
}

html[data-theme="light"] .theme-trigger.theme-switch {
    background: #ebebeb;
}

html[data-theme="light"] .theme-trigger.theme-switch::after {
    left: 2px;
    transform: translateX(0);
    background: linear-gradient(180deg, #ffcc89, #d8860b);
}

html[data-theme="light"] .theme-switch-sun {
    color: #ffffff;
}

html[data-theme="light"] .theme-switch-moon {
    color: #565b63;
}

@media (max-width: 520px) {
    .theme-trigger.theme-switch {
        width: 70px;
        height: 30px;
        min-width: 70px;
        border-radius: 30px;
    }

    .theme-trigger.theme-switch::after {
        top: 2px;
        left: 2px;
        width: 26px;
        height: 26px;
    }

    .theme-trigger.theme-switch:active::after {
        width: 32px;
    }

    .theme-switch-icon {
        top: 7px;
        width: 16px;
        height: 16px;
    }

    .theme-switch-icon svg {
        width: 16px;
        height: 16px;
    }


    .theme-switch-sun { left: 7px; }
    .theme-switch-moon { right: 7px; }

    html[data-theme="dark"] .theme-trigger.theme-switch::after {
        left: 68px;
    }
}

/* ==========================================================
   Remplissage automatique de la connexion
   ========================================================== */


/*
   Firefox / Chromium / Safari peuvent colorer les champs remplis par le
   gestionnaire de mots de passe. L'ombre interne recouvre visuellement cette
   couleur sans désactiver l'autoremplissage ni modifier les identifiants.
*/
.auth-page .form-control:autofill,
.auth-page .form-control:-webkit-autofill,
.auth-page .form-control:-webkit-autofill:hover,
.auth-page .form-control:-webkit-autofill:focus,
.auth-page .form-control:-webkit-autofill:active {
    -webkit-text-fill-color: var(--text) !important;
    caret-color: var(--text) !important;
    -webkit-box-shadow: 0 0 0 1000px var(--surface-solid) inset !important;
    box-shadow: 0 0 0 1000px var(--surface-solid) inset !important;
    border-color: var(--border-strong) !important;
    background-clip: content-box !important;
}

/* Firefox : conserve les couleurs du thème quand un champ est autofill. */
@supports selector(input:-moz-autofill) {
    .auth-page .form-control:-moz-autofill {
        color: var(--text) !important;
        caret-color: var(--text) !important;
        box-shadow: 0 0 0 1000px var(--surface-solid) inset !important;
        border-color: var(--border-strong) !important;
        filter: none !important;
    }
}


/* ==========================================================
   Accent principal #0062cc + retouches visuelles
   ========================================================== */
.sidebar .nav-link.active {
    background: #e7f1ff;
    color: #0062cc;
}

.sidebar .nav-badge {
    background: #0062cc;
}

html[data-theme="dark"] .sidebar .nav-link.active {
    background: var(--primary-button-bg);
    color: #7eb7ff;
}

html[data-theme="dark"] .sidebar .nav-link:hover {
    background: var(--primary-button-hover);
}

html[data-theme="dark"] .sidebar .nav-badge {
    background: #7eb7ff;
}

/* Petite branche du titre : version plus simple et plus proche du mockup. */
.hero-leaf {
    color: #22a36a;
    vertical-align: middle;
    transform: translateY(-1px);
}
.hero-leaf .ui-icon {
    width: .84em;
    height: .84em;
    stroke-width: 1.85;
}

/* Carte bien-être : retour à une plante plus douce et plus propre. */
.health-card {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 44% 18%, rgba(255,255,255,.42), transparent 16%),
        linear-gradient(112deg, #6f9ecb 0%, #8fb0d3 46%, #a8c1d8 68%, #bfd2cb 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.22);
}
.health-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(28,74,122,.18), transparent 32%),
        radial-gradient(circle at 24% 72%, rgba(48,84,123,.14), transparent 24%);
    pointer-events: none;
}
.health-card svg {
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 5px 12px rgba(29,77,64,.10));
}
.health-leaf-stem { stroke: rgba(56,122,93,.58); }
.health-leaf { fill: rgba(86,145,110,.64); }
.health-leaf-2 { fill: rgba(106,164,128,.58); }
.health-leaf-3 { fill: rgba(73,129,98,.68); }

/* ==========================================================
   Interactions uniformes des boutons principaux
   Tous les boutons d’accent suivent désormais le même état
   normal / survol / clic que le bouton principal du dashboard.
   ========================================================== */
.primary-btn,
.action-link.primary,
.quick-action.primary {
    background: var(--primary-button-bg);
    color: #fff;
    border-color: transparent;
    transition:
        background-color .16s ease,
        border-color .16s ease,
        box-shadow .16s ease,
        transform .10s ease;
}

.primary-btn:not(.action-confirm-danger):hover,
.action-link.primary:hover,
.quick-action.primary:hover {
    background: var(--primary-button-hover);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 9px 20px rgba(var(--primary-button-rgb),.22);
}
html[data-theme="light"] .primary-btn:not(.action-confirm-danger):active,
html[data-theme="light"] .action-link.primary:active,
html[data-theme="light"] .quick-action.primary:active {
    background: var(--primary-button-active);
    color: #fff;
    border-color: transparent;
    transform: translateY(1px);
    box-shadow: 0 4px 10px rgba(var(--primary-button-rgb),.18);
}

.primary-btn:focus-visible,
.action-link.primary:focus-visible,
.quick-action.primary:focus-visible {
    box-shadow: 0 0 0 3px rgba(var(--primary-button-rgb),.20), 0 8px 18px rgba(var(--primary-button-rgb),.18);
}

/* ==========================================================
   Tableau de bord et navigation mobile
   ========================================================== */
.mobile-section-link,
.mobile-panel-link,
.mobile-medication-summary,
.mobile-medication-open,
.mobile-stock-title {
    display: none;
}

@media (max-width: 899px) {
    /* Le document porte le défilement vertical sur mobile. */
    html {
        overflow-x: clip;
    }

    body,
    .app-shell {
        min-height: 100svh;
    }

    .topbar {
        position: relative;
        top: auto;
        background: var(--bg);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .section-shell,
    .panel,
    .form-section {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .page {
        padding-top: 16px;
    }

    /* Topbar mobile plus légère. */

    .user-profile {
        gap: 6px;
    }

    .avatar {
        width: 32px;
        height: 32px;
        font-size: .88rem;
    }

    .user-menu-arrow {
        width: 24px;
        height: 32px;
    }

    /* Hero compact : conserve l'identité du site sans repousser le contenu utile. */
    .hero-dashboard-plain {
        margin: 0 0 8px;
        padding: 5px 2px 8px;
    }

    .hero-dashboard .eyebrow {
        margin-bottom: 4px;
        font-size: .83rem;
    }

    .hero-dashboard h1,
    .hero-dashboard-plain h1 {
        max-width: none;
        gap: 7px;
        font-size: clamp(1.25rem, 5vw, 1.5rem);
        line-height: 1.02;
        letter-spacing: -.045em;
    }

    .hero-leaf .ui-icon {
        width: .76em;
        height: .76em;
    }

    /* Onglets fins, inspirés d'une navigation d'app native. */


    /* Toutes les cartes du dashboard utilisent le même rythme mobile. */
    .dashboard-page .section-shell,
    .dashboard-page .panel {
        margin: 0;
        border-radius: 20px;
        box-shadow: 0 8px 24px rgba(30,41,59,.055);
    }

    /* Même espacement que les cartes de la grille du tableau de bord. */
    .dashboard-page .dashboard-stock-activity { margin-bottom: 14px; }

    /* Stock global — premier contenu utile. */
    .desktop-stock-title { display: none; }
    .mobile-stock-title { display: inline; }

    .stock-overview-card .panel-heading {
        min-height: 44px;
        padding: 13px 15px 4px;
    }

    .stock-overview-card .panel-heading h3 {
        margin: 0;
        font-size: .95rem;
    }

    .mobile-panel-link {
        width: 30px;
        height: 30px;
        display: grid;
        place-items: center;
        margin-left: auto;
        border-radius: 10px;
        color: var(--text-muted);
    }

    .mobile-panel-link .ui-icon {
        width: 16px;
        height: 16px;
    }

    .stock-overview-card .stock-content {
        display: grid;
        grid-template-columns: 116px minmax(0, 1fr);
        align-items: center;
        gap: 18px;
        padding: 5px 16px 15px;
    }

    .stock-overview-card .donut {
        width: 112px;
        height: 112px;
        margin: 0;
    }


    .stock-overview-card .donut-label strong {
        font-size: 1.58rem;
    }

    .stock-overview-card .donut-caption {
        font-size: .72rem;
        line-height: 1.15;
    }

    .stock-overview-card .legend {
        min-width: 0;
        gap: 7px;
    }

    .stock-overview-card .legend-item {
        font-size: .8rem;
    }

    .stock-overview-card .panel-footer-link {
        display: none;
    }

    /* Médicaments — lignes de résumé dédiées au smartphone. */
    .dashboard-medications .section-heading {
        min-height: 59px;
        padding: 12px 14px 10px;
    }

    .dashboard-medications .section-title-wrap {
        gap: 10px;
        min-width: 0;
    }

    .dashboard-medications .section-icon {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
        border-radius: 12px;
    }

    .dashboard-medications .section-heading h2 {
        font-size: 1rem;
        line-height: 1.15;
    }

    .dashboard-medications .section-heading p {
        font-size: .75rem;
        line-height: 1.2;
    }

    .mobile-section-link {
        display: inline-flex;
        align-items: center;
        flex: 0 0 auto;
        margin-left: auto;
        color: var(--blue);
        font-size: .78rem;
        font-weight: 820;
    }

    .dashboard-medications .medication-dashboard-table {
        border-top: 1px solid var(--border);
    }

    .dashboard-medications .medication-dashboard-row {
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: 8px;
        min-height: 67px;
        padding: 10px 13px;
    }

    .dashboard-medications .med-main {
        min-width: 0;
        gap: 10px;
    }

    .dashboard-medications .med-icon {
        width: 40px;
        height: 40px;
        flex: 0 0 40px;
        border-radius: 12px;
    }

    .dashboard-medications .med-name {
        overflow: hidden;
        font-size: .9rem;
        line-height: 1.17;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .dashboard-medications .med-meta {
        overflow: hidden;
        margin-top: 2px;
        font-size: .73rem;
        line-height: 1.15;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .dashboard-medications .dashboard-row-actions {
        display: none !important;
    }

    .mobile-medication-summary {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 7px;
        min-width: 0;
    }

    .mobile-days {
        color: var(--text-soft);
        font-size: .73rem;
        font-weight: 760;
        white-space: nowrap;
    }

    .mobile-medication-summary .status {
        padding: 5px 8px;
        font-size: .66rem;
        white-space: nowrap;
    }

    .mobile-medication-open {
        width: 27px;
        height: 34px;
        display: grid;
        place-items: center;
        border-radius: 9px;
        color: var(--text-muted);
    }

    .mobile-medication-open .ui-icon {
        width: 15px;
        height: 15px;
    }

    /* Rappels — timeline plus dense et lisible. */
    .reminders-card .panel-heading {
        min-height: 49px;
        padding: 12px 14px 6px;
    }

    .reminders-card .panel-heading h3 {
        font-size: .95rem;
    }

    .reminders-card .link-btn {
        font-size: .78rem;
    }

    .reminders-card .timeline {
        padding: 0 14px 10px;
    }

    .reminders-card .timeline-item {
        grid-template-columns: 10px minmax(0, 1fr) 24px;
        gap: 9px;
        min-height: 58px;
        padding: 7px 0 9px;
    }

    .reminders-card .timeline-item:not(:last-child)::after {
        left: 4px;
        top: 24px;
        bottom: -1px;
    }

    .reminders-card .timeline-dot {
        width: 9px;
        height: 9px;
        margin-top: 5px;
    }

    .reminders-card .timeline-kicker {
        margin-bottom: 1px;
        font-size: .71rem;
    }

    .reminders-card .timeline-title {
        font-size: .88rem;
        line-height: 1.16;
    }

    .reminders-card .timeline-meta {
        font-size: .72rem;
        line-height: 1.15;
    }

    .reminders-card .timeline-arrow {
        width: 24px;
        height: 30px;
    }

    /* Le dashboard mobile ne duplique plus les Actions rapides. */
    .dashboard-page .quick-actions-card {
        display: none !important;
    }

    /* Barre mobile fixe, sans flou ni couche graphique supplémentaire. */
    .bottom-nav {
        position: fixed;
        left: 14px;
        right: 14px;
        bottom: calc(10px + env(safe-area-inset-bottom));
        z-index: 50;
        min-height: 64px;
        padding: 6px;
        gap: 2px;
        overflow: hidden;
        border: 1px solid rgba(255,255,255,.58);
        border-radius: 22px;
        background: #f6faff;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        box-shadow: 0 8px 24px rgba(15,23,42,.14);
    }

    .bottom-link {
        position: relative;
        z-index: 1;
        transition: color .16s ease, background-color .16s ease, transform .10s ease;
    }

    .bottom-link:active {
        transform: scale(.97);
    }


    .bottom-icon {
        display: grid;
        place-items: center;
    }


    html[data-theme="dark"] .bottom-nav {
        border-color: rgba(255,255,255,.13);
        background: #0f1823;
        box-shadow: 0 10px 26px rgba(0,0,0,.34);
    }

}

@media (max-width: 430px) {
    .page {
        padding-top: 14px;
    }

    .hero-dashboard h1,
    .hero-dashboard-plain h1 {
        font-size: clamp(1.25rem, 5vw, 1.5rem);
    }

    .stock-overview-card .stock-content {
        grid-template-columns: 102px minmax(0, 1fr);
        gap: 13px;
        padding-left: 13px;
        padding-right: 13px;
    }

    .stock-overview-card .donut {
        width: 98px;
        height: 98px;
    }


    .mobile-medication-summary {
        gap: 5px;
    }

    .mobile-medication-summary .status {
        max-width: 78px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .bottom-nav {
        left: 13px;
        right: 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bottom-link {
        transition: none;
    }
}

/* ==========================================================
   Topbar, onglets et navigation mobile
   ========================================================== */
.mobile-settings-only {
    display: none;
}

@media (max-width: 899px) {
    /* Topbar mobile : uniquement marque + avatar. */
    .topbar-inner {
        min-height: 52px;
        padding: 8px 15px;
        gap: 10px;
    }

    .mobile-logo {
        gap: 8px;
        font-size: .98rem;
        line-height: 1;
    }

    .mobile-logo .brand-logo,
    .mobile-logo .app-logo-svg {
        width: 27px;
        height: 27px;
    }

    .topbar-actions {
        gap: 0;
        margin-left: auto;
    }

    .topbar .theme-trigger {
        display: none !important;
    }

    .topbar .user-profile {
        gap: 8px;
    }

    .topbar .avatar {
        width: 31px;
        height: 31px;
        font-size: .84rem;
    }


    /* Deux onglets strictement alignés, comme une barre d'onglets native. */

    .bottom-link {
        min-height: 48px;
        gap: 1px;
        border-radius: 15px;
        background: transparent;
        box-shadow: none;
        font-size: .62rem;
    }

    .bottom-link.active {
        background: rgba(0,98,204,.055);
        color: var(--blue);
        box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
    }

    .bottom-icon {
        min-height: 24px;
    }

    .bottom-icon .ui-icon {
        width: 20px;
        height: 20px;
    }

    /* Réglages mobile : thème et déconnexion quittent la topbar. */
    .mobile-settings-only {
        display: block;
    }

    .mobile-appearance-session .form-section-heading {
        margin-bottom: 8px;
    }

    .mobile-settings-list .settings-row {
        gap: 12px;
    }

    .mobile-theme-row {
        align-items: center;
    }

    .settings-theme-switch {
        flex: 0 0 auto;
    }

    html[data-theme="dark"] .bottom-link.active {
        background: rgba(0,98,204,.16);
        color: #84bdff;
        box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
    }
}

@media (max-width: 430px) {
    .topbar-inner {
        padding-left: 13px;
        padding-right: 13px;
    }


}

/* aperçu avatar Canvas compatible CSP stricte. */
.avatar-preview canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: inherit;
    object-fit: cover;
}

.avatar-preview canvas[hidden],
.avatar-preview img[hidden] {
    display: none !important;
}

/* ==========================================================
   avatar stable au rafraîchissement + nav mobile
   ========================================================== */
@media (max-width: 899px) {
    /* Même largeur visuelle que les cartes de la page (padding mobile : 14 px). */

    /* L'avatar garde toujours sa boîte, même pendant le décodage de l'image. */
    .topbar .avatar-static {
        flex: 0 0 31px;
        width: 31px;
        height: 31px;
        overflow: hidden;
        contain: layout paint;
    }

    .topbar .avatar-static img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

/* ==========================================================
   profil mobile + menu Plus
   ========================================================== */
.user-name-mobile,
.mobile-user-menu-trigger,
.account-label-mobile,
.bottom-more-popover {
    display: none;
}

.bottom-more-trigger {
    border: 0;
    font: inherit;
    cursor: pointer;
}

@media (max-width: 899px) {
    /* Profil mobile : nom + photo cliquable. Le desktop reste inchangé. */
    .topbar .avatar-static,
    .topbar .user-name-desktop,
    .topbar .user-menu-arrow {
        display: none !important;
    }

    .topbar .user-arrow-wrap {
        display: block !important;
        width: 0;
        height: 0;
        min-width: 0;
    }


    .user-name-mobile {
        display: inline-block;
        max-width: 118px;
        overflow: hidden;
        color: var(--text);
        font-size: .86rem;
        font-weight: 800;
        line-height: 1;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-user-menu-trigger {
        width: 34px;
        height: 34px;
        display: grid;
        place-items: center;
        flex: 0 0 34px;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: transparent;
        cursor: pointer;
    }

    .mobile-user-menu-trigger:focus-visible {
        outline: 3px solid rgba(0,98,204,.22);
        outline-offset: 2px;
    }

    .mobile-user-menu-trigger .mobile-profile-avatar {
        width: 32px;
        height: 32px;
        overflow: hidden;
        contain: layout paint;
    }

    .mobile-user-menu-trigger .mobile-profile-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .account-label-desktop {
        display: none !important;
    }

    .account-label-mobile {
        display: inline !important;
    }

    .topbar .user-popover {
        top: 61px;
        right: 13px;
    }

    /* Menu flottant ouvert directement par « Plus ». */
    .bottom-more-popover {
        position: fixed;
        right: 14px;
        bottom: calc(82px + env(safe-area-inset-bottom));
        z-index: 58;
        width: min(260px, calc(100vw - 28px));
        padding: 7px;
        border: 1px solid rgba(255,255,255,.64);
        border-radius: 20px;
        background: rgba(248,251,255,.88);
        -webkit-backdrop-filter: blur(28px) saturate(185%);
        backdrop-filter: blur(28px) saturate(185%);
        box-shadow: 0 18px 48px rgba(15,23,42,.20), inset 0 1px 0 rgba(255,255,255,.82);
    }

    .bottom-more-popover:not([hidden]) {
        display: grid;
        gap: 2px;
    }

    .bottom-more-link {
        min-height: 46px;
        display: grid;
        grid-template-columns: 34px minmax(0, 1fr) 18px;
        align-items: center;
        gap: 9px;
        padding: 6px 9px;
        border-radius: 13px;
        color: var(--text);
        font-size: .86rem;
        font-weight: 760;
    }

    .bottom-more-link:hover,
    .bottom-more-link.active {
        background: rgba(0,98,204,.08);
        color: var(--blue);
    }

    .bottom-more-icon {
        width: 32px;
        height: 32px;
        display: grid;
        place-items: center;
        border-radius: 10px;
        background: var(--blue-soft);
        color: var(--blue);
    }

    .bottom-more-icon .ui-icon {
        width: 18px;
        height: 18px;
    }

    .bottom-more-link > .ui-icon:last-child {
        width: 15px;
        height: 15px;
        color: var(--text-muted);
    }

    .bottom-more-trigger {
        background: transparent;
        color: var(--text-muted);
    }

    .bottom-more-trigger[aria-expanded="true"] {
        background: rgba(0,98,204,.08);
        color: var(--blue);
    }

    html[data-theme="dark"] .bottom-more-popover {
        border-color: rgba(255,255,255,.12);
        background: rgba(15,24,35,.91);
        box-shadow: 0 20px 48px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.08);
    }

    .stock-overview-card .donut {
        justify-self: end;
        transform: translateX(24px);
    }

    .stock-overview-card .legend {
        justify-self: stretch;
        width: 100%;
    }

    .stock-overview-card .legend-item {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 9px;
        width: 100%;
    }

    .stock-overview-card .legend-left {
        flex: 0 0 128px;
        width: 128px;
        margin-left: auto;
    }

    .stock-overview-card .legend-item strong {
        flex: 0 0 18px;
        min-width: 18px;
        margin-left: 9px;
        text-align: right;
    }
}

@media (max-width: 430px) {
    .bottom-more-popover {
        right: 13px;
        width: min(252px, calc(100vw - 26px));
    }

    .stock-overview-card .donut {
        transform: translateX(27px);
    }

    .stock-overview-card .legend-left {
        flex-basis: 124px;
        width: 124px;
    }

    .stock-overview-card .legend-item strong {
        margin-left: 8px;
    }
}

@media (max-width: 899px) {
    /* Les vrais onglets de Paramètres redeviennent ceux de la page elle-même. */
    .settings-page-v131 > .settings-tabs {
        display: flex !important;
    }

    /* Annule le centrage tardif de .refined-toolbar sur smartphone. */
    .page-toolbar.refined-toolbar {
        align-items: stretch;
        text-align: left;
    }

    .page-toolbar.refined-toolbar > div:first-child {
        width: 100%;
        text-align: left;
    }

    .page-toolbar.refined-toolbar .page-kicker,
    .page-toolbar.refined-toolbar h1,
    .page-toolbar.refined-toolbar p {
        text-align: left;
    }

    .page-toolbar.refined-toolbar .page-toolbar-actions {
        justify-content: flex-start;
        margin-left: 0;
        margin-right: 0;
    }
}

/* ==========================================================
   titres mobile épurés
   Les petits libellés au-dessus des grands titres sont retirés
   sur smartphone. Le desktop conserve sa présentation.
   ========================================================== */
@media (max-width: 899px) {
    .page-toolbar.refined-toolbar .page-kicker {
        display: none !important;
    }
}

/* ==========================================================
   navigation mobile sans doublons
   La navigation générale reste dans les onglets principaux,
   la barre inférieure et le menu Plus. Les pages conservent
   uniquement leurs actions contextuelles.
   ========================================================== */
@media (max-width: 899px) {
    .mobile-nav-redundant,
    .mobile-duplicate-action {
        display: none !important;
    }
}

/* ==========================================================
   Référentiel officiel et notices locales
   ========================================================== */
.official-search-shell {
    display: grid;
    gap: 10px;
}

.official-search-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.official-search-label-row > label {
    color: var(--text);
    font-weight: 760;
}

.identifier-help-group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    font-size: .78rem;
}

.identifier-help {
    position: relative;
}

.identifier-help > summary {
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    list-style: none;
    cursor: pointer;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: var(--surface-solid);
    color: var(--blue);
    font-size: .72rem;
    font-weight: 850;
}

.identifier-help > summary::-webkit-details-marker { display: none; }

.identifier-help > div {
    position: absolute;
    z-index: 260;
    bottom: calc(100% + 8px);
    right: 0;
    width: min(290px, 82vw);
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-solid);
    box-shadow: 0 16px 38px rgba(15,23,42,.16);
    color: var(--text-muted);
    line-height: 1.45;
}

.official-search-control {
    position: relative;
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 9px 6px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 13px;
    background: var(--surface-solid);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.official-search-control:focus-within {
    border-color: color-mix(in srgb, var(--blue) 42%, var(--border-strong));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 9%, transparent);
}

.official-search-icon {
    display: grid;
    place-items: center;
    color: var(--text-muted);
}

.official-search-icon .ui-icon { width: 18px; height: 18px; }

.official-search-control > input {
    min-width: 0;
    flex: 1;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: var(--text);
}

.official-search-control > input::placeholder { color: var(--text-soft); }

.official-search-control .search-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    width: auto;
    max-height: 360px;
}

.official-search-option {
    width: 100%;
    border: 0;
    text-align: left;
    background: transparent;
    cursor: pointer;
    font: inherit;
}

.official-search-empty {
    color: var(--text-muted);
    cursor: default;
}

.official-selection-card {
    display: grid;
    gap: 14px;
    margin-top: 4px;
    padding: 14px;
    border: 1px solid color-mix(in srgb, var(--blue) 22%, var(--border));
    border-radius: 14px;
    background: color-mix(in srgb, var(--blue) 5%, var(--surface-solid));
}

.official-selection-card[hidden] { display: none !important; }

.official-selection-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.official-selection-head > div {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.official-selection-head strong {
    color: var(--text);
    line-height: 1.35;
}

.official-selection-head span {
    color: var(--text-muted);
    font-size: .82rem;
    line-height: 1.4;
}

.action-link.compact {
    min-height: 34px;
    padding: 7px 10px;
    font-size: .78rem;
}

.official-code-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.official-code-grid > div {
    display: grid;
    gap: 2px;
    padding: 9px 10px;
    border-radius: 10px;
    background: var(--surface-soft);
}

.official-code-grid span {
    color: var(--text-muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.official-code-grid strong {
    color: var(--text);
    font-size: .88rem;
}

.field-help-text {
    margin: 0;
    color: var(--text-muted);
    font-size: .8rem;
}


.notice-source-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.notice-source-row > div {
    display: grid;
    gap: 3px;
}

.notice-source-row strong { color: var(--text); }
.notice-source-row span { color: var(--text-muted); font-size: .82rem; }

.subtle-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text-muted) !important;
    font-size: .76rem !important;
}

.notice-reader {
    overflow: hidden;
    padding: clamp(18px, 3vw, 34px);
}

.notice-reader h1,
.notice-reader h2,
.notice-reader h3,
.notice-reader h4,
.notice-reader h5,
.notice-reader h6 {
    margin: 1.45em 0 .65em;
    color: var(--text);
    line-height: 1.25;
}

.notice-reader h1:first-child,
.notice-reader h2:first-child,
.notice-reader h3:first-child { margin-top: 0; }

.notice-reader p,
.notice-reader li,
.notice-reader td,
.notice-reader th {
    color: var(--text);
    line-height: 1.68;
}

.notice-reader p { margin: .72em 0; }
.notice-reader ul,
.notice-reader ol { padding-left: 1.35rem; }
.notice-reader table { width: 100%; border-collapse: collapse; }
.notice-reader th,
.notice-reader td { padding: 8px; border: 1px solid var(--border); vertical-align: top; }
.notice-reader .notice-plain-fallback p { white-space: pre-line; }

.med-row-actions .notice-row-link { color: var(--blue); }

@media (max-width: 899px) {
    .official-search-control .search-suggestions {
        position: absolute;
        left: 0;
        right: 0;
        top: calc(100% + 8px);
    }

    .official-selection-head { align-items: stretch; }
    .official-selection-head .action-link { flex: 0 0 auto; }
    .notice-source-row { align-items: flex-start; }
}

@media (max-width: 560px) {
    .official-search-label-row { align-items: flex-start; }
    .identifier-help-group { width: 100%; }
    .official-code-grid { grid-template-columns: 1fr; }
    .official-selection-head { flex-direction: column; }
    .official-selection-head .action-link { align-self: flex-start; }
    .notice-reader { padding: 16px; }
}

/* réapprovisionnement par conditionnement officiel */
.stock-box-mode {
    display: grid;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface-soft);
}

.stock-box-mode[hidden],
.stock-box-count[hidden] {
    display: none !important;
}

.stock-box-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text);
    font-weight: 750;
}

.stock-box-toggle input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--blue);
}

.stock-box-count {
    margin: 0;
}

[data-stock-quantity][readonly] {
    background: var(--surface-soft);
    cursor: default;
}


/* ==========================================================
   Notices : carte unifiée et espacements corrigés
   ========================================================== */
.notice-search-section {
    overflow: visible;
}

.notice-search-body {
    padding: 0 18px 18px;
}

.notice-reference-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-soft) 72%, transparent);
}

.notice-reference-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.notice-reference-copy strong {
    color: var(--text);
    font-size: .9rem;
}

.notice-reference-copy span {
    color: var(--text-muted);
    font-size: .8rem;
    line-height: 1.4;
}

.notice-reference-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.notice-reference-state {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 800;
    white-space: nowrap;
}

.notice-reference-state.is-ready {
    background: var(--green-soft);
    color: var(--green);
}

.notice-reference-state.is-pending {
    background: var(--amber-soft);
    color: var(--amber);
}

.notice-reference-state.is-warning {
    background: var(--red-soft);
    color: var(--red);
}

@media (max-width: 899px) {
    .notice-search-body {
        padding: 0 16px 16px;
    }

    .notice-reference-footer {
        align-items: flex-start;
        flex-direction: column;
        padding: 13px 16px 15px;
    }

    .notice-reference-meta {
        justify-content: flex-start;
    }
}

/* ==========================================================
   Assistant d’aide local
   ========================================================== */

.help-assistant {
    position: fixed;
    right: 0;
    bottom: 22px;
    z-index: 120;
    pointer-events: none;
}

.help-assistant-launcher,
.help-assistant-panel {
    pointer-events: auto;
}

.help-assistant-launcher {
    width: 150px;
    min-height: 48px;
    margin-right: 12px;
    justify-content: center;
    overflow: hidden;
    transition: width .28s ease, margin-right .28s ease, gap .28s ease, border-radius .28s ease;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border: 1px solid color-mix(in srgb, var(--blue) 35%, var(--border));
    border-radius: 999px;
    background: var(--surface-solid);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .14);
    cursor: pointer;
}

.help-assistant-launcher:hover {
    border-color: color-mix(in srgb, var(--blue) 58%, var(--border));
}

.help-assistant-launcher-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    color: var(--icon-accent);
}

.help-assistant-panel {
    position: absolute;
    right: 12px;
    bottom: 58px;
    width: min(390px, calc(100vw - 28px));
    max-height: min(620px, calc(100vh - 110px));
    display: grid;
    grid-template-rows: auto minmax(130px, 1fr) auto auto auto;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface-solid);
    box-shadow: 0 20px 55px rgba(15, 23, 42, .18);
}

.help-assistant-panel[hidden] {
    display: none;
}

.help-assistant-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.help-assistant-header > div {
    min-width: 0;
    display: grid;
    gap: 2px;
    flex: 1;
}

.help-assistant-header strong {
    font-size: .96rem;
}

.help-assistant-header span {
    color: var(--text-soft);
    font-size: .78rem;
}

.help-assistant-close {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.help-assistant-messages {
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 16px 12px;
}

.help-assistant-message {
    display: flex;
}

.help-assistant-message.user {
    justify-content: flex-end;
}

.help-assistant-bubble {
    max-width: 91%;
    padding: 11px 13px;
    border-radius: 16px 16px 16px 5px;
    background: color-mix(in srgb, var(--blue) 10%, var(--surface-solid));
    color: var(--text);
    font-size: .88rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.help-assistant-message.user .help-assistant-bubble {
    background: var(--blue);
    border: 0;
    border-radius: 16px 16px 5px 16px;
    color: #fff;
}

.help-assistant-link {
    display: flex;
    margin-top: 0;
    max-width: 91%;
    color: var(--blue);
    font-weight: 600;
    text-decoration: none;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--blue) 22%, var(--border));
    border-radius: 13px;
    background: var(--surface-solid);
}

.help-assistant-link:hover {
    text-decoration: none;
    border-color: var(--blue);
}


.help-assistant-suggestions {
    display: flex;
    gap: 7px;
    overflow-x: visible;
    padding: 0 14px 10px;
    flex-wrap: wrap;
}

.help-assistant-suggestions button {
    flex: 0 0 auto;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: .76rem;
    cursor: pointer;
    flex-shrink: 1;
    min-height: 44px;
}

.help-assistant-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 6px;
    align-items: center;
    margin: 0 14px 10px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-soft);
}

.help-assistant .help-assistant-input {
    min-width: 0;
    resize: none;
    border: 0;
    outline: none;
    box-shadow: none;
    border-radius: 11px;
    background: transparent;
    color: var(--text);
    padding: 10px 8px;
    font: inherit;
    font-size: 16px;
    height: 44px;
}

.help-assistant-send {
    align-self: stretch;
    padding: 0;
    border: 0;
    border-radius: 13px;
    background: var(--primary-button-bg);
    color: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    width: 44px;
    min-height: 44px;
    display: grid;
    place-items: center;
}

.help-assistant-send:disabled {
    opacity: .55;
    cursor: wait;
}

.help-assistant-note {
    margin: 0;
    padding: 0 14px 12px;
    color: var(--text-soft);
    font-size: .7rem;
    line-height: 1.35;
    text-align: center;
}

.help-assistant-header .help-assistant-header-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 12px;
    background: color-mix(in srgb, var(--blue) 10%, var(--surface-solid));
    color: var(--blue);
}

.help-assistant-header .help-assistant-subtitle {
    display: block;
}

.help-assistant-message.assistant {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.help-assistant-action-content {
    flex: 1;
    min-width: 0;
}

.help-assistant-action-icon,
.help-assistant-action-arrow {
    display: inline-flex;
    flex-shrink: 0;
}

.help-assistant-action-title,
.help-assistant-action-detail {
    display: block;
}

.help-assistant-action-detail {
    margin-top: 3px;
    font-size: .75rem;
    font-weight: 400;
    color: var(--text-soft);
}

.help-assistant-action-title {
    font-size: .82rem;
    font-weight: 700;
}

.help-assistant-action-help {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--blue);
    font-size: .75rem;
}

.help-assistant-send-icon {
    display: inline-flex;
}

.help-assistant-launcher > span {
    max-width: 110px;
    overflow: hidden;
    white-space: nowrap;
    opacity: 1;
    transform: translateX(0);
    transition: max-width .28s ease, opacity .2s ease, transform .28s ease;
}

.help-assistant:not(.is-launcher-expanded) .help-assistant-launcher {
    width: 48px;
    min-height: 48px;
    margin-right: 0;
    justify-content: center;
    gap: 0;
    border-right: 0;
    border-radius: 24px 0 0 24px;
}

.help-assistant:not(.is-launcher-expanded) .help-assistant-launcher > span {
    /* Le nom reste accessible aux lecteurs d’écran. */
    max-width: 0;
    opacity: 0;
    transform: translateX(12px);
}


@media (max-width: 899px) {
    .help-assistant {
        right: 0;
        bottom: calc(18px + env(safe-area-inset-bottom));
        z-index: 55;
    }

    .help-assistant-panel {
        position: fixed;
        inset: auto 12px calc(18px + env(safe-area-inset-bottom)) auto;
        width: min(390px, calc(100vw - 24px));
        height: min(60dvh, 520px);
        max-height: calc(100dvh - 96px - env(safe-area-inset-bottom));
        grid-template-rows: auto minmax(64px, 1fr) auto auto auto;
        overflow-y: auto;
    }
}

.help-assistant-message-enter {
    animation: help-assistant-message-in .18s ease-out;
}

.help-assistant-typing {
    min-width: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.help-assistant-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .3;
    animation: help-assistant-dot 1s infinite ease-in-out;
}

.help-assistant-typing span:nth-child(2) {
    animation-delay: .14s;
}

.help-assistant-typing span:nth-child(3) {
    animation-delay: .28s;
}

.help-assistant-link-enter {
    animation: help-assistant-link-in .16s ease-out;
}

@keyframes help-assistant-dot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: .3;
    }

    30% {
        transform: translateY(-3px);
        opacity: .8;
    }
}

@keyframes help-assistant-message-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes help-assistant-link-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .help-assistant-message-enter,
    .help-assistant-link-enter,
    .help-assistant-typing span {
        animation: none;
    }

    .help-assistant-launcher,
    .help-assistant-launcher > span {
        transition: none;
    }
}



/* ---------- Sélecteur d’espace ---------- */
.space-switch-form {
    padding: 10px 12px 12px;
    border-bottom: 1px solid var(--border);
}

.space-switch-label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.space-switch-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.space-switch-row select {
    min-width: 0;
    flex: 1 1 auto;
    height: 38px;
    padding: 0 34px 0 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .82rem;
}

.space-switch-submit {
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--text);
    font: inherit;
    font-size: .78rem;
    font-weight: 800;
    cursor: pointer;
}

.space-switch-submit:hover {
    border-color: color-mix(in srgb, var(--blue) 35%, var(--border));
    color: var(--blue);
}
