/*
 * Nexus design system
 * A bespoke, dependency-free UI kit inspired by Notion, Linear, GitHub & Vercel.
 * Theming is driven by CSS custom properties toggled via [data-theme] on <html>.
 */

/* Figtree — the same humanist, compact sans Monday.com uses in its data grids.
 * Self-hosted (the egress proxy blocks font CDNs at runtime), variable weight
 * so a single tiny file covers 400–800. font-display: swap avoids invisible text. */
@font-face {
    font-family: 'Figtree';
    font-style: normal;
    font-weight: 300 800;
    font-display: swap;
    src: url("../fonts/figtree/figtree-latin-0e3f5cb09cbf6b5ffe352e08693565ff.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: 'Figtree';
    font-style: normal;
    font-weight: 300 800;
    font-display: swap;
    src: url("../fonts/figtree/figtree-latin-ext-89912320ab285381b98463c44622c1c2.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;
}

/* The [hidden] attribute must always win, even over components that set their own
 * display (buttons, flex menus…). Prevents popovers/toggles leaking on load. */
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ *
 * Design tokens
 * ------------------------------------------------------------------ */
:root {
    color-scheme: light;

    --font-sans: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;

    /* Motion — strong custom curves (the built-in CSS easings lack punch).
       Never use ease-in for UI: it delays the first frame, the moment the user
       is watching most closely, and feels sluggish. */
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
    --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-full: 999px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

    --sidebar-width: 264px;
    --topbar-height: 60px;

    /* Light palette */
    --canvas: #f7f8fa;
    --surface: #ffffff;
    --surface-2: #f4f5f7;
    --surface-hover: #f0f1f4;
    --border: rgba(15, 23, 42, 0.09);
    --border-strong: rgba(15, 23, 42, 0.16);
    --text: #15181f;
    --text-muted: #626b7a;
    --text-faint: #8b94a3;

    --primary: #5b5ef0;
    --primary-hover: #4b4ee0;
    --primary-soft: rgba(91, 94, 240, 0.12);
    --primary-contrast: #ffffff;

    --focus-ring: rgba(91, 94, 240, 0.35);

    /* Semantic accent tokens: soft background + readable foreground */
    --blue-bg: #e7edff;   --blue-fg: #2c53c4;
    --green-bg: #dcf5e7;  --green-fg: #1a7a45;
    --amber-bg: #fdefd0;  --amber-fg: #9a6410;
    --red-bg: #fde3e1;    --red-fg: #c23934;
    --violet-bg: #efe6fd; --violet-fg: #7a3fce;
    --slate-bg: #eceef1;  --slate-fg: #55606f;
    --pink-bg: #fce4f1;   --pink-fg: #c63d86;
    --orange-bg: #ffe8d6; --orange-fg: #c1591a;
    --brown-bg: #ece2da;  --brown-fg: #7a5230;
    --olive-bg: #eef0d6;  --olive-fg: #7a7320;
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --canvas: #0b0c0e;
    --surface: #151619;
    --surface-2: #1c1e22;
    --surface-hover: #212327;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #ecedef;
    --text-muted: #9ba1ac;
    --text-faint: #6b7280;

    --primary: #7c7ef7;
    --primary-hover: #8f91ff;
    --primary-soft: rgba(124, 126, 247, 0.16);
    --primary-contrast: #ffffff;

    --focus-ring: rgba(124, 126, 247, 0.45);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);

    --blue-bg: #1b2c52;   --blue-fg: #9db8ff;
    --green-bg: #163a2a;  --green-fg: #6ee2a4;
    --amber-bg: #3d2f12;  --amber-fg: #f0c069;
    --red-bg: #401f1f;    --red-fg: #f79b95;
    --violet-bg: #2c1f47; --violet-fg: #c4a3f5;
    --slate-bg: #24272d;  --slate-fg: #a7b0bd;
    --pink-bg: #3d1f30;   --pink-fg: #f5a3d0;
    --orange-bg: #3d2613; --orange-fg: #f5b482;
    --brown-bg: #2e241c;  --brown-fg: #d0a888;
    --olive-bg: #2c2d16;  --olive-fg: #d2d072;
}

/* ------------------------------------------------------------------ *
 * Base
 * ------------------------------------------------------------------ */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--canvas);
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; line-height: 1.25; }

::selection { background: var(--primary-soft); }

:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 1px;
    border-radius: var(--radius-sm);
}

/* Thin, unobtrusive scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }

/* Interaction ergonomics: no 300ms tap delay, no grey tap flash, and number
   columns stay aligned with tabular figures. */
button, a, input, select, textarea, [role="button"], .cell-pill { -webkit-tap-highlight-color: transparent; }
.btn, .icon-btn, .nav-item, .cell-pill, .seg-item, a[href], button, [role="button"] { touch-action: manipulation; }

h1, h2, h3, .page-title { text-wrap: balance; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono, .stat-value, .timer-display { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------------ *
 * App shell
 * ------------------------------------------------------------------ */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 14px 12px;
    gap: 4px;
    z-index: 40;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 14px;
}
.brand-mark {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--primary), #9b6bff);
    color: #fff;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--text-faint); margin-top: -2px; }

.nav-group-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-faint);
    font-weight: 600;
    padding: 14px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 11px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-weight: 500;
    transition: background .14s var(--ease-out), color .14s var(--ease-out);
    position: relative;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item:active { transform: scale(0.98); }
