/* ==========================================================================
   WeMaDesk — Design System (Cabinet WeMa IT Service Desk)
   100% autonome (zéro CDN), compatible CSP stricte default-src 'self'
   ========================================================================== */

:root {
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-soft: rgba(29, 78, 216, 0.08);
    --sidebar-bg: #0f1b2d;
    --sidebar-border: rgba(255, 255, 255, 0.08);
    --sidebar-text: #cbd5e1;
    --sidebar-text-active: #ffffff;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-subtle: #f8fafc;
    --border: #e4e7ec;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --warning: #b45309;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --success: #15803d;
    --success-bg: #f0fdf4;
    --success-border: #bbf7d0;
    --info: #1d4ed8;
    --info-bg: #eff6ff;
    --info-border: #bfdbfe;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code, .mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

code {
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 5px;
    font-size: 12.5px;
}

/* --------------------------------------------------------------------------
   Authenticated Application Shell
   -------------------------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 256px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--sidebar-border);
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    transition: transform 0.2s ease;
}

.sidebar-brand {
    padding: 20px 20px 18px;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.02em;
    flex-shrink: 0;
    overflow: hidden;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #ffffff;
    padding: 3px;
}

.brand-info {
    min-width: 0;
}

.brand-title {
    color: #ffffff;
    font-weight: 650;
    font-size: 15px;
    letter-spacing: -0.01em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-sub {
    color: #94a3b8;
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    padding: 12px 10px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 13.5px;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    text-decoration: none;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.12);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

.nav-item svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-cta {
    margin: 4px 0 10px;
    background: var(--primary);
    color: #ffffff;
    justify-content: center;
    font-weight: 600;
}

.nav-cta:hover {
    background: var(--primary-hover);
    color: #ffffff;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.user-mini {
    min-width: 0;
}

.user-mini-name {
    color: #f8fafc;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-mini-role {
    color: #94a3b8;
    font-size: 11.5px;
}

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

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 6px 8px;
    cursor: pointer;
    color: var(--text);
}

.page-heading {
    margin: 0;
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -0.015em;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.security-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 999px;
}

.page-content {
    padding: 24px 28px 40px;
    max-width: 1340px;
    width: 100%;
    margin: 0 auto;
}

/* --------------------------------------------------------------------------
   Public / Auth / Installer Shell
   -------------------------------------------------------------------------- */
.public-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f6 100%);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 32px;
}

.install-card {
    width: 100%;
    max-width: 820px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.install-header {
    background: var(--sidebar-bg);
    color: #ffffff;
    padding: 24px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.install-header h1 {
    margin: 0 0 4px;
    font-size: 20px;
    letter-spacing: -0.015em;
}

.install-header p {
    margin: 0;
    color: #94a3b8;
    font-size: 13px;
}

.install-body {
    padding: 28px 32px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.auth-brand h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.auth-brand p {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Cards, Panels, KPI Strip
   -------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    margin-bottom: 20px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 650;
    color: var(--text);
}

.card-subtitle {
    margin: 2px 0 0;
    font-size: 12.5px;
    color: var(--text-muted);
}

.card-body {
    padding: 20px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow-xs);
}

.kpi-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.kpi-value {
    margin-top: 6px;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.kpi-value.danger {
    color: var(--danger);
}

.kpi-value.success {
    color: var(--success);
}

/* --------------------------------------------------------------------------
   Forms & Controls
   -------------------------------------------------------------------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group.full {
    grid-column: 1 / -1;
}

label.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.input, select.input, textarea.input {
    width: 100%;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea.input {
    min-height: 110px;
    resize: vertical;
}

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.checkbox-title {
    font-weight: 600;
    font-size: 13.5px;
    display: block;
}

.checkbox-desc {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #ffffff;
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    background: var(--surface-subtle);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-ghost {
    background: transparent;
    color: var(--sidebar-text);
    padding: 6px 10px;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.btn-sm {
    padding: 6px 11px;
    font-size: 12.5px;
}

.btn-block {
    width: 100%;
}

.btn-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Badges & Alerts
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.badge-open { background: #eff6ff; color: #1d4ed8; }
.badge-in_progress { background: #fef3c7; color: #b45309; }
.badge-waiting_user { background: #f3e8ff; color: #7e22ce; }
.badge-resolved { background: #dcfce7; color: #15803d; }
.badge-closed { background: #f1f5f9; color: #475569; }

.badge-critical { background: #fee2e2; color: #b91c1c; }
.badge-high { background: #ffedd5; color: #c2410c; }
.badge-normal { background: #e0f2fe; color: #0369a1; }
.badge-low { background: #f1f5f9; color: #475569; }

.badge-ok, .badge-met { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-warn, .badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-fail, .badge-breached { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-paused { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-info { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-border); }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    margin-bottom: 16px;
    font-size: 13.5px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.alert-error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.alert-info { background: var(--info-bg); border-color: var(--info-border); color: var(--info); }

/* --------------------------------------------------------------------------
   Tables & Filters
   -------------------------------------------------------------------------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-subtle);
}

.filter-bar .input {
    width: auto;
    min-width: 150px;
    padding: 7px 10px;
    font-size: 13px;
}

.filter-bar .search-input {
    flex: 1;
    min-width: 210px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

table.data-table th {
    text-align: left;
    padding: 11px 16px;
    font-size: 11.5px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.data-table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data-table tbody tr:hover {
    background: #f8fafc;
}

table.data-table tbody tr:last-child td {
    border-bottom: none;
}

.ticket-link {
    font-weight: 600;
    color: var(--text);
    display: block;
}

.ticket-link:hover {
    color: var(--primary);
}

.ticket-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Ticket Detail Layout & Thread
   -------------------------------------------------------------------------- */
.ticket-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 20px;
    align-items: start;
}

.message-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
}

.message-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.message-item.internal {
    background: #fffbeb;
    border-color: #fde68a;
}

.message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 12.5px;
    color: var(--text-muted);
}

