:root {
    /* Couleurs principales - Thème violet/bleu */
    --bg-body: #0a0e17;
    --bg-sidebar: #0d1219;
    --bg-card: #131a24;
    --bg-card-hover: #1a2332;
    --bg-input: #0d1219;
    --bg-hover: rgba(255, 255, 255, 0.05);
    --border: #1e2a3a;
    --border-light: #2a3a4a;
    --text: #e8eaed;
    --text-dim: #9aa0a6;
    --text-muted: #5f6368;

    /* Accent gradient */
    --accent: #667eea;
    --accent-hover: #5a6fd6;
    --purple: #764ba2;
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-soft: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.1) 100%);

    /* Status */
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;

    /* UI */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 4px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 10px 40px rgba(102, 126, 234, 0.3);
    --transition: all 0.2s ease;
    --sidebar-width: 260px;
}

[data-theme="light"] {
    --bg-body: #f0f2f5;
    --bg-sidebar: #fff;
    --bg-card: #fff;
    --bg-card-hover: #f9fafb;
    --bg-input: #f3f4f6;
    --bg-hover: rgba(0, 0, 0, 0.05);
    --border: #e5e7eb;
    --border-light: #d1d5db;
    --text: #111827;
    --text-dim: #4b5563;
    --text-muted: #9ca3af;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}

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

html {
    font-size: 14px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

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

a:hover {
    text-decoration: underline;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    text-decoration: none !important;
    color: var(--text) !important;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: var(--gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: var(--shadow-glow);
    flex-shrink: 0;
    padding: 0 !important;
}

.logo-icon i {
    font-size: 1.25rem;
    line-height: 1;
    width: auto;
    height: auto;
    text-align: center;
}

.logo-icon svg {
    width: 22px;
    height: 22px;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-version {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
}

.nav-section {
    margin-bottom: 0.5rem;
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.75rem 1.25rem 0.375rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    margin: 0 0.5rem;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    text-decoration: none !important;
    transition: var(--transition);
    position: relative;
}

.nav-item i {
    width: 18px;
    text-align: center;
    font-size: 0.95rem;
}

.nav-item span {
    flex: 1;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.nav-item.active {
    background: var(--gradient-soft);
    color: var(--accent);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--gradient);
    border-radius: 0 4px 4px 0;
}

.nav-badge {
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid var(--border);
    color: #fff;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.btn-logout {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
    text-decoration: none;
}

/* Main */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin 0.3s ease;
}

.topbar {
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.btn-menu {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0 !important;
    margin: 0;
    border: none;
    background: var(--bg-hover);
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 0;
}

.btn-menu i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    line-height: 1;
    margin: 0 !important;
    padding: 0 !important;
}

.search-global {
    flex: 1;
    max-width: 480px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 1rem;
    transition: var(--transition);
}

.search-global:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.search-global i {
    color: var(--text-muted);
}

.search-global input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    padding: 0.625rem 0;
    font-size: 0.875rem;
}

.search-global input::placeholder {
    color: var(--text-muted);
}

.search-global kbd {
    font-size: 0.65rem;
    padding: 0.125rem 0.375rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-muted);
}

.topbar-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;  /* ne jamais écraser les boutons */
}

.topbar-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg-hover);
    color: var(--text-dim);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    position: relative;
}

.topbar-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}

.page-content {
    padding: 1.5rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-light);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title i {
    color: var(--accent);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none !important;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient);
    color: #fff;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

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

.btn-warning {
    background: rgba(249, 115, 22, 0.9);
    color: #fff;
}

.btn-warning:hover {
    background: rgba(249, 115, 22, 1);
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
}

.btn-group {
    display: flex;
    gap: 0.375rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-dim);
}

.form-label i {
    margin-right: 0.375rem;
    color: var(--accent);
}

.form-label.required::after {
    content: ' *';
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.875rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    cursor: pointer;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    background: var(--bg-hover);
    color: var(--text-dim);
}

.badge-primary {
    background: rgba(102, 126, 234, 0.15);
    color: var(--accent);
}

.badge-success {
    background: rgba(52, 211, 153, 0.15);
    color: var(--success);
}

.badge-warning {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warning);
}

.badge-danger {
    background: rgba(248, 113, 113, 0.15);
    color: var(--danger);
}

.badge-purple {
    background: rgba(118, 75, 162, 0.15);
    color: var(--purple);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-body);
}

.table tbody tr:hover td {
    background: var(--bg-hover);
}

.table-actions {
    white-space: nowrap;
}

/* Page layout with sidebar */
.page-with-sidebar {
    display: flex;
    gap: 1.5rem;
}