.nav-item .icon { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item .badge-count {
    margin-left: auto;
    font-size: 11px;
    background: var(--surface-2);
    color: var(--text-muted);
    padding: 1px 7px;
    border-radius: var(--radius-full);
    font-weight: 600;
}
.nav-item.active .badge-count { background: var(--primary); color: #fff; }

.sidebar-footer { position: relative; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    transition: background .12s ease;
    cursor: pointer;
    width: 100%;
    border: none;
    background: none;
    font-family: inherit;
    color: inherit;
    text-align: left;
}
.user-chip:hover { background: var(--surface-hover); }
.user-chip .meta { min-width: 0; flex: 1; }
.user-chip .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .role { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 24px;
    background: color-mix(in srgb, var(--canvas) 82%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 30;
}
.topbar h1 { font-size: 16px; }
.topbar-spacer { flex: 1; }

.page { padding: 24px; width: 100%; margin: 0; }
.page-header { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header .titles { flex: 1; min-width: 200px; }
.page-title { font-size: 22px; }
.page-subtitle { color: var(--text-muted); margin-top: 3px; }

/* Mobile menu button hidden on desktop */
.icon-btn.menu-toggle { display: none; }

/* ------------------------------------------------------------------ *
 * Search
 * ------------------------------------------------------------------ */
.search {
    position: relative;
    width: min(420px, 42vw);
}
.search input[type="search"] {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 38px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13.5px;
    transition: border-color .12s, box-shadow .12s;
}
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search .search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.search kbd {
    position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
    font-family: var(--font-mono); font-size: 11px; color: var(--text-faint);
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px;
}

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    overscroll-behavior: contain;
    max-height: 60vh;
    overflow: auto;
    z-index: 50;
}
.search-results:empty { display: none; }
.search-result {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 10px; border-radius: var(--radius); cursor: pointer;
    color: var(--text);
}
.search-result:hover, .search-result.active { background: var(--surface-hover); }
.search-result .icon { color: var(--text-muted); }
.search-result .r-title { font-weight: 550; }
.search-result .r-meta { font-size: 12px; color: var(--text-faint); margin-left: auto; }
.search-section-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 600; padding: 8px 10px 4px; }
.search-empty { padding: 18px; text-align: center; color: var(--text-faint); }

/* ------------------------------------------------------------------ *
 * Buttons
 * ------------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 15px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .14s var(--ease-out), border-color .14s var(--ease-out), box-shadow .14s var(--ease-out), transform .14s var(--ease-out);
}
.btn:hover { background: var(--surface-hover); }
/* Instant, tactile press feedback — the UI confirms it heard the click. */
.btn:active { transform: scale(0.97); }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); border-color: transparent; color: var(--primary-contrast); box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--red-bg); border-color: transparent; color: var(--red-fg); }
.btn-danger:hover { filter: brightness(0.97); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn.borderless { border-color: transparent; background: transparent; }

/* ------------------------------------------------------------------ *
 * Cards
 * ------------------------------------------------------------------ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.card-pad { padding: 18px; }
.card-header {
    display: flex; align-items: center; gap: 12px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 14.5px; }
.card-header .icon { color: var(--text-muted); }
.card-header .header-action { margin-left: auto; }
.card-body { padding: 18px; }
.card-hoverable { transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out), transform .18s var(--ease-out); display: block; }
.card-hoverable:active { transform: scale(0.995); }
@media (hover: hover) and (pointer: fine) {
    .card-hoverable:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }
}

.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* Utilisation meter (subnet capacity, quotas…) */
.meter { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 999px; background: var(--primary); transition: width .2s ease; }
.meter-fill.is-high { background: var(--amber-fg); }
.meter-fill.is-full { background: var(--red-fg); }

/* Report bars & charts */
.track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.track-fill { height: 100%; border-radius: 999px; transition: width .2s; }
.bar-row { margin-bottom: 12px; }
.bar-row:last-child { margin-bottom: 0; }
.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-muted); }
.chart-legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: middle; }
.linechart { width: 100%; height: auto; overflow: visible; }
.linechart text { fill: var(--text-muted); font-size: 10px; }

/* Editable ticket table (Monday-style inline cells) */
.data-board td { vertical-align: middle; }
.cell-edit { position: relative; display: inline-block; }
.cell-pill { cursor: pointer; border: none; font: inherit; }
.cell-pill:hover { filter: brightness(0.97); box-shadow: 0 0 0 2px var(--border-strong); }
.cell-menu { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-sm); padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 160px; transform-origin: top left; transition: opacity .14s var(--ease-out), transform .14s var(--ease-out); }
@starting-style { .cell-menu { opacity: 0; transform: scale(0.95); } }
.cell-menu[hidden] { display: none; }
.cell-menu .badge { cursor: pointer; border: none; text-align: left; width: 100%; font: inherit; transition: filter .12s var(--ease-out); }
.cell-menu .badge:hover { filter: brightness(0.97); }
.cell-menu .badge:active { transform: scale(0.98); }

/* Inline collaborator picker (ticket table) */
.assignee-cell { position: relative; }
.assignee-pill {
    display: inline-flex; align-items: center; gap: 7px;
    max-width: 100%; padding: 2px 8px 2px 2px;
    border: 1px solid transparent; border-radius: 999px;
    background: none; font: inherit; color: var(--text); cursor: pointer;
    transition: background .12s var(--ease-out), border-color .12s var(--ease-out);
}
.assignee-pill:hover { background: var(--surface-hover); border-color: var(--border); }
.assignee-name { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.assignee-empty { font-size: 12.5px; padding-left: 6px; }
.assignee-avatars { display: inline-flex; }
.assignee-avatars .avatar { margin-left: -7px; border: 1.5px solid var(--surface); }
.assignee-avatars .avatar:first-child { margin-left: 0; }
.assignee-pop { min-width: 220px; max-height: 300px; overflow-y: auto; padding: 8px; }
.assignee-opt-check {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 6px; border-radius: var(--radius);
    font-size: 13px; color: var(--text); cursor: pointer;
}
.assignee-opt-check:hover { background: var(--surface-hover); }
.cell-pill:active { transform: scale(0.97); }
.timer-cell { display: inline-flex; align-items: center; gap: 7px; }
.timer-cell .timer-display { color: var(--text-muted); }
.timer-cell.is-running .timer-display { color: var(--green-fg); font-weight: 600; }
.timer-btn { color: var(--text-muted); width: 26px; height: 26px; }
.timer-cell.is-running .timer-btn { color: var(--red-fg); }

/* Kanban board (projects) */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.kanban-col-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px; }
.kanban-cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; border-radius: var(--radius); transition: background .12s, outline .12s; padding: 2px; }
.kanban-cards.is-over { background: color-mix(in srgb, var(--primary) 10%, transparent); outline: 2px dashed var(--primary); outline-offset: -2px; }
.kanban-empty { text-align: center; font-size: 12px; padding: 14px 0; opacity: .6; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 11px; box-shadow: var(--shadow-xs); cursor: grab; display: flex; flex-direction: column; gap: 8px; transition: border-color .15s var(--ease-out), box-shadow .15s var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .kanban-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); } }
.kanban-card.is-dragging { opacity: .5; cursor: grabbing; box-shadow: var(--shadow-md); }
.kanban-card-title { font-size: 13.5px; font-weight: 550; color: var(--text); line-height: 1.35; text-decoration: none; }
.kanban-card-title:hover { color: var(--primary); }
.kanban-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kanban-card-spacer { flex: 1; }
.kanban-add { display: flex; align-items: center; gap: 6px; justify-content: center; padding: 8px; font-size: 12.5px; color: var(--text-muted); border-radius: var(--radius); border: 1px dashed var(--border); text-decoration: none; }
.kanban-add:hover { color: var(--primary); border-color: var(--primary); }

