/* ==========================================================================
   Clarity Pro Services — système visuel
   Le standard de la catégorie, exécuté au niveau de finition de Stripe
   Dashboard (lisibilité des données), Notion/Height (générosité) et de
   l'e-banking suisse (sobriété institutionnelle).
   Règles tenues : pas de carte décorative, pas de dégradé posé pour décorer,
   pas d'ombre molle, un seul bleu d'action, le statut lisible sans la couleur.
   ========================================================================== */

/* ----- Typographie hébergée (Archivo variable, 400-700) ------------------- */

@font-face {
    font-family: 'Archivo';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/archivo-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
        U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Archivo';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/archivo-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
        U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
        U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ----- Jetons ------------------------------------------------------------ */

:root {
    /* Encres et surfaces */
    --text: #0E1626;
    --text-2: #4A5468;
    --text-3: #6E7689;
    --line: #E3E6EC;
    --line-strong: #CDD3DC;
    --canvas: #F6F7F9;
    --surface: #FFFFFF;
    --surface-2: #FAFBFC;
    --surface-3: #F1F3F6;

    /* Bleu d'action, tiré du haut du logo */
    --brand: #2E5BD4;
    --brand-hover: #2549B0;
    --brand-active: #1E3C92;
    --brand-tint: #EEF3FE;
    --brand-border: #C6D6F8;

    /* Violet, tiré du bas du logo : réservé à l'attente d'une réponse client */
    --violet: #6247C4;
    --violet-tint: #F1EEFC;
    --violet-border: #DAD1F5;

    /* États */
    --green: #0E7A4F;
    --green-tint: #E8F4EE;
    --green-border: #BCDFCE;
    --red: #B3261E;
    --red-tint: #FCEDEB;
    --red-border: #F0C9C5;
    --amber: #8A5A00;
    --amber-tint: #FDF4E4;
    --amber-border: #EEDCB6;
    --grey: #5C6478;
    --grey-tint: #F1F2F5;
    --grey-border: #DDE0E7;

    /* Typographie */
    --font: 'Archivo', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9375rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;

    /* Espacements */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;
    --sp-14: 56px;

    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(14, 22, 38, .06), 0 1px 3px rgba(14, 22, 38, .08);
    --shadow-md: 0 4px 8px rgba(14, 22, 38, .06), 0 12px 24px rgba(14, 22, 38, .08);

    --ease: cubic-bezier(.2, .7, .3, 1);
    --speed: 160ms;
}

/* ----- Base -------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scrollbar-color: var(--line-strong) transparent;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--canvas);
    color: var(--text);
    font-family: var(--font);
    font-size: var(--text-base);
    line-height: 1.55;
    font-feature-settings: 'cv11' 1;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, figure { margin: 0; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.012em; font-weight: 620; }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }

a { color: var(--brand); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
b, strong { font-weight: 620; }
[hidden] { display: none !important; }

/* Surfaces du navigateur : elles font partie du design */
::selection { background: var(--brand-tint); color: var(--brand-active); }
:root { caret-color: var(--brand); accent-color: var(--brand); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border: 3px solid var(--canvas); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #B9C0CC; }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Chiffres alignés partout où une valeur se compare */
.table, .details dd, .timeline__meta, .ticket-row__meta, .settings-item__meta,
.count, .tabs__count, .file-list__size { font-variant-numeric: tabular-nums; }

.mono, .ref {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'ss01' 1;
    letter-spacing: 0.01em;
}
.ref { font-weight: 560; }

.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.text-warning { color: var(--amber); font-weight: 560; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.icon { width: 16px; height: 16px; flex: none; }
.icon--lg { width: 20px; height: 20px; }
.icon--xl { width: 28px; height: 28px; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 var(--sp-6); }
.main { flex: 1; padding: var(--sp-8) 0 var(--sp-14); }

/* ----- En-tête ----------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding-top: env(safe-area-inset-top);
}
.topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    min-height: 60px;
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand__mark { width: auto; height: 30px; }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand__name { font-size: var(--text-base); font-weight: 620; letter-spacing: -0.015em; white-space: nowrap; }
.brand__area { font-size: var(--text-xs); color: var(--text-3); white-space: nowrap; }

.nav { display: flex; align-items: center; gap: 2px; }
.nav__form { margin: 0; display: flex; }
.nav__link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-2);
    font-size: var(--text-sm);
    font-weight: 540;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--speed) var(--ease), color var(--speed) var(--ease);
}
.nav__link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav__link.is-active { background: var(--brand-tint); color: var(--brand-active); }
.nav__link .icon { color: var(--text-3); }
.nav__link.is-active .icon { color: var(--brand); }
.nav__cta { margin-left: var(--sp-2); }
.nav__push.is-on { color: var(--violet); }
.nav__push.is-on .icon { color: var(--violet); }

/* ----- Pied de page ------------------------------------------------------ */

.footer {
    border-top: 1px solid var(--line);
    background: var(--surface);
    padding-bottom: env(safe-area-inset-bottom);
}
.footer__inner {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2) var(--sp-6);
    padding: var(--sp-5) 0;
    font-size: var(--text-sm);
    color: var(--text-3);
}
.footer__inner a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.footer__inner a:hover { color: var(--brand); }
.footer__inner .icon { width: 14px; height: 14px; color: var(--text-3); }

/* ----- Boutons ----------------------------------------------------------- */

.btn {
    --btn-bg: var(--surface);
    --btn-fg: var(--text);
    --btn-bd: var(--line-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid var(--btn-bd);
    border-radius: var(--radius-sm);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-size: var(--text-sm);
    font-weight: 560;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--speed) var(--ease), border-color var(--speed) var(--ease),
        box-shadow var(--speed) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled='true'] { opacity: .55; cursor: not-allowed; }

.btn--primary {
    --btn-bg: var(--brand); --btn-fg: #fff; --btn-bd: var(--brand);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14);
}
.btn--primary:hover { --btn-bg: var(--brand-hover); --btn-bd: var(--brand-hover); }
.btn--primary:active { --btn-bg: var(--brand-active); }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-2); }
.btn--ghost:hover { --btn-bg: var(--surface-3); --btn-fg: var(--text); }
.btn--success { --btn-bg: var(--green); --btn-fg: #fff; --btn-bd: var(--green); }
.btn--success:hover { filter: brightness(.93); }
.btn--violet { --btn-bg: var(--violet); --btn-fg: #fff; --btn-bd: var(--violet); }
.btn--violet:hover { filter: brightness(.93); }
.btn--danger-outline { --btn-fg: var(--red); --btn-bd: var(--red-border); }
.btn--danger-outline:hover { --btn-bg: var(--red-tint); }
.btn--danger-text { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--red); }
.btn--danger-text:hover { --btn-bg: var(--red-tint); }
.btn--sm { min-height: 32px; padding: 0 10px; font-size: var(--text-xs); }
.btn--lg { min-height: 44px; padding: 0 18px; font-size: var(--text-base); }
.btn--block { width: 100%; }
.btn .icon { width: 15px; height: 15px; }

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 15px; height: 15px;
    border: 2px solid currentColor;
    border-color: rgba(255, 255, 255, .95) rgba(255, 255, 255, .95) transparent transparent;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
.btn--ghost.is-loading::after, .btn--danger-outline.is-loading::after, .btn.is-loading:not([class*='--']) ::after {
    border-color: var(--brand) var(--brand) transparent transparent;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-3);
    cursor: pointer;
    transition: background-color var(--speed) var(--ease), color var(--speed) var(--ease);
}
.icon-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn--danger:hover:not(:disabled) { background: var(--red-tint); color: var(--red); }

