/* =====================================================================
   SCOOPS-COZAK — STYLE — thème vert foncé, vert #1F5E3E / or #C9A227
   ===================================================================== */

:root {
  --bg: #0A1712;
  --bg2: #0F2018;
  --card: #13251C;
  --card-h: #17301F;
  --border: #234030;
  --border-l: #34593F;
  --text: #EAE6D9;
  --muted: #8AA08A;
  --green: #1F5E3E;
  --green-l: #2F8C5A;
  --green-d: #123322;
  --gold: #C9A227;
  --gold-l: #DDBF4E;
  --blue: #2C7DA0;
  --orange: #D4760A;
  --red: #B3442F;
  --red-tint: #2A1613;
  --radius: 10px;
  --font-display: "Georgia", "DejaVu Serif", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font-body); background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font-family: inherit; font-size: 16px; color: var(--text); }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; margin: 0 0 4px; color: var(--text); }
p { margin: 0 0 6px; color: var(--muted); line-height: 1.45; }

/* ---------- Auth ---------- */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 30% 20%, #163826 0%, var(--bg) 60%); padding: 20px; }
.auth-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 32px 24px; max-width: 380px; width: 100%; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,0.4); }
.auth-logo { width: 64px; height: 64px; border-radius: 16px; background: linear-gradient(135deg, var(--green), var(--green-l)); color: var(--gold); font-family: var(--font-display); font-weight: 700; font-size: 24px; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.auth-card h1 { font-size: 22px; }
.auth-sub { font-size: 13px; margin-bottom: 20px; }
.auth-card form { text-align: left; }
.auth-card label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.auth-card input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; background: var(--bg2); color: var(--text); }
.auth-error { color: #E67E67; font-size: 13px; text-align: center; margin-top: 10px; }
.auth-hint { font-size: 12px; margin-top: 18px; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: var(--radius); border: none; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-primary { background: var(--green-l); color: #06120C; }
.btn-secondary { background: var(--bg2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--red-tint); color: #E8846E; border: 1px solid #4A241D; }
.icon-btn { background: transparent; border: none; font-size: 19px; padding: 8px; cursor: pointer; border-radius: 8px; line-height: 1; color: var(--text); }
.icon-btn.small { font-size: 15px; padding: 3px 5px; }
.icon-btn:active { background: rgba(255,255,255,0.08); }
.only-mobile { display: none; }

/* ---------- Structure générale ---------- */
.shell { min-height: 100vh; display: flex; }
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 270px; background: linear-gradient(180deg, #0B1A12 0%, #0F2216 100%); border-right: 1px solid var(--border); z-index: 100; display: flex; flex-direction: column; }
.sidebar-header { display: flex; align-items: center; gap: 12px; padding: 18px 16px; border-bottom: 1px solid var(--border); }
.sidebar-logo { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--green), var(--green-l)); color: var(--gold); display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; flex-shrink: 0; }
.sidebar-title { font-size: 14.5px; font-weight: 700; }
.sidebar-sub { font-size: 11px; color: var(--muted); }
.sidebar-titles { flex: 1; }
.sidebar-search { padding: 10px 14px; }
.sidebar-search input { width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 13px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 8px; }
.sidebar-footer { padding: 8px; border-top: 1px solid var(--border); }
.cat-label { padding: 14px 10px 6px; font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); opacity: .75; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; padding: 9px 10px; border: none; background: transparent; border-radius: 8px; cursor: pointer; font-size: 13.5px; color: var(--muted); margin-bottom: 1px; }
.nav-item:active, .nav-item.active { background: rgba(47,140,90,0.15); color: var(--gold); font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; min-width: 18px; text-align: center; }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 90; opacity: 0; pointer-events: none; transition: opacity .2s; }
.sidebar-overlay.open { opacity: 1; pointer-events: auto; }

.main-content { margin-left: 270px; flex: 1; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 50; background: rgba(10,23,18,0.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); padding: 0 16px; height: 58px; display: flex; align-items: center; gap: 10px; }
.breadcrumb { font-family: var(--font-display); font-size: 16.5px; font-weight: 700; flex: 1; }
.breadcrumb-sep { color: var(--muted); font-weight: 400; font-size: 13px; }
.page-content { padding: 18px 20px 60px; max-width: 1000px; }

/* ---------- Page header ---------- */
.page-header { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.page-header-icon { font-size: 30px; }
.page-header h2 { font-size: 19px; }
.page-header p { font-size: 13px; }
.section-subtitle { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.kpi-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: left; cursor: pointer; position: relative; overflow: hidden; }
.kpi-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.kpi-card.cg::before { background: var(--green-l); } .kpi-card.ca::before { background: var(--gold); }
.kpi-card.cb::before { background: var(--blue); } .kpi-card.co::before { background: var(--orange); }
.kpi-card.cr::before { background: var(--red); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.kpi-icon { font-size: 18px; }
.kpi-value { font-family: var(--font-display); font-size: 17px; font-weight: 700; line-height: 1.15; color: var(--text); word-break: break-word; }
.kpi-label { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.kpi-trend { font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.kpi-trend.up { color: var(--green-l); background: rgba(47,140,90,0.15); }
.kpi-trend.down { color: #E67E67; background: rgba(179,68,47,0.15); }
.kpi-trend.neutral { color: var(--muted); background: rgba(138,160,138,0.1); }

/* ---------- Graphiques ---------- */
.chart-section { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
.chart-header h3 { font-size: 14px; margin-bottom: 8px; }
.chart-container { width: 100%; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis-label { font-size: 9.5px; fill: var(--muted); font-family: var(--font-body); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend-item i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.chart-legend-label { font-size: 10.5px; fill: var(--text); font-family: var(--font-body); }
.chart-legend-value { font-size: 10.5px; fill: var(--muted); font-family: var(--font-body); font-weight: 700; }
.chart-donut-total { font-size: 17px; font-weight: 700; fill: var(--text); font-family: var(--font-display); }
.chart-donut-sub { font-size: 10px; fill: var(--muted); font-family: var(--font-body); }
.chart-empty { text-align: center; padding: 30px 10px; }
.chart-empty-icon { font-size: 28px; margin-bottom: 6px; opacity: .6; }
.chart-empty p { font-size: 12.5px; margin-bottom: 2px; }
.chart-empty-sub { font-size: 11.5px; opacity: .8; }

/* ---------- Dashboard ---------- */
.dash-hero { background: linear-gradient(135deg, var(--green-d), #17301F 60%, rgba(201,162,39,0.1)); border: 1px solid var(--border); border-radius: 16px; padding: 26px 22px; margin-bottom: 18px; }
.dash-hero h2 { font-size: 22px; }
.dash-hero p { font-size: 13px; }
.dash-charts { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 6px; }
.dash-cat h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
.dash-quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.quick-link { background: var(--card); border: 1px solid var(--border); border-radius: 9px; padding: 12px; cursor: pointer; display: flex; align-items: center; gap: 10px; text-align: left; }
.quick-link:active { border-color: var(--green-l); }
.quick-link-icon { font-size: 17px; }
.quick-link span:last-child { font-size: 12.5px; font-weight: 600; }

/* ---------- Onglets ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.tab { white-space: nowrap; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.tab.active { background: var(--green-l); color: #06120C; border-color: var(--green-l); }

/* ---------- Tableau ---------- */
.table-section { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.table-toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.table-toolbar h3 { font-size: 13.5px; font-weight: 700; }
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.table-actions input { flex: 1; min-width: 120px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg2); font-size: 13px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.data-table { border-collapse: collapse; width: 100%; min-width: 620px; font-size: 12.5px; }
.data-table th { background: var(--bg2); color: var(--muted); text-align: left; padding: 9px 12px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.data-table td { padding: 9px 12px; border-top: 1px solid var(--border); white-space: nowrap; }
.data-table tr.row-alert td { background: rgba(179,68,47,0.08); }
.col-actions { text-align: right; }
.txt-bad { color: #E67E67; font-weight: 700; }
.txt-ok { color: var(--green-l); font-weight: 700; }

.status { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.status-ok { background: rgba(47,140,90,0.18); color: var(--green-l); }
.status-warn { background: rgba(212,118,10,0.18); color: #E8A353; }
.status-bad { background: rgba(179,68,47,0.18); color: #E67E67; }
.status-neutral { background: rgba(138,160,138,0.15); color: var(--muted); }

.empty-state { text-align: center; padding: 36px 16px; background: var(--bg2); border-radius: var(--radius); border: 1px dashed var(--border); }
.empty-icon { font-size: 30px; margin-bottom: 8px; }
.empty-sub { font-size: 12px; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--bg2); border: 1px solid var(--border); width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; border-radius: 16px 16px 0 0; }
@media (min-width: 640px) { .modal-overlay { align-items: center; } .modal { border-radius: 16px; margin: 20px; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 15px; }
.modal-body { padding: 18px; }
.modal-footer { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.modal-footer .btn { flex: 1; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

/* ---------- Alertes ---------- */
.alert-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.alert-item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--orange); border-radius: 9px; padding: 12px; cursor: pointer; text-align: left; width: 100%; }
.alert-item.alert-danger { border-left-color: var(--red); }
.alert-item.alert-warning { border-left-color: var(--orange); }
.alert-item-icon { font-size: 18px; }
.alert-item-body { flex: 1; min-width: 0; }
.alert-item-title { font-size: 13px; font-weight: 700; }
.alert-item-detail { font-size: 11.5px; color: var(--muted); }
.alert-item-classeur { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- Planning ---------- */
.planning-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.planning-item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 9px; padding: 12px; cursor: pointer; text-align: left; width: 100%; }
.planning-item-date { font-size: 12px; font-weight: 700; color: var(--gold); min-width: 52px; }
.planning-item-body { flex: 1; min-width: 0; }
.planning-item-title { font-size: 13px; font-weight: 700; }
.planning-item-detail { font-size: 11.5px; color: var(--muted); }
.planning-item-classeur { font-size: 16px; }

/* ---------- Rapport ---------- */
.rapport-print { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.rapport-title { text-align: center; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 2px solid var(--gold); }
.rapport-title h1 { font-size: 22px; color: var(--gold); }
.rapport-section { margin-bottom: 18px; }
.rapport-section h3 { font-size: 14px; color: var(--gold); border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-bottom: 10px; }
.rapport-alert-list { margin: 0; padding-left: 18px; font-size: 12.5px; }
.rapport-alert-list li { margin-bottom: 4px; color: var(--text); }
.rapport-classeur { margin-bottom: 12px; }
.rapport-classeur h4 { font-size: 13px; margin-bottom: 6px; }
.rapport-kpi-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 12px; }
.rapport-kpi { display: flex; justify-content: space-between; font-size: 11.5px; padding: 4px 0; border-bottom: 1px dotted var(--border); }
.rapport-kpi-label { color: var(--muted); }
.rapport-kpi-value { font-weight: 700; }

/* ---------- Paramètres ---------- */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.panel h3 { font-size: 14.5px; margin-bottom: 6px; }
.panel-danger { border-color: #4A241D; }
.hint { font-size: 11.5px; margin-top: 8px; }

/* ---------- Toasts ---------- */
.toast-container { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; width: calc(100% - 32px); max-width: 360px; }
.toast { padding: 12px 16px; border-radius: 10px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); transition: opacity .3s; background: var(--card); border: 1px solid var(--border); }
.toast-success { border-color: var(--green-l); color: var(--green-l); }
.toast-error { border-color: #7A3226; color: #E67E67; }
.toast-info { border-color: var(--blue); color: #5DADE2; }

/* ---------- Accessibilité / responsive ---------- */
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media (min-width: 860px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .dash-charts { grid-template-columns: 1fr 1fr; }
  .dash-quick { grid-template-columns: repeat(4, 1fr); }
  .table-toolbar { flex-direction: row; align-items: center; justify-content: space-between; }
  .table-actions input { min-width: 220px; flex: none; }
  .rapport-kpi-row { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 859px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .only-mobile { display: inline-flex; }
}

/* ---------- Impression (Rapport) ---------- */
@media print {
  #sidebar, #sidebarOverlay, #mainHeader, .no-print, #toastContainer { display: none !important; }
  .main-content { margin-left: 0 !important; }
  body { background: #fff; color: #111; }
  .rapport-print { border: none; background: #fff; color: #111; }
  .rapport-title h1, .rapport-section h3 { color: #123322; }
  .rapport-kpi-value, .rapport-kpi-label { color: #111; }
}