/* Segmented control (view toggles) */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg-item { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--text-muted); text-decoration: none; }
.seg-item.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* Signature generator preview — always on a white "email" canvas */
.signature-preview { background: #ffffff; color: #1a1a1a; border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; overflow-x: auto; }
.signature-preview a { color: inherit; }
.swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,.12); display: inline-block; flex-shrink: 0; }

/* Runbook checklist (procedures) */
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.checklist-step { display: flex; gap: 12px; padding: 10px 8px; border-radius: var(--radius); align-items: flex-start; transition: background .12s; }
.checklist-step:hover { background: var(--surface-2); }
.checklist-check { position: relative; flex-shrink: 0; cursor: pointer; display: inline-grid; place-items: center; }
.checklist-check input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.checklist-num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 650; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); transition: background .16s var(--ease-out), border-color .16s var(--ease-out), color .16s var(--ease-out); }
.checklist-check:active .checklist-num { transform: scale(0.92); }
.checklist-check input:checked + .checklist-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.checklist-check input:focus-visible + .checklist-num { outline: 2px solid var(--primary); outline-offset: 2px; }
.checklist-body { padding-top: 2px; min-width: 0; }
.checklist-body > :first-child { margin-top: 0; }
.checklist-body > :last-child { margin-bottom: 0; }
.checklist-step.is-done .checklist-body { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }

/* Stat widget */
.stat {
    display: flex; flex-direction: column; gap: 10px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out), transform .18s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
    .stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
}
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 550; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat-trend { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.trend-up { color: var(--green-fg); }
.trend-flat { color: var(--text-faint); }
/* Clickable stat tiles jump straight to their filtered list — no menu-diving. */
.stat-link { text-decoration: none; color: inherit; cursor: pointer; }
.stat-go { color: var(--text-faint); opacity: 0; transform: translateX(-4px); transition: opacity .18s var(--ease-out), transform .18s var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
    .stat-link:hover .stat-go { opacity: 1; transform: translateX(0); }
}
@media (hover: none) { .stat-go { opacity: .5; transform: none; } }

/* ------------------------------------------------------------------ *
 * Badges, avatars, pills
 * ------------------------------------------------------------------ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-blue { background: var(--blue-bg); color: var(--blue-fg); }
.badge-green { background: var(--green-bg); color: var(--green-fg); }
.badge-amber { background: var(--amber-bg); color: var(--amber-fg); }
.badge-red { background: var(--red-bg); color: var(--red-fg); }
.badge-violet { background: var(--violet-bg); color: var(--violet-fg); }
.badge-slate { background: var(--slate-bg); color: var(--slate-fg); }
.badge-pink { background: var(--pink-bg); color: var(--pink-fg); }
.badge-orange { background: var(--orange-bg); color: var(--orange-fg); }
.badge-brown { background: var(--brown-bg); color: var(--brown-fg); }
.badge-olive { background: var(--olive-bg); color: var(--olive-fg); }

.avatar {
    display: inline-grid; place-items: center;
    width: 34px; height: 34px;
    border-radius: 50%;
    font-size: 12.5px; font-weight: 650;
    color: #fff;
    flex-shrink: 0;
    user-select: none;
}
.avatar-sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-xs { width: 21px; height: 21px; font-size: 9px; border: 1.5px solid var(--surface); }
.avatar-lg { width: 46px; height: 46px; font-size: 16px; }
.avatar-a { background: linear-gradient(135deg,#6366f1,#8b5cf6); }
.avatar-b { background: linear-gradient(135deg,#0ea5e9,#2563eb); }
.avatar-c { background: linear-gradient(135deg,#10b981,#059669); }
.avatar-d { background: linear-gradient(135deg,#f59e0b,#f97316); }
.avatar-e { background: linear-gradient(135deg,#ec4899,#db2777); }
.avatar-f { background: linear-gradient(135deg,#64748b,#475569); }

/* ------------------------------------------------------------------ *
 * Tables
 * ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; line-height: 1.4; }
table.data th {
    text-align: left; font-weight: 600; color: var(--text-muted);
    padding: 11px 16px; border-bottom: 1px solid var(--border);
    background: var(--surface-2); white-space: nowrap; font-size: 12.5px;
}
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .1s; }
/* Sortable column headers */
table.data th:has(.th-sort) { padding: 0; }
.th-sort {
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
    padding: 11px 16px; color: inherit; text-decoration: none; white-space: nowrap;
    cursor: pointer; user-select: none;
}
.th-sort:hover { color: var(--text); background: var(--surface-hover); }
.th-sort.active { color: var(--text); }
.th-sort-end { display: inline-flex; align-items: center; gap: 5px; }
.th-arrow { font-size: 11px; opacity: .3; transition: opacity .12s var(--ease-out); }
.th-sort:hover .th-arrow { opacity: .7; }
.th-sort.active .th-arrow { opacity: 1; color: var(--primary); }
/* Rank badge shown on each column when sorting by several at once. */
.th-rank {
    display: inline-grid; place-items: center;
    min-width: 15px; height: 15px; padding: 0 3px;
    border-radius: 999px; background: var(--primary); color: #fff;
    font-size: 9.5px; font-weight: 700; line-height: 1;
}
[data-density="compact"] .th-sort { padding: 6px 11px; }

/* Live-update flash — a discreet "Mis à jour" pill after a background refresh. */
.live-flash {
    position: absolute; top: -6px; right: 0; z-index: 5;
    background: var(--green-bg); color: var(--green-fg);
    font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
    box-shadow: var(--shadow-sm); pointer-events: none;
    opacity: 0; transform: translateY(-4px);
}
.live-flash.is-on { animation: live-flash 2.4s var(--ease-out) forwards; }
@keyframes live-flash {
    0% { opacity: 0; transform: translateY(-4px); }
    12% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) { .live-flash.is-on { animation: none; opacity: 1; } }
table.data tbody tr:hover { background: var(--surface-hover); }
table.data a.row-link { font-weight: 600; color: var(--text); }
table.data a.row-link:hover { color: var(--primary); }

.cell-user { display: flex; align-items: center; gap: 9px; }

/* ------------------------------------------------------------------ *
 * Forms
 * ------------------------------------------------------------------ */
.form-row { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
label.field-label, form label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.checkbox-row label { margin-bottom: 0; }
.field-help { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number],
input[type=search], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b94a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px;
}
.form-errors, .form-errors ul { color: var(--red-fg); font-size: 12.5px; margin: 5px 0 0; padding-left: 16px; list-style: disc; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--primary); }