.message-author {
    font-weight: 650;
    color: var(--text);
}

.message-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--text);
    font-weight: 500;
}

.attachment-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
}

.meta-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 13px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.meta-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.meta-key {
    color: var(--text-muted);
}

.meta-val {
    font-weight: 600;
    text-align: right;
}

/* --------------------------------------------------------------------------
   Admin Tabs & Health Check List
   -------------------------------------------------------------------------- */
.tabs {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 1px;
}

.tab-link {
    padding: 10px 16px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.tab-link:hover {
    color: var(--text);
    text-decoration: none;
}

.tab-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.check-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.check-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-subtle);
}

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 12px;
}

.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.mfa-secret-box {
    background: var(--surface-subtle);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-family: var(--font-mono);
    font-size: 14px;
    letter-spacing: 0.08em;
    text-align: center;
    word-break: break-all;
    margin: 12px 0;
}

.empty-state {
    text-align: center;
    padding: 44px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    margin: 0 0 6px;
    font-size: 15px;
    color: var(--text);
}

.hidden {
    display: none !important;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 35;
}

/* --------------------------------------------------------------------------
   Ticket Timestamped History Timeline
   -------------------------------------------------------------------------- */
.timeline {
    position: relative;
    padding-left: 22px;
    margin: 0;
    list-style: none;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding: 0 0 14px 10px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -19px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--primary);
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px var(--border-strong);
}

