:root {
    color-scheme: light;
    --dark-brown: #48392e;
    --brown: #8f6d4a;
    --light-brown: #d8bf9f;
    --beige: #ebded4;
    --background: #fffaf0;
    --bg: var(--background);
    --card: #fffdf8;
    --card-soft: #f7eee3;
    --text: var(--dark-brown);
    --muted: #75685d;
    --primary: #8f6d4a;
    --primary-dark: #62472f;
    --accent: #c5943f;
    --green: #55745c;
    --red: #a64b3c;
    --border: #dfcfbd;
    --focus: rgba(197, 148, 63, .28);
    --shadow: 0 14px 38px rgba(72, 57, 46, .08);
}

html[data-theme="light"] {
    color-scheme: light;
}

html[data-theme="dark"] {
    color-scheme: dark;
}

.inline-form {
    display: inline;
}

.plot-legend-swatch {
    width: 12px;
    height: 12px;
    vertical-align: -.08em;
    margin-right: .35rem;
}

[hidden] {
    display: none !important;
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 8% 0%, rgba(216, 191, 159, .22), transparent 28rem),
        var(--bg);
    color: var(--text);
    font-family: Inter, ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.skip-link { position: fixed; left: 1rem; top: 1rem; z-index: 100; padding: .7rem 1rem; border-radius: 10px; background: var(--dark-brown); color: var(--card) !important; transform: translateY(-200%); }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

a {
    color: var(--primary-dark);
    text-underline-offset: .18em;
}

a:hover {
    color: var(--brown);
}

h1,
h2,
h3,
h4 {
    color: var(--dark-brown);
    line-height: 1.18;
    text-wrap: balance;
}

h1 {
    margin: .65em 0 .55em;
    font-size: clamp(2rem, 4vw, 3.15rem);
    letter-spacing: -.045em;
}

h2 {
    margin: .4em 0 .7em;
    font-size: clamp(1.35rem, 2.4vw, 2rem);
    letter-spacing: -.025em;
}

h3 {
    margin: 1.2em 0 .55em;
}

p {
    margin: .6em 0 1em;
}

.top {
    position: sticky;
    top: 0;
    z-index: 5;
    background: rgba(255, 250, 240, .92);
    border-bottom: 1px solid rgba(143, 109, 74, .2);
    box-shadow: 0 4px 20px rgba(72, 57, 46, .04);
    backdrop-filter: blur(14px);
}

.nav {
    max-width: 1180px;
    min-height: 74px;
    margin: auto;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    color: var(--dark-brown) !important;
    font-size: 21px;
    font-weight: 900;
    letter-spacing: -.04em;
    text-decoration: none;
}

.brand img {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    box-shadow: 0 4px 12px rgba(72, 57, 46, .16);
}

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

.nav a {
    text-decoration: none;
}

.navlinks a {
    padding: 9px 11px;
    border-radius: 11px;
    color: var(--text);
    font-weight: 650;
}

.navlinks a:hover {
    background: var(--beige);
    color: var(--dark-brown);
}

.spacer {
    flex: 1;
}

.wrap {
    width: min(100% - 36px, 1180px);
    min-height: calc(100vh - 160px);
    margin: 0 auto;
    padding: 34px 0 48px;
}

