:root {
    --ink: #101828;
    --muted: #667085;
    --line: #d0d7e2;
    --panel: #ffffff;
    --page: #f5f7fb;
    --nav: #1f2937;
    --accent: #0a84ff;
    --accent-soft: #eaf4ff;
    --warn: #fff2bd;
    --danger: #b3261e;
    --green: #16a36a;
    --orange: #f08a24;
    --purple: #7656d6;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    padding-bottom: 28px;
    color: var(--ink);
    background:
        linear-gradient(180deg, #fbfcff 0, #f4f7fb 260px, #eef3f8 100%);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Arial, Helvetica, sans-serif;
}

body::after {
    content: "Powered by DOUDOU BAKUTU - Tous droits réservés.";
    position: fixed;
    right: 14px;
    bottom: 8px;
    z-index: 1000;
    color: rgba(71, 84, 103, 0.78);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0;
    pointer-events: none;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.86), rgba(243,246,250,0.96)),
        linear-gradient(90deg, #e4eef7 0 1px, transparent 1px 100%),
        linear-gradient(0deg, #e4eef7 0 1px, transparent 1px 100%);
    background-size: auto, 56px 56px, 56px 56px;
}

.login-shell {
    position: relative;
    width: min(980px, 100%);
    display: grid;
    grid-template-columns: minmax(300px, 420px) 1fr;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(23, 32, 51, 0.16);
}

.login-panel,
.notice-panel {
    padding: 34px;
}

.notice-panel {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 460px;
    color: white;
    background:
        linear-gradient(rgba(22, 119, 200, 0.88), rgba(38, 50, 65, 0.92)),
        repeating-linear-gradient(0deg, transparent 0 38px, rgba(255, 255, 255, 0.14) 39px 40px),
        repeating-linear-gradient(90deg, transparent 0 92px, rgba(255, 255, 255, 0.10) 93px 94px),
        #263241;
}

.brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 42px;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 54px;
    height: 54px;
    color: white;
    background: var(--accent);
    font-weight: 800;
    letter-spacing: 0;
    border-radius: 6px;
}

.brand-logo {
    width: 54px;
    height: 54px;
    object-fit: contain;
    flex: 0 0 auto;
    border-radius: 12px;
    background: #0a74c9;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
}

.brand p,
.topbar p,
.eyebrow {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.notice-panel .eyebrow {
    color: #b9f2d1;
}

.admin-gear-link {
    position: absolute;
    left: 18px;
    bottom: 18px;
    z-index: 1001;
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    color: #344054;
    background: #f8fbff;
    border: 1px solid rgba(208, 215, 226, 0.92);
    border-radius: 50%;
    box-shadow: 0 8px 22px rgba(16, 24, 40, 0.12);
    font-size: 19px;
    line-height: 1;
    text-decoration: none;
    transition: transform 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.admin-gear-link:hover {
    color: var(--accent);
    background: white;
    transform: translateY(-1px);
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

.brand h1 {
    font-size: 22px;
    line-height: 1.18;
}

.login-form {
    display: grid;
    gap: 18px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
}

input {
    min-height: 38px;
    border: 1px solid var(--line);
    padding: 0 12px;
    color: var(--ink);
    font: inherit;
    border-radius: 10px;
}

select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    padding: 9px 12px;
    color: var(--ink);
    background: white;
    font: inherit;
    border-radius: 10px;
}

select {
    min-height: 38px;
}

textarea {
    resize: vertical;
}

button,
.logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    border: 0;
    padding: 0 14px;
    color: white;
    background: #344054;
    font: inherit;
    font-size: 13px;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
    border-radius: 9px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.10);
}

.logout {
    background: #48566f;
    box-shadow: none;
}

.top-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    max-width: 820px;
}

.error {
    margin: 0;
    color: var(--danger);
    font-weight: 700;
}

.success,
.admin-error {
    margin: 0 0 12px;
    padding: 10px 12px;
    color: #0f5132;
    background: rgba(223, 245, 232, 0.72);
    border: 1px solid #a9ddbf;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 750;
}