/* Filter bar */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .grow { flex: 1 1 220px; min-width: 180px; }
.toolbar select, .toolbar input { height: 38px; }
/* Filters sit inline and wrap, rather than each taking a full-width row. */
.toolbar select { width: auto; min-width: 150px; flex: 0 1 auto; }
@media (max-width: 640px) { .toolbar select { flex: 1 1 45%; min-width: 130px; } }

/* Permission editor */
.perm-group { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 14px; }
.perm-group h4 { font-size: 13px; margin-bottom: 10px; }
.perm-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 16px; }

/* ------------------------------------------------------------------ *
 * Dropdown menu
 * ------------------------------------------------------------------ */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 6px);
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 60;
    /* Scale in from the trigger corner — never from nothing (scale(0)). */
    transform-origin: top right;
    opacity: 1; transform: scale(1);
    transition: opacity .15s var(--ease-out), transform .15s var(--ease-out);
}
@starting-style { .dropdown-menu { opacity: 0; transform: scale(0.95); } }
.dropdown-menu.up { top: auto; bottom: calc(100% + 6px); transform-origin: bottom right; }
.dropdown-menu.left { right: auto; left: 0; transform-origin: top left; }
.dropdown-menu.up.left { transform-origin: bottom left; }
.dropdown-menu[hidden] { display: none; }
.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius);
    font-size: 13.5px; color: var(--text); cursor: pointer; width: 100%;
    background: none; border: none; font-family: inherit; text-align: left;
}
.dropdown-item:hover { background: var(--surface-hover); }
.dropdown-item .icon { color: var(--text-muted); width: 17px; height: 17px; }
.dropdown-item.danger { color: var(--red-fg); }
.dropdown-item.danger .icon { color: var(--red-fg); }
.dropdown-sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* Right-click context menu (ticket rows) — floats at the cursor. */
.ctx-menu {
    position: fixed; z-index: 200;
    min-width: 210px; max-width: 260px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    transform-origin: top left;
    transition: opacity .12s var(--ease-out), transform .12s var(--ease-out);
}
@starting-style { .ctx-menu { opacity: 0; transform: scale(0.96); } }
.ctx-item {
    display: block; width: 100%; text-align: left;
    padding: 7px 10px; border-radius: var(--radius);
    font: inherit; font-size: 13px; color: var(--text);
    background: none; border: none; cursor: pointer;
}
.ctx-item:hover { background: var(--surface-hover); }
.ctx-item.danger { color: var(--red-fg); }
.ctx-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.ctx-group { padding: 4px 6px 2px; }
.ctx-group-title { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 5px; }
.ctx-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.ctx-pills .badge { cursor: pointer; border: none; font: inherit; font-size: 11.5px; transition: filter .12s var(--ease-out); }
.ctx-pills .badge:hover { filter: brightness(0.97); }
.ctx-pills .badge:active { transform: scale(0.98); }