/* ----- Panneaux ---------------------------------------------------------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.panel + .panel { margin-top: var(--sp-4); }
.panel + .page-head, .callout + .page-head, .empty + .page-head { margin-top: var(--sp-8); }
.panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--line);
}
.panel__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-md);
    font-weight: 620;
    letter-spacing: -0.012em;
}
.panel__title .icon { color: var(--text-3); }
.panel__note { padding: 0 var(--sp-5) var(--sp-4); color: var(--text-2); font-size: var(--text-sm); }
.panel__head + .panel__note { padding-top: var(--sp-4); }
.panel__body { padding: var(--sp-5); }
.panel__body > p + p, .panel__body > p + form, .panel__body > form + form { margin-top: var(--sp-3); }
.panel__footer { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line); }
.panel--flush .panel__body { padding: 0; }

.panel--accent { border-color: var(--violet-border); }
.panel--accent .panel__head { background: var(--violet-tint); border-bottom-color: var(--violet-border); }
.panel--accent .panel__title .icon { color: var(--violet); }
.panel--confirmed { border-color: var(--green-border); }
.panel--confirmed .panel__head { background: var(--green-tint); border-bottom-color: var(--green-border); }
.panel--confirmed .panel__title { color: var(--green); }
.panel--confirmed .panel__title .icon { color: var(--green); }

.count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 99px;
    background: var(--surface-3);
    color: var(--text-2);
    font-size: var(--text-xs);
    font-weight: 620;
}

/* ----- Statuts ----------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    padding: 0 9px 0 7px;
    border: 1px solid;
    border-radius: 99px;
    font-size: var(--text-xs);
    font-weight: 560;
    white-space: nowrap;
    vertical-align: middle;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--blue { background: var(--brand-tint); border-color: var(--brand-border); color: var(--brand-active); }
.badge--violet { background: var(--violet-tint); border-color: var(--violet-border); color: var(--violet); }
.badge--green { background: var(--green-tint); border-color: var(--green-border); color: var(--green); }
.badge--red { background: var(--red-tint); border-color: var(--red-border); color: var(--red); }
.badge--grey { background: var(--grey-tint); border-color: var(--grey-border); color: var(--grey); }
/* Le statut reste lisible sans la couleur : forme du point + libellé */
.badge--green::before { border-radius: 2px; }
.badge--red::before { border-radius: 1px; transform: rotate(45deg); }
.badge--violet::before { background: transparent; box-shadow: inset 0 0 0 2px currentColor; }
.badge--grey::before { background: transparent; box-shadow: inset 0 0 0 1px currentColor; }

