/* ============================================================================
   ITCity Admin — Design system (bi-thème)
   A · Atelier  = sombre + accent or (défaut)   →  :root
   B · Clarté   = clair  + accent ambre         →  :root[data-theme="light"]
   Les composants se stylent via ces variables ; data-bs-theme (posé par app.js)
   laisse Bootstrap thémer ses propres composants, on superpose la marque.
   ============================================================================ */
:root {
    --sidebar-width: 264px;

    --bg: #15161b;
    --bg-2: #101116;
    --surface: #1e222b;
    --surface-2: #232834;
    --surface-3: #2a3040;
    --sidebar: #1a1c22;
    --sidebar-2: #141720;

    --line: #2b313d;
    --line-soft: #232833;

    --ink: #e7e9ee;
    --muted: #8b91a3;
    --muted-2: #636b7e;

    --accent: #f5b731;
    --accent-ink: #241a00;
    --accent-2: #ffe08a;                 /* texte sur état actif */
    --accent-dim: rgba(245, 183, 49, .14);
    --accent-line: rgba(245, 183, 49, .35);

    --success: #38c793;
    --warning: #ff9d43;
    --danger: #ef5b5b;
    --info: #4aa3ff;

    --field: #191b21;
    --field-line: #333a48;

    --primary-color: var(--accent);      /* nom hérité, réutilisé par le map grid */
    --shadow: 0 12px 32px -14px rgba(0, 0, 0, .62);
    --shadow-soft: 0 4px 14px -8px rgba(0, 0, 0, .5);
    --r-sm: 8px;
    --r: 12px;
    --r-lg: 16px;

    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
    --ui: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg: #eceaf0;
    --bg-2: #e4e1ea;
    --surface: #ffffff;
    --surface-2: #f5f3f8;
    --surface-3: #ece9f1;
    --sidebar: #ffffff;
    --sidebar-2: #f7f5fa;

    --line: #e2dfe8;
    --line-soft: #eeecf2;

    --ink: #23212b;
    --muted: #6a6575;
    --muted-2: #948fa0;

    --accent: #bf8a12;
    --accent-ink: #ffffff;
    --accent-2: #8a6100;
    --accent-dim: rgba(191, 138, 18, .13);
    --accent-line: rgba(191, 138, 18, .4);

    --success: #2fa27a;
    --warning: #c9781f;
    --danger: #d64545;
    --info: #2f6dbf;

    --field: #ffffff;
    --field-line: #d7d3df;

    --shadow: 0 14px 34px -16px rgba(30, 20, 50, .22);
    --shadow-soft: 0 4px 14px -10px rgba(30, 20, 50, .18);

    color-scheme: light;
}

* { box-sizing: border-box; }

body {
    font-family: var(--ui);
    background:
        radial-gradient(900px 520px at 84% -10%, var(--accent-dim), transparent 60%),
        var(--bg);
    color: var(--ink);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-dim); }