.timeline-dot.status_changed { background: #15803d; }
.timeline-dot.assigned { background: #0284c7; }
.timeline-dot.priority_changed { background: #d97706; }
.timeline-dot.internal_note { background: #b45309; }
.timeline-dot.attachment_added { background: #475569; }
.timeline-dot.created { background: var(--primary); }

.timeline-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.timeline-summary {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.timeline-time {
    font-size: 11.5px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.timeline-sub {
    margin-top: 3px;
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.timeline-pill {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 5px;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text);
}

.impersonate-banner {
    background: #fef3c7;
    border-bottom: 1px solid #f59e0b;
    color: #78350f;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 13px;
}

.sidebar-version {
    padding: 8px 16px 12px;
    font-size: 11px;
    color: #64748b;
    border-top: 1px solid var(--sidebar-border);
    letter-spacing: 0.01em;
}

/* --------------------------------------------------------------------------
   Bandeau d'information global (Panne / Incident majeur)
   -------------------------------------------------------------------------- */
.global-banner {
    padding: 11px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 13.5px;
    line-height: 1.45;
    border-bottom: 1px solid transparent;
}

.global-banner-card {
    width: 100%;
    max-width: 440px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    margin-bottom: 16px;
    padding: 12px 16px;
}

.global-banner.severity-info {
    background: var(--info-bg);
    border-color: var(--info-border);
    color: #1e3a8a;
}

.global-banner.severity-warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: #78350f;
}

.global-banner.severity-critical {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: #991b1b;
}

.global-banner-exp {
    font-size: 11.5px;
    opacity: 0.85;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Escalades Sous-traitants & Cartographie Expertises IA
   -------------------------------------------------------------------------- */
.timeline-dot.vendor_escalation { background: #7c3aed; }
.timeline-dot.vendor_reply { background: #0d9488; }

.vendor-esc-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.vendor-esc-item {
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.expertise-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.expertise-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    background: #ffffff;
}

.expertise-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

@media (max-width: 900px) {
    .expertise-grid {
        grid-template-columns: 1fr;
    }
}

/* --------------------------------------------------------------------------
   Statistiques Admin
   -------------------------------------------------------------------------- */
.stats-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.stats-range-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.stats-kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stats-kpi-sub {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.stats-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 12px;
    color: var(--text-secondary);
}

.stats-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.stats-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}

.stats-chart-wrap {
    width: 100%;
    overflow-x: auto;
}

.stats-svg {
    width: 100%;
    height: auto;
    min-width: 480px;
    display: block;
}

.stats-bar-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-bar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.stats-bar-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: var(--bg);
    overflow: hidden;
    border: 1px solid var(--border);
}

.stats-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
    min-width: 0;
}

@media (max-width: 1120px) {
    .stats-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* --------------------------------------------------------------------------
   Copilote IA Agent IT (Gemini)
   -------------------------------------------------------------------------- */
.ai-copilot-card {
    border-color: var(--info-border);
    box-shadow: var(--shadow-sm);
}

.ai-copilot-card .card-header {
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.ai-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-spark-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--primary);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.ai-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.ai-reformulate-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.ai-tone-select {
    width: auto;
    min-width: 155px;
    padding: 6px 10px;
    font-size: 12.5px;
    height: auto;
}

.ai-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--info-bg);
    border: 1px solid var(--info-border);
    color: var(--info);
    font-size: 13px;
    font-weight: 500;
}

.ai-spinner {
    width: 15px;
    height: 15px;
    border: 2px solid rgba(29, 78, 216, 0.25);
    border-top-color: var(--primary);
    border-radius: 999px;
    animation: ai-spin 0.75s linear infinite;
    flex-shrink: 0;
}

@keyframes ai-spin {
    to { transform: rotate(360deg); }
}

.ai-result-panel {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-subtle);
}

.ai-meta-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding-bottom: 10px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.ai-meta-tags {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ai-meta-item {
    font-size: 12px;
    color: var(--text-muted);
}

.ai-close-btn {
    color: var(--text-muted);
}

.ai-section {
    margin-bottom: 12px;
}

.ai-section:last-child {
    margin-bottom: 0;
}

.ai-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.ai-paragraph {
    margin: 0;
    font-size: 13.5px;
    color: var(--text);
    white-space: pre-line;
}

.ai-text-muted {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

.ai-list {
    margin: 0;
    padding-left: 18px;
    font-size: 13.5px;
    color: var(--text);
}

.ai-list li {
    margin-bottom: 4px;
}

.ai-draft-section {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-strong);
}

.ai-draft-preview {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-improvements {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.ai-result-actions {
    margin-top: 10px;
}

.ai-guarantees {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

/* --------------------------------------------------------------------------
   Base de Connaissances (KB & RAG)
   -------------------------------------------------------------------------- */
.kb-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kb-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    background: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.kb-item:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.kb-item-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.kb-item-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.kb-item-title:hover {
    color: var(--primary);
    text-decoration: underline;
}

.kb-item-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

.kb-item-excerpt {
    margin: 10px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.kb-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.kb-section {
    margin-bottom: 18px;
}

.kb-section-title {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.kb-suggestion-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kb-suggestion-item {
    display: block;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 11px;
    background: var(--surface-subtle);
    text-decoration: none;
    transition: border-color 0.15s ease;
}

.kb-suggestion-item:hover {
    border-color: var(--primary);
    background: var(--surface);
}

/* --------------------------------------------------------------------------
   Explorateur OpenAPI / Swagger local (Admin)
   -------------------------------------------------------------------------- */
.swagger-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.swagger-endpoint {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    overflow: hidden;
}

.swagger-endpoint > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    cursor: pointer;
    list-style: none;
    background: var(--surface-subtle);
    flex-wrap: wrap;
}

.swagger-endpoint > summary::-webkit-details-marker {
    display: none;
}

.swagger-endpoint[open] > summary {
    border-bottom: 1px solid var(--border);
}

.http-method {
    display: inline-block;
    min-width: 58px;
    text-align: center;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: 6px;
    color: #fff;
}

.http-method.GET { background: #1d4ed8; }
.http-method.POST { background: #15803d; }
.http-method.PATCH { background: #b45309; }
.http-method.DELETE { background: #b91c1c; }

.swagger-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.swagger-code {
    margin: 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 12px;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* --------------------------------------------------------------------------
   Responsive Breakpoints
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .ticket-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-backdrop.open {
        display: block;
    }
    .menu-toggle {
        display: inline-flex;
        align-items: center;
    }
    .topbar {
        padding: 0 16px;
    }
    .page-content {
        padding: 18px 16px 32px;
    }
    .form-grid, .form-grid-3 {
        grid-template-columns: 1fr;
    }
    .security-pill {
        display: none;
    }
}
