/* Portal styles, after the wireframes in docs/wireframes. */

/*
 * Colour tokens. MyCompanion's identity is a blue (--accent): main buttons, the
 * current menu entry, links, tabs and the focus ring. The neutrals carry a
 * light tint of it. White text on a filled blue button is AA in both themes.
 * The brand never says a state. A success takes a leaf green (--success) and
 * always a check (--icon-check), which the brand never wears. Danger and
 * errors take a red (--danger), an icon, and an outlined button, never a
 * filled one; waiting takes the amber of --warning. Work in progress takes the
 * violet of --info, a hue apart from the brand's blue, and keeps its own
 * marks: its clock, and a dashed or bold outline (--icon-clock where the
 * markup has no icon).
 * Text contrasts are AA (4.5:1 at least) on every background they sit on.
 * Interface outlines reach 3:1: --accent, --focus, and --border-strong and
 * --danger-border, which outline the fields and the secondary buttons that
 * nothing else sets apart from their card (WCAG 1.4.11, against --surface,
 * --subtle and --bg, as measured in a browser by tests/e2e/run.sh --ecrans).
 */
:root {
    --bg: #F3F6FA;
    --surface: #FFFFFF;
    --subtle: #F8FAFC;
    --border: #DBE1EA;
    --border-strong: #7B8494;
    --divider: #E8EDF4;
    --text: #161C27;
    --text-soft: #343C4A;
    --text-muted: #566072;
    --text-inverse: #FFFFFF;
    --selected: #DCE7FA;
    --link-hover: #143F8F;
    --primary-hover: #184DAD;
    /* Danger and errors: a red, with an icon and an outline (see .button--danger). */
    --danger: #B3261E;
    --danger-bg: #FDEDEC;
    --danger-border: #D9645C;
    /* Success: a leaf green, and always its check. */
    --success: #1E6720;
    --success-bg: #EAF6E6;
    --success-border: #9ACF8F;
    --warning: #7A4D00;
    --warning-bg: #FFF4DA;
    --warning-border: #EBC36A;
    /*
     * Work in progress, and what is asked for with the member's passkey (« Mes connecteurs »):
     * a violet, a hue apart from the brand's blue, never the brand's colour.
     */
    --info: #6E3AA7;
    --info-bg: #F4EEFC;
    --info-border: #C2A6E8;
    /* Brand: filled buttons and marks (--accent, text on it --on-accent); accent text and links (--accent-text). */
    --accent: #1E5FD0;
    --accent-hover: #184DAD;
    --accent-text: #1A56C0;
    --on-accent: #FFFFFF;
    /* Tinted backgrounds: the current entry (--accent-soft), a hover (--accent-tint), and their outline. */
    --accent-soft: #E4EDFC;
    --accent-tint: #F2F6FE;
    --accent-border: #A7C2F0;
    --focus: #1E5FD0;
    /* The menu and the page header, a shade apart from the page. */
    --nav-bg: #F9FBFD;
    --header-bg: #FFFFFF;
    /* Depth: cards (sm), menus and the composer (md), toasts and pop-ups (lg), filled buttons (accent). */
    --shadow-sm: 0 1px 2px rgb(22 28 39 / 5%), 0 1px 3px rgb(22 28 39 / 4%);
    --shadow-md: 0 1px 2px rgb(22 28 39 / 4%), 0 6px 18px rgb(22 28 39 / 7%);
    --shadow-lg: 0 12px 32px rgb(22 28 39 / 16%);
    --shadow-accent: 0 1px 2px rgb(24 77 173 / 20%), 0 4px 12px rgb(30 95 208 / 22%);
    /* Outline of the logo's tile, which only needs one on a dark background. */
    --logo-ring: transparent;
    --radius: 10px;
    color-scheme: light;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
    accent-color: var(--accent);
}

/*
 * Dark theme, chosen in the settings (data-theme="dark" on <html>, set by the
 * server from a cookie), or following the device when nothing is chosen.
 * Same contrasts as the light theme. Both blocks hold the same values.
 */
