:root {
    --bg: #1a1a14;
    --card: #242420;
    --card-hover: #2d2d26;
    --border: #3d3d30;
    --border-lt: #4d4d38;
    --text: #f5f0e1;
    --text-dim: #a8a080;
    --olive: #7a7a3a;
    --olive-lt: #9a9a5a;
    --olive-dk: #5a5a2a;
    --cream: #f5f0e1;
    --orange: #d97a2c;
    --orange-lt: #e8a050;
    --orange-dk: #b5641e;
    --green: #5a8a3a;
    --green-lt: #7aa85a;
    --red: #c0442c;
    --red-lt: #e0544c;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    padding: 20px;
    max-width: 900px;
    margin: 0 auto;
}
a { color: var(--orange-lt); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.8em; margin-bottom: 8px; color: var(--olive-lt); }
h2 { font-size: 1.3em; margin-bottom: 12px; color: var(--olive-lt); }
h3 { color: var(--olive-lt); margin-bottom: 12px; }
.subtitle { color: var(--text-dim); margin-bottom: 24px; font-size: 0.95em; }

/* ===== Boutons ===== */
.btn {
    display: inline-block; padding: 10px 20px; border: none; border-radius: 8px;
    font-size: 1em; font-weight: 600; cursor: pointer; transition: all 0.2s;
    font-family: inherit; text-decoration: none; text-align: center;
    border: 2px solid transparent;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--olive); color: var(--cream);
    border: 2px solid var(--olive-lt);
}
.btn-primary:hover { background: var(--olive-lt); border-color: var(--olive-lt); }

.btn-orange {
    background: var(--orange); color: #fff;
    border: 2px solid var(--orange-lt);
}
.btn-orange:hover { background: var(--orange-lt); }

.btn-secondary {
    background: transparent; color: var(--olive-lt);
    border: 2px solid var(--olive);
}
.btn-secondary:hover { background: var(--olive-dk); color: var(--cream); }

.btn-danger {
    background: var(--red); color: #fff;
    border: 2px solid var(--red-lt);
}
.btn-danger:hover { background: var(--red-lt); }

.btn-outline {
    background: transparent; color: var(--text-dim);
    border: 2px solid var(--border-lt);
}
.btn-outline:hover { border-color: var(--olive-lt); color: var(--olive-lt); }

.btn-sm { padding: 6px 14px; font-size: 0.85em; }

/* ===== Barre de progression ===== */
.progress-bar {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 8px; height: 24px; margin-bottom: 24px; overflow: hidden;
}
.progress-fill {
    background: linear-gradient(90deg, var(--olive), var(--orange));
    height: 100%; width: 0%; transition: width 0.4s ease;
    display: flex; align-items: center; justify-content: flex-end;
    padding-right: 10px; font-size: 0.8em; font-weight: 600; color: #fff; min-width: 40px;
}

/* ===== Cartes / sections ===== */
.section {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 12px; margin-bottom: 16px; overflow: hidden;
}
.section-header {
    padding: 14px 18px; font-size: 1.1em; font-weight: 600;
    border-bottom: 1px solid var(--border); display: flex; align-items: center;
    justify-content: space-between; gap: 8px;
}
.section-title { display: flex; align-items: center; gap: 8px; }
.section-total {
    font-size: 0.85em; font-weight: 700; color: var(--green);
    background: rgba(90,138,58,0.15); padding: 4px 12px; border-radius: 6px;
    white-space: nowrap;
}

/* ===== Items (page publique) ===== */
.item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 10px 18px; cursor: pointer; transition: background 0.15s;
}
.item:hover { background: rgba(217,122,44,0.06); }
.item input[type="checkbox"] {
    appearance: none; -webkit-appearance: none;
    width: 22px; height: 22px; border: 2px solid var(--border-lt);
    border-radius: 6px; cursor: pointer; position: relative;
    flex-shrink: 0; margin-top: 2px; transition: all 0.2s;
}
.item input[type="checkbox"]:checked { background: var(--green); border-color: var(--green); }
.item input[type="checkbox"]:checked::after {
    content: '✓'; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); color: #fff; font-size: 14px; font-weight: bold;
}
.item.done .item-text { text-decoration: line-through; color: var(--text-dim); }
.item.done .item-price { opacity: 0.5; }
.item-text { flex: 1; }
.item-label { font-weight: 500; margin-bottom: 2px; }
.item-detail { font-size: 0.85em; color: var(--text-dim); }
.item-price {
    flex-shrink: 0; font-weight: 700; font-size: 1em; color: var(--orange-lt);
    min-width: 70px; text-align: right; margin-top: 2px;
}
.item-qty {
    flex-shrink: 0; font-weight: 600; font-size: 0.9em; color: var(--olive-lt);
    min-width: 50px; text-align: right; margin-top: 2px;
}

