:root {
    --bg-dark: #121417;
    --bg-card: #1c1f24;
    --bg-sidebar: #0a0c0e;
    --acc-primary: #00d2ff;
    --acc-success: #2ecc71;
    --acc-warning: #f39c12;
    --acc-danger: #e74c3c;
    --text-main: #e0e0e0;
    --text-muted: #888;
    --border-metal: #343a40;
    --card-shadow: 0 10px 30px rgba(0,0,0,0.5);
    --concitoyen-bg: #1a3a2a;
    --pnj-bg: #2a1a3a;
    --quota-bg: #2a2a1a;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; background: var(--bg-dark); color: var(--text-main); overflow: hidden; height: 100vh; }
.app-container { display: flex; height: 100%; }

/* ── LOGIN ───────────────────────── */
.login-overlay { position: fixed; top:0; left:0; right:0; bottom:0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 3000; }
.login-overlay.hidden { display: none; }
.login-box { background: var(--bg-card); border: 1px solid var(--border-metal); border-radius: 16px; padding: 2.5rem; width: 350px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.login-box h2 { margin-bottom: .5rem; }
.login-box p { color: var(--text-muted); margin-bottom: 1.5rem; font-size: .9rem; }
.login-box input { width: 100%; padding: .75rem; background: #0d1117; border: 1px solid var(--border-metal); color: #fff; border-radius: 8px; margin-bottom: .8rem; font-size: .95rem; text-align: center; }
.login-box input:focus { border-color: var(--acc-primary); outline: none; }
.login-box button { width: 100%; margin-top: .5rem; }
.login-error { color: var(--acc-danger); font-size: .85rem; margin-top: .5rem; }
.login-error.hidden { display: none; }

/* ── SIDEBAR ────────────────────── */
.sidebar { width: 240px; min-width: 240px; background: var(--bg-sidebar); border-right: 1px solid var(--border-metal); display: flex; flex-direction: column; padding: 1.5rem 0; }
.logo { padding: 0 1.5rem 1.5rem; display: flex; align-items: center; gap: .8rem; }
.logo .icon { font-size: 1.8rem; }
.logo h1 { font-size: 1rem; letter-spacing: 2px; font-weight: 700; background: linear-gradient(to right,#fff,#888); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.nav-links { list-style: none; flex-grow: 1; }
.nav-links li { padding: .85rem 1.5rem; cursor: pointer; transition: all .3s; display: flex; align-items: center; gap: .8rem; color: var(--text-muted); border-left: 4px solid transparent; font-size: .9rem; }
.nav-links li:hover, .nav-links li.active { color: var(--acc-primary); background: rgba(0,210,255,.05); border-left-color: var(--acc-primary); }
.sidebar-footer { padding: 1rem 1.5rem; display: flex; flex-direction: column; gap: .5rem; }

/* ── CONTENT ────────────────────── */
.content { flex-grow: 1; padding: 1.5rem; overflow-y: auto; background: radial-gradient(circle at top right,#1a1e23,#121417); }
.page { display: none; }
.page.active { display: block; animation: fadeIn .4s ease-out; }
@keyframes fadeIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
.header { margin-bottom: 1.5rem; }
.header h2 { font-size: 1.5rem; margin-bottom: .25rem; }
.header p { color: var(--text-muted); font-size: .9rem; }

/* ── CARDS ───────────────────────── */
.card { background: var(--bg-card); border: 1px solid var(--border-metal); border-radius: 12px; padding: 1.5rem; box-shadow: var(--card-shadow); margin-bottom: 1.25rem; }
.card-title { margin-bottom: 1rem; font-size: 1rem; }
.info-card { background: rgba(0,210,255,.04); border-color: rgba(0,210,255,.2); }
.info-card ul { list-style: none; margin-top: .5rem; }
.info-card li { margin-bottom: .2rem; color: var(--text-muted); font-size: .85rem; }
.info-card li::before { content: "• "; color: var(--acc-primary); }

/* ── FORM ────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 1.2rem; }
.params-grid { grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); }
.input-group { display: flex; flex-direction: column; gap: .4rem; }
.input-group label { font-size: .7rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.required { color: var(--acc-danger); }
.input-group input, .input-group select { background: #0d1117; border: 1px solid var(--border-metal); color: #fff; padding: .65rem; border-radius: 6px; font-size: .9rem; outline: none; transition: border-color .3s; font-family: 'Inter',sans-serif; }
.input-group input:focus, .input-group select:focus { border-color: var(--acc-primary); }
.input-group input[readonly] { background: #0a0c0e; color: #666; cursor: not-allowed; }
.highlight { background: rgba(0,210,255,.05); padding: .8rem; border-radius: 8px; }
.price-badge { font-family: 'Courier New',monospace; font-size: 1.1rem; background: #000; padding: .4rem .8rem; border-radius: 4px; color: var(--acc-success); border: 1px solid #333; }
.price-badge.large { font-size: 1.5rem; font-weight: 700; }

/* ── BUTTONS ─────────────────────── */
.actions { margin-top: 1.5rem; display: flex; gap: .8rem; flex-wrap: wrap; }
button { padding: .65rem 1.2rem; border-radius: 8px; border: none; font-weight: 700; cursor: pointer; transition: transform .2s,background .3s; text-transform: uppercase; letter-spacing: 1px; font-size: .8rem; font-family: 'Inter',sans-serif; }
button:active { transform: scale(.97); }
.btn-success { background: var(--acc-success); color: #000; }
.btn-success:hover { background: #27ae60; }
.btn-warning { background: var(--acc-warning); color: #000; }
.btn-danger { background: var(--acc-danger); color: #fff; }
.btn-sm { padding: .35rem .6rem; font-size: .7rem; }

/* ── TABLE ───────────────────────── */
.table-container { overflow-x: auto; margin-top: .5rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border-metal); white-space: nowrap; font-size: .85rem; }
th { color: var(--text-muted); font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; }
tbody tr:hover { background: rgba(255,255,255,.02); }
.empty-msg { text-align: center; color: #555; padding: 2rem !important; }

/* Row colors */
.row-concitoyen { background: var(--concitoyen-bg) !important; }
.row-pnj { background: var(--pnj-bg) !important; }
.row-quota { background: var(--quota-bg) !important; }
.type-badge { padding: .2rem .5rem; border-radius: 4px; font-size: .7rem; font-weight: 700; }
.type-concitoyen { background: #27ae6033; color: #2ecc71; }
.type-pnj { background: #9b59b633; color: #a569bd; }
.type-quota { background: #f39c1233; color: #f1c40f; }

.green { color: #2ecc71; }
.purple { color: #a569bd; }
.yellow { color: #f1c40f; }
.red { color: #e74c3c; }
.orange { color: #f39c12; }

/* ── SUMMARY ROW ────────────────── */
.summary-row { display: flex; flex-wrap: wrap; gap: .8rem; justify-content: space-between; }
.summary-cell { display: flex; flex-direction: column; align-items: center; gap: .2rem; min-width: 90px; padding: .6rem; border-radius: 8px; background: rgba(255,255,255,.02); border: 1px solid var(--border-metal); }
.summary-cell.highlight-cell { background: rgba(0,210,255,.08); border-color: rgba(0,210,255,.3); }
.summary-label { font-size: .6rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); font-weight: 600; }
.summary-value { font-size: 1rem; font-weight: 700; font-family: 'Courier New',monospace; }
.summary-value.big { font-size: 1.3rem; }
.summary-value.green { color: #2ecc71; }
.summary-value.purple { color: #a569bd; }
.summary-value.red { color: #e74c3c; }
.summary-value.orange { color: #f39c12; }

/* ── LEGEND ──────────────────────── */
.legend-bar { display: flex; gap: 1.5rem; flex-wrap: wrap; padding: .6rem 1rem; margin-bottom: 1rem; background: rgba(255,255,255,.03); border-radius: 6px; font-size: .75rem; color: var(--text-muted); }
.legend-item { display: flex; align-items: center; gap: .4rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.green-dot { background: #2ecc71; }
.purple-dot { background: #a569bd; }
.yellow-dot { background: #f1c40f; }
.blue-dot { background: #3498db; }

/* ── INLINE INPUTS ──────────────── */
.cell-input { background: #0d1117; border: 1px solid var(--border-metal); color: #fff; padding: .25rem .4rem; border-radius: 4px; width: 85px; font-size: .8rem; text-align: right; font-family: 'Courier New',monospace; }
.cell-input:focus { border-color: var(--acc-primary); outline: none; }
.checkbox-cell { text-align: center; }
.checkbox-cell input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--acc-primary); }

/* ── QUOTA CHECKBOXES (GREEN when checked) ── */
.checkbox-cell.cell-quota-ok {
    background: rgba(46, 204, 113, 0.2);
    box-shadow: inset 0 0 10px rgba(46, 204, 113, 0.3);
}
.checkbox-cell input[type="checkbox"].quota-ok {
    accent-color: #2ecc71;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.8);
    transform: scale(1.2);
}
.checkbox-cell input[type="checkbox"].quota-ok + *,
.checkbox-cell input[type="checkbox"].quota-ok {
    filter: brightness(1.2);
}

/* ── SIMULATEUR ─────────────────── */
.sim-input-wrap { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.sim-big-input { width: 120px; font-size: 1.5rem !important; text-align: center; padding: .5rem !important; font-weight: 700; color: #f1c40f !important; background: #0a0c0e !important; border: 2px solid #f1c40f !important; border-radius: 8px; }
.sim-craft-label { display: flex; align-items: center; gap: .5rem; color: var(--text-muted); font-size: .85rem; cursor: pointer; }
.sim-results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.sim-table { width: 100%; }
.sim-table td { padding: .6rem .75rem; border-bottom: 1px solid var(--border-metal); font-size: .9rem; }
.sim-per { color: var(--text-muted); font-size: .8rem; text-align: right; }
.sim-total { text-align: right; font-weight: 700; font-family: 'Courier New',monospace; }
.sim-total.green { color: #2ecc71; }
.sim-total.red { color: #e74c3c; }
.sim-total.big { font-size: 1.2rem; }
.sim-total-row { border-top: 2px solid var(--acc-primary); }

/* ── ARCHIVES ───────────────────── */
.archive-card { border-left: 4px solid var(--acc-primary); }
.archive-detail { margin-top: 1rem; padding-top: .5rem; border-top: 1px solid var(--border-metal); }
.archive-detail.hidden { display: none; }

/* ── NOTIFICATIONS ──────────────── */
#notifications { position: fixed; top: 20px; right: 20px; z-index: 1000; max-width: 400px; }
.notification { background: var(--bg-card); border-left: 4px solid var(--acc-primary); padding: .8rem 1.2rem; margin-bottom: .5rem; border-radius: 4px; box-shadow: 0 5px 15px rgba(0,0,0,.3); color: #fff; min-width: 280px; transition: opacity .5s; animation: slideIn .3s ease-out; font-size: .85rem; line-height: 1.4; }
.notification.success { border-color: var(--acc-success); }
.notification.danger { border-color: var(--acc-danger); }
.notification.info { border-color: var(--acc-primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity:0; } to { transform: translateX(0); opacity:1; } }

/* ── MODAL ───────────────────────── */
.modal-overlay { position: fixed; top:0; left:0; right:0; bottom:0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 2000; }
.modal-overlay.hidden { display: none; }
.modal { background: var(--bg-card); border: 1px solid var(--border-metal); border-radius: 12px; padding: 1.5rem; max-width: 450px; width: 90%; }
.modal h3 { margin-bottom: .8rem; }
.modal p { color: var(--text-muted); margin-bottom: .8rem; white-space: pre-line; }
.modal input { width: 100%; padding: .6rem; background: #0d1117; border: 1px solid var(--border-metal); color: #fff; border-radius: 6px; margin-bottom: .8rem; font-size: .9rem; }
.modal-actions { display: flex; gap: .8rem; justify-content: flex-end; }
.hidden { display: none !important; }