:root[data-theme="dark"] {
    --bg: #0F1218;
    --surface: #171B22;
    --subtle: #1E232B;
    --border: #2E3540;
    --border-strong: #6A7384;
    --divider: #252B34;
    --text: #ECF0F6;
    --text-soft: #CCD3DE;
    --text-muted: #9DA6B5;
    --text-inverse: #0F1218;
    --selected: #162B4F;
    --link-hover: #C2D6FF;
    --primary-hover: #2560CF;
    --danger: #FFABA5;
    --danger-bg: #341A1A;
    --danger-border: #B25C55;
    --success: #95D88A;
    --success-bg: #16280F;
    --success-border: #3F6E36;
    --warning: #F3C96D;
    --warning-bg: #2D2410;
    --warning-border: #7D5E1F;
    --info: #CFB5F5;
    --info-bg: #251B38;
    --info-border: #5F4A8A;
    --accent: #2B6CE6;
    --accent-hover: #2560CF;
    --accent-text: #8DB3FF;
    --on-accent: #FFFFFF;
    --accent-soft: #162B4F;
    --accent-tint: #141F33;
    --accent-border: #2F5596;
    --focus: #8DB3FF;
    --nav-bg: #13161C;
    --header-bg: #13161C;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 35%);
    --shadow-md: 0 2px 6px rgb(0 0 0 / 35%), 0 8px 24px rgb(0 0 0 / 25%);
    --shadow-lg: 0 16px 40px rgb(0 0 0 / 55%);
    --shadow-accent: 0 4px 14px rgb(43 108 230 / 22%);
    --logo-ring: #333B48;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0F1218;
        --surface: #171B22;
        --subtle: #1E232B;
        --border: #2E3540;
        --border-strong: #6A7384;
        --divider: #252B34;
        --text: #ECF0F6;
        --text-soft: #CCD3DE;
        --text-muted: #9DA6B5;
        --text-inverse: #0F1218;
        --selected: #162B4F;
        --link-hover: #C2D6FF;
        --primary-hover: #2560CF;
        --danger: #FFABA5;
        --danger-bg: #341A1A;
        --danger-border: #B25C55;
        --success: #95D88A;
        --success-bg: #16280F;
        --success-border: #3F6E36;
        --warning: #F3C96D;
        --warning-bg: #2D2410;
        --warning-border: #7D5E1F;
        --info: #CFB5F5;
        --info-bg: #251B38;
        --info-border: #5F4A8A;
        --accent: #2B6CE6;
        --accent-hover: #2560CF;
        --accent-text: #8DB3FF;
        --on-accent: #FFFFFF;
        --accent-soft: #162B4F;
        --accent-tint: #141F33;
        --accent-border: #2F5596;
        --focus: #8DB3FF;
        --nav-bg: #13161C;
        --header-bg: #13161C;
        --shadow-sm: 0 1px 2px rgb(0 0 0 / 35%);
        --shadow-md: 0 2px 6px rgb(0 0 0 / 35%), 0 8px 24px rgb(0 0 0 / 25%);
        --shadow-lg: 0 16px 40px rgb(0 0 0 / 55%);
        --shadow-accent: 0 4px 14px rgb(43 108 230 / 22%);
        --logo-ring: #333B48;
        color-scheme: dark;
    }
}

/*
 * The icons of errors (a circled "!"), of successes (a check) and of work in
 * progress (a clock), drawn in their colour through a mask.
 */
:root {
    --icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 7.5v5'/%3E%3Cpath d='M12 16.5h.01'/%3E%3C/svg%3E");
    --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
    --icon-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 6v6l4 2'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
body { margin: 0; -webkit-font-smoothing: antialiased; }
/* The browser's own placeholder grey is too faint on the dark theme's fields. */
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
h1, h2, h3, h4 { letter-spacing: -0.01em; }
.icon { flex-shrink: 0; }
/* One focus ring everywhere, in the brand colour; a screen's own rule wins (zero specificity). */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
:where(input, select, textarea):focus-visible { outline-offset: 1px; }
/* Hover states change colours only, gently; nothing moves. */
:where(a, button, summary, .button, .chip, .tab, .nav-item) { transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease; }
@media (prefers-reduced-motion: reduce) {
    :where(a, button, summary, .button, .chip, .tab, .nav-item) { transition: none; }
}
/* Tables of figures: digits line up. */
table, .counter, .request-rows dd { font-variant-numeric: tabular-nums; }

/*
 * Depth: the cards and panels of every screen share one soft shadow over
 * their border. Zero specificity, so that a :target or a screen's own
 * shadow still wins.
 */
:where(.connector-card, .request-card, .chat-message--assistant, .chat-card, .card,
    .catalog-card, .audit-table, .audit-panel, .rights-card, .rights-groups,
    .settings-card, .editor-card:not(.editor-card--dashed), .editor-login-card, .ecat-connectors, .ecat-sheet, .tool-request) {
    box-shadow: var(--shadow-sm);
}
.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
}