/* ---------- Login ---------- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(700px 460px at 80% -10%, var(--accent-dim), transparent 55%),
        linear-gradient(160deg, var(--bg-2), var(--bg));
    padding: 1.5rem;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    padding: 2.5rem;
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
}
.login-card h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--ink);
    font-weight: 700;
}

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

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    height: 100vh;
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: var(--ink);
    border-right: 1px solid var(--line-soft);
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width .2s ease, transform .2s ease;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 1.15rem 1.25rem .9rem;
    flex-shrink: 0;
}
.sidebar-header h4 {
    margin: 0;
    color: var(--ink);
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: .2px;
    display: flex;
    align-items: center;
    gap: .55rem;
}
.sidebar-header h4 .bi {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: inline-grid;
    place-items: center;
    font-size: .95rem;
    color: var(--accent-ink);
    background: linear-gradient(160deg, var(--accent), #d99a12);
    box-shadow: 0 6px 16px -6px var(--accent-line);
}
.sidebar-header small {
    color: var(--muted-2);
    font-size: .64rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    font-weight: 700;
    padding-left: calc(30px + .55rem);
}

/* menu search */
.sidebar-search {
    position: relative;
    padding: 0 .9rem .7rem;
    flex-shrink: 0;
}
.sidebar-search > .bi {
    position: absolute;
    left: 1.6rem;
    top: .55rem;
    font-size: .82rem;
    color: var(--muted-2);
    pointer-events: none;
}
.menu-search-input {
    width: 100%;
    padding: .5rem 2rem .5rem 2.05rem;
    color: var(--ink);
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: .84rem;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.menu-search-input::placeholder { color: var(--muted-2); }
.menu-search-input:focus {
    border-color: var(--accent-line);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.menu-search-input::-webkit-search-cancel-button { display: none; }
.menu-search-clear {
    position: absolute;
    right: 1.35rem;
    top: .5rem;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border: 0;
    background: transparent;
    color: var(--muted-2);
    border-radius: 6px;
    cursor: pointer;
    font-size: .7rem;
}
.menu-search-clear:hover { color: var(--ink); background: var(--surface-2); }

/* groups list */
.nav-groups {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .15rem .55rem 1rem;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}
.nav-groups::-webkit-scrollbar { width: 8px; }
.nav-groups::-webkit-scrollbar-track { background: transparent; }
.nav-groups::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
.nav-groups::-webkit-scrollbar-thumb:hover { background: var(--surface-3); background-clip: padding-box; }

.nav-group { margin-top: 2px; }
.nav-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .6rem .4rem;
    border: 0;
    background: transparent;
    border-radius: var(--r-sm);
    color: var(--muted-2);
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    cursor: pointer;
}
.nav-group-header:hover { color: var(--muted); }
.nav-group-header:focus-visible {
    outline: 2px solid var(--accent-line);
    outline-offset: -2px;
    color: var(--muted);
}
.nav-group-icon { font-size: .82rem; width: 15px; text-align: center; }
.nav-group-label { flex: 1; text-align: left; }
.nav-group-chevron {
    font-size: .7rem;
    transition: transform .18s ease;
    color: var(--muted-2);
}
.nav-group.collapsed .nav-group-chevron { transform: rotate(-90deg); }

.nav-group-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 2px 0 4px;
    margin: 0;
    list-style: none;
}

.sidebar .nav-item { list-style: none; }
.sidebar .nav-link {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .7rem;
    color: var(--muted);
    padding: .5rem .7rem;
    border-radius: var(--r-sm);
    transition: background .12s, color .12s;
    cursor: pointer;
    background: transparent;
    border: 0;
    text-align: left;
    font-size: .88rem;
    position: relative;
}
.sidebar .nav-link i {
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    font-size: .95rem;
    color: var(--muted-2);
    transition: color .12s;
}
.sidebar .nav-link:hover { color: var(--ink); background: var(--surface-2); }
.sidebar .nav-link:hover i { color: var(--muted); }
.sidebar .nav-link:focus-visible {
    outline: 2px solid var(--accent-line);
    outline-offset: -2px;
    color: var(--ink);
}
.sidebar .nav-link.active {
    color: var(--accent-2);
    background: var(--accent-dim);
    font-weight: 600;
}
.sidebar .nav-link.active i { color: var(--accent); }
.sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    left: -.55rem;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}

.nav-empty {
    color: var(--muted-2);
    font-size: .8rem;
    text-align: center;
    padding: 1.2rem .5rem;
    margin: 0;
}

.nav-label, .logout-label { white-space: nowrap; }

.sidebar-footer {
    padding: .9rem 1rem;
    border-top: 1px solid var(--line-soft);
    flex-shrink: 0;
}
.sidebar-footer .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 90;
}