/* ----- Messages ---------------------------------------------------------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: var(--sp-5);
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
}
.alert .icon { margin-top: 2px; flex: none; }
.alert--success { background: var(--green-tint); border-color: var(--green-border); color: #0B5D3C; }
.alert--error { background: var(--red-tint); border-color: var(--red-border); color: #8C1D17; }
.alert--info { background: var(--brand-tint); border-color: var(--brand-border); color: var(--brand-active); }

.callout {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: var(--text-sm);
}
.callout:hover { text-decoration: none; }
.callout > span { flex: 1; }
.callout strong { display: block; font-weight: 600; }
.callout--violet { background: var(--violet-tint); border-color: var(--violet-border); }
.callout--violet > .icon:first-child { color: var(--violet); }
.callout--blue { background: var(--brand-tint); border-color: var(--brand-border); }
.callout--blue > .icon:first-child { color: var(--brand); }
.callout--warning { background: var(--amber-tint); border-color: var(--amber-border); }
.callout--warning > .icon:first-child { color: var(--amber); }

/* ----- Titres de page ---------------------------------------------------- */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
    margin-bottom: var(--sp-6);
}
.page-head__title { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: var(--text-2xl); }
.page-head__subtitle { margin-top: 2px; color: var(--text-2); font-size: var(--text-sm); }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: var(--sp-4);
    color: var(--text-3);
    font-size: var(--text-sm);
    font-weight: 540;
}
.back-link:hover { color: var(--brand); text-decoration: none; }

/* ----- Formulaires ------------------------------------------------------- */

.form { display: grid; gap: var(--sp-4); }
.form--narrow { max-width: 560px; }

.field { display: grid; gap: 6px; min-width: 0; }
.field__top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.field__label { font-size: var(--text-sm); font-weight: 560; color: var(--text); }
.field__optional { margin-left: 5px; font-size: var(--text-xs); font-weight: 450; color: var(--text-3); }
.field__hint { font-size: var(--text-xs); color: var(--text-3); }
.field__error { display: flex; align-items: center; gap: 5px; font-size: var(--text-xs); font-weight: 540; color: var(--red); }