/* Sous-éléments (subtasks) */
.subtask-progress { margin-bottom: 10px; }
.subtasks { display: flex; flex-direction: column; }
.subtask {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 4px; border-radius: var(--radius);
    font-size: 13px; line-height: 1.3;
}
.subtask:hover { background: var(--surface-hover); }
.subtask-check {
    flex-shrink: 0; width: 18px; height: 18px;
    display: inline-grid; place-items: center;
    border: 1.6px solid var(--border-strong, var(--border)); border-radius: 6px;
    background: none; color: #fff; cursor: pointer; padding: 0;
    transition: background .12s var(--ease-out), border-color .12s var(--ease-out);
}
button.subtask-check:hover { border-color: var(--primary); }
.subtask.is-done .subtask-check { background: var(--green-fg, #22c55e); border-color: var(--green-fg, #22c55e); }
.subtask-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subtask.is-done .subtask-title { text-decoration: line-through; color: var(--text-muted); }
.subtask-due { font-size: 11px; white-space: nowrap; display: inline-flex; align-items: center; gap: 2px; }
.subtask-due.is-overdue { color: var(--red-fg); font-weight: 600; }
.subtask-people { display: inline-flex; }
.subtask-people .avatar { margin-left: -5px; }
.subtask-people .avatar:first-child { margin-left: 0; }
.subtask-tools { display: inline-flex; gap: 1px; opacity: 0; transition: opacity .12s var(--ease-out); }
.subtask:hover .subtask-tools { opacity: 1; }
.subtask-tools .icon-btn { padding: 3px; }
.subtask-add { display: flex; gap: 6px; margin-top: 8px; }
.subtask-add input { flex: 1; }
.subtask-pop { padding: 8px; min-width: 200px; max-height: 280px; overflow: auto; }
.subtask-people-opt { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: var(--radius); font-size: 13px; cursor: pointer; }
.subtask-people-opt:hover { background: var(--surface-hover); }
.subtask-due-actions { display: flex; gap: 6px; margin-top: 8px; }
.subtask-time { font-size: 11px; white-space: nowrap; display: inline-flex; align-items: center; gap: 2px; }
.subtask-time-by { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.subtask-time-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; }
.subtask-time-quick { display: flex; gap: 5px; margin-bottom: 6px; }
.subtask-time-quick .btn { flex: 1; }
.subtask-time-custom { display: flex; gap: 6px; }
.subtask-time-custom input { width: 70px; }

/* Per-person time ledger */
.time-by { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.time-by-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.time-by-who { display: inline-flex; align-items: center; gap: 8px; }
.time-entries { margin: 4px 0 10px; }
.time-entries > summary { cursor: pointer; font-size: 12px; color: var(--text-muted); user-select: none; }
.time-entries > summary:hover { color: var(--text); }
.time-entries-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.time-entry { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 8px; font-size: 12.5px; padding: 3px 0; }
.time-entry-day { color: var(--text-muted); font-size: 11.5px; }
.time-entry-note { grid-column: 2 / -1; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time-entry-del { padding: 2px; }
.time-log-form { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.time-log-fields { display: flex; gap: 12px; flex-wrap: wrap; }
.time-log-field { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--text-muted); }
.time-log-hm { display: flex; gap: 5px; }
.time-log-hm input { width: 58px; }
.time-log-note { width: 100%; margin-top: 8px; }
.dropdown-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); padding: 7px 10px 4px; font-weight: 600; }

/* ------------------------------------------------------------------ *
 * Flash messages
 * ------------------------------------------------------------------ */
.flashes { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.flash {
    display: flex; align-items: flex-start; gap: 11px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 12px 14px;
    animation: flash-in .28s var(--ease-out);
}
.flash.success { border-left-color: var(--green-fg); }
.flash.error { border-left-color: var(--red-fg); }
.flash.warning { border-left-color: var(--amber-fg); }
.flash .icon { flex-shrink: 0; margin-top: 1px; }
.flash.success .icon { color: var(--green-fg); }
.flash.error .icon { color: var(--red-fg); }
.flash .msg { flex: 1; font-size: 13.5px; }
.flash .close { cursor: pointer; color: var(--text-faint); background: none; border: none; }
@keyframes flash-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ *
 * Timeline (ticket / equipment history)
 * ------------------------------------------------------------------ */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 12px; }
.timeline-rail { display: flex; flex-direction: column; align-items: center; }
.timeline-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-muted); flex-shrink: 0; }
.timeline-line { width: 2px; flex: 1; background: var(--border); margin: 3px 0; min-height: 8px; }
.timeline-content { padding-bottom: 16px; flex: 1; padding-top: 4px; }
.timeline-item:last-child .timeline-content { padding-bottom: 0; }
.timeline-content .t-summary { font-size: 13.5px; }
.timeline-content .t-meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

/* Comments */
.comment { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment-body { flex: 1; }
.comment-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.comment-head .author { font-weight: 650; }
.comment-head .when { font-size: 12px; color: var(--text-faint); }
.comment-text { white-space: pre-wrap; word-break: break-word; }

/* Misc */
.stack { display: flex; flex-direction: column; }
.stack-gap > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.prose { white-space: pre-wrap; word-break: break-word; line-height: 1.65; }

.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state .icon { color: var(--text-faint); margin-bottom: 12px; }
.empty-state h3 { margin-bottom: 6px; }

.def-list { display: grid; grid-template-columns: 130px 1fr; gap: 12px 16px; font-size: 13.5px; align-items: center; }
.def-list dt { color: var(--text-muted); }
.def-list dd { margin: 0; font-weight: 550; }

/* ------------------------------------------------------------------ *\
   Compact density — the working default for this business tool. Trims
   padding across every data-dense surface so operators read more rows
   per screen without scrolling. "Comfortable" is the opt-in alternative,
   toggled from the top bar (persisted in localStorage as nexus-density).
   Airy surfaces meant to breathe (empty states) are left generous.
\* ------------------------------------------------------------------ */
.density-toggle span { font-size: 18px; line-height: 1; font-weight: 600; color: var(--text-muted); }

[data-density="compact"] .page { padding: 16px 20px; }
[data-density="compact"] .page-header { margin-bottom: 14px; gap: 12px; }
[data-density="compact"] .page-title { font-size: 19px; }

[data-density="compact"] .card-header { padding: 10px 14px; }
[data-density="compact"] .card-body { padding: 13px 14px; }
[data-density="compact"] .card-pad { padding: 13px; }

[data-density="compact"] table.data { font-size: 13px; }
[data-density="compact"] table.data th { padding: 6px 11px; }
[data-density="compact"] table.data td { padding: 5px 11px; }

[data-density="compact"] .toolbar { margin-bottom: 12px; gap: 8px; }
[data-density="compact"] .toolbar select,
[data-density="compact"] .toolbar input { height: 34px; }

[data-density="compact"] .grid { gap: 12px; }
[data-density="compact"] .stat { padding: 13px 14px; gap: 7px; }
[data-density="compact"] .stat-icon { width: 32px; height: 32px; border-radius: 9px; }
[data-density="compact"] .stat-value { font-size: 23px; }
[data-density="compact"] .def-list { gap: 7px 14px; }
[data-density="compact"] .empty-state { padding: 40px 20px; }

/* Vertical rhythm everywhere else — stacks, forms, comments, prose, lists,
   nav — so no surface keeps loose "marketing" spacing. */
[data-density="compact"] .stack-gap > * + * { margin-top: 10px; }
[data-density="compact"] .form-row { margin-bottom: 11px; }
[data-density="compact"] .form-grid { gap: 11px 14px; }
[data-density="compact"] .form-actions { margin-top: 14px; }
[data-density="compact"] label.field-label, [data-density="compact"] form label { margin-bottom: 4px; }
[data-density="compact"] textarea { min-height: 72px; line-height: 1.45; }
[data-density="compact"] .divider { margin: 11px 0; }
[data-density="compact"] .prose { line-height: 1.5; }
[data-density="compact"] .comment { padding: 9px 0; }
[data-density="compact"] .perm-group { padding: 11px 13px; margin-bottom: 10px; }
[data-density="compact"] .nav-item { padding-top: 7px; padding-bottom: 7px; }
[data-density="compact"] .page-subtitle { margin-top: 1px; }
[data-density="compact"] .warn-banner { padding: 10px 13px; margin-bottom: 12px; }
[data-density="compact"] .doc-breadcrumb { margin-bottom: 9px; }
[data-density="compact"] .card + .card, [data-density="compact"] .card[style*="margin-bottom"] { margin-bottom: 12px !important; }

.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }

/* ------------------------------------------------------------------ *\
   Peek drawer — a right-hand panel that previews a record without
   leaving the list. Rows carry data-peek-url; the panel is filled over
   AJAX by peek_controller.js. Full record stays one explicit click away.
\* ------------------------------------------------------------------ */
.peek { position: fixed; inset: 0; z-index: 60; }
.peek-scrim {
    position: absolute; inset: 0; background: rgba(15, 17, 21, 0.42);
    opacity: 0; transition: opacity .22s var(--ease-out);
}
.peek-panel {
    position: absolute; top: 0; right: 0; height: 100%;
    width: min(460px, 92vw);
    background: var(--surface); border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg, -18px 0 48px rgba(0,0,0,.22));
    display: flex; flex-direction: column;
    transform: translateX(100%); transition: transform .26s var(--ease-out);
    outline: none;
}
.peek.is-open .peek-scrim { opacity: 1; }
.peek.is-open .peek-panel { transform: translateX(0); }
.peek-head {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 16px; border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}
.peek-head strong { flex: 1; font-size: 14.5px; }
.peek-body { padding: 16px; overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; }
.peek-loading { color: var(--text-muted); padding: 24px 4px; text-align: center; }
.peek-row { cursor: pointer; }
@media (hover: hover) and (pointer: fine) {
    .peek-row:hover td { background: var(--surface-2); }
}
.peek-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.peek-hero { margin-bottom: 14px; }
.peek-name { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; margin-top: 2px; }
.peek-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.peek-section-title { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 9px; }
.peek-section-title .icon { color: var(--text-faint); }
.peek-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-top: 16px; }
.peek-field { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.peek-field-label { font-size: 11.5px; font-weight: 600; color: var(--text-muted); }
.peek-thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.peek-comment-form textarea { width: 100%; min-height: 58px; resize: vertical; }
.peek-actions .timer-wrap { margin-left: auto; display: inline-flex; align-items: center; }
@media (prefers-reduced-motion: reduce) {
    .peek-scrim, .peek-panel { transition: none; }
}

/* Universal centred modal (e.g. Nouveau ticket) */
.modal { position: fixed; inset: 0; z-index: 80; }
.modal-scrim { position: absolute; inset: 0; background: rgba(15, 17, 21, 0.5); opacity: 0; transition: opacity .18s var(--ease-out); }
.modal-card {
    position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -48%) scale(0.98);
    width: min(720px, 94vw); max-height: 90vh;
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg, 0 24px 64px rgba(0,0,0,.28));
    opacity: 0; transition: opacity .18s var(--ease-out), transform .18s var(--ease-out);
    outline: none;
}
.modal.is-open .modal-scrim { opacity: 1; }
.modal.is-open .modal-card { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.modal-head strong { flex: 1; font-size: 15px; }
.modal-body { padding: 18px; overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; }
.modal-loading { color: var(--text-muted); padding: 28px 4px; text-align: center; }
/* Module form partials wrap themselves in a card; inside the modal the card
   chrome is redundant, so strip it and let the modal be the container. */
.modal-body .card,
.modal-body .card-body { border: none; box-shadow: none; background: none; padding: 0; max-width: none !important; }

/* GED (document library) */
.ged-crumb { display: flex; align-items: center; gap: 7px; font-size: 13.5px; flex-wrap: wrap; }
.ged-crumb a { display: inline-flex; align-items: center; gap: 5px; color: var(--text-muted); }
.ged-crumb a:hover { color: var(--text); }
.ged-folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 18px; }
.ged-folder {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg);
    background: var(--surface); color: var(--text);
    transition: border-color .12s var(--ease-out), background .12s var(--ease-out);
}
.ged-folder:hover { border-color: var(--primary); background: var(--surface-hover); }
.ged-folder .icon { color: var(--amber-fg, #f59e0b); flex-shrink: 0; }
.ged-folder-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ged-ext {
    display: inline-grid; place-items: center; flex-shrink: 0;
    min-width: 34px; height: 26px; padding: 0 6px;
    border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border);
    font-size: 9.5px; font-weight: 700; letter-spacing: .03em; color: var(--text-muted);
}
.ged-versions { display: flex; flex-direction: column; gap: 8px; }
.ged-version { display: flex; align-items: center; gap: 10px; }
.ged-version-no { flex-shrink: 0; font-size: 11px; color: var(--text-muted); min-width: 30px; }
.ged-version-body { flex: 1; min-width: 0; }
.ged-version-body .row-link { font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
    .modal-scrim, .modal-card { transition: none; }
}

/* ------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------ */
@media (max-width: 960px) {
    .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: var(--shadow-lg);
    }
    .app-shell.nav-open .sidebar { transform: none; }
    .icon-btn.menu-toggle { display: inline-grid; }
    .search { width: 100%; }
    .nav-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 39; }
    .nav-scrim[hidden] { display: none; }
}
@media (max-width: 560px) {
    .page { padding: 16px; }
    .topbar { padding: 0 14px; }
    .search kbd { display: none; }
    .def-list { grid-template-columns: 110px 1fr; }
}

/* ================================================================== *
 * Documentation / Wiki (Notion-inspired)
 * ================================================================== */
.wiki { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 22px; align-items: start; }

.wiki-tree {
    position: sticky; top: calc(var(--topbar-height) + 24px);
    align-self: start;
    max-height: calc(100vh - var(--topbar-height) - 48px);
    overflow-y: auto;
    padding-right: 4px;
}
.wiki-tree .tree-section-label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
    color: var(--text-faint); font-weight: 600; padding: 12px 8px 6px;
    display: flex; align-items: center; justify-content: space-between;
}
.wiki-tree .tree-section-label a { color: var(--text-faint); display: inline-flex; }
.wiki-tree .tree-section-label a:hover { color: var(--primary); }