/* Layout */
.portal { min-height: 100vh; display: flex; flex-wrap: wrap; }
.portal-nav {
    flex: 1 1 240px; max-width: 100%; background: var(--nav-bg); border-right: 1px solid var(--border);
    padding: 20px 14px; display: flex; flex-direction: column; gap: 20px;
}
.portal-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.portal-content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* The AI budget of the company is spent (decision 0015): above every page of the portal. */
.budget-banner { margin: 12px 24px 0; font-size: 14px; line-height: 1.5; }

/* Menu */
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; font-weight: 800; font-size: 17px; letter-spacing: -0.02em; }
.brand img { border-radius: 8px; box-shadow: 0 0 0 1px var(--logo-ring), var(--shadow-accent); }
.new-conversation {
    display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
    border-radius: var(--radius); background: var(--accent); color: var(--on-accent); text-decoration: none;
    font-size: 14px; font-weight: 600; box-shadow: var(--shadow-accent);
}
.new-conversation:hover { color: var(--on-accent); background: var(--accent-hover); }
.nav-scroll { flex: 1; display: flex; flex-direction: column; gap: 20px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-heading {
    padding: 0 12px 6px; font-size: 11px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .08em;
}
.nav-item {
    display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px;
    border-radius: var(--radius); font-size: 14px; text-decoration: none; color: var(--text-soft);
}
.nav-item .icon { color: var(--text-muted); }
.nav-item:hover { background: var(--accent-tint); color: var(--text); }
.nav-item:hover .icon { color: var(--accent-text); }
/* The current entry: tinted, bold, its icon and text in the brand colour. */
.nav-item[aria-current="page"] { background: var(--accent-soft); font-weight: 600; color: var(--accent-text); }
.nav-item[aria-current="page"] .icon { color: var(--accent-text); }
.nav-recent { flex: 1; }
.nav-empty { padding: 0 12px; font-size: 13px; color: var(--text-muted); }
.nav-user { display: flex; align-items: center; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--border); }
.avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
    box-shadow: inset 0 0 0 1px var(--accent-border);
}
.nav-user-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.nav-user-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user-role { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-button {
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius); color: var(--text-soft);
}
.icon-button:hover { background: var(--accent-tint); color: var(--accent-text); }

/* Page */
.page-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 16px 32px; border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--header-bg);
}
.page-header h1 { margin: 0; font-size: 17px; font-weight: 700; }
.company-name {
    padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text);
    font-size: 13px; font-weight: 600;
}

/* Chat */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* The conversation scrolls across the whole width, its content in a centred 820px column. */
.chat-messages {
    flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; justify-content: center; gap: 16px;
    padding: 32px max(24px, calc((100% - 772px) / 2));
}
.chat-empty { text-align: center; color: var(--text-soft); line-height: 1.5; }
/* A welcoming mark above « Bonjour … » (decorative): a tinted tile with a sparkle. */
.chat-empty::before, .placeholder::before {
    content: ""; display: block; width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px;
    background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-border);
}
.chat-empty, .placeholder { position: relative; }
.chat-empty::after, .placeholder::after {
    content: ""; position: absolute; top: 14px; left: calc(50% - 14px); width: 28px; height: 28px; background: var(--accent-text);
    -webkit-mask: var(--sparkle) center / contain no-repeat; mask: var(--sparkle) center / contain no-repeat;
}
.placeholder::after { top: 62px; }
.chat-empty, .placeholder {
    --sparkle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z'/%3E%3Cpath d='M19 15l.8 2.2L22 18l-2.2.8L19 21l-.8-2.2L16 18l2.2-.8z'/%3E%3C/svg%3E");
}
.chat-welcome { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); margin-bottom: 6px; }
.chat-composer { flex-shrink: 0; width: 100%; max-width: 820px; margin: 0 auto; padding: 0 24px 20px; }
.composer-box {
    display: flex; flex-direction: column; gap: 8px; padding: 12px 14px;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow-md);
    transition: border-color .15s ease, box-shadow .15s ease;
}
/* The textarea has no outline of its own: the whole box shows the focus. */
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md); }
.composer-box textarea {
    border: none; resize: none; font: inherit; font-size: 15px; line-height: 1.5;
    color: var(--text); background: transparent; outline: none;
}
.composer-actions { display: flex; justify-content: flex-end; }
.send-button {
    width: 44px; height: 44px; border-radius: 12px; border: none; background: var(--accent); color: var(--on-accent);
    display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--shadow-accent);
}
.send-button:hover { background: var(--accent-hover); }
.send-button:disabled { background: var(--border-strong); color: var(--text-inverse); box-shadow: none; cursor: not-allowed; }
.composer-note {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    margin: 8px 0 0; font-size: 12px; color: var(--text-muted);
}