/* ---------- Content ---------- */
.content {
    margin-left: var(--sidebar-width);
    padding: 1.75rem 2rem 2.5rem;
    flex: 1;
    width: calc(100% - var(--sidebar-width));
    min-width: 0;
    transition: margin-left .2s ease, width .2s ease;
}
.content > div { animation: pageIn .25s ease-out; }
@keyframes pageIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Topbar */
.content-toolbar {
    display: flex;
    align-items: center;
    gap: .85rem;
    margin: -1.75rem -2rem 1.5rem;
    padding: .8rem 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line-soft);
}
.crumb {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
    font-size: .9rem;
    color: var(--muted);
}
.crumb-group { white-space: nowrap; }
.crumb-sep { font-size: .68rem; color: var(--muted-2); }
.crumb-view { color: var(--ink); font-weight: 700; }
.toolbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .7rem;
}
.btn-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
}
.btn-icon:hover { color: var(--ink); border-color: var(--field-line); background: var(--surface-2); }
.toolbar-user {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .3rem .7rem .3rem .35rem;
    border: 1px solid var(--line);
    border-radius: 40px;
    background: var(--surface);
    font-size: .82rem;
    color: var(--muted);
    max-width: 220px;
}
.toolbar-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, var(--info), #2f6dbf);
    color: #fff;
    font-weight: 700;
    font-size: .78rem;
    flex-shrink: 0;
}
.toolbar-user-name {
    color: var(--ink);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-toggle {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* view titles */
.content h2 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -.01em;
    margin-bottom: 1.1rem;
    display: flex;
    align-items: center;
    gap: .55rem;
}
.content h2 .bi { color: var(--accent); }

/* ---------- Metric cards ---------- */
.metric-card {
    border-radius: var(--r);
    padding: 1.35rem 1.4rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}
.metric-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, .12) 0%, transparent 60%);
    pointer-events: none;
}
.metric-card i {
    font-size: 2rem;
    opacity: .32;
    position: absolute;
    top: 1rem;
    right: 1rem;
}
.metric-value {
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: .25rem;
    font-variant-numeric: tabular-nums;
}
.metric-label {
    font-size: .82rem;
    opacity: .92;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.metric-card small { opacity: .8; }

/* ---------- Tables ---------- */
.table {
    --bs-table-bg: var(--surface);
    --bs-table-color: var(--ink);
    --bs-table-border-color: var(--line-soft);
    --bs-table-hover-bg: var(--surface-2);
    --bs-table-hover-color: var(--ink);
    background: var(--surface);
    border-radius: var(--r);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    margin-bottom: 0;
    color: var(--ink);
    vertical-align: middle;
}
.table thead th {
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 600;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    padding: .7rem .9rem;
}
.table tbody td { border-top: 1px solid var(--line-soft); padding: .7rem .9rem; }
.table tbody tr { transition: background .15s ease; }
.table tbody tr:hover > * { background: var(--surface-2); }

.dt-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.dt-sortable:hover { color: var(--accent); }
.dt-sortable .bi { font-size: .7rem; opacity: .5; }
.dt-sortable:hover .bi { opacity: 1; }

/* wrap tables so wide ones scroll inside their own box */
.table-responsive { border-radius: var(--r); }

.dt-controls { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .75rem; flex-wrap: wrap; }
.dt-footer { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-top: .75rem; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--line-soft);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-soft);
    border-radius: var(--r);
    --bs-card-bg: var(--surface);
    --bs-card-color: var(--ink);
    --bs-card-border-color: var(--line-soft);
}
.card-header {
    background: var(--surface-2);
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink);
    font-weight: 600;
}
.card-header h5 { display: flex; align-items: center; gap: .5rem; margin: 0; font-size: 1rem; }
.card-header .bi { color: var(--accent); }

/* ---------- Modals ---------- */
.modal-content {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
}
.modal-header, .modal-footer { border-color: var(--line-soft); }
.modal-title { color: var(--ink); font-weight: 700; }

/* ---------- Forms ---------- */
.form-label { color: var(--muted); font-weight: 600; font-size: .82rem; margin-bottom: .35rem; }
.form-control, .form-select {
    background: var(--field);
    border: 1px solid var(--field-line);
    color: var(--ink);
    border-radius: var(--r-sm);
}
.form-control::placeholder { color: var(--muted-2); }
.form-control:focus, .form-select:focus {
    background: var(--field);
    color: var(--ink);
    border-color: var(--accent-line);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-control:disabled, .form-select:disabled { background: var(--surface-2); color: var(--muted); }
.form-check-input {
    background-color: var(--field);
    border-color: var(--field-line);
}
.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}
.form-check-input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-check-label { color: var(--ink); }
.input-group-text {
    background: var(--surface-2);
    border: 1px solid var(--field-line);
    color: var(--muted);
}

