:root { color-scheme: light; font-family: system-ui, sans-serif; background: #f1f5f4; color: #182622; }
* { box-sizing: border-box; }
body { margin: 0; }
body.connected { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: 100vh; }
aside { background: #163c33; color: white; padding: 1.5rem; }
a { color: #175b49; text-underline-offset: .18em; }
aside a { color: #fff; }
.brand { font-size: 1.1rem; font-weight: 750; }
nav { display: grid; gap: .8rem; margin: 2rem 0; }
main { width: min(100%, 76rem); margin: 0 auto; padding: clamp(1rem, 4vw, 3rem); }
.guest main { max-width: 34rem; margin-top: min(10vh, 5rem); }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0 0 1.3rem; }
h2 { font-size: 1.15rem; margin: 0; }
p { line-height: 1.55; }
.card { background: white; border: 1px solid #d5e2de; border-radius: .8rem; padding: clamp(1rem, 3vw, 1.6rem); margin-bottom: 1rem; }
.form { display: grid; gap: .9rem; max-width: 42rem; }
.form p { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1rem; align-items: start; }
label { display: grid; gap: .35rem; font-weight: 650; }
input, select, button { font: inherit; padding: .63rem .75rem; border-radius: .45rem; }
input, select { width: 100%; background: white; border: 1px solid #728780; color: inherit; }
button { width: fit-content; border: 1px solid transparent; background: #175b49; color: white; font-weight: 700; cursor: pointer; }
button.secondary { border-color: #a9c2b9; background: transparent; }
:focus-visible { outline: 3px solid #337eb2; outline-offset: 3px; }
.badge { display: inline-block; background: #e1eee9; border-radius: .35rem; padding: .2rem .45rem; }
.notice { padding: .75rem; background: #e1eee9; border-radius: .45rem; }
.notice.error { background: #fae6e3; color: #7a201c; }
.muted { color: #485e57; font-size: .92rem; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: .75rem; }
th, td { text-align: left; padding: .7rem .6rem; border-bottom: 1px solid #d5e2de; }
@media (max-width: 720px) {
    body.connected { display: block; }
    aside { padding: 1rem; }
    nav { display: flex; flex-wrap: wrap; margin: .85rem 0; }
}
textarea { width: 100%; padding: .63rem .75rem; border: 1px solid #728780; border-radius: .45rem; font: inherit; }
fieldset { display: grid; gap: .7rem; min-width: 0; border: 1px solid #d5e2de; border-radius: .45rem; }
legend { font-weight: 700; }
.filters, .actions { display: flex; align-items: end; flex-wrap: wrap; gap: .85rem; }
.filters { padding-block: .75rem; }
.actions form { margin: 0; }
.primary { display: inline-block; background: #175b49; color: white; text-decoration: none; padding: .65rem .8rem; border-radius: .45rem; font-weight: 650; }
.shortage { background: #fae6e3; color: #7a201c; }
.booking-form { max-width: 58rem; }
.details { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .45rem 1rem; }
.details dt { font-weight: 650; }
.details dd { margin: 0; overflow-wrap: anywhere; }
.calendar-header { justify-content: space-between; margin-bottom: .85rem; align-items: center; }
[aria-current=page] { font-weight: 750; }
.calendar-grid { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: .35rem; }
.calendar-grid.one-day { grid-template-columns: minmax(0,1fr); }
.calendar-day { min-height: 6rem; padding: .55rem; background: white; border: 1px solid #d5e2de; border-radius: .45rem; overflow-wrap: anywhere; }
.calendar-day.other-month { background: #e8eeec; }
.calendar-day h3 { margin: 0 0 .5rem; font-size: .9rem; }
.calendar-event { display: grid; gap: .15rem; background: #e1eee9; border-radius: .3rem; margin-top: .35rem; padding: .4rem; font-size: .83rem; }
.signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; min-height: 8rem; margin-top: 2rem; }
@media (max-width: 900px) { .calendar-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 450px) { .calendar-grid { grid-template-columns: minmax(0,1fr); } }
@media print {
  .printable { display: block !important; background: white; }
  .printable aside, .screen-only, .printable main > h1 { display: none; }
  .printable main, .printable .card { width: 100%; padding: 0; border: 0; }
  .printable .table-wrap { overflow: visible; }
  .printable tr { break-inside: avoid; }
}
.finance-form { margin-top: 1rem; }
.inline-form { display: flex; align-items: end; gap: .7rem; flex-wrap: wrap; }
.rate-row { border-top: 1px solid #d5e2de; }
.rate-row > div { min-width: 12rem; }
.check { display: flex; align-items: center; gap: .5rem; }
.check input { width: auto; }

/* Interface commune */
:root {
    --canvas: #f2f5f8;
    --surface: #fff;
    --ink: #1c2b3c;
    --muted: #526379;
    --line: #d9e2ec;
    --nav: #14253a;
    --nav-active: #284359;
    --accent: #126452;
    --accent-darker: #0c4d40;
    color: var(--ink);
    background: var(--canvas);
    font-family: "Segoe UI",system-ui,sans-serif;
}
[hidden] { display: none !important; }
a { color: var(--accent-darker); }
a:hover { text-decoration-thickness: 2px; }
body.connected { grid-template-columns: 15rem minmax(0,1fr); align-items: start; }
.app-sidebar { background: var(--nav); position: sticky; top: 0; min-height: 100vh; max-height: 100vh; overflow: auto; padding: 1.45rem 1rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; line-height: 1.12; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: .6rem; background: #d8f2e9; color: #103e34; font-size: .94rem; font-weight: 800; }
.sidebar-head { padding: 0 .45rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.app-sidebar nav { gap: .2rem; margin: 1.6rem 0; }
.app-sidebar nav a, .sidebar-account > a, .nav-details summary {
    display: block; padding: .68rem .65rem; color: #eef5ff; text-decoration: none; font-weight: 600; border-radius: .45rem;
}
.nav-details summary { display: list-item; cursor: pointer; }
.nav-details a { margin-left: .6rem; }
.app-sidebar nav a:hover, .sidebar-account > a:hover, .nav-details summary:hover { background: var(--nav-active); }
.app-sidebar nav a[aria-current=page], .sidebar-account > a[aria-current=page] {
    background: #d8f2e9; color: #153d34; font-weight: 750;
}
.sidebar-account { border-top: 1px solid #496075; padding: .75rem .1rem 0; display: grid; gap: .65rem; }
.sidebar-account form { padding-left: .45rem; }
.sidebar-account button { font-size: .9rem; }
main { width: min(100%, 99rem); padding: clamp(.9rem,3.1vw,2.6rem); }
main:focus-visible { outline-offset: -3px; }
.app-topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); margin-bottom: 1.4rem; }
.global-search { display: flex; gap: .45rem; width: min(100%,31rem); }
.global-search input { flex: 1; min-width: 0; padding-left: .8rem; }
.global-search button { flex: none; }
.session-label { text-align: right; min-width: min(13ch,22%); overflow-wrap: anywhere; }
.session-label span { font-weight: 700; }
.session-label small { color: var(--muted); display: block; }
.page-heading { display: flex; gap: .65rem; justify-content: space-between; align-items: center; margin: 0 0 .9rem; }
.page-heading h1 { margin: 0; letter-spacing: -.04em; line-height: 1.1; }
.card { border-color: var(--line); border-radius: .7rem; box-shadow: 0 2px 4px #16284008; }
.muted, .empty-state, .cell-note { color: var(--muted); }
.cell-note { display: block; font-size: .86rem; margin-top: .2rem; }
.empty-state { padding: .65rem .75rem; background: #f5f8fb; border-radius: .4rem; }
button, .primary { background: var(--accent); color: white; }
button:hover, .primary:hover { background: var(--accent-darker); }
button.secondary:hover { background: var(--nav-active); }
.quiet {
    display: inline-block; width: fit-content; border: 1px solid #a6b6c7; border-radius: .45rem;
    background: #fff; color: #26394d; padding: .6rem .75rem; font: inherit; font-weight: 650; text-decoration: none;
}
.quiet:hover { background: #e9f0f7; color: #26394d; }
.skip-link {
    position: fixed; z-index: 10; top: .5rem; left: .5rem; transform: translateY(-160%);
    padding: .75rem; color: #fff; background: var(--nav); border-radius: .4rem;
}
.skip-link:focus { transform: translateY(0); }
.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid #4278b0; outline-offset: 3px; }
.app-sidebar :focus-visible { outline-color: #a9d8ff; }
input, select, textarea { min-width: 0; border-color: #8497a9; }
select { overflow: hidden; text-overflow: ellipsis; }
.toolbar, .pagination { margin: .9rem 0 1rem; align-items: center; }
.table-card { padding-top: .45rem; }
th { color: #3c5269; font-size: .87rem; font-weight: 700; }
th, td { border-color: var(--line); overflow-wrap: anywhere; }
td a { font-weight: 650; }
tr:last-child td { border-bottom: 0; }
.status, .count-chip { display: inline-block; padding: .23rem .48rem; border-radius: .32rem; font-weight: 650; font-size: .82rem; line-height: 1.3; }
.status-draft, .status-cancelled { background: #edf0f5; color: #3e4a5c; --status-edge: #63758c; }
.status-pending { background: #fcefce; color: #684200; --status-edge: #a26918; }
.status-approved { background: #dcf4eb; color: #174b3e; --status-edge: #2b826d; }
.status-out { background: #dfedff; color: #194975; --status-edge: #357cb9; }
.status-partial { background: #f3e7fb; color: #582975; --status-edge: #8555ae; }
.status-returned, .status-closed { background: #e8f1f2; color: #345660; --status-edge: #527b82; }
.status-late { background: #fce8e6; color: #8d2824; --status-edge: #a43b35; }
.count-chip { background: #edf2f7; color: #3c5269; min-width: 1.8rem; text-align: center; }
.section-heading, .dashboard-intro { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.dashboard-intro { margin: 0 0 1.2rem; }
.dashboard-intro p { color: var(--muted); margin: 0; }
.filter-panel { padding: .95rem 1.05rem; margin-bottom: 1.1rem; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,8.8rem),1fr)); gap: .7rem; }
.filter-grid label { font-size: .88rem; }
.filter-actions { margin-top: .75rem; align-items: center; }
.metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .8rem; margin: 0 0 1.1rem; }
.metric {
    display: flex; flex-direction: column; gap: .35rem; text-decoration: none; padding: .9rem 1rem;
    background: var(--surface); border: 1px solid var(--line); border-top: 4px solid #2b826d;
    border-radius: .65rem; color: var(--ink); min-width: 0;
}
.metric:hover { background: #f4faf8; }
.metric-pending { border-top-color: #a26918; }
.metric-out { border-top-color: #357cb9; }
.metric-returns { border-top-color: #8555ae; }
.metric > span { font-weight: 700; font-size: .94rem; }
.metric > strong { font-size: 2.15rem; line-height: 1.05; font-variant-numeric: tabular-nums; }
.metric > small { color: var(--muted); overflow-wrap: anywhere; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .95rem; align-items: start; }
.dashboard-section { margin: 0; min-width: 0; }
.dashboard-grid .full-width { grid-column: 1/-1; }
.section-link { display: inline-block; margin-top: .65rem; font-size: .91rem; font-weight: 700; }
.result-list { list-style: none; margin: .65rem 0; padding: 0; }
.result-list li { border-top: 1px solid var(--line); padding: .65rem .1rem; }
.result-list li a { font-weight: 700; }
.calendar-tools { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: 1rem; margin: 0 0 .9rem; }
.view-switch { display: inline-flex; background: #dfe8f1; overflow: hidden; gap: 2px; padding: .25rem; border-radius: .5rem; margin: 0; }
.view-switch a { display: block; padding: .42rem .62rem; border-radius: .3rem; color: var(--ink); text-decoration: none; }
.view-switch a[aria-current=page] { background: #fff; box-shadow: 0 1px 3px #1c2b3c28; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .8rem; padding: 0; list-style: none; }
.calendar-day.current-day { border: 2px solid #276f61; }
.calendar-event { border-left: 4px solid var(--status-edge); color: inherit; }
.calendar-event:hover { text-decoration: underline; }
.guest .page-heading { margin-top: 1rem; }

@media (max-width: 1060px) {
    .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (min-width: 741px) and (max-width: 980px) {
    body.connected { grid-template-columns: 12rem minmax(0,1fr); }
}
@media (max-width: 740px) {
    body.connected { display: block; }
    .app-sidebar { position: static; min-height: 0; max-height: none; padding: .65rem .85rem; overflow: visible; }
    .app-sidebar nav { margin: .8rem 0; padding: 0; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
    .nav-details { grid-column: 1/-1; }
    .sidebar-account { display: flex; align-items: center; flex-wrap: wrap; }
    .session-label { display: none; }
    .global-search { width: 100%; }
    .global-search button { padding-inline: .55rem; }
    .dashboard-grid { grid-template-columns: minmax(0,1fr); }
    .calendar-grid { grid-template-columns: minmax(0,1fr); }
    .calendar-grid:not(.one-day) .empty-day { display: none; }
}
@media (max-width: 390px) {
    .metric { padding-inline: .65rem; }
    .dashboard-intro { align-items: flex-start; flex-direction: column; }
    .details { grid-template-columns: minmax(0,1fr); gap: .35rem; }
    .details dd { margin-bottom: .35rem; }
}
@media print {
    body.printable { display: block !important; background: white; font-size: 9pt; }
    .printable main { padding: 0; margin: 0; }
    .printable .card { box-shadow: none; border: 1px solid #bbb; padding: .35rem; break-inside: auto; }
    .app-sidebar, .print-hide, .skip-link, .screen-only, form, .actions button, .actions a.primary { display: none !important; }
    .page-heading h1 { font-size: 17pt; }
    .printable .table-wrap { overflow: visible; }
    .dashboard-grid, .metric-grid { gap: .35rem; }
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
    .metric-grid { grid-template-columns: repeat(4,1fr); }
    .calendar-grid:not(.one-day) { grid-template-columns: repeat(7,minmax(0,1fr)); }
    .calendar-grid:not(.one-day) .empty-day { display: block; }
    .calendar-day, .metric { break-inside: avoid; }
    thead { display: table-header-group; }
    a { color: inherit; }
    th, td { padding: .25rem; }
}

.print-only { display: none; }
@media print { .print-only { display: block; } }

.filter-shell > summary {
    display: none;
    font-weight: 700;
    color: var(--accent-darker);
    border: 1px solid var(--line);
    border-radius: .55rem;
    background: white;
    padding: .72rem .9rem;
    margin: 0 0 .8rem;
    cursor: pointer;
}
@media (max-width: 740px) {
    .filter-shell > summary { display: list-item; }
    .filter-shell .filter-panel { border-radius: .55rem; }
}

/* Thème ComFet pour les écrans */
@media screen {
    :root {
        --canvas: #f5f5ef;
        --surface: #fff;
        --ink: #172e25;
        --muted: #506457;
        --line: #dce5db;
        --nav: #132f26;
        --nav-active: #25483a;
        --accent: #216345;
        --accent-darker: #194d36;
        --shadow: 0 1px 2px #193d2810, 0 8px 24px #193d2809;
        font-family: system-ui, sans-serif;
    }

    .app-sidebar {
        background: linear-gradient(160deg, #183a2d, var(--nav) 65%);
        border-right: 1px solid #244335;
    }

    .brand-mark {
        flex: 0 0 2.65rem;
        height: 2.65rem;
        border-radius: .85rem;
        background: #e5ebc9;
        color: #254431;
    }

    .app-sidebar nav a, .sidebar-account > a, .nav-details summary {
        color: #edf4eb;
        border-radius: .7rem;
    }

    .app-sidebar nav a[aria-current=page], .sidebar-account > a[aria-current=page] {
        background: #e3edce;
        color: #233f2e;
    }

    .sidebar-account { border-color: #476455; }
    .app-sidebar :focus-visible { outline-color: #e5ebc9; }

    h1, .page-heading h1 {
        font: 500 clamp(2rem, 4vw, 3.2rem)/1.08 Georgia, serif;
        letter-spacing: -.04em;
        overflow-wrap: anywhere;
    }

    .page-heading { margin-bottom: 1.2rem; }
    .app-topbar { margin-bottom: clamp(1.25rem, 3vw, 2rem); }
    .app-topbar .session-label { color: var(--accent-darker); }

    .card {
        border-radius: 1rem;
        box-shadow: var(--shadow);
    }

    input, select, textarea {
        background: #fff;
        border-color: #849589;
        border-radius: .65rem;
    }

    button, .primary, .quiet { border-radius: .65rem; }
    .quiet { color: var(--accent-darker); border-color: #849589; }
    .quiet:hover { background: #edf4eb; color: var(--accent-darker); }
    :focus-visible { outline-color: #206a50; }

    .metric {
        --metric-color: #286648;
        gap: .5rem;
        padding: clamp(.8rem, 1.7vw, 1.2rem);
        border: 1px solid var(--line);
        border-top: 4px solid var(--metric-color);
        border-radius: .9rem;
        box-shadow: var(--shadow);
    }

    .metric-pending { --metric-color: #9a641a; }
    .metric-out { --metric-color: #397097; }
    .metric-returns { --metric-color: #784e87; }
    .metric > strong { color: var(--metric-color); font-size: clamp(1.8rem, 3vw, 2.65rem); }
    .metric > span { overflow-wrap: anywhere; }
    .metric:hover { background: #f7faf5; border-color: var(--metric-color); }
    .section-heading h2 { line-height: 1.28; }

    .empty-state {
        background: #f4f7f0;
        border-radius: .65rem;
        margin-block: .85rem .35rem;
    }

    .table-wrap thead { background: #f0f4ed; }
    .table-wrap th { color: #395345; }
    .table-wrap tbody tr:hover { background: #f7faf5; }
    .status, .count-chip { border-radius: .65rem; }
    .count-chip { background: #e8efe2; color: #315140; }

    .calendar-day { border-color: var(--line); border-radius: .65rem; }
    .calendar-day.other-month { background: #edf0e8; }
    .calendar-day.current-day { border-color: var(--accent); }
    .view-switch { background: #e5ece0; }

    body.guest {
        min-height: 100vh;
        background: radial-gradient(ellipse at 14% 0, #e2edd9, transparent 56%),
            radial-gradient(ellipse at 100% 85%, #efe9d8, transparent 55%),
            var(--canvas);
        display: flow-root;
    }

    .guest main { max-width: 32rem; margin: clamp(1.5rem, 12vh, 7rem) auto 2rem; }
    .guest .page-heading { margin-top: 0; }
    .guest form {
        background: var(--surface);
        border: 1px solid var(--line);
        box-shadow: var(--shadow);
        border-radius: 1.1rem;
        padding: clamp(1.15rem, 4vw, 2rem);
    }

    .guest form button { width: 100%; margin-top: .3rem; }
}