.chat-message { max-width: 85%; padding: 12px 16px; border-radius: 16px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message--user { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 6px; box-shadow: var(--shadow-accent); }
.chat-message--assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.chat-message.is-writing:empty::after { content: "…"; color: var(--text-muted); }
/* Answers rendered from Markdown: normal spacing instead of preserved line breaks. */
.chat-message.is-markdown { white-space: normal; }
.chat-message.is-markdown > :first-child { margin-top: 0; }
.chat-message.is-markdown > :last-child { margin-bottom: 0; }
.chat-message.is-markdown p, .chat-message.is-markdown ul, .chat-message.is-markdown ol { margin: 0 0 10px; }
.chat-message.is-markdown ul, .chat-message.is-markdown ol { padding-left: 22px; }
.chat-message.is-markdown h1, .chat-message.is-markdown h2, .chat-message.is-markdown h3 { font-size: 15px; margin: 14px 0 6px; }
.chat-message.is-markdown code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.chat-message.is-markdown pre { background: var(--bg); padding: 10px 12px; border-radius: 8px; overflow-x: auto; white-space: pre; }
.chat-message.is-markdown pre code { padding: 0; background: none; }
.chat-message.is-markdown table { border-collapse: collapse; margin: 0 0 10px; }
.chat-message.is-markdown th, .chat-message.is-markdown td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.chat-message.is-error { color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg); }
.chat-messages:has(.chat-message) { justify-content: flex-start; }

/* Content pages (Mes connecteurs…) */
.page { width: 100%; max-width: 820px; padding: 24px 32px 40px; display: flex; flex-direction: column; gap: 16px; }
.page-intro, .page-note { margin: 0; color: var(--text-soft); line-height: 1.5; }
.page-note { font-size: 13px; color: var(--text-muted); }
.notice { margin: 0; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border); border-left: 4px solid var(--accent-border); background: var(--surface); }
.notice--success { border-color: var(--success-border); background: var(--success-bg); color: var(--success); }
.notice--error { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }
/*
 * Errors carry an alert icon (decorative: their words say it all), so that
 * their red never says it alone: boxed ones in their left padding, inline
 * ones before their text.
 */
:where(.notice--error, .chat-message.is-error, .editor-step-up-error, .request-error, .field-error, .catalog-error, .ecat-error p, .new-company-error p)::before {
    content: ""; display: inline-block; width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px; background: currentColor;
    -webkit-mask: var(--icon-alert) center / contain no-repeat; mask: var(--icon-alert) center / contain no-repeat;
}
.notice--error, .chat-message.is-error { position: relative; padding-left: 40px; }
.notice--error::before { position: absolute; left: 14px; top: 12px; margin: 0; }
.chat-message.is-error::before { position: absolute; left: 16px; top: 14px; margin: 0; }
/*
 * Successes carry a check (decorative too), which the brand's blue never
 * wears: a success then never reads as a mark of the brand, nor the brand as
 * a success. Those of the editor space and of the audit log have it in their
 * markup (.icon--check).
 */