.admin-error {
    color: var(--danger);
    background: #fff1f0;
    border-color: #efb7b2;
}

.demo-note {
    margin: 22px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.app-page {
    display: grid;
    grid-template-columns: 210px 1fr;
    height: 100vh;
    overflow: hidden;
    background: var(--page);
}

.side-nav {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 14px 10px;
    color: white;
    background: rgba(31, 41, 55, 0.98);
    border-right: 1px solid rgba(16, 24, 40, 0.22);
    overflow-y: auto;
}

.side-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.side-brand .brand-logo {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    box-shadow: none;
}

.side-brand strong,
.side-brand span {
    display: block;
}

.side-brand span {
    margin-top: 3px;
    color: #b7c2d0;
    font-size: 12px;
}

.side-nav nav {
    display: grid;
    gap: 4px;
    margin-top: 12px;
}

.side-nav a {
    display: block;
    padding: 9px 10px;
    color: #d8e0eb;
    text-decoration: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 650;
}

.nav-export {
    color: #d8e0eb;
}

.nav-export summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 10px;
    color: #d8e0eb;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 650;
    list-style: none;
}

.nav-export summary::-webkit-details-marker {
    display: none;
}

.nav-export:not([open]) > :not(summary) {
    display: none;
}

.nav-export .chevron {
    color: #9fb1c5;
    font-size: 11px;
    line-height: 1;
    transition: transform 0.15s ease;
}

.nav-export[open] .chevron {
    transform: rotate(180deg);
}

.nav-export[open] summary,
.nav-export summary:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.side-nav .nav-export a {
    margin: 4px 0 0 12px;
    padding: 8px 10px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.06);
}

.nav-add-client-form {
    display: grid;
    gap: 8px;
    margin: 6px 0 0 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 12px;
}

.nav-add-client-form label {
    gap: 4px;
    color: #d8e0eb;
    font-size: 11px;
    font-weight: 750;
}

.nav-add-client-form input {
    width: 100%;
    min-height: 32px;
    padding: 0 9px;
    color: #0f172a;
    background: white;
    border-color: rgba(255, 255, 255, 0.34);
    border-radius: 8px;
    font-size: 12px;
}

.nav-add-client-form button {
    width: 100%;
    min-height: 32px;
    background: #1677c8;
}

.side-nav a.active,
.side-nav a:hover {
    color: white;
    background: #1677c8;
}

.app-main {
    height: 100vh;
    min-width: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 18px;
    color: var(--ink);
    background: white;
    border-bottom: 1px solid rgba(208, 215, 226, 0.85);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset;
}

.topbar p {
    color: var(--muted);
    font-size: 11px;
    margin-bottom: 4px;
}

.topbar h1 {
    font-size: 22px;
    line-height: 1.15;
}

.topbar-client-select {
    display: flex;
    align-items: flex-end;
    min-width: min(430px, 44vw);
}

.topbar-client-select label {
    width: 100%;
    gap: 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.topbar-client-select select {
    min-height: 36px;
    padding: 7px 36px 7px 12px;
    color: #111827;
    background-color: #f9fbff;
    border-color: #cbd5e1;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.dashboard {
    width: min(1500px, calc(100% - 20px));
    margin: 10px auto 36px;
}

.alert,
.table-section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.05);
    overflow: hidden;
}

.alert {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
    padding: 16px;
    border-left: 4px solid var(--accent);
}

.alert h2 {
    font-size: 20px;
}

.power-chip {
    display: inline-block;
    margin: 12px 0 0;
    padding: 6px 9px;
    color: #123828;
    background: var(--accent-soft);
    border: 1px solid #b6dec6;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 750;
}

.alert p:last-child {
    margin: 0;
    line-height: 1.55;
    font-weight: 700;
}

.table-section {
    margin-top: 12px;
}

.sticky-table-section {
    overflow: visible;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.client-page .metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.metric-card {
    min-height: 86px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.045);
}

.metric-card:nth-child(2) {
    border-top-color: var(--orange);
}

.metric-card:nth-child(3) {
    border-top-color: var(--green);
}