/* ===== Total général ===== */
.grand-total {
    background: linear-gradient(135deg, rgba(122,122,58,0.15), rgba(217,122,44,0.1));
    border: 1px solid var(--olive); border-radius: 12px;
    padding: 16px 20px; margin-bottom: 16px;
    display: flex; justify-content: space-between; align-items: center;
}
.grand-total-label { font-size: 1.1em; font-weight: 600; }
.grand-total-value { font-size: 1.4em; font-weight: 800; color: var(--orange); }

/* ===== Formulaires ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--olive-lt); }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%; padding: 10px 14px; background: var(--bg);
    border: 2px solid var(--border); border-radius: 8px;
    color: var(--text); font-size: 1em; font-family: inherit;
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none; border-color: var(--olive-lt);
}
.form-group textarea { resize: vertical; }

.checkbox-label {
    display: flex; align-items: center; gap: 8px;
    font-weight: 400; color: var(--text); font-size: 0.95em;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    appearance: none; -webkit-appearance: none;
    width: 20px; height: 20px; border: 2px solid var(--border-lt);
    border-radius: 5px; cursor: pointer; position: relative;
    flex-shrink: 0; transition: all 0.2s;
}
.checkbox-label input[type="checkbox"]:checked { background: var(--olive); border-color: var(--olive-lt); }
.checkbox-label input[type="checkbox"]:checked::after {
    content: '✓'; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); color: var(--cream); font-size: 12px; font-weight: bold;
}

/* Form inline (ajout colonne etc.) */
.form-inline {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.input-inline {
    flex: 1; min-width: 150px;
    padding: 10px 14px; background: var(--bg);
    border: 2px solid var(--border); border-radius: 8px;
    color: var(--text); font-size: 1em; font-family: inherit;
    transition: border-color 0.2s;
}
.input-inline:focus { outline: none; border-color: var(--olive-lt); }
.select-inline {
    padding: 10px 14px; background: var(--bg);
    border: 2px solid var(--border); border-radius: 8px;
    color: var(--text); font-size: 1em; font-family: inherit;
    cursor: pointer;
}
.select-inline:focus { outline: none; border-color: var(--olive-lt); }

.checkbox-label-inline {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.9em; color: var(--text-dim); cursor: pointer;
    white-space: nowrap;
}
.checkbox-label-inline input[type="checkbox"] {
    appearance: none; -webkit-appearance: none;
    width: 18px; height: 18px; border: 2px solid var(--border-lt);
    border-radius: 5px; cursor: pointer; position: relative;
    flex-shrink: 0;
}
.checkbox-label-inline input[type="checkbox"]:checked { background: var(--olive); border-color: var(--olive-lt); }
.checkbox-label-inline input[type="checkbox"]:checked::after {
    content: '✓'; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); color: var(--cream); font-size: 11px; font-weight: bold;
}

/* ===== Header / nav ===== */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
    flex-wrap: wrap; gap: 12px;
}
.topbar-brand { font-size: 1.2em; font-weight: 700; color: var(--olive-lt); }
.topbar-brand a { color: var(--olive-lt); text-decoration: none; }
.topbar-nav { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ===== Landing page ===== */
.landing-hero { text-align: center; padding: 60px 20px 40px; }
.landing-hero h1 { font-size: 2.5em; color: var(--olive-lt); margin-bottom: 16px; }
.landing-hero p { font-size: 1.2em; color: var(--text-dim); max-width: 600px; margin: 0 auto 32px; }
.landing-features {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px; margin-top: 32px;
}
.feature-card {
    background: var(--card); border: 2px solid var(--border);
    border-radius: 12px; padding: 24px;
    transition: border-color 0.2s;
}
.feature-card:hover { border-color: var(--olive); }
.feature-card h3 { color: var(--orange-lt); margin-bottom: 8px; font-size: 1.1em; }
.feature-card p { color: var(--text-dim); font-size: 0.9em; }

/* Listes publiques sur la landing */
.public-lists { margin-top: 48px; }
.list-link {
    display: block; background: var(--card); border: 2px solid var(--border);
    border-radius: 10px; padding: 14px 18px; margin-bottom: 8px;
    color: var(--text); text-decoration: none; transition: all 0.2s;
}
.list-link:hover { border-color: var(--olive); background: var(--card-hover); text-decoration: none; }
.list-link-title { font-weight: 600; color: var(--orange-lt); }
.list-link-meta { font-size: 0.85em; color: var(--text-dim); margin-top: 4px; }

/* ===== Footer ===== */
.footer {
    margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border);
    text-align: center; color: var(--text-dim); font-size: 0.85em;
}

