/* ============================================================================
   GeoCopro Admin Panel - Styles
   Thème clair / sombre via variables CSS, aucune dépendance externe.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   Tokens
   ---------------------------------------------------------------------------- */

:root {
    --bg: #f3f5fa;
    --surface: #ffffff;
    --surface-2: #f7f8fc;
    --surface-3: #eef0f7;
    --border: #e3e6ef;
    --border-strong: #cfd4e2;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #8a94a8;

    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: #eef0ff;
    --accent-text: #3730a3;

    --success: #15803d;
    --success-soft: #dcfce7;
    --success-text: #166534;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --warning-text: #92400e;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-soft: #fee2e2;
    --danger-text: #991b1b;
    --info: #0369a1;
    --info-soft: #e0f2fe;
    --info-text: #075985;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .06);
    --shadow-lg: 0 20px 60px rgba(15, 23, 42, .22);
    --ring: 0 0 0 3px rgba(79, 70, 229, .25);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --sidebar-w: 260px;
    --topbar-h: 64px;

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

    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0b1020;
    --surface: #121a2e;
    --surface-2: #17203a;
    --surface-3: #1d2745;
    --border: #232e4d;
    --border-strong: #33406a;
    --text: #e7ebf5;
    --text-2: #a9b3c9;
    --text-3: #6f7a95;

    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: rgba(129, 140, 248, .16);
    --accent-text: #c7d2fe;

    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, .14);
    --success-text: #bbf7d0;
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, .14);
    --warning-text: #fde68a;
    --danger: #f87171;
    --danger-hover: #fca5a5;
    --danger-soft: rgba(248, 113, 113, .14);
    --danger-text: #fecaca;
    --info: #38bdf8;
    --info-soft: rgba(56, 189, 248, .14);
    --info-text: #bae6fd;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, .6);
    --ring: 0 0 0 3px rgba(129, 140, 248, .35);

    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b1020;
        --surface: #121a2e;
        --surface-2: #17203a;
        --surface-3: #1d2745;
        --border: #232e4d;
        --border-strong: #33406a;
        --text: #e7ebf5;
        --text-2: #a9b3c9;
        --text-3: #6f7a95;

        --accent: #818cf8;
        --accent-hover: #a5b4fc;
        --accent-soft: rgba(129, 140, 248, .16);
        --accent-text: #c7d2fe;

        --success: #4ade80;
        --success-soft: rgba(74, 222, 128, .14);
        --success-text: #bbf7d0;
        --warning: #fbbf24;
        --warning-soft: rgba(251, 191, 36, .14);
        --warning-text: #fde68a;
        --danger: #f87171;
        --danger-hover: #fca5a5;
        --danger-soft: rgba(248, 113, 113, .14);
        --danger-text: #fecaca;
        --info: #38bdf8;
        --info-soft: rgba(56, 189, 248, .14);
        --info-text: #bae6fd;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .35);
        --shadow-lg: 0 24px 70px rgba(0, 0, 0, .6);
        --ring: 0 0 0 3px rgba(129, 140, 248, .35);

        color-scheme: dark;
    }
}

/* ----------------------------------------------------------------------------
   Base
   ---------------------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

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

code, .hid {
    font-family: var(--mono);
    font-size: 12.5px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 2px 6px;
    color: var(--text);
    word-break: break-all;
}

small, .hint { font-size: 12px; color: var(--text-3); }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.text-danger { color: var(--danger); }
.link-strong { font-weight: 600; color: var(--text); }
.link-strong:hover { color: var(--accent); }
.req { color: var(--danger); }

.icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    vertical-align: -4px;
}
.icon-lg { width: 40px; height: 40px; color: var(--text-3); }

/* HID : jamais coupé en plein milieu dans les tableaux */
.hid { white-space: nowrap; word-break: normal; }

.skip-link {
    position: absolute;
    left: -9999px;
    top: 8px;
    background: var(--accent);
    color: #fff;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    z-index: 100;
}
.skip-link:focus { left: 8px; }

:focus-visible { outline: none; box-shadow: var(--ring); }

/* ----------------------------------------------------------------------------
   Layout : sidebar + main
   ---------------------------------------------------------------------------- */

body.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 40;
}

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

.brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: #fff;
    box-shadow: 0 6px 16px rgba(79, 70, 229, .35);
    flex: 0 0 auto;
    font-weight: 700;
}
.brand-logo .icon { width: 20px; height: 20px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: -.01em; }
.brand-text small { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }

.brand .sidebar-close { display: none; margin-left: auto; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 14px 12px; flex: 1 1 auto; overflow-y: auto; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-item .icon { width: 19px; height: 19px; color: var(--text-3); transition: color .15s; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover .icon { color: var(--text-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-item.active .icon { color: var(--accent); }

.sidebar-footer { padding: 14px 12px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }

.admin-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.admin-chip-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.admin-chip-text strong { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-chip-text small { font-size: 11.5px; color: var(--text-3); }

.logout-form { margin: 0; }

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 14px;
    height: var(--topbar-h);
    padding: 0 28px;
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.topbar-title { font-size: 17px; font-weight: 650; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar .sidebar-toggle { display: none; }

.topbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 340px;
    max-width: 40vw;
    padding: 0 12px;
    height: 38px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-3);
    transition: border-color .15s, box-shadow .15s;
}
.topbar-search:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.topbar-search input { flex: 1 1 auto; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; outline: none; }
.topbar-search input::placeholder { color: var(--text-3); }

.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
    :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: inline; }
}

.content { padding: 28px; max-width: 1480px; width: 100%; flex: 1 1 auto; }

.footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 28px;
    border-top: 1px solid var(--border);
    color: var(--text-3);
    font-size: 12.5px;
}

.sidebar-backdrop { display: none; }

/* ----------------------------------------------------------------------------
   Page head / breadcrumb
   ---------------------------------------------------------------------------- */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.page-head h2 { font-size: 22px; margin-bottom: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: 13.5px; }
.breadcrumb a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.breadcrumb a:hover { color: var(--accent); }

/* ----------------------------------------------------------------------------
   Cards
   ---------------------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.card-head h2 { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.card-head h2 .icon { color: var(--accent); }
.card-head .count {
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-3);
    color: var(--text-2);
    border-radius: 999px;
    padding: 2px 9px;
}

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

.grid-lic { display: grid; grid-template-columns: 1fr; gap: 20px; margin-bottom: 20px; }
.grid-lic .card { margin-bottom: 0; }

.grid-admins { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: 20px; }
.grid-admins .card { margin-bottom: 0; }

/* ----------------------------------------------------------------------------
   Stat cards (dashboard)
   ---------------------------------------------------------------------------- */

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

.stat {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    color: inherit;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
a.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); color: inherit; }

.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    flex: 0 0 auto;
}
.stat-icon .icon { width: 22px; height: 22px; }
.stat-icon.accent { background: var(--accent-soft); color: var(--accent); }
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.danger { background: var(--danger-soft); color: var(--danger); }
.stat-icon.info { background: var(--info-soft); color: var(--info); }
.stat-icon.muted { background: var(--surface-3); color: var(--text-3); }

.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12.5px; color: var(--text-2); }

/* ----------------------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 14px;
    border-radius: 9px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    font-size: 13.5px;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s, transform .05s;
    user-select: none;
    text-decoration: none;
}
.btn .icon { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-3); color: var(--text); }
[data-theme="dark"] .btn-secondary { background: var(--surface-3); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .btn-secondary { background: var(--surface-3); }
}

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.08); color: #fff; }

.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); color: var(--danger); }

.btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 44px; font-size: 15px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }

.actions { display: inline-flex; gap: 4px; flex-wrap: wrap; }

/* ----------------------------------------------------------------------------
   Forms
   ---------------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { font-weight: 600; font-size: 13px; color: var(--text-2); }

.input, .select {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input::placeholder { color: var(--text-3); }
.input:user-invalid { border-color: var(--danger); }

.select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a94a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
}

.input-pwd { position: relative; display: flex; }
.input-pwd .input { padding-right: 44px; }
.input-pwd .btn { position: absolute; right: 2px; top: 2px; height: 36px; width: 36px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .field { margin-bottom: 0; }
.field-full { grid-column: 1 / -1; }

.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-stack .field { margin: 0; }

.checkbox { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; margin: 6px 0; }
.checkbox input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--accent); }

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.toolbar .select { width: auto; min-width: 200px; }
.toolbar-wrap .select { min-width: 180px; }

.search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 260px;
    max-width: 460px;
    height: 40px;
    padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    color: var(--text-3);
    transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.search input { flex: 1 1 auto; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; outline: none; }
.search-sm { flex: 0 1 200px; }

.date-field { display: inline-flex; align-items: center; gap: 8px; }
.date-field .input { width: 160px; }

/* ----------------------------------------------------------------------------
   Tables
   ---------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }

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

.table th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-3);
    padding: 10px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
.table th:first-child { border-top-left-radius: var(--radius-sm); }
.table th:last-child { border-top-right-radius: var(--radius-sm); }

.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table-compact td { padding: 9px 12px; }
.row-muted td { opacity: .6; }

.th-id { width: 60px; }
.th-actions, .td-actions { text-align: right; white-space: nowrap; }
.td-lic { min-width: 170px; }

.th-sort { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.th-sort:hover, .th-sort.active { color: var(--accent); }
.sort-arrow { font-size: 9px; }

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

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 700;
    font-size: 14px;
    flex: 0 0 auto;
}
.avatar-sm { width: 28px; height: 28px; font-size: 12px; border-radius: 8px; }
.avatar-lg { width: 60px; height: 60px; font-size: 24px; border-radius: 16px; }

/* ----------------------------------------------------------------------------
   Badges, progress, license cells
   ---------------------------------------------------------------------------- */