.tree-item {
    display: flex; align-items: center; gap: 7px;
    padding: 6px 8px; border-radius: 8px;
    color: var(--text-muted); font-size: 13.5px; font-weight: 500;
    line-height: 1.3;
}
.tree-item:hover { background: var(--surface-hover); color: var(--text); }
.tree-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tree-item .t-emoji { width: 18px; text-align: center; flex-shrink: 0; }
.tree-item .t-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

details.tree-node > summary { list-style: none; cursor: pointer; }
details.tree-node > summary::-webkit-details-marker { display: none; }
.tree-node .tree-caret { transition: transform .15s ease; color: var(--text-faint); display: inline-flex; flex-shrink: 0; }
details.tree-node[open] > summary .tree-caret { transform: rotate(90deg); }
.tree-children { margin-left: 14px; border-left: 1px solid var(--border); padding-left: 4px; }
.tree-leaf-spacer { width: 16px; flex-shrink: 0; }

/* Document view ---------------------------------------------------- */
.doc-header { margin-bottom: 8px; }
.doc-breadcrumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--text-faint); margin-bottom: 14px; }
.doc-breadcrumb a { color: var(--text-muted); }
.doc-breadcrumb a:hover { color: var(--primary); }
.doc-title-row { display: flex; align-items: flex-start; gap: 14px; }
.doc-emoji { font-size: 42px; line-height: 1; }
.doc-title { font-size: 32px; font-weight: 720; letter-spacing: -0.02em; }
.doc-meta { color: var(--text-faint); font-size: 12.5px; margin-top: 8px; }

/* Rendered markdown ------------------------------------------------ */
.markdown { font-size: 15px; line-height: 1.7; color: var(--text); }
.markdown > *:first-child { margin-top: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 1.6em 0 .5em; line-height: 1.3; letter-spacing: -0.01em; }
.markdown h1 { font-size: 1.7em; padding-bottom: .25em; border-bottom: 1px solid var(--border); }
.markdown h2 { font-size: 1.4em; padding-bottom: .2em; border-bottom: 1px solid var(--border); }
.markdown h3 { font-size: 1.2em; }
.markdown h4 { font-size: 1.05em; }
.markdown p { margin: .7em 0; }
.markdown a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.markdown ul, .markdown ol { margin: .6em 0; padding-left: 1.5em; }
.markdown li { margin: .25em 0; }
.markdown li input[type=checkbox] { margin-right: 6px; accent-color: var(--primary); }
.markdown blockquote { margin: 1em 0; padding: .4em 1em; border-left: 3px solid var(--primary); background: var(--surface-2); border-radius: 0 8px 8px 0; color: var(--text-muted); }
.markdown code { font-family: var(--font-mono); font-size: .88em; background: var(--surface-2); padding: .15em .4em; border-radius: 5px; border: 1px solid var(--border); }
.markdown pre { margin: 1em 0; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.markdown pre code { background: none; border: none; padding: 0; font-size: .86em; line-height: 1.6; }
.markdown img { max-width: 100%; border-radius: var(--radius); margin: .6em 0; }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }
.markdown table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: .95em; display: block; overflow-x: auto; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.markdown th { background: var(--surface-2); font-weight: 600; }
.markdown tr:nth-child(even) td { background: var(--surface-2); }

/* Inter-document links (the headline feature) */
.doc-link {
    display: inline; text-decoration: none;
    color: var(--primary); font-weight: 550;
    background: var(--primary-soft);
    padding: .05em .4em; border-radius: 6px;
    box-decoration-break: clone; -webkit-box-decoration-break: clone;
    transition: background .12s, color .12s;
}
.doc-link::before { content: "🔗"; font-size: .8em; margin-right: 3px; opacity: .7; }
.doc-link:hover { background: var(--primary); color: #fff; }
.doc-link.missing { color: var(--red-fg); background: var(--red-bg); border-bottom: 1px dashed currentColor; }
.doc-link.missing::before { content: "＋"; }

/* Related / backlinks panel */
.doc-relations { margin-top: 28px; }
.relation-card {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 14px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); margin-bottom: 8px;
    transition: border-color .12s, box-shadow .12s, transform .12s;
}
.relation-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateX(2px); }
.relation-card .r-emoji { font-size: 20px; flex-shrink: 0; }
.relation-card .r-title { font-weight: 600; }
.relation-card .r-sub { font-size: 12px; color: var(--text-faint); }

/* Editor ----------------------------------------------------------- */
.doc-editor-shell { }
.doc-editor-toolbar {
    display: flex; align-items: center; gap: 3px; flex-wrap: wrap;
    padding: 6px; margin-bottom: 10px;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
    position: sticky; top: calc(var(--topbar-height)); z-index: 5;
}
.doc-editor-toolbar .tb-btn {
    display: inline-grid; place-items: center;
    min-width: 32px; height: 32px; padding: 0 8px;
    border: none; background: none; border-radius: 7px;
    color: var(--text-muted); cursor: pointer; font-family: inherit; font-size: 13.5px; font-weight: 600;
}
.doc-editor-toolbar .tb-btn:hover { background: var(--surface-hover); color: var(--text); }
.doc-editor-toolbar .tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.doc-editor-toolbar .tb-btn.mono { font-family: var(--font-mono); }
.doc-editor-toolbar .tb-spacer { flex: 1; }
.doc-editor-toolbar .tb-toggle { font-size: 12.5px; }
.doc-editor-toolbar .tb-toggle.on { background: var(--primary-soft); color: var(--primary); }

.doc-editor-panes { display: grid; grid-template-columns: 1fr; gap: 14px; }
.doc-editor-panes.split { grid-template-columns: 1fr 1fr; }
.doc-editor-input {
    width: 100%; min-height: 460px; resize: vertical;
    font-family: var(--font-mono); font-size: 13.5px; line-height: 1.7;
    tab-size: 2;
}
.doc-preview {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 20px; background: var(--surface); overflow-y: auto;
    min-height: 460px;
}
.doc-preview-empty { color: var(--text-faint); }
.doc-editor-panes:not(.split) .doc-preview { display: none; }