.metric-card:nth-child(4) {
    border-top-color: var(--purple);
}

.metric-card span {
    display: block;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.01em;
    font-weight: 800;
    text-transform: uppercase;
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 20px;
    line-height: 1.25;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    align-items: end;
}

.toolbar input,
.toolbar select {
    min-width: 190px;
}

.history-filter label {
    min-width: 160px;
}

.empty-state {
    padding: 28px;
    color: var(--muted);
}

.empty-state h3 {
    margin: 0 0 8px;
    color: var(--ink);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 9px;
    color: #334155;
    background: #eef2f7;
    border: 1px solid #d7dee8;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.status-ok {
    color: #0f5132;
    background: #dff5e8;
    border-color: #a9ddbf;
}

.status-wait {
    color: #7a4b00;
    background: #fff2d6;
    border-color: #f0cc88;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
}

.section-heading h2 {
    font-size: 18px;
}

.table-wrap {
    overflow-x: auto;
}

.sticky-table-wrap {
    max-height: none;
    overflow: visible;
    position: relative;
}

.sticky-table-wrap table {
    border-collapse: separate;
    border-spacing: 0;
}

table {
    width: 100%;
    min-width: 1040px;
    border-collapse: collapse;
    background: white;
    font-size: 12px;
}

th,
td {
    border: 1px solid #4d5562;
    padding: 5px 7px;
    text-align: center;
    white-space: nowrap;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 12;
    color: white;
    background: #2f3b4b;
    font-size: 11px;
    box-shadow: 0 1px 0 #4d5562, 0 6px 12px rgba(16, 24, 40, 0.10);
}

.admin-table thead th,
.client-page thead th {
    top: 0;
}

thead th span {
    color: #3a5d3e;
    font-size: 10px;
}

.observe {
    background: var(--accent-soft);
    color: #0c4f84;
    font-weight: 800;
}

.summary th {
    text-align: right;
}

.summary-total {
    font-weight: 800;
}

.summary-max {
    background: #e5effb;
}

.summary-average {
    background: #e8f5df;
}

.summary-low {
    background: #f0f0f0;
}

.admin-dashboard {
    width: min(1540px, calc(100% - 20px));
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(260px, 320px) 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.admin-card,
.admin-fields {
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.045);
}

.admin-card h2 {
    margin-bottom: 12px;
    font-size: 17px;
}

.admin-inline {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(190px, 1fr) minmax(150px, 1fr) auto;
    gap: 10px;
    align-items: end;
}

.compact-admin-grid {
    grid-template-columns: minmax(250px, 320px) 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.compact-card,
.compact-fields {
    padding: 10px 12px;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(16, 24, 40, 0.035);
}

.compact-card h2 {
    margin-bottom: 8px;
    font-size: 15px;
}

.compact-card label,
.compact-form-grid label,
.message-field {
    font-size: 11px;
    font-weight: 800;
}

.compact-card input,
.compact-card select,
.compact-form-grid input {
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
}

.compact-card button {
    min-height: 32px;
    padding: 0 14px;
    border-radius: 8px;
}

.add-client-card {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 12px;
    align-items: center;
}

.add-client-card h2 {
    margin: 0;
}

.add-client-card .admin-inline {
    grid-template-columns: minmax(130px, 1fr) minmax(180px, 1fr) minmax(130px, 1fr) auto;
    gap: 8px;
}

.compact-heading {
    min-height: auto;
    padding: 2px 6px 8px;
}

.compact-heading h2 {
    font-size: 17px;
}

.compact-form-grid {
    grid-template-columns: repeat(6, minmax(118px, 1fr));
    gap: 0;
    padding: 0;
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
}

.compact-form-grid label {
    display: grid;
    gap: 5px;
    min-width: 0;
    padding: 8px 10px;
    background: #ffffff;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.compact-form-grid input {
    width: 100%;
    min-width: 0;
}

.compact-fields .message-field {
    display: grid;
    gap: 6px;
    padding: 8px 10px 0;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-left: 1px solid var(--line);
    background: #ffffff;
}

.compact-fields .message-field textarea {
    min-height: 64px;
    border-radius: 8px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 10px 14px;
    padding: 14px 18px;
}

.message-field {
    padding: 0 18px 14px;
}

.admin-table input {
    width: 100%;
    min-width: 78px;
    min-height: 30px;
    padding: 5px 7px;
    text-align: center;
    border: 1px solid #bac3d1;
    font-size: 11px;
    border-radius: 4px;
}

.admin-table input[readonly] {
    color: #0c4f84;
    background: #edf6ff;
    font-weight: 800;
}

.admin-table td {
    padding: 3px;
}

.admin-table td:last-child input {
    min-width: 180px;
    text-align: left;
}

.publish-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 12px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(18px);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 -8px 24px rgba(16, 24, 40, 0.10);
}