:where(.notice--success, .badge--ok, .request-status--ok, .chat-card--ok .chat-card-title, .catalog-request-status--published, .tool-request-step--done, .editor-rule-state--applied)::before {
    content: ""; display: inline-block; flex-shrink: 0; width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; background: var(--success);
    -webkit-mask: var(--icon-check) center / contain no-repeat; mask: var(--icon-check) center / contain no-repeat;
}
.notice--success { position: relative; padding-left: 40px; }
.notice--success::before { position: absolute; left: 15px; top: 13px; margin: 0; }
.chat-card--ok .chat-card-title::before { width: 16px; height: 16px; margin: 0; }
/*
 * Work in progress carries its clock (decorative too), in the violet of
 * --info, so that it never reads as the brand's blue, whatever one sees of the
 * two hues. « Installation en cours » and the editor's badges have it in their
 * markup; a request's step and the current step of its timeline take it here.
 */
:where(.catalog-request-status:not(.catalog-request-status--published, .catalog-request-status--refused), .tool-request-step--current)::before {
    content: ""; display: inline-block; flex-shrink: 0; width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; background: currentColor;
    -webkit-mask: var(--icon-clock) center / contain no-repeat; mask: var(--icon-clock) center / contain no-repeat;
}
.connector-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.connector-head { display: flex; align-items: center; gap: 12px; }
.connector-head h2 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; }
.connector-card h3 { margin: 0; font-size: 12px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
/* A connector's initials, as a tile in the brand colour. */
.connector-pill {
    width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text);
    box-shadow: inset 0 0 0 1px var(--accent-border); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800;
}
.connector-account { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--text-soft); }
.connector-account form { margin: 0; }
.connector-form { display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.connector-form p { margin: 0; color: var(--text-soft); line-height: 1.5; }
.connector-form .connector-address { font-size: 13px; color: var(--text-muted); overflow-wrap: anywhere; }
.connector-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.connector-form input { height: 44px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); font: inherit; font-weight: 400; background: var(--surface); color: var(--text); }
.connector-form input:focus-visible { border-color: var(--accent); }
.connector-form .button { align-self: flex-start; border: none; cursor: pointer; font: inherit; font-weight: 600; }
.button--secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); cursor: pointer; font: inherit; }
.button--secondary:hover { background: var(--accent-tint); color: var(--text); }
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 12px; font-weight: 600; color: var(--text-soft); background: var(--surface); }
.badge--ok { border-color: var(--success-border); background: var(--success-bg); color: var(--success); }
.action-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
/*
 * « Mes connecteurs »: each action by what happens when the member asks for it, said by its colour,
 * its mark (a check when permitted, a dot otherwise, hollow when not permitted), the dashed outline
 * of the forbidden ones and the legend's words.
 */
.right {
    display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border-strong);
    font-size: 12px; font-weight: 600; color: var(--text-soft); background: var(--surface);
}
.right::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; align-self: center; flex-shrink: 0; }
.right--allowed { border-color: var(--success-border); background: var(--success-bg); color: var(--success); }
.right--allowed::before { width: 10px; height: 10px; border-radius: 0; -webkit-mask: var(--icon-check) center / contain no-repeat; mask: var(--icon-check) center / contain no-repeat; }
.right--passkey { border-color: var(--info-border); background: var(--info-bg); color: var(--info); }
.right--approval { border-color: var(--warning-border); background: var(--warning-bg); color: var(--warning); }
.right--forbidden { border-style: dashed; background: transparent; color: var(--text-muted); font-weight: 500; }
.right--forbidden::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.right-outcome { font-size: 11px; font-weight: 500; }
.action-legend { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-soft); }
.action-legend li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Placeholder pages */
.placeholder { margin: auto; padding: 48px 24px; text-align: center; color: var(--text-soft); }
.placeholder-title { font-size: 22px; font-weight: 700; color: var(--text); margin: 0 0 6px; }