.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-success { background: var(--success-soft); color: var(--success-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-info { background: var(--info-soft); color: var(--info-text); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-muted { background: var(--surface-3); color: var(--text-2); }

.progress {
    height: 7px;
    width: 100%;
    background: var(--surface-3);
    border-radius: 999px;
    overflow: hidden;
}
.progress-fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: var(--success);
    transition: width .4s ease;
}
.fill-success { background: var(--success); }
.fill-warning { background: var(--warning); }
.fill-danger { background: var(--danger); }

.lic { display: flex; flex-direction: column; gap: 5px; min-width: 130px; }
.lic-text { font-variant-numeric: tabular-nums; }
.lic-text strong { font-size: 15px; }

.kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.kpi {
    display: flex;
    flex-direction: column;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.kpi-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--text-3); }
.kpi-sub code { font-size: 11px; }
.kpi-success { border-color: color-mix(in srgb, var(--success) 40%, var(--border)); background: var(--success-soft); }
.kpi-success .kpi-value { color: var(--success-text); }
.kpi-warning { border-color: color-mix(in srgb, var(--warning) 40%, var(--border)); background: var(--warning-soft); }
.kpi-warning .kpi-value { color: var(--warning-text); }
.kpi-danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: var(--danger-soft); }
.kpi-danger .kpi-value { color: var(--danger-text); }

.lic-summary { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 15px; flex-wrap: wrap; }
.lic-card .progress { height: 10px; margin-bottom: 16px; }

.help {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-2);
}
.help .icon { color: var(--accent); margin-top: 1px; }

/* ----------------------------------------------------------------------------
   User head
   ---------------------------------------------------------------------------- */

.user-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.user-head-main { display: flex; align-items: center; gap: 16px; min-width: 0; }
.user-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 22px; margin-bottom: 6px; }
.user-meta { display: flex; gap: 18px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; }
.user-meta span { display: inline-flex; align-items: center; gap: 6px; }
.user-meta .icon { width: 15px; height: 15px; color: var(--text-3); }
.user-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ----------------------------------------------------------------------------
   Alerts, empty states, timeline, key/values
   ---------------------------------------------------------------------------- */