.publish-bar strong,
.publish-bar span {
    display: block;
}

.publish-bar span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

@supports (backdrop-filter: blur(18px)) {
    .topbar,
    .metric-card,
    .admin-card,
    .admin-fields,
    .table-section,
    .alert {
        backdrop-filter: blur(18px);
    }
}

.overview-table {
    min-width: 1220px;
}

.overview-table td,
.overview-table th {
    border-color: #d4dbe7;
}

.overview-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.overview-table tbody tr:hover {
    background: #eef6ff;
}

.history-scroll-wrap {
    max-height: none;
    overflow-x: auto;
}

.history-scroll-wrap.history-scroll-active {
    max-height: 590px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.history-scroll-wrap.history-scroll-active thead th {
    position: sticky;
    top: 0;
    z-index: 4;
}

.history-row-hidden {
    display: none !important;
}

.client-history-table {
    min-width: 1120px;
}

.selected-history-row {
    background: #eaf4ff !important;
}

.selected-history-row td:first-child {
    color: #0c4f84;
    font-weight: 900;
}

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

.actions-cell {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.actions-cell a {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 9px;
    color: #0c4f84;
    background: #edf6ff;
    border: 1px solid #badcff;
    border-radius: 5px;
    font-weight: 800;
    text-decoration: none;
}

.export-choice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 24px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.05);
}

.export-choice h2 {
    margin: 4px 0 8px;
    font-size: 22px;
}

.export-choice p:last-child {
    margin: 0;
    color: var(--muted);
    font-weight: 700;
}

.export-choice-actions {
    display: flex;
    gap: 12px;
}

.export-choice-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    min-height: 46px;
    padding: 0 18px;
    color: white;
    background: #1677c8;
    border-radius: 8px;
    font-weight: 850;
    text-decoration: none;
}

.export-choice-actions a:last-child {
    background: #2f3b4b;
}

@media (max-width: 760px) {
    .app-page {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .app-main {
        height: auto;
        overflow: visible;
    }

    .side-nav {
        position: static;
        height: auto;
    }

    .side-nav nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .login-shell {
        grid-template-columns: 1fr;
    }

    .notice-panel {
        min-height: 250px;
    }

    .alert {
        grid-template-columns: 1fr;
    }

    .topbar,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-client-select {
        width: 100%;
        min-width: 0;
    }

    .admin-grid,
    .admin-inline,
    .compact-admin-grid,
    .add-client-card,
    .add-client-card .admin-inline,
    .metric-grid,
    .client-page .metric-grid,
    .compact-form-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .toolbar,
    .publish-bar,
    .export-choice,
    .export-choice-actions {
        align-items: stretch;
        flex-direction: column;
    }
}

@media print {
    @page {
        size: A4 landscape;
        margin: 8mm;
    }

    html,
    body {
        background: white;
        height: auto;
        overflow: visible;
    }

    .app-page {
        display: block;
        height: auto;
        overflow: visible;
    }

    .app-main {
        height: auto;
        overflow: visible;
    }

    .side-nav,
    .topbar,
    .section-heading button,
    .logout {
        display: none;
    }

    .dashboard {
        width: 100%;
        margin: 0;
    }

    table {
        min-width: 0;
        font-size: 9px;
    }

    th,
    td {
        padding: 3px 4px;
    }

    .alert,
    .table-section {
        border: 0;
    }
}