.content-sidebar {
    width: 280px;
    flex-shrink: 0;
}

.content-main {
    flex: 1;
    min-width: 0;
}

.sidebar-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: sticky;
    top: 76px;
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-body);
}

.sidebar-section-header h4 {
    font-size: 0.8125rem;
    font-weight: 600;
}

.category-nav {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.category-nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text-dim);
    text-decoration: none !important;
    transition: var(--transition);
    border-left: 3px solid transparent;
    font-size: 0.875rem;
}

.category-nav-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.category-nav-item.active {
    background: var(--gradient-soft);
    color: var(--accent);
    border-left-color: var(--accent);
}

.category-nav-item .cat-icon {
    font-size: 1rem;
}

.category-nav-item span:nth-child(2) {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-count {
    background: var(--bg-body);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    color: var(--text-muted);
    min-width: 22px;
    text-align: center;
}

.cat-actions {
    display: flex;
    gap: 0.125rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.category-nav-item:hover .cat-actions {
    opacity: 1;
}

.cat-actions button {
    width: 22px;
    height: 22px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-xs);
    font-size: 0.7rem;
}

.cat-actions button:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* Items grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.item-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    cursor: pointer;
    transition: var(--transition);
}

.item-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.item-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.item-card-title {
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.item-card-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.item-card:hover .item-card-actions {
    opacity: 1;
}

.item-card-excerpt {
    color: var(--text-dim);
    font-size: 0.875rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.item-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.item-card-meta i {
    margin-right: 0.25rem;
}

.item-card-cat {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: var(--gradient-soft);
    color: var(--accent);
    border-radius: var(--radius-xs);
    font-size: 0.75rem;
}

.item-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.75rem;
}

.tag {
    padding: 0.125rem 0.5rem;
    background: var(--bg-hover);
    border-radius: var(--radius-xs);
    font-size: 0.7rem;
    color: var(--text-dim);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.modal-backdrop.active {
    opacity: 1;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-backdrop.active .modal {
    transform: scale(1);
}

.modal-lg {
    max-width: 720px;
}

.modal-xl {
    max-width: 960px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--gradient-soft);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--bg-body);
}

/* Toast */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 300px;
    max-width: 420px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-icon {
    font-size: 1.25rem;
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-error .toast-icon {
    color: var(--danger);
}

.toast-warning .toast-icon {
    color: var(--warning);
}

.toast-info .toast-icon {
    color: var(--accent);
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.875rem;
}

.toast-message {
    font-size: 0.8125rem;
    color: var(--text-dim);
    margin-top: 0.125rem;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none !important;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--gradient-soft);
    color: var(--accent);
}

.stat-icon.green {
    background: rgba(52, 211, 153, 0.15);
    color: var(--success);
}

.stat-icon.yellow {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warning);
}

.stat-icon.red {
    background: rgba(248, 113, 113, 0.15);
    color: var(--danger);
}

.stat-icon.purple {
    background: rgba(118, 75, 162, 0.15);
    color: var(--purple);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
}

.empty-state-icon {
    font-size: 3.5rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state-text {
    color: var(--text-dim);
    margin-bottom: 1.5rem;
}

/* Progress */
.progress {
    height: 6px;
    background: var(--bg-body);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--gradient);
    border-radius: 9999px;
    transition: width 0.3s ease;
}

/* Status dot */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-dot.offline {
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

.status-dot.unknown {
    background: var(--text-muted);
}

/* Icon picker */
.icon-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: 0.75rem;
    background: var(--bg-body);
    border-radius: var(--radius-sm);
    max-height: 150px;
    overflow-y: auto;
}

.icon-opt {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.icon-opt:hover {
    background: var(--bg-hover);
}

.icon-opt.selected {
    background: var(--gradient);
}

/* Kanban */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.kanban-column {
    flex: 0 0 280px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 200px);
}

.kanban-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border-radius: var(--radius) var(--radius) 0 0;
}