.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid;
    margin-bottom: 16px;
    font-size: 13.5px;
}
.alert .icon { margin-top: 1px; flex: 0 0 auto; }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, transparent); color: var(--info-text); }
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); color: var(--success-text); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); color: var(--warning-text); }
.alert-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger-text); }
.alert code { background: rgba(127, 127, 127, .15); border-color: transparent; color: inherit; }

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 36px 16px;
    text-align: center;
    color: var(--text-3);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
}
.empty p { margin: 0; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline-item { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: 0; }
.timeline-meta { font-size: 12.5px; color: var(--text-2); display: flex; gap: 6px; flex-wrap: wrap; }
.timeline-body { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.kvs { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.kv {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    background: var(--surface-3);
    font-size: 12.5px;
    color: var(--text-2);
}
.kv b { font-weight: 600; color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.kv strong { color: var(--text); }
.kv code { padding: 0 4px; font-size: 12px; }

.table-logs td { vertical-align: top; }

/* ----------------------------------------------------------------------------
   Pagination
   ---------------------------------------------------------------------------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 16px;
    flex-wrap: wrap;
}
.pagination-info { font-size: 13px; color: var(--text-3); }
.pagination-nav { display: inline-flex; gap: 4px; align-items: center; }
.pagination-nav .btn { min-width: 32px; }
.pagination-ellipsis { padding: 0 4px; color: var(--text-3); }

/* ----------------------------------------------------------------------------
   Modals (<dialog>)
   ---------------------------------------------------------------------------- */

.modal {
    width: min(640px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}
.modal-sm { width: min(480px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(8, 12, 28, .55); backdrop-filter: blur(3px); }
.modal[open] { animation: modal-in .18s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.modal-form { margin: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 18px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; }

/* ----------------------------------------------------------------------------
   Toasts
   ---------------------------------------------------------------------------- */

.toasts {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--info);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    pointer-events: auto;
    animation: toast-in .25s ease-out;
    font-size: 13.5px;
}
.toast.hide { animation: toast-out .25s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
.toast-icon { display: inline-flex; margin-top: 1px; color: var(--info); }
.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info { border-left-color: var(--info); }
.toast-text { flex: 1 1 auto; }
.toast-close { border: 0; background: transparent; color: var(--text-3); cursor: pointer; padding: 2px; display: inline-flex; border-radius: 6px; }
.toast-close:hover { background: var(--surface-3); color: var(--text); }
.toast-close .icon { width: 15px; height: 15px; }

/* ----------------------------------------------------------------------------
   Auth (login) page
   ---------------------------------------------------------------------------- */

body.auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px 16px;
    background:
        radial-gradient(900px 500px at 10% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
        radial-gradient(700px 400px at 100% 110%, color-mix(in srgb, #7c3aed 14%, transparent), transparent 60%),
        var(--bg);
}
.auth-card {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 30px 30px 22px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand div { display: flex; flex-direction: column; line-height: 1.15; }
.auth-brand strong { font-size: 17px; }
.auth-brand small { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.auth-title { font-size: 24px; margin-bottom: 4px; }
.auth-form { margin-top: 20px; }
.auth-form .btn { margin-top: 6px; }
.auth-foot { margin-top: 22px; text-align: center; font-size: 12px; }


/* ----------------------------------------------------------------------------
   Licences .lic (cellule, modales, liens signés)
   ---------------------------------------------------------------------------- */

.section-title { display: flex; align-items: center; gap: 10px; font-size: 16px; margin: 6px 0 14px; }
.section-title .icon { color: var(--accent); }
.section-title .muted { font-weight: 500; font-size: 13px; }

.td-lic-file { min-width: 280px; }
.lic-cell { display: flex; flex-direction: column; gap: 6px; }
.lic-cell-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lic-cell-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.lic-cell-meta b { font-weight: 600; color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.lic-cell-meta .icon { width: 14px; height: 14px; vertical-align: -3px; color: var(--text-3); }
.lic-cell-link { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--info-text); background: var(--info-soft); border-radius: var(--radius-xs); padding: 4px 8px; }
.lic-cell-link .icon { width: 14px; height: 14px; }
.lic-cell-actions { margin-top: 2px; }
.btn-inline { height: 26px; padding: 0 8px; font-size: 12px; }
.text-success { color: var(--success); }
.lic-files-summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; font-size: 13px; color: var(--text-2); }
.lic-files-summary .icon { color: var(--accent); }

.input-file { padding: 7px 10px; height: auto; line-height: 1.4; cursor: pointer; }
.input-file::file-selector-button { font: inherit; font-weight: 600; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); border-radius: 7px; padding: 5px 10px; margin-right: 10px; cursor: pointer; }
.input-copy { display: flex; gap: 8px; }
.input-copy .input { font-family: var(--mono); font-size: 12.5px; }
.tabs { display: flex; gap: 6px; }

@media (max-width: 960px) {
    .td-lic-file { min-width: 240px; }
    .lic-cell-actions .btn-sm span { display: none; }
    .lic-cell-actions .btn-sm { width: 32px; padding: 0; justify-content: center; }
}

/* ----------------------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------------------- */

@media (max-width: 1200px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-lic, .grid-admins { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
    body.app { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--sidebar-w);
        max-width: 85vw;
        transform: translateX(-100%);
        box-shadow: none;
    }
    /* La transition n'est activée qu'après le chargement (pas de glissement au premier rendu) */
    body.js-ready .sidebar { transition: transform .22s ease; }
    body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    .brand .sidebar-close { display: inline-flex; }
    .topbar .sidebar-toggle { display: inline-flex; }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(8, 12, 28, .5);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s;
        z-index: 35;
    }
    body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

    .topbar { padding: 0 16px; }
    .topbar-search { display: none; }
    .content { padding: 18px 16px; }
    .footer { padding: 14px 16px; flex-direction: column; gap: 4px; }
    .grid-2 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .timeline-item { grid-template-columns: 1fr; gap: 4px; }
    .kpis { grid-template-columns: 1fr; }
    .table-wrap { margin: 0 -16px; padding: 0 16px; }
    .card { padding: 16px; }
    /* Actions de tableau : icônes seules, sur une ligne (le tableau défile horizontalement) */
    .actions { flex-wrap: nowrap; }
    .actions .btn-sm span { display: none; }
    .actions .btn-sm .icon { width: 17px; height: 17px; }
    .actions .btn-sm { width: 32px; padding: 0; justify-content: center; }
}

@media (max-width: 600px) {
    .stat-grid { grid-template-columns: 1fr; }
    .page-head { align-items: flex-start; flex-direction: column; }
    .user-head-actions .btn span { display: none; }
    .user-head-actions .btn { width: 40px; padding: 0; }
    .toolbar .select { width: 100%; }
    .search { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
    .sidebar, .topbar, .footer, .toasts, .btn, .page-actions, .actions { display: none !important; }
    body.app { grid-template-columns: 1fr; }
    .card { box-shadow: none; }
}