/* ---------- Buttons ---------- */
.btn { border-radius: var(--r-sm); font-weight: 600; }
.btn-primary {
    background: linear-gradient(160deg, var(--accent), color-mix(in srgb, var(--accent) 82%, #000));
    border-color: transparent;
    color: var(--accent-ink);
}
.btn-primary:hover, .btn-primary:focus {
    filter: brightness(1.06);
    color: var(--accent-ink);
    border-color: transparent;
}
.btn-secondary {
    background: var(--surface-2);
    border-color: var(--line);
    color: var(--ink);
}
.btn-secondary:hover { background: var(--surface-3); color: var(--ink); border-color: var(--field-line); }

.btn-outline-secondary {
    color: var(--muted);
    border-color: var(--line);
    background: var(--surface);
}
.btn-outline-secondary:hover {
    color: var(--ink);
    background: var(--surface-2);
    border-color: var(--field-line);
}
.btn-outline-primary { color: var(--accent); border-color: var(--accent-line); }
.btn-outline-primary:hover { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-outline-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; border-color: transparent; }
.btn-outline-warning { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.btn-outline-warning:hover { background: var(--warning); color: #241a00; border-color: transparent; }
.btn-outline-info { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); }
.btn-outline-info:hover { background: var(--info); color: #fff; border-color: transparent; }
.btn-outline-success { color: var(--success); border-color: color-mix(in srgb, var(--success) 45%, transparent); }
.btn-outline-success:hover { background: var(--success); color: #06231a; border-color: transparent; }

/* ---------- Badges / pills ---------- */
.badge { font-weight: 600; letter-spacing: .01em; border-radius: 20px; }

/* ---------- Pagination ---------- */
.pagination {
    --bs-pagination-bg: var(--surface);
    --bs-pagination-color: var(--muted);
    --bs-pagination-border-color: var(--line);
    --bs-pagination-hover-bg: var(--surface-2);
    --bs-pagination-hover-color: var(--ink);
    --bs-pagination-hover-border-color: var(--field-line);
    --bs-pagination-active-bg: var(--accent);
    --bs-pagination-active-border-color: var(--accent);
    --bs-pagination-active-color: var(--accent-ink);
    --bs-pagination-disabled-bg: var(--surface);
    --bs-pagination-disabled-color: var(--muted-2);
    --bs-pagination-disabled-border-color: var(--line-soft);
    --bs-pagination-focus-box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ---------- Alerts ---------- */
.alert { border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.alert-info { border-color: color-mix(in srgb, var(--info) 40%, transparent); background: color-mix(in srgb, var(--info) 12%, var(--surface)); color: var(--ink); }
.alert-danger { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--ink); }
.alert-warning { border-color: color-mix(in srgb, var(--warning) 40%, transparent); background: color-mix(in srgb, var(--warning) 12%, var(--surface)); color: var(--ink); }

/* ---------- Misc ---------- */
.text-muted { color: var(--muted) !important; }
.toast { min-width: 300px; }

.dt-empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.dt-empty-state i { font-size: 2.5rem; opacity: .4; display: block; margin-bottom: .75rem; }

.was-validated .form-control:invalid,
.was-validated .form-select:invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--danger) 22%, transparent);
}

.search-shortcut {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .7rem;
    color: var(--muted-2);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 0 4px;
    line-height: 1.5;
    pointer-events: none;
}

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 1099px) {
    .sidebar { width: 232px; }

    /* tablet icon-rail: hide search + labels, flatten groups to just item icons */
    .sidebar.sidebar-collapsed { width: 74px; }
    .sidebar.sidebar-collapsed .sidebar-header { padding: 1rem .5rem; align-items: center; }
    .sidebar.sidebar-collapsed .sidebar-header h4 { gap: 0; font-size: 0; }   /* hide wordmark, keep the logo tile */
    .sidebar.sidebar-collapsed .sidebar-header h4 .bi { font-size: .95rem; }
    .sidebar.sidebar-collapsed .sidebar-header small,
    .sidebar.sidebar-collapsed .sidebar-search,
    .sidebar.sidebar-collapsed .nav-group-label,
    .sidebar.sidebar-collapsed .nav-group-chevron,
    .sidebar.sidebar-collapsed .nav-label,
    .sidebar.sidebar-collapsed .logout-label { display: none; }
    .sidebar.sidebar-collapsed .nav-group-header { justify-content: center; padding: .5rem 0 .2rem; }
    .sidebar.sidebar-collapsed .nav-group-header::after {
        content: '';
        display: block;
        width: 20px;
        height: 1px;
        background: var(--line);
    }
    .sidebar.sidebar-collapsed .nav-group-icon { display: none; }
    .sidebar.sidebar-collapsed .nav-group-items { display: flex !important; }
    .sidebar.sidebar-collapsed .nav-link { justify-content: center; padding: .6rem 0; gap: 0; }
    .sidebar.sidebar-collapsed .nav-link i { margin: 0; }
    .sidebar.sidebar-collapsed .nav-link.active::before { left: 0; }
    .sidebar.sidebar-collapsed .sidebar-footer { padding: 1rem .5rem; }

    .content { margin-left: 232px; width: calc(100% - 232px); }
    .content.content-tablet-collapsed { margin-left: 74px; width: calc(100% - 74px); }
}

@media (max-width: 767px) {
    .login-card { padding: 1.5rem; max-width: calc(100vw - 2rem); }

    .sidebar { width: min(288px, 86vw); }
    .sidebar.sidebar-overlay { transform: translateX(-100%); box-shadow: var(--shadow); }
    .sidebar.sidebar-overlay.sidebar-open { transform: translateX(0); }
    /* in the mobile drawer, groups behave like desktop (collapsible, labelled) */
    .sidebar.sidebar-overlay .nav-group-label,
    .sidebar.sidebar-overlay .nav-group-chevron,
    .sidebar.sidebar-overlay .sidebar-search,
    .sidebar.sidebar-overlay .nav-label { display: revert; }

    .content,
    .content.content-mobile,
    .content.content-tablet-collapsed {
        margin-left: 0;
        width: 100%;
        padding: 1rem;
    }
    .content-toolbar { margin: -1rem -1rem 1rem; padding: .6rem 1rem; }
    .toolbar-user-name { display: none; }

    .dt-controls, .dt-footer { flex-direction: column; align-items: stretch; }

    .table { display: block; overflow-x: auto; white-space: nowrap; }

    .btn-group .btn { min-width: 44px; min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============================================================================
   Map Grid (thème-aware light touch)
   ============================================================================ */
.map-grid-container {
    overflow: auto;
    max-height: 75vh;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--bg-2);
    padding: 1rem;
}
.map-grid { border-collapse: separate; border-spacing: 3px; margin: 0 auto; }
.map-grid .map-coord {
    font-size: .65rem;
    color: var(--muted-2);
    text-align: center;
    padding: 2px 4px;
    min-width: 20px;
    font-family: var(--mono);
}
.map-grid .map-cell {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 8px;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    position: relative;
    transition: transform .2s ease, box-shadow .2s ease;
    font-size: 1.3rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
}
.map-cell:hover {
    transform: scale(1.1);
    z-index: 2;
    box-shadow: 0 4px 12px var(--accent-line);
}
.map-cell.cell-building { background: linear-gradient(135deg, var(--info), #2f6dbf); color: #fff; }
.map-cell.cell-plot { background: linear-gradient(135deg, #e6e7e9, #d2d3d6); color: #333; }
.map-cell.cell-road { background: linear-gradient(135deg, #495057, #343a40); color: var(--accent); }
.map-cell.cell-tree { background: linear-gradient(135deg, var(--success), #146c43); color: #d1e7dd; }
.map-cell.cell-empty {
    background: var(--surface-2);
    color: var(--muted);
    border: 1px dashed var(--line);
    box-shadow: none;
}
.map-cell.cell-empty:hover { background: var(--surface-3); border-color: var(--accent-line); }
.map-cell-label {
    display: block;
    font-size: .5rem;
    font-weight: 600;
    line-height: 1;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: .3px;
    text-transform: uppercase;
}
.map-cell .bi { display: block; font-size: 1.2rem; line-height: 1; }
.map-cell-icon { display: block; font-size: 1.5rem; font-weight: bold; line-height: 1; }

/* Road orientation: 0=Nord, 1=Ouest, 2=Sud, 3=Est */
.road-orient-0 { transform: rotate(90deg); }
.road-orient-1 { transform: rotate(180deg); }
.road-orient-2 { transform: rotate(270deg); }
.road-orient-3 { transform: rotate(0deg); }

.orientation-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--ink);
    cursor: pointer;
    transition: all .15s;
}
.orientation-btn:hover { background: var(--surface-3); border-color: var(--field-line); }
.orientation-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 0 6px var(--accent-line);
}