/* Standalone pages (login failure) */
.standalone { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card {
    width: 100%; max-width: 420px; padding: 32px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 16px; text-align: center;
}
.card img { border-radius: 10px; box-shadow: var(--shadow-accent); }
.card h1 { font-size: 22px; margin: 16px 0 8px; }
.card p { color: var(--text-soft); line-height: 1.5; }
/* The main button of every screen, in the brand colour. */
.button {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px;
    border-radius: var(--radius); background: var(--accent); color: var(--on-accent); text-decoration: none; font-weight: 600;
    box-shadow: var(--shadow-accent);
}
.button:hover { color: var(--on-accent); background: var(--accent-hover); }
.button.button--secondary, .button.button--danger { box-shadow: none; }

/* Wide screens: the menu, the page header and the composer stay in place; only the content scrolls. */
@media (min-width: 821px) {
    .portal { height: 100vh; height: 100dvh; flex-wrap: nowrap; overflow: hidden; }
    .nav-scroll { min-height: 0; overflow-y: auto; }
    .portal-content { overflow-y: auto; }
}

/* Narrow screens: the menu sits above the page, which scrolls as a whole; the composer sticks to the bottom. */
@media (max-width: 820px) {
    .portal-nav { border-right: none; border-bottom: 1px solid var(--border); }
    .page-header { padding: 16px; }
    .chat-messages { overflow-y: visible; padding: 24px 16px; }
    .chat-composer { position: sticky; bottom: 0; padding: 12px 16px 16px; background: var(--bg); }
}

/* Validations (screens 2h, 3a, 3b, 3d) */
.page--wide { max-width: 880px; }
.counter {
    margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
    background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tab {
    min-height: 44px; padding: 0 16px; display: flex; align-items: center; gap: 8px; font-size: 14px;
    text-decoration: none; color: var(--text-muted); border-bottom: 3px solid transparent;
}
.tab:hover { color: var(--text); border-bottom-color: var(--accent-border); }
.tab[aria-current="page"] { color: var(--accent-text); font-weight: 700; border-bottom-color: var(--accent); }
.tab .counter { margin-left: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    min-height: 44px; padding: 0 16px; border-radius: 999px; display: flex; align-items: center;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); text-decoration: none; font-size: 14px;
}
.chip:hover { background: var(--accent-tint); border-color: var(--accent); color: var(--text); }
.chip[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; box-shadow: var(--shadow-accent); }
.request-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.request-card--active { border: 2px solid var(--accent); }
.request-card:target { box-shadow: 0 0 0 3px var(--accent-border); }
.request-head { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; background: var(--subtle); }
.request-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.request-title h2 { margin: 0; font-size: 17px; font-weight: 700; }
.request-number { font-weight: 500; color: var(--text-muted); font-size: 14px; }
.request-meta { margin: 0; font-size: 14px; color: var(--text-soft); }
.request-body { padding: 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.request-why { margin: 0; padding: 12px 14px; border: 1px dashed var(--border-strong); border-radius: 10px; font-size: 14px; line-height: 1.5; background: var(--accent-tint); }
.request-details h3 { margin: 0 0 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.request-rows { margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.request-rows div { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.request-rows dt { color: var(--text-muted); }
.request-rows dd { margin: 0; }
.request-lines { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.request-lines th, .request-lines td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--border); }
.request-lines th:first-child, .request-lines td:first-child { text-align: left; }
.request-lines thead th { font-weight: 600; color: var(--text-muted); font-size: 13px; }
.request-lines tfoot th, .request-lines tfoot td { font-weight: 700; border-bottom: none; }
.request-note, .request-progress { margin: 0; font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.request-decision { margin: 0; padding: 10px 14px; border-left: 3px solid var(--accent-border); background: var(--subtle); border-radius: 0 8px 8px 0; font-size: 14px; }
.request-decision p { margin: 0; }
.request-decision-who { color: var(--text-muted); font-size: 13px; margin-bottom: 4px !important; }
.request-decision--refused { border-left-color: var(--danger-border); }
.request-decision--approved, .request-decision--confirmed { border-left-color: var(--success-border); }
.request-status { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
/* Waiting for a decision: the amber of « Avec validation » (Mes connecteurs), dashed; never the brand's blue, which says no state. */
.request-status--wait { border: 1px dashed var(--warning-border); background: var(--warning-bg); color: var(--warning); }
.request-status--ok { border: 1px solid var(--success-border); background: var(--success-bg); color: var(--success); }
.request-status--no { border: 1px solid var(--danger-border); background: var(--danger-bg); color: var(--danger); }
.request-decide { display: flex; flex-direction: column; gap: 8px; }
.request-decide label { font-size: 14px; font-weight: 600; }
.request-decide .hint { font-weight: 400; color: var(--text-muted); }
.request-decide textarea { border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px 14px; font: inherit; font-size: 14px; resize: vertical; background: var(--surface); color: var(--text); }
.request-decide textarea:focus-visible { border-color: var(--accent); }
.request-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.request-actions .button, .request-cancel .button { border: none; cursor: pointer; font: inherit; font-weight: 600; }
.request-actions .button--secondary, .request-cancel .button--secondary { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.request-actions .button--secondary:hover, .request-cancel .button--secondary:hover { background: var(--accent-tint); color: var(--text); }
.button--key { gap: 8px; }
.button--key:disabled { opacity: .6; cursor: progress; }
.request-error { margin: 0; color: var(--danger); font-size: 14px; }
.request-cancel { margin: 0; display: flex; justify-content: flex-end; }

/* Conversations (2a to 2c, 2g) */
/* A long title in "Récentes" is cut, never widens the menu. */
.portal-nav { min-width: 0; }
.nav-recent-item {
    display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border-radius: var(--radius);
    font-size: 14px; color: var(--text-soft); text-decoration: none;
}
.nav-recent-item:hover { background: var(--accent-tint); color: var(--text); }
.nav-recent-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-recent-item.is-unseen { font-weight: 600; color: var(--text); }
.nav-recent-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* A request waiting for a decision: the clock in the amber of waiting, never the brand's blue. */
.nav-recent-mark { display: flex; color: var(--warning); }
.nav-recent-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; box-shadow: 0 0 0 3px var(--accent-soft); }
.nav-recent-archives { padding: 8px 12px 0; font-size: 13px; color: var(--text-muted); }
.conversation-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 32px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.conversation-tabs { border-bottom: none; }
.conversation-menu { position: relative; align-self: center; font-size: 14px; }
.conversation-menu summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; padding: 0 8px; color: var(--text-muted); list-style: none; }
.conversation-menu summary::-webkit-details-marker { display: none; }
.conversation-menu-panel {
    position: absolute; right: 0; top: 100%; z-index: 10; min-width: 260px; padding: 14px; display: flex; flex-direction: column; gap: 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.conversation-menu-panel form { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.conversation-menu-panel label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.conversation-menu-panel input { height: 40px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); font: inherit; background: var(--surface); color: var(--text); }
.conversation-menu-panel .button { border: 1px solid var(--border-strong); cursor: pointer; font: inherit; font-weight: 600; }
.conversation-menu-panel .button--secondary { background: var(--surface); color: var(--text); }
/* A destructive action: outlined in the red of --danger, with its icon; never filled like a main button. */
.button--danger { gap: 8px; background: var(--surface); color: var(--danger); border: 1px solid var(--danger-border) !important; }
.button--danger:hover { background: var(--danger-bg); color: var(--danger); }
.chat-card {
    align-self: stretch; max-width: 85%; padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.5;
    display: flex; flex-direction: column; gap: 6px; background: var(--surface);
}
.chat-card p { margin: 0; }
.chat-card--wait { border: 1px dashed var(--warning-border); }
.chat-card--wait .chat-card-title { color: var(--warning); }
.chat-card--ok { border: 1px solid var(--success-border); border-left: 4px solid var(--success); }
.chat-card--no { border: 1px solid var(--danger-border); border-left: 4px solid var(--danger); }
.chat-card-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.chat-card--ok .chat-card-title { color: var(--success); }
.chat-card--no .chat-card-title { color: var(--danger); }
.chat-card-who { color: var(--text-muted); font-size: 13px; }
.chat-card-comment { margin: 0; padding-left: 10px; border-left: 3px solid var(--accent-border); }
.chat-card-link { font-weight: 600; color: var(--accent-text); }
.chat-card:target { box-shadow: 0 0 0 3px var(--accent-border); }
.archive-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 820px) {
    .conversation-bar { padding: 0 16px; }
}

/* Live notices (live_controller.js) */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
    position: relative; padding: 12px 40px 12px 16px; border-radius: 12px; background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-left: 4px solid var(--accent); box-shadow: var(--shadow-lg); font-size: 14px; line-height: 1.5;
}
.toast p { margin: 0 0 4px; }
.toast a { font-weight: 600; color: var(--accent-text); }
.toast-close { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border: none; background: transparent; color: var(--text-muted); font-size: 20px; cursor: pointer; border-radius: var(--radius); }
.toast-close:hover { background: var(--accent-tint); color: var(--text); }