.card {
    margin-bottom: 20px;
    padding: clamp(18px, 3vw, 26px);
    background: rgba(255, 253, 248, .96);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.card> :first-child {
    margin-top: 0;
}

.card> :last-child {
    margin-bottom: 0;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.grid2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    align-items: stretch;
}

.btn {
    display: inline-flex;
    min-height: 46px;
    min-width: 112px;
    padding: 10px 18px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: var(--primary);
    color: #fffdf8 !important;
    font: inherit;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}

.btn:hover {
    transform: translateY(-1px);
    background: var(--primary-dark);
    box-shadow: 0 8px 18px rgba(72, 57, 46, .16);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn.secondary {
    border-color: var(--border);
    background: var(--card-soft);
    color: var(--dark-brown) !important;
}

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

.btn.green {
    background: var(--green);
}

.btn.green:hover {
    background: #405e47;
}

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

.btn.danger:hover {
    background: #84392f;
}

.btn.small {
    min-height: 38px;
    min-width: 0;
    padding: 7px 12px;
    border-radius: 10px;
    font-size: 13px;
}

.pill {
    display: inline-flex;
    padding: 6px 11px;
    align-items: center;
    border: 1px solid #ddc9ae;
    border-radius: 999px;
    background: #f3e6d5;
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 800;
}

.pill.green {
    border-color: #c7d6c8;
    background: #edf3eb;
    color: #405e47;
}

.pill.red {
    border-color: #e5c1b9;
    background: #fbede9;
    color: #84392f;
}

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

.form {
    display: grid;
    gap: 14px;
}

.grid>.form,
.grid2>.form {
    height: 100%;
}

.grid>.form>.btn:last-child,
.grid2>.form>.btn:last-child {
    width: 100%;
    margin-top: auto;
}

label {
    color: var(--dark-brown);
    font-weight: 720;
}

label>input,
label>textarea,
label>select {
    margin-top: 6px;
}

input,
textarea,
select {
    width: 100%;
    min-height: 46px;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 11px;
    outline: none;
    background: #fffefb;
    color: var(--text);
    font: inherit;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

input:hover,
textarea:hover,
select:hover {
    border-color: var(--light-brown);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--focus);
    background: #fff;
}

input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    min-height: 18px;
    accent-color: var(--primary);
}

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

.table th,
.table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.table th {
    color: var(--primary-dark);
    background: #f7eee3;
    font-size: 13px;
    letter-spacing: .025em;
}

.table tr:first-child th:first-child {
    border-radius: 10px 0 0 0;
}

.table tr:first-child th:last-child {
    border-radius: 0 10px 0 0;
}

.table tbody tr:hover,
.table tr:hover td {
    background: rgba(235, 222, 212, .24);
}

.notice {
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 12px;
    background: var(--card);
}

.notice.success {
    border-color: #bfd0bf;
    border-left-color: var(--green);
    background: #f3f7f0;
}

.notice.error {
    border-color: #e5c1b9;
    border-left-color: var(--red);
    background: #fbefeb;
}

.choice {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 8px 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #fffefb;
    font-weight: 600;
}

.choice input {
    flex: 0 0 auto;
    margin-top: 3px;
}

.footer {
    padding: 32px 18px 40px;
    border-top: 1px solid rgba(143, 109, 74, .14);
    color: var(--muted);
    text-align: center;
}

.footer a {
    color: inherit;
}

.row,
.bulk-actions,
.bulk-actions form,
.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.bulk-actions {
    margin: 12px 0;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    margin-top: 16px;
}

.pagination-status {
    color: var(--muted);
    font-weight: 700;
}

.select-column {
    width: 2.6rem;
    text-align: center !important;
}

.code {
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #f8f1e8;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    white-space: pre-wrap;
}

.trash-table .pill {
    white-space: nowrap;
}

.credentials-box code {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 7px;
    background: #fff;
    font-size: 16px;
    user-select: all;
}

.credentials-box h2 {
    margin-top: 0;
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}

@media (max-width: 760px) {
    .nav {
        min-height: 0;
        align-items: center;
        flex-wrap: wrap;
    }

    .brand {
        margin-right: auto;
    }

    .navlinks {
        width: 100%;
        order: 3;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 2px;
    }

    .navlinks a {
        white-space: nowrap;
    }

    .spacer {
        display: none;
    }

    .wrap {
        width: min(100% - 24px, 1180px);
        padding-top: 24px;
    }

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

    .card {
        border-radius: 16px;
    }

    .table,
    .trash-table {
        display: block;
        overflow-x: auto;
    }
}

/* Thème sombre : surfaces chaudes et contrastes doux, sans noir absolu. */
html[data-theme="dark"] {
    --dark-brown: #f1dfca;
    --brown: #c9a578;
    --light-brown: #715a46;
    --beige: #3b2f27;
    --background: #181411;
    --bg: var(--background);
    --card: #241e1a;
    --card-soft: #302720;
    --text: #eee2d4;
    --muted: #bcae9f;
    --primary: #a98258;
    --primary-dark: #d8b98f;
    --accent: #d4a64f;
    --green: #78937b;
    --red: #c76b5b;
    --border: #4a3c32;
    --focus: rgba(212, 166, 79, .32);
    --shadow: 0 16px 42px rgba(0, 0, 0, .24);
}

html[data-theme="dark"] body {
    background: radial-gradient(circle at 8% 0%, rgba(143, 109, 74, .14), transparent 28rem), var(--bg);
}

html[data-theme="dark"] .top {
    background: rgba(24, 20, 17, .92);
    border-bottom-color: var(--border);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .notice,
html[data-theme="dark"] .choice {
    background: var(--card);
}

html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    background: #201a17;
    color: var(--text);
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] select:focus {
    background: #29211c;
}

html[data-theme="dark"] .table th {
    background: #302720;
    color: var(--primary-dark);
}

html[data-theme="dark"] .table tbody tr:hover,
html[data-theme="dark"] .table tr:hover td {
    background: rgba(216, 191, 159, .07);
}

html[data-theme="dark"] .notice.success {
    background: #202a22;
    border-color: #465b49;
}

html[data-theme="dark"] .notice.error {
    background: #30201d;
    border-color: #6b4039;
}

html[data-theme="dark"] .code,
html[data-theme="dark"] .credentials-box code {
    background: #1b1714;
    color: var(--text);
}

html[data-theme="dark"] .pill {
    background: #392d24;
    border-color: #5a4737;
    color: #e5c89e;
}

html[data-theme="dark"] .pill.green {
    background: #263228;
    border-color: #455a48;
    color: #bdd0be;
}

html[data-theme="dark"] .pill.red {
    background: #38231f;
    border-color: #684139;
    color: #edb2a7;
}

.theme-toggle {
    display: inline-grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card-soft);
    color: var(--text);
    font: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: transform .16s ease, background .16s ease, border-color .16s ease;
}

.theme-toggle:hover {
    transform: translateY(-1px);
    background: var(--beige);
    border-color: var(--light-brown);
}

.logout-form {
    display: inline-flex;
    margin: 0;
}
