/* ==========================================================================
   Pupitre — inventaire d'association musicale
   Design system posé sur Pico (qui sert de reset et de base de formulaires).
   ========================================================================== */

/* --- Jetons ------------------------------------------------------------- */
/* « html:root:not(...) » (0,2,1) passe devant les sélecteurs de Pico (0,2,0). */
html:root:not([data-theme="dark"]) {
  --brand: #8b1e3f;
  --brand-strong: #6e1631;
  --brand-soft: #f6e8ed;
  --bg: #f6f5f3;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --border: #e6e3de;
  --border-strong: #d4d0c8;
  --text: #1d1b19;
  --text-2: #57534e;
  --text-3: #8a857e;
  --ok: #1e7a45;      --ok-bg: #e7f4ec;
  --warn: #8a5a00;    --warn-bg: #fdf3dc;
  --danger: #b42318;  --danger-bg: #fdecea;
  --info: #1f5fbf;    --info-bg: #e8f0fd;
  --series-1: #2a78d6;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(29, 27, 25, .06), 0 1px 1px rgba(29, 27, 25, .04);
  --shadow-lg: 0 10px 30px rgba(29, 27, 25, .16);
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --tabbar-h: 64px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Pico */
  --pico-font-family: var(--font);
  --pico-font-size: 15px;
  --pico-line-height: 1.5;
  --pico-border-radius: var(--radius-sm);
  --pico-background-color: var(--bg);
  --pico-color: var(--text);
  --pico-muted-color: var(--text-3);
  --pico-muted-border-color: var(--border);
  --pico-primary: var(--brand);
  --pico-primary-background: var(--brand);
  --pico-primary-border: var(--brand);
  --pico-primary-hover: var(--brand-strong);
  --pico-primary-hover-background: var(--brand-strong);
  --pico-primary-hover-border: var(--brand-strong);
  --pico-primary-focus: rgba(139, 30, 63, .25);
  --pico-primary-inverse: #fff;
  --pico-form-element-background-color: var(--surface);
  --pico-form-element-border-color: var(--border-strong);
  --pico-form-element-spacing-vertical: .55rem;
  --pico-form-element-spacing-horizontal: .75rem;
  --pico-card-background-color: var(--surface);
  --pico-card-sectioning-background-color: var(--surface-2);
  --pico-card-box-shadow: var(--shadow);
  --pico-spacing: 1rem;
  --pico-typography-spacing-vertical: 1rem;
  --pico-block-spacing-vertical: 1.25rem;
  --pico-block-spacing-horizontal: 1.25rem;
  --pico-table-border-color: var(--border);
}

@media (prefers-color-scheme: dark) {
  html:root:not([data-theme="light"]) {
    --brand: #d0547a;
    --brand-strong: #e06a8e;
    --brand-soft: #3a1b26;
    --bg: #141312;
    --surface: #1c1b19;
    --surface-2: #232220;
    --border: #2f2d2a;
    --border-strong: #3d3a36;
    --text: #f0eeea;
    --text-2: #c2bdb5;
    --text-3: #8f8a82;
    --ok: #7fd3a1;      --ok-bg: #16301f;
    --warn: #f2c66d;    --warn-bg: #352812;
    --danger: #f4908a;  --danger-bg: #3a1716;
    --info: #92b8f5;    --info-bg: #17243b;
    --series-1: #3987e5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
    --pico-primary-inverse: #141312;
    --pico-primary-focus: rgba(208, 84, 122, .3);
    --pico-background-color: var(--bg);
    --pico-color: var(--text);
    --pico-muted-color: var(--text-3);
    --pico-muted-border-color: var(--border);
    --pico-form-element-background-color: var(--surface);
    --pico-form-element-border-color: var(--border-strong);
    --pico-card-background-color: var(--surface);
    --pico-card-sectioning-background-color: var(--surface-2);
    --pico-table-border-color: var(--border);
    --pico-primary: var(--brand);
    --pico-primary-background: var(--brand);
    --pico-primary-border: var(--brand);
    --pico-primary-hover: var(--brand-strong);
    --pico-primary-hover-background: var(--brand-strong);
    --pico-primary-hover-border: var(--brand-strong);
  }
}