.input {
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: var(--text-base);
    transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
    -webkit-appearance: none;
    appearance: none;
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: #B8BFCC; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.input[aria-invalid='true'] { border-color: var(--red); }
.input[aria-invalid='true']:focus { box-shadow: 0 0 0 3px var(--red-tint); }
.input:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
.input--sm { min-height: 32px; padding: 5px 9px; font-size: var(--text-sm); }
.textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
.select {
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236E7689' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    background-size: 16px;
}
input[type='datetime-local'].input { min-height: 40px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.grid-npa { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--sp-4); }
.form-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); flex-wrap: wrap; }

.inline-form { display: flex; gap: var(--sp-2); }
.inline-form .input { flex: 1; }
.inline-form--compact { margin-top: var(--sp-2); max-width: 400px; }

.divider { display: flex; align-items: center; gap: var(--sp-3); color: var(--text-3); font-size: var(--text-xs); }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.action-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }

.dropzone {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: var(--sp-5);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: var(--text-sm);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--speed) var(--ease), background-color var(--speed) var(--ease);
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--brand); background: var(--brand-tint); }
.dropzone.is-invalid { border-color: var(--red); background: var(--red-tint); }
.dropzone .icon { color: var(--text-3); }
.dropzone:hover .icon, .dropzone.is-dragover .icon { color: var(--brand); }
.dropzone__text strong { color: var(--brand); font-weight: 560; }
.dropzone__input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }

.file-list { display: grid; gap: 6px; margin: var(--sp-3) 0 0; padding: 0; list-style: none; }
.file-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 6px 6px 6px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: var(--text-sm);
}
.file-list .icon { color: var(--text-3); }
.file-list__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list__size { color: var(--text-3); font-size: var(--text-xs); }
.file-list li.is-error { border-color: var(--red-border); background: var(--red-tint); color: #8C1D17; }

/* ----- Barre d'outils, onglets, recherche -------------------------------- */

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
    margin-bottom: var(--sp-4);
}