/* ===== Cartes admin ===== */
.admin-card {
    background: var(--card); border: 2px solid var(--border);
    border-radius: 12px; padding: 20px; margin-bottom: 16px;
}
.admin-card h3 { color: var(--olive-lt); margin-bottom: 16px; font-size: 1.1em; }

.list-item-admin {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px; background: var(--bg); border: 2px solid var(--border);
    border-radius: 10px; margin-bottom: 8px;
    transition: border-color 0.2s;
}
.list-item-admin:hover { border-color: var(--olive-dk); }
.list-item-admin .list-info { flex: 1; }
.list-item-admin .list-info .title { font-weight: 600; color: var(--text); }
.list-item-admin .list-info .title a { color: var(--text); }
.list-item-admin .list-info .title a:hover { color: var(--orange-lt); }
.list-item-admin .list-info .meta { font-size: 0.85em; color: var(--text-dim); margin-top: 4px; }
.list-item-admin .list-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Item partiellement fait */
.item.partial .item-text { color: var(--text); }
.item.partial .item-label { color: var(--orange-lt); }

/* ===== Tableau editable ===== */
.table-wrapper { overflow-x: auto; }
table.data-table {
    width: 100%; border-collapse: collapse; margin-bottom: 16px;
}
table.data-table th {
    background: var(--bg); padding: 10px 14px; text-align: left;
    border-bottom: 2px solid var(--olive-dk); color: var(--olive-lt);
    font-weight: 600; font-size: 0.9em; white-space: nowrap;
}
table.data-table td {
    padding: 8px 14px; border-bottom: 1px solid var(--border);
}
table.data-table tr:hover td { background: rgba(217,122,44,0.04); }

.cell-input, table.data-table input[type="text"], table.data-table input[type="number"] {
    width: 100%; padding: 6px 10px; background: transparent;
    border: 2px solid transparent; border-radius: 6px;
    color: var(--text); font-family: inherit; font-size: 0.95em;
    transition: border-color 0.2s;
}
.cell-input:focus, table.data-table input:focus {
    border-color: var(--olive-lt); background: var(--bg); outline: none;
}

/* Checkbox dans le tableau (mode admin) */
.item-checkbox {
    appearance: none; -webkit-appearance: none;
    width: 22px; height: 22px; border: 2px solid var(--border-lt);
    border-radius: 6px; cursor: pointer; position: relative;
    flex-shrink: 0; transition: all 0.2s;
}
.item-checkbox:checked { background: var(--green); border-color: var(--green-lt); }
.item-checkbox:checked::after {
    content: '✓'; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); color: #fff; font-size: 14px; font-weight: bold;
}

/* ===== Badges ===== */
.badge {
    display: inline-block; font-size: 0.75em; font-weight: 600;
    padding: 2px 8px; border-radius: 4px;
    background: rgba(122,122,58,0.2); color: var(--olive-lt);
    margin-left: 6px;
}

/* ===== Zone d'ajout ===== */
.add-row {
    padding-top: 14px;
    border-top: 1px solid var(--border);
    margin-top: 14px;
}

/* ===== Notifications ===== */
.notification {
    padding: 12px 16px; border-radius: 8px; margin-bottom: 16px;
    border: 2px solid;
}
.notification.success { background: rgba(90,138,58,0.12); border-color: var(--green); color: var(--green-lt); }
.notification.error { background: rgba(192,68,44,0.12); border-color: var(--red); color: var(--red-lt); }

/* ===== Save indicator ===== */
.save-indicator {
    position: fixed; bottom: 20px; right: 20px;
    background: var(--card); border: 2px solid var(--border-lt);
    border-radius: 8px; padding: 8px 14px; font-size: 0.85em;
    color: var(--text-dim); opacity: 0; transition: opacity 0.3s; pointer-events: none;
    z-index: 1000;
}
.save-indicator.show { opacity: 1; }
.save-indicator.saved { color: var(--green-lt); border-color: var(--green); }
.save-indicator.error { color: var(--red-lt); border-color: var(--red); }

/* ===== Responsive ===== */
@media (max-width: 600px) {
    body { padding: 12px; }
    h1 { font-size: 1.4em; }
    .landing-hero h1 { font-size: 1.8em; }
    .item { flex-wrap: wrap; }
    .topbar { flex-direction: column; gap: 12px; }
    .form-inline { flex-direction: column; align-items: stretch; }
    .input-inline, .select-inline { width: 100%; }
    .list-item-admin { flex-direction: column; align-items: flex-start; gap: 10px; }
    .list-item-admin .list-actions { width: 100%; }
}