.kanban-title {
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.kanban-count {
    background: var(--bg-hover);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.kanban-cards {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 100px;
}

.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.875rem;
    cursor: grab;
    transition: var(--transition);
}

.kanban-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.kanban-card:active {
    cursor: grabbing;
}

.kanban-card-title {
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.kanban-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
}

/* Notes */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.note-card {
    border-radius: var(--radius);
    padding: 1rem;
    cursor: pointer;
    transition: var(--transition);
    min-height: 150px;
    display: flex;
    flex-direction: column;
}

.note-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.note-card.pinned {
    box-shadow: 0 0 0 2px var(--accent);
}

.note-card-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.note-card-content {
    flex: 1;
    font-size: 0.8125rem;
    line-height: 1.5;
    overflow: hidden;
}

.note-card-footer {
    font-size: 0.7rem;
    margin-top: 0.5rem;
}

/* Markdown */
.markdown-content {
    line-height: 1.7;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
    margin: 1.5rem 0 0.75rem;
    font-weight: 600;
}

.markdown-content h1 {
    font-size: 1.5rem;
}

.markdown-content h2 {
    font-size: 1.25rem;
}

.markdown-content h3 {
    font-size: 1.1rem;
}

.markdown-content p {
    margin-bottom: 1rem;
}

.markdown-content code {
    background: var(--bg-body);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-xs);
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.875em;
}

.markdown-content pre {
    background: var(--bg-body);
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 1rem 0;
}

.markdown-content pre code {
    background: none;
    padding: 0;
}

.markdown-content ul,
.markdown-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.markdown-content li {
    margin-bottom: 0.25rem;
}

.markdown-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-dim);
}

.markdown-content img {
    max-width: 100%;
    border-radius: var(--radius-sm);
}