.tabs { display: flex; gap: var(--sp-1); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs__item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: var(--text-sm);
    font-weight: 540;
    white-space: nowrap;
    transition: background-color var(--speed) var(--ease), color var(--speed) var(--ease);
}
.tabs__item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.tabs__item.is-active { background: var(--surface); border-color: var(--line-strong); color: var(--text); font-weight: 600; }
.tabs__count {
    min-width: 19px;
    padding: 0 5px;
    border-radius: 99px;
    background: var(--surface-3);
    color: var(--text-3);
    font-size: 11px;
    font-weight: 620;
    text-align: center;
}
.tabs__item.is-active .tabs__count { background: var(--surface-3); color: var(--text-2); }
.tabs__count--alert { background: var(--brand); color: #fff; }

.search { position: relative; width: min(100%, 320px); }
.search > .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search__input { padding-left: 34px; }

.subnav { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-bottom: var(--sp-5); }
.subnav a {
    height: 30px;
    display: inline-flex;
    align-items: center;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 99px;
    background: var(--surface);
    color: var(--text-2);
    font-size: var(--text-xs);
    font-weight: 540;
}
.subnav a:hover { border-color: var(--brand-border); background: var(--brand-tint); color: var(--brand-active); text-decoration: none; }

/* ----- Tableau de demandes ----------------------------------------------- */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
    padding: 10px var(--sp-4);
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: left;
    white-space: nowrap;
}
.table td { padding: 11px var(--sp-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table__row { cursor: pointer; transition: background-color 100ms var(--ease); }
.table__row:hover { background: var(--surface-2); }
.table__row.is-new td:first-child { box-shadow: inset 2px 0 0 var(--brand); }
.table__link { font-variant-numeric: tabular-nums; font-weight: 560; color: var(--text); }
.table__row:hover .table__link { color: var(--brand); }
.table__sub { display: block; margin-top: 1px; color: var(--text-3); font-size: var(--text-xs); }

/* ----- Liste des demandes (client) --------------------------------------- */

.ticket-list {
    display: grid;
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.ticket-list li + li { border-top: 1px solid var(--line); }
.ticket-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-5);
    color: var(--text);
    transition: background-color 100ms var(--ease);
}
.ticket-row:hover { background: var(--surface-2); text-decoration: none; }
.ticket-row__main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ticket-row__ref { font-variant-numeric: tabular-nums; font-size: var(--text-xs); color: var(--text-3); }
.ticket-row__title { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-row__meta { display: flex; flex-wrap: wrap; gap: 3px var(--sp-4); font-size: var(--text-xs); color: var(--text-2); }
.ticket-row__meta span { display: inline-flex; align-items: center; gap: 5px; }
.ticket-row__meta .icon { width: 13px; height: 13px; color: var(--text-3); }
.ticket-row__chevron { color: var(--line-strong); }

/* ----- Détail d'une demande ---------------------------------------------- */

.layout-split { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: var(--sp-4); align-items: start; }
.layout-split__side { position: sticky; top: 84px; display: grid; gap: var(--sp-4); }
.layout-split__main { display: grid; gap: var(--sp-4); }

.details { display: grid; margin: 0; }
.details__row {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: var(--sp-4);
    padding: 11px 0;
    border-top: 1px solid var(--line);
}
.details__row:first-child { border-top: 0; padding-top: 0; }
.details dt { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-size: var(--text-sm); }
.details dt .icon { width: 14px; height: 14px; color: var(--text-3); }
.details dd { margin: 0; }
.details__row--block { grid-template-columns: 1fr; gap: 5px; }
.details__row--block dt { color: var(--text-3); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; }
.details__row--highlight, .details__row--violet {
    margin-bottom: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-top: 0;
    border-radius: var(--radius-sm);
}
.details__row--highlight { background: var(--green-tint); border: 1px solid var(--green-border); }
.details__row--highlight dt, .details__row--highlight dt .icon { color: var(--green); }
.details__row--violet { background: var(--violet-tint); border: 1px solid var(--violet-border); }
.details__row--violet dt, .details__row--violet dt .icon { color: var(--violet); }
.details__row--highlight + .details__row, .details__row--violet + .details__row { border-top: 0; }
.prose { overflow-wrap: anywhere; }

.big-date { font-size: var(--text-lg); font-weight: 620; letter-spacing: -0.015em; }
.contact-links { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); font-size: var(--text-sm); font-weight: 540; }
.contact-links a { display: inline-flex; align-items: center; gap: 7px; }
.contact-links--stack { flex-direction: column; gap: var(--sp-2); }
.contact-links .icon { width: 14px; height: 14px; color: var(--text-3); }

/* ----- Pièces jointes ---------------------------------------------------- */

.attachments {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: var(--sp-3);
    margin: 0;
    padding: 0;
    list-style: none;
}
.attachment {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    overflow: hidden;
    transition: border-color var(--speed) var(--ease);
}
.attachment:hover { border-color: var(--brand); text-decoration: none; }
.attachment--image img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.attachment--file { gap: 6px; padding: var(--sp-3); }
.attachment--file .icon { color: var(--text-3); }
.attachment__name { font-size: var(--text-xs); font-weight: 560; overflow-wrap: anywhere; }
.attachment__meta { font-size: 11px; color: var(--text-3); }

/* ----- Historique -------------------------------------------------------- */

.timeline { position: relative; display: grid; gap: var(--sp-4); margin: 0; padding: 0 0 0 var(--sp-5); list-style: none; }
.timeline::before { content: ''; position: absolute; left: 4px; top: 5px; bottom: 5px; width: 1px; background: var(--line); }
.timeline__item { position: relative; }
.timeline__dot {
    position: absolute;
    left: calc(-1 * var(--sp-5) + 1px);
    top: 5px;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--line-strong);
}
.timeline__item--blue .timeline__dot { background: var(--brand); }
.timeline__item--green .timeline__dot { background: var(--green); }
.timeline__item--red .timeline__dot { background: var(--red); }
.timeline__item--violet .timeline__dot { background: var(--violet); }
.timeline__text { font-size: var(--text-sm); font-weight: 560; }
.timeline__meta { margin-top: 1px; font-size: var(--text-xs); color: var(--text-3); }
.timeline__comment {
    margin: var(--sp-2) 0 0;
    padding: var(--sp-2) var(--sp-3);
    border-left: 1px solid var(--line-strong);
    background: var(--surface-2);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: var(--text-sm);
    color: var(--text-2);
}

