:root[data-theme="dark"] {
    --bg: #1b1d22;
    --bg-elevated: #23262d;
    --bg-hover: #2c2f38;
    --border: #33363f;
    --text: #e4e5ea;
    --text-muted: #8b8f9c;
    --accent: #6f8bff;
    --accent-contrast: #10121a;
    --danger: #e5675f;
    --success: #6fcf7a;
    --code-bg: #14161b;
}

:root[data-theme="light"] {
    --bg: #f7f7f5;
    --bg-elevated: #ffffff;
    --bg-hover: #ececea;
    --border: #dcdcd8;
    --text: #1e1f22;
    --text-muted: #6a6d78;
    --accent: #3955d8;
    --accent-contrast: #ffffff;
    --danger: #c53a32;
    --success: #2e7d32;
    --code-bg: #eeeeec;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ---------- Login ---------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2.5rem;
    width: 100%;
    max-width: 360px;
}
.login-card h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.login-card .subtitle { margin: 0 0 1.5rem; color: var(--text-muted); font-size: 0.9rem; }
.login-card form { display: flex; flex-direction: column; gap: 0.4rem; }
.login-card label { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; }
.login-card input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 0.55rem 0.7rem;
    font-size: 0.95rem;
}
.login-card input:focus, button:focus-visible, textarea:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.login-card button, .btn-primary {
    margin-top: 1.2rem;
    background: var(--accent);
    color: var(--accent-contrast);
    border: none;
    border-radius: 6px;
    padding: 0.6rem;
    font-size: 0.95rem;
    cursor: pointer;
}
.login-card .error, .error {
    background: rgba(229, 103, 95, 0.15);
    color: var(--danger);
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    font-size: 0.85rem;
}
.login-card .hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0.3rem 0 0;
}

/* ---------- Coquille applicative ---------- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.5rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}
.app-header h1 { font-size: 1.2rem; margin: 0; }
.app-header nav { display: flex; gap: 1rem; align-items: center; }
.app-header a { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; }
.app-header a:hover, .app-header a.active { color: var(--text); }
.app-main { padding: 1.5rem; max-width: 900px; margin: 0 auto; }

.btn-small {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    cursor: pointer;
}
.btn-small:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: white; border-color: transparent; }
.btn-ghost { background: transparent; }

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

table.data-table { width: 100%; border-collapse: collapse; }
table.data-table th, table.data-table td {
    text-align: left;
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
table.data-table th { color: var(--text-muted); font-weight: 600; }

.tree-empty { color: var(--text-muted); font-size: 0.9rem; }
.status-line { padding: 0.6rem 1.5rem; font-size: 0.85rem; color: var(--text-muted); min-height: 1.2rem; }

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px;
    padding: 1.5rem; max-width: 460px; width: 100%; max-height: 85vh; overflow-y: auto;
}
.modal-box h2 { margin-top: 0; font-size: 1.1rem; }
.modal-form {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.modal-form label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.7rem;
}
.modal-form label:first-child { margin-top: 0; }
.modal-form input[type="text"],
.modal-form input[type="password"],
.modal-form input[type="date"],
.modal-form input[type="file"] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 0.55rem 0.7rem;
    font-size: 0.95rem;
    width: 100%;
}
.modal-form input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.modal-form .radio-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.7rem;
    color: var(--text);
    font-size: 0.9rem;
}
.modal-form .radio-line input[type="radio"] { width: auto; margin: 0; }
.modal-form button {
    margin-top: 1.2rem;
    align-self: flex-start;
}

/* ---------- Bascule de thème ---------- */
.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1.1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover { background: var(--bg-hover); }