/* Search results */
.search-results {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-height: 60vh;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-results.active {
    display: block;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none !important;
    color: var(--text);
}

.search-result-item:hover {
    background: var(--gradient-soft);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-icon {
    width: 36px;
    height: 36px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.search-result-content {
    flex: 1;
}

.search-result-title {
    font-weight: 500;
}

.search-result-type {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Shortcuts modal */
.shortcuts-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.shortcuts-modal.active {
    opacity: 1;
    visibility: visible;
}

.shortcuts-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 500px;
    width: 90%;
}

.shortcuts-content h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.shortcuts-grid {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.shortcut {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.shortcut kbd {
    padding: 0.25rem 0.5rem;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 0.75rem;
    font-family: monospace;
}

.shortcut span {
    color: var(--text-dim);
    margin-left: auto;
}

/* Page title */
.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.page-title i {
    color: var(--accent);
}

/* Utilities */
.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-danger {
    color: var(--danger);
}

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

.text-dim {
    color: var(--text-dim);
}

.text-accent {
    color: var(--accent);
}

.text-center {
    text-align: center;
}

.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.font-mono {
    font-family: 'SF Mono', Monaco, monospace;
}

.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flex {
    display: flex;
}

.flex-1 {
    flex: 1;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.items-start {
    align-items: flex-start;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-1 {
    gap: 0.25rem;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 0.75rem;
}

.gap-4 {
    gap: 1rem;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 0.75rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 0.75rem;
}

.mt-4 {
    margin-top: 1rem;
}

.ml-auto {
    margin-left: auto;
}

.mr-1 {
    margin-right: 0.25rem;
}

.p-2 {
    padding: 0.5rem;
}

.p-3 {
    padding: 0.75rem;
}

.p-4 {
    padding: 1rem;
}

.grid {
    display: grid;
}

.bg-hover {
    background: var(--bg-hover);
}

/* Cat icons */
.cat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    font-size: 1rem;
}

.cat-icon img {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    object-fit: cover;
}

.category-nav-item .cat-icon img {
    width: 16px;
    height: 16px;
}

.item-card-cat img {
    width: 14px;
    height: 14px;
    vertical-align: middle;
    margin-right: 2px;
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        /* Garantit que la sidebar reste visible et accessible même si JS ne charge pas */
        will-change: transform;
        /* Empêche le scroll du body quand sidebar ouverte */
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

    /* Quand sidebar ouverte : bloquer le scroll du body */
    body.sidebar-open {
        overflow: hidden;
        touch-action: none;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .btn-menu {
        display: flex;
    }

    .page-with-sidebar {
        flex-direction: column;
    }

    .content-sidebar {
        width: 100%;
    }

    .sidebar-section {
        position: static;
    }

    .category-nav {
        max-height: 200px;
    }

    .search-global kbd {
        display: none;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 13px;
    }

    .page-content {
        padding: 1rem;
    }

    .page-title {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    /* Stack buttons */
    .flex.justify-between {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    /* Stats grid: 2 columns on tablet */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    /* Tables: horizontal scroll */
    .card.p-0 {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table th,
    .table td {
        padding: 0.625rem 0.5rem;
        font-size: 0.8rem;
    }

    /* Kanban: single column */
    .kanban-board {
        flex-direction: column;
    }

    .kanban-column {
        flex: 1 1 auto;
        max-height: none;
    }

    /* Cards */
    .card {
        padding: 1rem;
    }

    .card-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Items grid */
    .items-grid {
        grid-template-columns: 1fr;
    }

    .notes-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    /* Forms */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Topbar responsive */
    .topbar {
        padding: 0.5rem 1rem;
        gap: 0.5rem;
    }

    .search-global {
        max-width: 100%;
        min-width: 0;   /* autorise la réduction */
        flex: 1 1 80px; /* peut aller jusqu'à 80px min avant de disparaître */
    }

    /* Sur mobile, cacher les boutons non essentiels */
    #extInstallBtn,
    .topbar-btn[onclick*="showShortcuts"] {
        display: none;
    }

    /* Touch-friendly buttons */
    .btn {
        min-height: 40px;
        padding: 0.5rem 0.875rem;
    }

    .btn-sm {
        min-height: 34px;
        padding: 0.375rem 0.625rem;
    }

    .topbar-btn {
        width: 40px;
        height: 40px;
    }

    .btn-menu {
        width: 40px;
        height: 40px;
    }

    /* Modals: almost full screen */
    .modal-backdrop {
        padding: 0.5rem;
    }

    .modal {
        max-height: 95vh;
        border-radius: 12px;
    }

    .modal-lg,
    .modal-xl {
        max-width: 100%;
    }

    /* Toast: full width */
    .toast-container {
        left: 0.5rem;
        right: 0.5rem;
        top: auto;
        bottom: 1rem;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 12.5px;
    }

    .page-content {
        padding: 0.75rem;
    }

    /* Stats: 1 column */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Sidebar en tiroir : on garde un liseré du contenu visible pour qu'il
       reste evident qu'on peut refermer en touchant a cote. Plein ecran, le
       menu passait pour une page a part entiere. */
    .sidebar {
        width: min(88%, 340px);
    }

    .sidebar.open {
        box-shadow: none;
    }

    /* Table: hide less important columns on very small screens */
    .table th:nth-child(n+4),
    .table td:nth-child(n+4) {
        display: none;
    }

    /* Search */
    .search-global {
        font-size: 0.8rem;
    }

    .search-results {
        width: 95%;
        top: 60px;
    }

    /* Topbar very small: boutons compacts */
    .topbar-btn {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }

    /* Cacher aussi le bouton push sur très petit écran si nécessaire */
    .topbar { gap: 0.35rem; padding: 0.4rem 0.75rem; }
}

/* PWA safe areas (notch, home indicator) */
@supports (padding-top: env(safe-area-inset-top)) {
    .topbar {
        padding-top: env(safe-area-inset-top);
    }

    .sidebar {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .page-content {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

.modal-backdrop:not(.active),
.search-results:not(.active) {
    display: none !important;
    pointer-events: none !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-secondary) 100%);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--accent-secondary) 0%, var(--accent) 100%);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--accent) var(--bg-body);
}

/* Sidebar scrollbar */
.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(102, 126, 234, 0.5) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 2px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.8);
}

/* Mobile navigation: keep the page locked while allowing a natural one-finger
   scroll inside the menu, including behind iOS/Android dynamic browser bars. */
@media (max-width: 1024px) {
    .sidebar {
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
        overscroll-behavior: contain;
    }

    body.sidebar-open {
        overflow: hidden;
        touch-action: auto;
        overscroll-behavior: none;
    }

    .sidebar-header,
    .sidebar-footer {
        flex: 0 0 auto;
    }

    /* Application installee sur iPhone : le haut passe sous la Dynamic Island
       et le bas sous la barre d'accueil. On decale des deux cotes. */
    .sidebar-header {
        padding-top: max(1rem, env(safe-area-inset-top));
    }

    .sidebar-footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .sidebar-nav {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        overflow-x: hidden;
        overflow-y: auto;
        padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
        overscroll-behavior-y: contain;
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    .sidebar-nav .nav-item {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
}

/* Definitive single-row header: page, fluid search and actions share one axis. */
.main-content > .topbar {
    height: 64px;
    min-height: 64px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
    padding: 0 1.25rem;
}

.topbar-main-row {
    display: flex;
    align-items: center;
    gap: .9rem;
    width: 100%;
    height: 44px;
    min-height: 44px;
    line-height: 1;
}

.main-content > .topbar > .topbar-main-row > .topbar-context {
    display: flex;
    align-items: center;
    gap: .55rem;
    flex: 0 0 auto;
    min-width: 155px;
    max-width: 220px;
    height: 38px;
    padding: .3rem .65rem .3rem .35rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: color-mix(in srgb,var(--accent) 5%,var(--bg-card));
    line-height: 1;
    color: var(--text);
    font-size: .88rem;
    font-weight: 700;
    overflow: hidden;
}

.topbar-context-icon {
    display: grid;
    place-items: center;
    width: 27px;
    height: 27px;
    flex: 0 0 27px;
    border-radius: 7px;
    background: var(--gradient-soft);
    color: var(--accent-secondary);
    font-size: .76rem;
}

.topbar-context-title {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    letter-spacing: -.01em;
}

.main-content > .topbar > .topbar-main-row > .topbar-actions {
    position: static;
    display: flex;
    align-items: center;
    height: 44px;
    gap: .35rem;
    flex: none;
    margin-left: 0;
}

.main-content > .topbar > .topbar-main-row > .topbar-actions .topbar-btn {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    margin: 0;
}

.main-content > .topbar > .topbar-main-row > .topbar-actions .notif-wrapper {
    display: flex;
    align-items: center;
    height: 38px;
}

.main-content > .topbar > .topbar-main-row > .search-global,
.main-content > .topbar > .topbar-main-row > .search-global:focus-within {
    width: auto;
    max-width: none;
    min-width: 0;
    flex: 1 1 auto;
    height: 42px;
    margin: 0;
    padding: 0 1rem;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--bg-input);
    box-shadow: none;
}

.main-content > .topbar > .topbar-main-row > .search-global:hover {
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
    background: color-mix(in srgb, var(--accent) 4%, var(--bg-input));
}

.main-content > .topbar > .topbar-main-row > .search-global:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.main-content > .topbar > .topbar-main-row > .search-global input {
    font-size: .9rem;
}

.main-content > .topbar > .topbar-main-row > .search-global > i {
    color: var(--accent-secondary);
    font-size: .88rem;
}

.main-content > .topbar > .topbar-main-row > .search-global kbd {
    padding: .2rem .45rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    opacity: 1;
}

@media (max-width: 760px) {
    .main-content > .topbar {
        height: 58px;
        min-height: 58px;
        padding: 0 .75rem;
    }

    .topbar-main-row {
        height: 42px;
        min-height: 42px;
        gap: .5rem;
    }

    .main-content > .topbar > .topbar-main-row > .topbar-context {
        display: none;
    }

    .main-content > .topbar > .topbar-main-row > .search-global,
    .main-content > .topbar > .topbar-main-row > .search-global:focus-within {
        height: 40px;
    }

    .main-content > .topbar > .topbar-main-row > .search-global kbd {
        display: none;
    }
}

/* Final topbar composition: a full command bar, centered and stable. */
@media (min-width: 761px) {
    .topbar {
        min-height: 70px;
        justify-content: flex-start;
        gap: 1rem;
    }

    .topbar-context {
        display: none;
    }

    .topbar .topbar-actions {
        position: static;
        flex: none;
        margin-left: 0;
    }

    .topbar .search-global,
    .topbar .search-global:focus-within {
        width: auto;
        max-width: none;
        min-width: 0;
        flex: 1 1 auto;
        height: 48px;
        margin: 0;
        padding: 0 1rem;
        background: var(--bg-input);
        border: 1px solid var(--border-light);
        border-radius: 12px;
    }

    .topbar .search-global input {
        font-size: .93rem;
    }

    .topbar .search-global > i {
        font-size: .9rem;
        color: var(--accent-secondary);
    }

    .topbar .search-global kbd {
        padding: .2rem .45rem;
        border: 1px solid var(--border);
        background: var(--bg-card);
    }

    .topbar .search-global:hover {
        border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
        background: color-mix(in srgb, var(--accent) 4%, var(--bg-input));
    }
}

@media (min-width: 761px) and (max-width: 1250px) {
    .topbar .search-global,
    .topbar .search-global:focus-within {
        width: auto;
        min-width: 0;
        flex: 1 1 auto;
    }
}

/* Interactive links: subtle accent instead of a white highlight. */
.nav-item:hover,
.category-nav-item:hover,
.quick-link:hover,
.search-result-item:hover,
.search-result-item.active,
.stat-card:hover {
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-card));
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
    color: var(--text);
    text-decoration: none;
}

.topbar-btn:hover,
.btn-ghost:hover,
.btn-secondary:hover {
    background: color-mix(in srgb, var(--accent) 9%, var(--bg-card));
    color: var(--text);
}

/* Topbar: quieter context and compact command search. */
.topbar-context {
    display: flex;
    align-items: center;
    min-width: 0;
    color: var(--text-dim);
    font-size: .86rem;
    font-weight: 650;
}

.topbar .search-global {
    width: 320px;
    max-width: 320px;
    flex: 0 1 320px;
    margin-left: auto;
    padding: 0 .65rem;
    background: transparent;
    border-color: transparent;
    border-radius: 8px;
    transition: width .22s ease, max-width .22s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.topbar .search-global:hover {
    background: var(--bg-input);
    border-color: var(--border);
}

.topbar .search-global:focus-within {
    width: min(480px, 42vw);
    max-width: 480px;
    background: var(--bg-input);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.topbar .search-global > i {
    font-size: .78rem;
}

.topbar .search-global kbd {
    border: 0;
    background: transparent;
    opacity: .72;
}

.topbar .topbar-actions {
    margin-left: 0;
}

@media (max-width: 760px) {
    .topbar-context {
        display: none;
    }

    .topbar .search-global,
    .topbar .search-global:focus-within {
        width: auto;
        max-width: none;
        flex: 1 1 auto;
        margin-left: 0;
    }

    .topbar .search-global kbd {
        display: none;
    }
}

/* ── Interface refresh v3.16 ───────────────────────────────────── */
:root {
    --bg-body: #080d16;
    --bg-sidebar: #0a101b;
    --bg-card: #101824;
    --bg-card-hover: #172231;
    --bg-input: #0b121d;
    --bg-secondary: #0b121d;
    --border: #1d2a3a;
    --border-light: #31445b;
    --text: #edf4ff;
    --text-dim: #a8b6c8;
    --text-muted: #6f8197;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-secondary: #38bdf8;
    --primary: #3b82f6;
    --purple: #8b5cf6;
    --gradient: linear-gradient(135deg, #2563eb 0%, #38bdf8 100%);
    --gradient-soft: linear-gradient(135deg, rgba(37, 99, 235, .16) 0%, rgba(56, 189, 248, .08) 100%);
    --radius: 14px;
    --shadow: 0 14px 40px rgba(0, 0, 0, .22);
    --shadow-glow: 0 10px 32px rgba(37, 99, 235, .28);
    --sidebar-compact-width: 78px;
}

[data-theme="light"] {
    --bg-body: #f4f7fb;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f4f7fb;
    --bg-input: #f7f9fc;
    --bg-secondary: #f7f9fc;
    --border: #e3eaf2;
    --border-light: #cbd7e5;
    --text: #102033;
    --text-dim: #52657a;
    --text-muted: #8292a5;
}

body {
    background-image:
        radial-gradient(circle at 85% -10%, rgba(37, 99, 235, .1), transparent 30rem),
        linear-gradient(180deg, rgba(255, 255, 255, .012), transparent 20rem);
}

.sidebar-header { position: relative; }
.logo-icon { border-radius: 12px; }
.nav-section-title { letter-spacing: .1em; }

.nav-item {
    padding: .65rem .8rem;
    border-radius: 10px;
}

.nav-item::after {
    content: "";
    position: absolute;
    right: .65rem;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: transparent;
}

.nav-item.active::after {
    background: var(--accent-secondary);
    box-shadow: 0 0 10px var(--accent-secondary);
}

.sidebar-collapse-btn {
    position: absolute;
    right: -13px;
    top: 50%;
    z-index: 2;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border-light);
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-collapse-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.topbar {
    height: 66px;
    background: color-mix(in srgb, var(--bg-card) 82%, transparent);
    backdrop-filter: blur(18px);
}

.search-global {
    max-width: 560px;
    border-radius: 11px;
}

.page-content {
    max-width: 1680px;
    margin: 0 auto;
    padding: 1.5rem clamp(1rem, 2vw, 2rem) 2.5rem;
}

.card { border-radius: 16px; }

.search-results-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .7rem .85rem .45rem;
    color: var(--text-muted);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.search-results-head small {
    font-size: .62rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

.search-result-item.active,
.search-result-item:hover { background: var(--bg-card-hover); }

.search-result-arrow {
    color: var(--text-muted);
    font-size: .7rem;
    opacity: 0;
    transform: translateX(-4px);
    transition: var(--transition);
}

.search-result-item:hover .search-result-arrow,
.search-result-item.active .search-result-arrow {
    opacity: 1;
    transform: translateX(0);
}

.search-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .65rem;
    padding: 2rem;
    color: var(--text-muted);
}

@media (min-width: 1025px) {
    body.sidebar-compact .sidebar { width: var(--sidebar-compact-width); }
    body.sidebar-compact .main-content { margin-left: var(--sidebar-compact-width); }
    body.sidebar-compact .sidebar-header { padding: 1rem; }

    body.sidebar-compact .logo-text,
    body.sidebar-compact .nav-section-title,
    body.sidebar-compact .nav-item span,
    body.sidebar-compact .user-info,
    body.sidebar-compact .btn-logout,
    body.sidebar-compact .nav-item::after { display: none; }

    body.sidebar-compact .logo { justify-content: center; }
    body.sidebar-compact .logo-icon { width: 42px; height: 42px; }

    body.sidebar-compact .nav-item {
        justify-content: center;
        margin: .25rem .7rem;
        padding: .7rem;
    }

    body.sidebar-compact .nav-item i {
        margin: 0;
        font-size: 1rem;
    }

    body.sidebar-compact .user-card {
        justify-content: center;
        padding: .6rem 0;
    }
}

@media (max-width: 1024px) {
    .sidebar-collapse-btn { display: none; }
}

/* ── Desktop workspace refinement v3.16.1 ──────────────────────── */
:root {
    --bg-body: #0b1018;
    --bg-sidebar: #0d131d;
    --bg-card: #111923;
    --bg-card-hover: #18222f;
    --bg-input: #0c131d;
    --bg-secondary: #0c131d;
    --border: #202d3c;
    --border-light: #34465b;
    --text: #e8eef6;
    --text-dim: #a4b1c1;
    --text-muted: #718096;
    --accent: #4f8cff;
    --accent-hover: #3978ed;
    --accent-secondary: #73a7ff;
    --gradient: linear-gradient(135deg, #3978ed 0%, #62a0ff 100%);
    --gradient-soft: rgba(79, 140, 255, .09);
    --radius: 9px;
    --radius-sm: 7px;
    --shadow: 0 8px 24px rgba(0, 0, 0, .16);
    --shadow-glow: 0 6px 20px rgba(79, 140, 255, .18);
    --sidebar-width: 248px;
}

[data-theme="light"] {
    --bg-body: #f3f5f8;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f5f7fa;
    --bg-input: #f7f8fa;
    --bg-secondary: #f7f8fa;
    --border: #dfe5ec;
    --border-light: #c8d2de;
    --text: #17212e;
    --text-dim: #536274;
    --text-muted: #7d8b9b;
}

body {
    background-image: none;
    letter-spacing: -.005em;
}

.sidebar {
    box-shadow: 4px 0 18px rgba(0, 0, 0, .08);
}

.sidebar-header {
    min-height: 64px;
    padding: .85rem 1rem;
}

.logo {
    gap: .7rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    box-shadow: none;
}

.logo-icon i {
    font-size: 1.05rem;
}

.logo-title {
    font-size: 1.02rem;
}

.logo-version {
    font-size: .63rem;
}

.sidebar-nav {
    padding: .45rem 0 .7rem;
}

.nav-section {
    margin-bottom: .18rem;
}

.nav-section-title {
    padding: .65rem 1rem .25rem;
    font-size: .59rem;
    letter-spacing: .12em;
}

.nav-item {
    min-height: 34px;
    gap: .65rem;
    padding: .43rem .72rem;
    margin: 0 .45rem .08rem;
    border-radius: 6px;
    font-size: .82rem;
}

.nav-item i {
    width: 17px;
    font-size: .88rem;
}

.nav-item.active {
    background: rgba(79, 140, 255, .12);
    color: #8ab4ff;
    box-shadow: inset 2px 0 0 var(--accent);
}

.nav-item.active::after {
    display: none;
}

.sidebar-footer {
    padding: .65rem .75rem;
}

.user-card {
    padding: .55rem;
    border-radius: 7px;
}

.user-avatar {
    width: 32px;
    height: 32px;
}

.sidebar-collapse-btn {
    width: 22px;
    height: 22px;
    right: -11px;
    font-size: .67rem;
}

.topbar {
    height: 56px;
    padding: 0 1.25rem;
    gap: .8rem;
    background: color-mix(in srgb, var(--bg-card) 94%, transparent);
}

.search-global {
    width: min(480px, 45vw);
    max-width: 480px;
    flex: 0 1 480px;
    height: 36px;
    border-radius: 7px;
    padding: 0 .75rem;
}

.search-global input {
    padding: .45rem 0;
    font-size: .82rem;
}

.topbar-actions {
    margin-left: auto;
    gap: .3rem;
}

.topbar-btn,
.btn-menu {
    width: 34px;
    height: 34px;
    border-radius: 6px;
}

.page-content {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 1.15rem 1.35rem 2rem;
}

.card {
    padding: 1rem;
    border-radius: 9px;
    box-shadow: none;
}

.card-header {
    margin-bottom: .8rem;
    padding-bottom: .7rem;
}

.btn {
    border-radius: 6px;
    font-size: .8rem;
}

.btn-primary {
    box-shadow: none;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(79, 140, 255, .2);
}

.stats-grid {
    gap: .8rem;
    margin-bottom: 1rem;
}

.stat-card {
    min-height: 76px;
    padding: .85rem 1rem;
    border-radius: 9px;
    box-shadow: none;
}

.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: none;
}

.stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 7px;
    font-size: 1rem;
}

.stat-value {
    font-size: 1.35rem;
}

.stat-label {
    font-size: .72rem;
}

.search-results {
    top: 50px;
    width: min(540px, calc(100vw - 2rem));
    max-height: min(520px, calc(100vh - 80px));
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .32);
}

.search-result-item {
    padding: .65rem .8rem;
}

@media (min-width: 1440px) {
    html { font-size: 14px; }
    .page-content { padding-left: 1.6rem; padding-right: 1.6rem; }
}

@media (min-width: 1800px) {
    :root { --sidebar-width: 260px; }
    .page-content { padding-left: 2rem; padding-right: 2rem; }
}

/* Sidebar desktop: stronger visual anchor without sacrificing workspace density. */
@media (min-width: 1025px) {
    :root {
        --sidebar-width: 284px;
    }

    html {
        font-size: 15.5px;
    }

    body {
        line-height: 1.48;
    }

    .sidebar-header {
        min-height: 72px;
        padding: .95rem 1.15rem;
    }

    .logo {
        gap: .8rem;
    }

    .logo-icon {
        width: 40px;
        height: 40px;
    }

    .logo-icon i {
        font-size: 1.12rem;
    }

    .logo-title {
        font-size: 1.1rem;
    }

    .logo-version {
        margin-top: .08rem;
        font-size: .66rem;
    }

    .sidebar-nav {
        padding-top: .55rem;
    }

    .nav-section {
        margin-bottom: .3rem;
    }

    .nav-section-title {
        padding: .72rem 1.15rem .3rem;
        font-size: .62rem;
    }

    .nav-item {
        min-height: 40px;
        gap: .72rem;
        padding: .52rem .82rem;
        margin-left: .55rem;
        margin-right: .55rem;
        font-size: .9rem;
    }

    .nav-item i {
        width: 19px;
        font-size: .94rem;
    }

    .sidebar-footer {
        padding: .75rem .85rem;
    }

    .user-card {
        padding: .65rem;
    }

    .user-avatar {
        width: 35px;
        height: 35px;
    }

    .topbar {
        height: 60px;
    }

    .search-global {
        height: 39px;
        max-width: 520px;
        flex-basis: 520px;
    }

    .search-global input {
        font-size: .86rem;
    }

    .topbar-btn,
    .btn-menu {
        width: 37px;
        height: 37px;
    }

    .page-content {
        padding: 1.35rem 1.55rem 2.2rem;
    }

    .btn {
        min-height: 36px;
        font-size: .84rem;
    }

    .btn-sm {
        min-height: 32px;
        font-size: .78rem;
    }

    .form-control,
    input,
    select,
    textarea {
        font-size: .9rem;
    }

    .table th {
        font-size: .76rem;
    }

    .table td {
        font-size: .86rem;
    }

    .card-title {
        font-size: 1rem;
    }

    .stat-card {
        min-height: 84px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: .78rem;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-secondary) 100%);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--accent-secondary) 0%, var(--accent) 100%);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--accent) var(--bg-body);
}

/* Sidebar scrollbar */
.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(102, 126, 234, 0.5) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.8);
}


/* ── Zones sûres iOS, application installée ─────────────────────────────────
   Ajouté le 28/08/2026, en même temps que viewport-fit=cover.

   La règle `.main-content > .topbar` (spécificité 0,2,0) l'emportait sur le
   `.topbar` du bloc @supports plus haut (0,1,0) : son `padding: 0 1.25rem`
   annulait le décalage, et la barre passait sous la Dynamic Island. Sa hauteur
   fixe de 64 px aurait de toute façon écrasé le contenu contre l'encoche.
   On décale ET on agrandit d'autant.

   Écrit en fin de fichier, avec la même spécificité que la règle concurrente,
   pour l'emporter par l'ordre du cascade. */
@supports (padding-top: env(safe-area-inset-top)) {
    .main-content > .topbar {
        padding-top: env(safe-area-inset-top);
        height: calc(64px + env(safe-area-inset-top));
        min-height: calc(64px + env(safe-area-inset-top));
    }

    /* Le contenu défile sous la barre : on lui rend la marge du bas aussi. */
    .main-content > .page-content {
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }
}