/* ----- Inscriptions en attente ------------------------------------------- */

.pending-list { display: grid; margin: 0; padding: 0; list-style: none; }
.pending-list li + li { border-top: 1px solid var(--line); }
.pending {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-5);
}
.pending__name { font-weight: 600; }
.pending__meta { display: flex; flex-wrap: wrap; gap: 2px var(--sp-4); margin-top: 2px; font-size: var(--text-xs); color: var(--text-2); }
.pending__meta a { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); }
.pending__meta a:hover { color: var(--brand); }
.pending__meta .icon { width: 13px; height: 13px; color: var(--text-3); }
.pending__actions { display: flex; gap: var(--sp-2); flex: none; }

/* ----- Paramètres -------------------------------------------------------- */

.settings-section { scroll-margin-top: 88px; }
.settings-list { display: grid; margin: 0; padding: 0; list-style: none; }
.settings-list li + li { border-top: 1px solid var(--line); }
.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-3) var(--sp-5);
}
.settings-item.is-muted .settings-item__title { color: var(--text-3); }
.settings-item__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.settings-item__title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: var(--text-sm); font-weight: 560; }
.settings-item__title .icon { color: var(--text-3); }
.settings-item__meta { font-size: var(--text-xs); color: var(--text-3); overflow-wrap: anywhere; }
.settings-item__meta a { color: var(--text-2); }
.settings-item__actions { display: flex; align-items: center; gap: var(--sp-1); flex: none; }
.settings-item__actions form { margin: 0; }
.push-test { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3); font-size: var(--text-sm); color: var(--text-2); }
.empty-inline { padding: var(--sp-4) var(--sp-5); color: var(--text-3); font-size: var(--text-sm); }

/* ----- États vides ------------------------------------------------------- */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-14) var(--sp-6);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-align: center;
}
.empty__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    margin-bottom: var(--sp-2);
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text-3);
}
.empty__title { font-size: var(--text-md); font-weight: 620; }
.empty__text { max-width: 420px; color: var(--text-2); font-size: var(--text-sm); }
.empty .btn { margin-top: var(--sp-3); }
.empty--page { max-width: 480px; margin: var(--sp-10) auto 0; }
.empty__code {
    font-variant-numeric: tabular-nums;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-3);
    letter-spacing: 0.04em;
}
.empty__actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }

/* ----- Connexion / inscription ------------------------------------------- */

.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); min-height: calc(100vh - 60px); }
.auth--single { display: block; max-width: 420px; margin: 0 auto; padding: var(--sp-10) 0; }

.auth__aside {
    display: flex;
    flex-direction: column;
    gap: var(--sp-6);
    padding: var(--sp-14) var(--sp-10);
    border-right: 1px solid var(--line);
    background: var(--surface);
}
.auth__brand { display: flex; align-items: center; gap: 10px; font-weight: 620; font-size: var(--text-base); }
.auth__mark { width: auto; height: 34px; }
.auth__heading { font-size: var(--text-2xl); letter-spacing: -0.02em; max-width: 15ch; }
.auth__points { display: grid; gap: var(--sp-3); margin: 0; padding: 0; list-style: none; }
.auth__points li { display: flex; gap: 10px; align-items: flex-start; color: var(--text-2); font-size: var(--text-sm); }
.auth__points .icon { margin-top: 2px; color: var(--green); flex: none; }
.auth__contact { margin-top: auto; padding-top: var(--sp-6); border-top: 1px solid var(--line); font-size: var(--text-sm); color: var(--text-3); }
.auth__contact a { font-weight: 560; }