/* --- Base --------------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); min-height: 100vh; }
h1, h2, h3 { color: var(--text); letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: .35rem; }
h2 { font-size: 1.15rem; font-weight: 650; margin: 1.75rem 0 .75rem; }
h3 { font-size: 1rem; font-weight: 600; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
small, .small { font-size: .82rem; }
.muted { color: var(--text-3); }
.error { color: var(--danger); }
.icon { flex: none; vertical-align: -.2em; }
code { background: var(--surface-2); color: var(--text); padding: .1rem .35rem; border-radius: 4px; }
hr { border-color: var(--border); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* --- Mise en page ------------------------------------------------------- */
body.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.content { width: 100%; max-width: 1200px; margin: 0 auto; padding: 1.75rem 2rem 4rem; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border); padding: 1rem .75rem;
}
.brand { display: flex; align-items: center; gap: .65rem; padding: .35rem .5rem 1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--text-3); font-size: .75rem; }
.sidebar nav { display: flex; flex-direction: column; justify-content: flex-start; gap: 1px; flex: 1; }
.nav-title { margin: 1rem .6rem .3rem; font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.nav-link { display: flex; align-items: center; gap: .65rem; padding: .48rem .6rem; border-radius: var(--radius-sm); color: var(--text-2); font-size: .92rem; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.sidebar-user { display: flex; align-items: center; gap: .6rem; padding: .75rem .5rem 0; margin-top: 1rem; border-top: 1px solid var(--border); }
.who { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.who strong { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--text-3); font-size: .75rem; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2);
          border: 1px solid var(--border); color: var(--text-2); font-size: .78rem; font-weight: 650; flex: none; }
.avatar.small { width: 32px; height: 32px; }

.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: .75rem;
  padding: 0 1.25rem; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-brand, .nav-toggle { display: none; }
.spacer { flex: 1; }
.global-search { flex: 1; max-width: 520px; position: relative; margin: 0; }
.global-search .icon { z-index: 1; position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.global-search input[type=search] { margin: 0; padding-left: 2.3rem; background-image: none; height: 38px; border-radius: 999px; background: var(--surface); }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: var(--text-2);
               background: transparent; border: 0; padding: 0; margin: 0; position: relative; cursor: pointer; }
.icon-button:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.bell { margin-left: auto; }
.bell-count { position: absolute; top: 3px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
              background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; }
.user-menu { margin: 0; }
details.dropdown.user-menu > summary:not([role]) { list-style: none; padding: 0; border: 0; background: none; height: auto; box-shadow: none; }
details.dropdown.user-menu > summary:not([role])::after { display: none; }
.user-menu > ul { min-width: 14rem; }

.tabbar, .scrim { display: none; }

body.guest { display: grid; place-items: center; padding: 1.5rem 1rem; }
.guest-main { width: 100%; max-width: 26rem; }

/* --- Composants --------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin-bottom: .2rem; }
.crumbs { margin: 0 0 .25rem; font-size: .82rem; color: var(--text-3); }
.crumbs a { color: var(--text-2); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actions form { margin: 0; }
.actions button, .actions [role=button] { margin: 0; width: auto; }

button, [role=button], input[type=submit] { font-weight: 550; padding: .5rem 1rem; border-radius: var(--radius-sm); }
button.small, [role=button].small, .small > button { padding: .25rem .6rem; font-size: .82rem; }
.link-button { all: unset; cursor: pointer; color: var(--brand); font-size: inherit; }
/* Pico force `button[type=submit] { width: 100% }`, plus spécifique que `.link-button`. */
button.link-button { width: auto; }
.link-button:hover { text-decoration: underline; }
.link-button.small { font-size: .8rem; }
[role=button].secondary, button.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
[role=button].secondary:hover, button.secondary:hover { background: var(--surface-2); border-color: var(--text-3); }
button.outline, [role=button].outline { background: transparent; }
button.contrast.outline { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
button.contrast.outline:hover { background: var(--danger-bg); }

article { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.narrow { max-width: 30rem; margin: 1.5rem auto; }
.wide { max-width: 46rem; }

.flash { display: flex; gap: .5rem; padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .92rem; border: 1px solid transparent; }
.flash ul { margin: .25rem 0 0; padding-left: 1.1rem; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 20%, transparent); }
.flash-error { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 20%, transparent); }
.flash-warning { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 20%, transparent); }
.flash-info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 20%, transparent); }
.flash { flex-direction: column; }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .55rem; border-radius: 999px; font-size: .76rem;
         font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.status-demande { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.status-valide { background: var(--info-bg); color: var(--info); border-color: transparent; }
.status-en_cours { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.status-refuse, .status-annule, .status-rendu { color: var(--text-3); }
.badge.overdue { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.tag { display: inline-block; padding: .05rem .5rem; margin: .1rem .15rem; border-radius: 4px; font-size: .74rem; font-weight: 550;
       background: var(--brand-soft); color: var(--brand); }
.swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .35rem; vertical-align: middle; }

/* Statistiques */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .75rem; margin-bottom: 1.75rem; }
.stat { margin: 0; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .15rem; color: var(--text); }
a.stat:hover { text-decoration: none; border-color: var(--border-strong); }
.stat-value { font-size: 1.65rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-label { color: var(--text-3); font-size: .82rem; }

/* Tableaux */
.overflow-auto { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1rem; }
table { margin: 0; font-size: .9rem; }
th { font-size: .75rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); background: var(--surface-2); white-space: nowrap; }
th, td { padding: .6rem .8rem; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
table.striped tbody tr:nth-child(odd) td, table.striped tbody tr:nth-child(odd) th { background: transparent; }
tbody tr:hover td { background: var(--surface-2); }
td a { font-weight: 550; }
.small-table { font-size: .8rem; }

/* Formulaires et filtres */
label { font-size: .88rem; font-weight: 550; color: var(--text-2); }
input, select, textarea { font-size: .93rem; }
.filters { display: grid; grid-template-columns: minmax(14rem, 2fr) repeat(auto-fit, minmax(9rem, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.filters > * { margin-bottom: 0; }
.bulk { margin: 1rem 0 .5rem; display: flex; flex-wrap: wrap; gap: .5rem; padding: .75rem; background: var(--surface);
        border: 1px solid var(--border); border-radius: var(--radius); }
.bulk > * { flex: 1 1 10rem; width: auto; margin: 0 !important; border-radius: var(--radius-sm) !important; }
.bulk > button { flex: 0 0 auto; white-space: nowrap; }
.nowrap { white-space: nowrap; }
details summary { font-weight: 600; color: var(--text-2); }
fieldset { margin-bottom: .75rem; min-width: 0; }
fieldset[role=group] input { min-width: 0; }
.pagination { display: flex; gap: 1rem; justify-content: center; align-items: center; margin: 1rem 0; }

.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tabs a { padding: .55rem .8rem; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; font-size: .9rem; font-weight: 550; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current=page] { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .count { font-size: .72rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 .4rem; margin-left: .2rem; }

/* Sections de premier niveau en cartes */
.content > section:not(.stats):not(.hello):not(.report) {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem;
}
.content > section > h2:first-child { margin-top: 0; }
.content > section .overflow-auto { box-shadow: none; }
input[type=file] { font-size: .85rem; }
input[type=file]::file-selector-button { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .35rem .75rem; margin-right: .6rem; cursor: pointer; }
.no-photo { display: grid; place-items: center; min-height: 9rem; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--text-3); gap: .25rem; text-align: center; }

/* Fiches */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; margin-bottom: 1.5rem; }
.detail-grid > section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.detail-grid > section > h2:first-child { margin-top: 0; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0; align-items: baseline; }
.props dt { color: var(--text-3); font-size: .85rem; }
.props dd { margin: 0; }
.props .meta { display: block; font-size: .8rem; }
.loan-admin { margin-top: 1.25rem; padding-top: 1.1rem; border-top: 1px solid var(--border); }
.loan-admin form:last-child fieldset { margin-bottom: 0; }
.description { white-space: pre-line; color: var(--text-2); margin-top: 1rem; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: .5rem; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.gallery figcaption { font-size: .78rem; color: var(--text-3); }
.photo-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; margin-top: 1rem; }
.photo-form > * { margin: 0; }
.qr-block { display: flex; gap: 1rem; align-items: center; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: .9rem; }
.qr-block img { background: #fff; padding: 4px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.thumb-cell { width: 3.5rem; }
.thumb { width: 2.75rem; height: 2.75rem; object-fit: cover; border-radius: var(--radius-sm); display: block; }

.note { padding: .75rem 1rem; margin-bottom: .5rem; box-shadow: none; }
.note p { margin: .25rem 0; white-space: pre-line; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline > li { position: relative; list-style: none; padding: 0 0 .9rem 1.25rem; border-left: 2px solid var(--border); margin-left: .35rem; }
.timeline > li::before { content: ""; position: absolute; left: -6px; top: .3rem; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.changes { font-size: .84rem; margin: .25rem 0 0; color: var(--text-2); }
.tree { list-style: none; padding-left: 1.1rem; }
.tree li { list-style: none; padding: .15rem 0; }
.tree > li > a { font-weight: 550; }
.loan-lines { list-style: none; padding: 0; margin: 0; }
.loan-lines > li { list-style: none; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.loan-lines > li:last-child { border-bottom: 0; }
.loan-lines select { margin: .4rem 0 0; }
.compact { list-style: none; padding: 0; font-size: .9rem; margin: 0; }
.compact li { list-style: none; padding: .3rem 0; border-bottom: 1px solid var(--border); }
.columns { columns: 2 18rem; }
form.inline { display: inline; }

/* Prêts */
.picker-results { list-style: none; padding: 0; margin: .25rem 0 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.picker-results:empty { display: none; }
.picker-results li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .5rem .75rem; border-bottom: 1px solid var(--border); list-style: none; }
.picker-results li:last-child { border-bottom: 0; }
.picker-results button, .picker-results form { margin: 0; padding: .2rem .65rem; width: auto; }
#selected-lines .line { display: flex; align-items: center; gap: .75rem; padding: .5rem .75rem; margin-bottom: .35rem; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
#selected-lines .line span { flex: 1; font-weight: 550; }
#selected-lines .qty { width: 5rem; margin: 0; padding: .25rem .5rem; height: auto; }
.password { font-size: 1.35rem; letter-spacing: .05em; }
.notifications { list-style: none; padding: 0; }
.notifications li { list-style: none; padding: .75rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .4rem; }
.notifications li.unread { border-left: 3px solid var(--brand); font-weight: 600; }

/* Stocks, calendrier, scan */
.quick-move { display: flex; gap: .35rem; margin: 0; }
.quick-move select, .quick-move input, .quick-move button { margin: 0; padding: .3rem .5rem; height: auto; width: auto; font-size: .85rem; }
.quick-move input { width: 5rem; }
.legend { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .84rem; color: var(--text-2); }
.legend span::before { content: ""; display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; background: var(--c); margin-right: .35rem; vertical-align: middle; }
#calendar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.5rem; box-shadow: var(--shadow); }
#calendar .fc-toolbar-title { font-size: 1.15rem; text-transform: capitalize; }
#calendar .fc-button { padding: .3rem .7rem; font-size: .85rem; background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: none; text-transform: capitalize; }
#calendar .fc-button-active, #calendar .fc-button:active { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
#calendar a { text-decoration: none; }
#calendar .fc-theme-standard td, #calendar .fc-theme-standard th, #calendar .fc-scrollgrid { border-color: var(--border); }
#calendar th { background: transparent; text-transform: none; }
.ical { margin-top: 1rem; }
.scan-page #scan-reader { width: 100%; margin-bottom: 1rem; border-radius: var(--radius); overflow: hidden; }
.scan-page button, .file-button { width: 100%; margin-bottom: .5rem; }
.file-button { display: block; text-align: center; }
#audit-scanner #scan-reader { max-width: 28rem; }
#scan-feedback .flash { margin-bottom: .4rem; padding: .5rem .75rem; }
progress { height: .6rem; border-radius: 999px; }

/* Rapports : barres horizontales triées, une seule teinte. */
.period { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; margin-bottom: 1.5rem; }
.period label, .period input, .period button { margin: 0; }
.period button { width: auto; }
.report { margin: 0 0 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); }
.report h2 { margin: 0 0 .5rem; }
.report .overflow-auto, .report table { box-shadow: none; }
.report-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.hbars { list-style: none; padding: 0; margin: .5rem 0 1rem; }
.hbars li { display: grid; grid-template-columns: minmax(8rem, 15rem) 1fr auto; gap: .75rem; align-items: center; padding: .25rem 0; list-style: none; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; color: var(--text-2); }
.hbar-track { height: .7rem; }
.hbar { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar[style="width: 0%"] { display: none; }
.hbar:hover { filter: brightness(1.12); }
.hbar-value { font-variant-numeric: tabular-nums; font-size: .88rem; color: var(--text); font-weight: 550; }
.mapping-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0 1rem; }

/* Tableau de bord */
.hello { margin-bottom: 1.25rem; }
.hello p { color: var(--text-2); margin: 0; }
.quick-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; }
.quick-actions [role=button] { display: inline-flex; align-items: center; gap: .45rem; }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); min-width: 0; }
.card > h2 { margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; font-size: 1rem; }
.card > h2 .count { margin-left: auto; font-size: .78rem; color: var(--text-3); font-weight: 600; }
.card .overflow-auto { box-shadow: none; border-radius: var(--radius-sm); }
.card.span-2 { grid-column: 1 / -1; }
.stat .icon { color: var(--brand); margin-bottom: .25rem; }
.empty { color: var(--text-3); font-size: .9rem; margin: 0; padding: .5rem 0; }

/* Connexion */
.login-card { padding: 2rem; }
.login-card .brand { padding: 0 0 1.25rem; }
.login-card h1 { font-size: 1.35rem; }
.login-or { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0; }
.login-or::before, .login-or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* --- Mobile ------------------------------------------------------------- */
@media (max-width: 960px) {
  body.app { display: block; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: min(86vw, 300px); height: auto;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); }
  body.nav-open .scrim { display: block; }
  .nav-toggle { display: grid; }
  .topbar { padding: 0 .75rem; gap: .4rem; }
  .topbar-brand { display: block; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .global-search { display: none; }
  .content { padding: 1.1rem 1rem 2rem; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .tabbar > a, .tabbar > button {
    all: unset; display: flex; flex-direction: column; align-items: center; gap: .15rem; font-size: .68rem; font-weight: 600;
    color: var(--text-3); cursor: pointer; padding: .35rem 0;
  }
  .tabbar > a.active { color: var(--brand); }
  .tabbar .tab-scan { justify-self: center; width: 54px; height: 54px; margin-top: -22px; border-radius: 50%; background: var(--brand);
                      color: #fff; display: grid; place-items: center; padding: 0; box-shadow: 0 6px 16px rgba(139, 30, 63, .35); }
  .detail-grid, .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .photo-form { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input[type=search] { grid-column: 1 / -1; }
  h1 { font-size: 1.35rem; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
  .stat { padding: .65rem .7rem; }
  .stat .icon { display: none; }
  .stat-value { font-size: 1.3rem; }
  .stat-label { font-size: .72rem; }
  .quick-actions [role=button] { flex: 1 1 auto; justify-content: center; padding: .5rem .7rem; }
  /* Tableaux « responsive » : chaque ligne devient une carte. */
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
  table.responsive tr:last-child { border-bottom: 0; }
  table.responsive td { border: 0; padding: .1rem 0; display: flex; gap: .75rem; justify-content: space-between; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--text-3); font-size: .78rem; text-align: left; flex: none; }
  table.responsive td[data-label=""]::before { content: none; }
  table.responsive tbody td, table.responsive tbody tr:hover td, table.responsive.striped tbody tr:nth-child(odd) td { background: transparent; }
  table.responsive .quick-move { flex: 1; min-width: 0; margin-top: .35rem; }
  table.responsive .quick-move select { flex: 1; min-width: 0; }
  .hbars li { grid-template-columns: 1fr auto; }
  .hbar-track { grid-column: 1 / -1; order: 3; }
  th, td { padding: .5rem .6rem; }
}

/* --- Impression --------------------------------------------------------- */
@media print {
  body.app { display: block; background: #fff; }
  .sidebar, .topbar, .tabbar, .scrim, .period, .page-head button, .report-head a, .actions { display: none !important; }
  details > summary { display: none; }
  details { display: block; }
  .report, .card, .overflow-auto, .detail-grid > section { box-shadow: none; break-inside: avoid; }
  .content { padding: 0; max-width: none; }
}
