:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #667085;
    --border: #e2e5ea;
    --accent: #3b5bdb;
    --accent-text: #ffffff;
    --ok-bg: #e6f6ec;
    --ok-text: #18794e;
    --error-bg: #fdecec;
    --error-text: #b42318;
    --wait-bg: #fff4e0;
    --wait-text: #9a5b00;
    --info-bg: #eef2ff;
    --info-text: #3b4cc0;
    --radius: 10px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151b;
        --surface: #1b2029;
        --text: #e6e9ef;
        --muted: #98a2b3;
        --border: #2c3340;
        --accent: #6b8cff;
        --accent-text: #0b1020;
        --ok-bg: #12301f;
        --ok-text: #6fd19a;
        --error-bg: #3a1717;
        --error-text: #ff8a80;
        --wait-bg: #33260d;
        --wait-text: #f5b84d;
        --info-bg: #1d2547;
        --info-text: #a9b8ff;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
code, pre { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
pre { background: var(--bg); padding: .75rem 1rem; border-radius: 6px; overflow-x: auto; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 0; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar nav { display: flex; align-items: center; gap: 1rem; }
.brand { font-weight: 600; color: var(--text); text-decoration: none; }

.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}
.card.narrow { max-width: 640px; }
.card.login { margin: 3rem auto; max-width: 420px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; align-items: start; }
.grid-cards .card { margin-bottom: 0; }
.card-head, .page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.muted { color: var(--muted); margin: .25rem 0 0; }
.small { font-size: .875rem; margin-top: 1rem; }

.button {
    display: inline-block;
    border: 0;
    border-radius: 8px;
    padding: .55rem 1rem;
    background: var(--accent);
    color: var(--accent-text);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.button:disabled { opacity: .45; cursor: not-allowed; }
.button-small { padding: .35rem .75rem; font-size: .875rem; }
.button-secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.button-danger { background: var(--error-text); color: #fff; }
.button-secondary-danger { background: transparent; color: var(--error-text); border: 1px solid var(--error-text); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.row-actions { display: flex; gap: .75rem; align-items: center; white-space: nowrap; }
.row-actions form { display: inline; margin: 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
.danger-link { color: var(--error-text); }
.small-inline { font-size: .8rem; }
.form-section { font-size: 1rem; margin: 1.5rem 0 .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.advanced { margin: 0 0 1.25rem; }
.advanced summary { cursor: pointer; color: var(--muted); margin-bottom: .75rem; }
input:disabled, select:disabled { opacity: .6; }
.card.danger { border-color: var(--error-text); }
.notice { background: var(--wait-bg); color: var(--wait-text); padding: .75rem 1rem; border-radius: 8px; }
.import td:first-child, .import th:first-child { width: 2rem; }
.import input[type=checkbox] { width: auto; }
tr.muted td { color: var(--muted); }
.site-list { columns: 2; padding-left: 1.2rem; }

.toolbar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
td.detail { color: var(--muted); font-size: .875rem; max-width: 420px; }

.badge {
    display: inline-block;
    padding: .1rem .55rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
    background: var(--info-bg);
    color: var(--info-text);
}
.badge-ready { background: var(--ok-bg); color: var(--ok-text); }
.badge-error { background: var(--error-bg); color: var(--error-text); }
.badge-busy { background: var(--wait-bg); color: var(--wait-text); }
.badge-pending, .badge-deleted { background: var(--bg); color: var(--muted); }
.badge-deleting { background: var(--error-bg); color: var(--error-text); }
.badge-waiting { background: var(--wait-bg); color: var(--wait-text); }
.badge-bts { background: var(--accent); color: var(--accent-text); font-size: .75rem; vertical-align: middle; }
.bts-box { border: 1px dashed var(--border); border-radius: 8px; padding: .75rem 1rem 0; margin-bottom: 1rem; }
.bts-box input[type=checkbox], label.checkbox input { width: auto; margin-right: .4rem; }
.bts-steps ol { padding-left: 1.2rem; }
.bts-steps li { margin-bottom: .4rem; }
.bts-steps li.done { color: var(--ok-text); }
.bts-steps li.done::marker { content: '✓  '; }
.release { display: flex; flex-direction: column; gap: .75rem; align-items: flex-start; margin-top: 1rem; }
label.checkbox { font-weight: normal; }

.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-error { background: var(--error-bg); color: var(--error-text); }
.flash-success { background: var(--ok-bg); color: var(--ok-text); }

/* Formulaires */
form > div, .grid-2 > div { margin-bottom: 1rem; }
form .button + a { margin-left: 1rem; }
label { display: block; font-weight: 600; margin-bottom: .3rem; }
input, select {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.help-text, form small { display: block; color: var(--muted); font-size: .85rem; margin-top: .25rem; }
ul:has(> li) { padding-left: 1.2rem; }
.invalid-feedback, form ul li { color: var(--error-text); font-size: .875rem; }

@media (max-width: 640px) {
    .container { padding: 1rem; }
    .grid-2 { grid-template-columns: 1fr; }
    .sites th:nth-child(2), .sites td:nth-child(2) { display: none; }
}

@media print {
    .topbar, .no-print, .flash { display: none; }
    body { background: #fff; color: #000; }
    .card { border: 0; padding: 0; }
}