.auth__panel { padding: var(--sp-14) var(--sp-10); max-width: 460px; }
.auth--single .auth__panel { padding: var(--sp-6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); max-width: none; }
.auth__head { margin-bottom: var(--sp-6); }
.auth__head h1 { margin-bottom: 4px; font-size: var(--text-2xl); letter-spacing: -0.02em; }
.auth__head--center { text-align: center; }
.auth__logo { width: auto; height: 42px; margin: 0 auto var(--sp-4); }
.auth__foot { margin-top: var(--sp-5); text-align: center; font-size: var(--text-sm); color: var(--text-2); }
.auth__foot a { font-weight: 560; display: inline-flex; align-items: center; gap: 5px; }
.auth__company { margin-top: var(--sp-3); text-align: center; font-size: var(--text-xs); }
.auth__company a { color: var(--text-3); }
.auth__company a:hover { color: var(--brand); }

/* ----- Adaptation -------------------------------------------------------- */

@media (max-width: 960px) {
    .layout-split { grid-template-columns: 1fr; }
    .layout-split__side { position: static; }
    .auth { grid-template-columns: 1fr; min-height: 0; }
    .auth__aside { padding: var(--sp-6); border-right: 0; border-bottom: 1px solid var(--line); }
    .auth__aside .auth__points, .auth__aside .auth__contact { display: none; }
    .auth__heading { font-size: var(--text-lg); max-width: none; }
    .auth__panel { padding: var(--sp-8) var(--sp-6); max-width: none; }
}

@media (max-width: 720px) {
    .container { padding: 0 var(--sp-4); }
    .main { padding: var(--sp-5) 0 var(--sp-10); }
    .page-head__title { font-size: var(--text-xl); }
    .panel__body, .panel__head, .panel__note { padding-left: var(--sp-4); padding-right: var(--sp-4); }
    .ticket-row, .pending, .settings-item, .empty-inline { padding-left: var(--sp-4); padding-right: var(--sp-4); }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-npa { grid-template-columns: 96px minmax(0, 1fr); }
    .details__row { grid-template-columns: 1fr; gap: 3px; }
    .details dt { font-size: var(--text-xs); color: var(--text-3); }
    .ticket-row { grid-template-columns: minmax(0, 1fr) auto; }
    .ticket-row__chevron { display: none; }
    .pending { flex-direction: column; align-items: stretch; }
    .pending__actions .btn { flex: 1; }
    .search { width: 100%; }
    .toolbar { gap: var(--sp-3); }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
    .settings-item { flex-direction: column; align-items: stretch; }
    .settings-item__actions { justify-content: flex-end; }
    .btn, .nav__link { min-height: 40px; }
    .icon-btn { width: 40px; height: 40px; }

    /* Le tableau devient une liste de lignes lisibles */
    .table-wrap { border: 0; border-radius: 0; background: none; overflow: visible; }
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; }
    .table tbody { display: grid; gap: var(--sp-2); }
    .table__row {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 3px var(--sp-3);
        padding: var(--sp-4);
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: var(--radius);
    }
    .table td { padding: 0; border: 0; }
    .table td[data-label='Statut'] { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
    .table td[data-label='Client'], .table td[data-label='Arrivée'],
    .table td[data-label='Lieu'], .table td[data-label='Reçue'] { grid-column: 1; font-size: var(--text-sm); }
    .table td[data-label='Arrivée']::before { content: 'Arrivée : '; color: var(--text-3); }
    .table td[data-label='Reçue'] { font-size: var(--text-xs); color: var(--text-3); }
    .table td[data-label='Reçue']::before { content: 'Reçue le '; }
    .table__row.is-new { box-shadow: inset 2px 0 0 var(--brand); }
    .table__row.is-new td:first-child { box-shadow: none; }
}

@media (max-width: 560px) {
    .brand__area { display: none; }
    .nav__link span, .nav__cta span {
        position: absolute; width: 1px; height: 1px;
        overflow: hidden; clip-path: inset(50%); white-space: nowrap;
    }
    .nav__link, .nav__cta { padding: 0 10px; }
    .nav .icon { width: 18px; height: 18px; }
    .footer__inner { flex-direction: column; gap: var(--sp-2); }
    .action-buttons { grid-template-columns: 1fr; }
}

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