.icon-input { width: 70px; text-align: center; font-size: 22px; }

/* [[ autocomplete popup */
.doc-autocomplete {
    position: absolute; z-index: 70;
    min-width: 260px; max-height: 280px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 6px;
}
.doc-autocomplete[hidden] { display: none; }
.doc-ac-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.doc-ac-item:hover, .doc-ac-item.active { background: var(--surface-hover); }
.doc-ac-item .ac-emoji { width: 18px; text-align: center; }
.doc-ac-empty { padding: 10px; color: var(--text-faint); font-size: 13px; }

/* WYSIWYG live editor (Notion / Word style) ------------------------ */
.wysiwyg-toolbar {
    position: sticky; top: var(--topbar-height); z-index: 20;
    display: flex; align-items: center; gap: 3px; flex-wrap: wrap;
    padding: 6px; margin: 6px 0 4px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); box-shadow: var(--shadow-sm);
}
.wysiwyg-toolbar[hidden] { display: none; }
.wysiwyg-toolbar .tb-btn {
    display: inline-grid; place-items: center;
    min-width: 32px; height: 32px; padding: 0 8px;
    border: none; background: none; border-radius: 7px;
    color: var(--text-muted); cursor: pointer; font-family: inherit; font-size: 13.5px; font-weight: 600;
}
.wysiwyg-toolbar .tb-btn:hover { background: var(--surface-hover); color: var(--text); }
.wysiwyg-toolbar .tb-btn.mono { font-family: var(--font-mono); }
.wysiwyg-toolbar .tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

.wysiwyg-linkbox {
    position: absolute; z-index: 70; margin-top: 6px;
    width: 300px; padding: 8px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.wysiwyg-linkbox[hidden] { display: none; }
.wysiwyg-linkbox .input { width: 100%; margin-bottom: 6px; }
.wysiwyg-linkbox .doc-autocomplete { position: static; box-shadow: none; border: none; padding: 0; min-width: 0; }

/* The article doubles as the editing surface. */
.doc-editable.editing {
    outline: none;
    border-radius: var(--radius);
    box-shadow: 0 0 0 2px var(--primary-soft);
    padding: 14px 16px; margin: 0 -16px;
    min-height: 320px;
    transition: box-shadow .15s ease;
}
.doc-editable.editing:focus { box-shadow: 0 0 0 2px var(--primary); }
.doc-editable.editing:empty::before,
.doc-editable.editing p:only-child:empty::before {
    content: 'Écrivez ici… utilisez la barre d\'outils pour la mise en forme.';
    color: var(--text-faint);
}
.wysiwyg-editing .doc-title[contenteditable="true"] {
    outline: none; border-radius: 6px;
    box-shadow: 0 0 0 2px var(--primary-soft); padding: 2px 6px; margin: -2px -6px;
}
.doc-save-status { margin-left: 10px; font-size: 12px; color: var(--text-faint); }
.doc-save-status.is-error { color: var(--danger); }

@media (max-width: 900px) {
    .wiki { grid-template-columns: 1fr; }
    .wiki-tree { position: static; max-height: none; border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 6px; }
    .doc-editor-panes.split { grid-template-columns: 1fr; }
    .wysiwyg-linkbox { width: calc(100vw - 60px); }
}

/* ================================================================== *
 * Coffre-fort (password vault)
 * ================================================================== */
.vault { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 22px; align-items: start; }
.vault-folders { position: sticky; top: calc(var(--topbar-height) + 24px); align-self: start; }
.vault-folders .tree-section-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); font-weight: 600; padding: 8px 8px 6px; display:flex; align-items:center; justify-content:space-between; }
.folder-item {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px; border-radius: 8px; color: var(--text-muted);
    font-size: 13.5px; font-weight: 500;
}
.folder-item:hover { background: var(--surface-hover); color: var(--text); }
.folder-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.folder-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.folder-item .f-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item .f-lock { color: var(--amber-fg); display: inline-flex; }
.folder-item .f-count { font-size: 11px; color: var(--text-faint); }

/* Secret value display */
.secret-value-box {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 10px 12px;
}
.secret-value {
    font-family: var(--font-mono); font-size: 14px; flex: 1;
    letter-spacing: .06em; color: var(--text-faint); word-break: break-all; white-space: pre-wrap;
}
.secret-value.revealed { letter-spacing: normal; color: var(--text); }

/* Password generator */
.pw-generator { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-top: 8px; background: var(--surface); }
.pw-generator .row { flex-wrap: wrap; gap: 14px; }
.pw-generator input[type=range] { accent-color: var(--primary); }
.pw-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }

.warn-banner {
    display: flex; align-items: flex-start; gap: 11px;
    background: var(--amber-bg); color: var(--amber-fg);
    border-radius: var(--radius); padding: 11px 14px; font-size: 13px; margin-bottom: 18px;
}
.warn-banner .icon { flex-shrink: 0; }

@media (max-width: 900px) {
    .vault { grid-template-columns: 1fr; }
    .vault-folders { position: static; }
}

/* 2FA (TOTP) widget */
.totp-panel {
    display: flex; align-items: center; gap: 12px;
    margin-top: 10px; padding: 10px 14px;
    background: var(--violet-bg); border-radius: var(--radius);
}
.totp-code {
    font-family: var(--font-mono); font-size: 24px; font-weight: 700;
    letter-spacing: 3px; color: var(--violet-fg); flex: 1;
}
.totp-countdown {
    font-size: 12px; font-weight: 700; color: var(--violet-fg);
    min-width: 34px; text-align: center;
    padding: 3px 8px; border-radius: 999px;
    background: color-mix(in srgb, var(--violet-fg) 18%, transparent);
}

/* ------------------------------------------------------------------ *
 * Reduced motion — motion sickness is real. Keep opacity/colour cues,
 * strip movement (transforms) and looping animations.
 * ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .card-hoverable:hover, .stat:hover, .btn:active, .cell-pill:active,
    .nav-item:active, .kanban-card:hover { transform: none !important; }
}
