/* ═══════════════════════════════════════════
   Kairos — Design System
   Dark premium · DM Sans + JetBrains Mono
   ═══════════════════════════════════════════ */

:root {
  /* ── Palette ── */
  --bg:           #07080c;
  --surface:      #0e1017;
  --surface2:     #151821;
  --surface3:     #1c202d;
  --border:       #222738;
  --border-light: #2d3348;
  
  --text:         #e2e5f0;
  --text-dim:     #8189a6;
  --text-muted:   #4a5068;
  
  --accent:       #6c8cff;
  --accent-dim:   rgba(108,140,255,0.12);
  --accent-glow:  rgba(108,140,255,0.25);
  
  --pink:         #e91e8c;
  --pink-dim:     rgba(233,30,140,0.12);
  
  --green:        #1dd1a1;
  --green-dim:    rgba(29,209,161,0.10);
  
  --red:          #ff6b6b;
  --red-dim:      rgba(255,107,107,0.10);
  
  --orange:       #ffa940;
  --orange-dim:   rgba(255,169,64,0.10);
  
  --cyan:         #38bdf8;

  /* ── Chart colors (for JS access) ── */
  --chart-grid:   #1c202d;
  --chart-text:   #4a5068;
  --chart-legend: #8189a6;
  
  /* ── Typography ── */
  --sans: 'DM Sans', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  
  /* ── Spacing ── */
  --radius:    6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* ── Light Theme ── */
html.light {
  --bg:           #f4f5f7;
  --surface:      #ffffff;
  --surface2:     #f0f1f4;
  --surface3:     #e5e7ed;
  --border:       #d4d7e0;
  --border-light: #c0c4d0;
  
  --text:         #1a1d28;
  --text-dim:     #5a6070;
  --text-muted:   #8a90a0;
  
  --accent:       #4a6fff;
  --accent-dim:   rgba(74,111,255,0.10);
  --accent-glow:  rgba(74,111,255,0.20);
  
  --pink:         #d41880;
  --pink-dim:     rgba(212,24,128,0.08);
  
  --green:        #0fba8c;
  --green-dim:    rgba(15,186,140,0.08);
  
  --red:          #e54545;
  --red-dim:      rgba(229,69,69,0.08);
  
  --orange:       #e09020;
  --orange-dim:   rgba(224,144,32,0.08);
  
  --cyan:         #2098d4;
  
  --chart-grid:   #e5e7ed;
  --chart-text:   #8a90a0;
  --chart-legend: #5a6070;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════ TOPBAR ═══════════ */
.topbar {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  white-space: nowrap;
}
.logo-icon {
  width: 30px; height: 30px;
  background: #0a0a0a;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 1.5px rgba(255,75,0,0.6), 0 2px 12px rgba(255,75,0,0.18);
}
.logo-name {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--text);
  text-transform: uppercase;
}
.logo span { display: none; }
.project-badge {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-tabs {
  display: flex;
  gap: 2px;
  margin-left: 20px;
}
.tab {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.tab.active { color: var(--accent); background: var(--bg); }
.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.topbar-right { margin-left: auto; display: flex; gap: 4px; }
.btn-icon {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-icon:hover { color: var(--text); border-color: var(--border-light); background: var(--surface2); }

/* ═══════════ FILTERS BAR ═══════════ */
.filters-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.filter-group label {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.filter-group select,
.filter-group input {
  font-family: var(--sans);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 5px 10px;
  min-width: 110px;
}
.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.search-group input { min-width: 180px; }
.filter-actions { margin-left: auto; }

/* ═══════════ STATS BAR ═══════════ */
.stats-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 6px 20px;
  display: flex;
  gap: 24px;
  font-size: 11px;
  color: var(--text-dim);
}
.stat span {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12px;
  color: var(--accent);
  margin: 0 2px;
}
.stat-spacer { flex: 1; }
.stat.ecart span.pos { color: var(--green); }
.stat.ecart span.neg { color: var(--red); }

/* ═══════════ MAIN ═══════════ */
#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.panel { display: none; height: 100%; overflow: hidden; flex-direction: column; }
.panel.active { display: flex; }

/* ═══════════ BUTTONS ═══════════ */
.btn {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-accent:hover { opacity: 0.85; }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-light); }
.btn-sm { font-size: 11px; padding: 5px 10px; }
.btn-danger { border-color: var(--red); color: var(--red); background: transparent; }
.btn-danger:hover { background: var(--red-dim); }

/* ═══════════ TABLE ═══════════ */
.table-toolbar {
  padding: 10px 20px;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.table-wrap {
  overflow: auto;
  flex: 1;
  padding: 0 20px 20px;
}
table {
  border-collapse: collapse;
  font-size: 12px;
  width: max-content;
  min-width: 100%;
}
thead { position: sticky; top: 0; z-index: 50; }
th {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-weight: 600;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-align: left;
}
th.th-num, td.td-num { text-align: right; }
th.th-sticky { position: sticky; left: 0; z-index: 55; }
th.th-actions { text-align: center; width: 50px; }

td {
  border: 1px solid var(--border);
  padding: 5px 10px;
  color: var(--text);
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}
td.td-code {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 5;
}
td.td-num {
  font-family: var(--mono);
  font-size: 11px;
  text-align: right;
  max-width: none;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  padding-left: 8px;
  padding-right: 10px;
}
td.td-desc {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-dim);
}
tr:hover td { background: rgba(255,255,255,0.015); }
tr:hover td.td-code { background: var(--surface2); }
tr.row-closed td { opacity: 0.45; }
tr.row-abandoned td { opacity: 0.3; text-decoration: line-through; }

/* Badges */
.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-open { background: var(--accent-dim); color: var(--accent); }
.badge-closed { background: var(--green-dim); color: var(--green); }
.badge-abandoned { background: var(--red-dim); color: var(--red); }

.num-pos { color: var(--green); }
.num-neg { color: var(--red); }
.num-zero { color: var(--text-muted); }

/* Progress mini bar */
.progress-mini {
  width: 50px; height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
}
.progress-mini-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}

/* Row actions */
.row-actions {
  display: flex; gap: 2px; justify-content: center;
}
.row-btn {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  border-radius: 4px; font-size: 13px;
  transition: all 0.1s;
}
.row-btn:hover { color: var(--text); background: var(--surface3); }
.row-btn.del:hover { color: var(--red); background: var(--red-dim); }

/* ═══════════ DASHBOARD ═══════════ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
  height: 100%;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-wide { grid-column: 1 / -1; }
.card-head {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
.card-body {
  padding: 16px;
  position: relative;
  min-height: 200px;
}
.card-body canvas { width: 100% !important; }

/* ═══════════ CONFIG ═══════════ */
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 20px;
  overflow-y: auto;
  height: 100%;
}
.config-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.config-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}
.config-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.config-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
}
.config-item .name { flex: 1; }
.config-item .meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
}
.config-item .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}
.config-item .dot.inactive { background: var(--text-muted); }

/* ═══════════ MODAL ═══════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: 95vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  animation: modalIn 0.2s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.btn-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text-dim); cursor: pointer;
  font-size: 20px; border-radius: var(--radius);
}
.btn-close:hover { color: var(--text); background: var(--surface3); }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* Form fields */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
.form-label {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.form-input, .form-select, .form-textarea {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.form-textarea { resize: vertical; min-height: 60px; }
.form-select option { background: var(--surface2); }
.form-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-dim);
}
.form-check input[type="checkbox"] { accent-color: var(--accent); }

/* ═══════════ TOAST ═══════════ */
.toast {
  position: fixed;
  bottom: 20px; right: 20px;
  background: var(--green);
  color: #0a0a0a;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s;
  z-index: 999;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); color: #fff; }

/* ═══════════ LOADING ═══════════ */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ═══════════ SCROLLBAR ═══════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }


/* ═══════════════════════════════════════════
   Kairos — Component Overrides
   ═══════════════════════════════════════════ */

/* ── Heatmap ── */
.heatmap-grid {
  display: grid;
  gap: 2px;
  font-size: 9px;
  font-family: var(--mono);
}
.heatmap-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s;
}
.heatmap-cell:hover { transform: scale(1.3); z-index: 1; }
.heatmap-label {
  font-size: 9px;
  color: var(--text-muted);
  text-align: right;
  padding-right: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Daily entry calendar ── */
.daily-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.daily-header {
  font-size: 9px;
  font-family: var(--mono);
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0;
  text-transform: uppercase;
}
.daily-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  text-align: center;
  min-height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  transition: all 0.1s;
}
.daily-cell:hover { border-color: var(--accent); background: var(--accent-dim); }
.daily-cell.has-entry { border-color: var(--green); background: var(--green-dim); }
.daily-cell .day-num {
  font-size: 10px;
  color: var(--text-dim);
}
.daily-cell .day-charge {
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--green);
}
.daily-cell.weekend { opacity: 0.3; pointer-events: none; }
.daily-cell.empty { border-color: transparent; background: transparent; pointer-events: none; }

/* ── Daily entry modal extras ── */
.daily-month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}
.daily-month-nav button {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.daily-month-nav button:hover { color: var(--text); border-color: var(--accent); }
.daily-month-label {
  font-size: 14px;
  font-weight: 600;
  min-width: 140px;
  text-align: center;
}

/* ── Inline edit ── */
.inline-edit {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 4px;
  width: 72px;
  min-width: 60px;
  text-align: right;
  box-sizing: border-box;
}
.inline-edit[type="number"] {
  width: 80px;
  -moz-appearance: textfield;
}
.inline-edit[type="number"]::-webkit-outer-spin-button,
.inline-edit[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.inline-edit:focus {
  background: var(--bg);
  border-color: var(--accent);
  outline: none;
}

/* ── Inline select in table ── */
.inline-sel {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 10px;
  padding: 2px 2px;
  width: 100%;
  min-width: 80px;
  max-width: 220px;
  cursor: pointer;
  text-overflow: clip;
}
.inline-sel:focus { background: var(--bg); border-color: var(--accent); outline: none; }
.inline-sel:hover { border-color: var(--border-light); }
.inline-sel option { background: var(--surface2); font-size: 11px; }
.inline-sel:disabled { opacity: 0.4; cursor: default; }
.inline-edit:disabled { opacity: 0.4; cursor: default; }

/* ── Warning row (no planifié, no RAF oper) ── */
tr.row-warn { background: rgba(255,169,64,0.04); }
tr.row-warn td { border-left-color: var(--orange); }

/* ── Context menu ── */
.context-menu {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  z-index: 600;
  min-width: 160px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.context-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: var(--sans);
}
.context-item:hover { color: var(--text); background: var(--surface3); }
.context-item.danger:hover { color: var(--red); background: var(--red-dim); }
.context-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .card-wide { grid-column: 1; }
  .config-grid { grid-template-columns: 1fr; }
  .filters-bar { padding: 8px 12px; gap: 8px; }
  .filter-group select,
  .filter-group input { min-width: 80px; }
}

/* ═══════════ DASHBOARD FOOTER ═══════════ */
.dash-footer {
  margin-top: 24px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface);
  border-radius: var(--radius-lg);
}
.dash-footer-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.dash-footer-logo-icon {
  width: 24px; height: 24px;
  background: #0a0a0a;
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 1.5px rgba(255,75,0,0.5), 0 2px 8px rgba(255,75,0,0.15);
}
.dash-footer-logo-name {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 2.5px;
  color: var(--text);
  text-transform: uppercase;
}
.dash-footer-logo span { display: none; }
.dash-footer-project {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.dash-footer-sep { flex: 1; }
.dash-footer-date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}
.dash-footer-tag {
  font-size: 9px;
  font-family: var(--mono);
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

/* ── Global footer ── */
.app-footer {
  flex-shrink: 0;
  padding: 6px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface);
}
html.light .modal { box-shadow: 0 24px 80px rgba(0,0,0,0.15); }
html.light tr:hover td { background: rgba(0,0,0,0.02); }
html.light tr:hover td.td-code { background: var(--surface2); }
html.light td.td-code { background: var(--surface); }
html.light .topbar { box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
html.light .card { box-shadow: 0 1px 4px rgba(0,0,0,0.05); }

/* ═══════════ KPI ROW (Dashboard) ═══════════ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  grid-column: 1 / -1;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.15s;
  border-radius: inherit;
}
.kpi-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.kpi-card:hover::before { opacity: 1; }
.kpi-card:active { transform: translateY(0); }
.kpi-value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}
.kpi-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 4px;
}
.kpi-sub {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-dim);
  margin-top: 2px;
}
.kpi-green .kpi-value { color: var(--green); }
.kpi-green::before { background: var(--green-dim); }
.kpi-red .kpi-value { color: var(--red); }
.kpi-red::before { background: var(--red-dim); }
.kpi-blue .kpi-value { color: var(--accent); }
.kpi-blue::before { background: var(--accent-dim); }
.kpi-orange .kpi-value { color: var(--orange); }
.kpi-orange::before { background: var(--orange-dim); }
.kpi-cyan .kpi-value { color: var(--cyan); }

/* ═══════════ MAINTENANCE SECTION (Config) ═══════════ */
.maintenance-section {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.maintenance-section h3 { color: var(--red); }
.maint-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.maint-row select { min-width: 160px; }
.maint-info {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
  margin-left: auto;
}

/* ═══════════ MULTI-SELECT CALENDAR ═══════════ */
.daily-cell.selected {
  border-color: var(--accent) !important;
  background: var(--accent-dim) !important;
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.daily-cell.selected.has-entry {
  border-color: var(--accent) !important;
  background: var(--accent-dim) !important;
}
.daily-bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 12px;
}
.daily-bulk-bar label {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}
.daily-bulk-bar input {
  width: 70px;
  text-align: center;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
}
.daily-day-list {
  max-height: 160px;
  overflow-y: auto;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.daily-day-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
}
.daily-day-item label { min-width: 70px; font-family: var(--mono); color: var(--text-dim); }
.daily-day-item input {
  width: 60px; text-align: center;
  font-family: var(--mono); font-size: 13px; font-weight: 600;
}
.daily-day-item .del-day {
  margin-left: auto; cursor: pointer; color: var(--red); font-size: 14px; border: none; background: none;
}
.daily-day-item .del-day:hover { opacity: 0.7; }

/* ═══════════ DASHBOARD FILTERS ═══════════ */
.dash-filters {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.dash-filters label {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-muted);
  text-transform: uppercase;
}
.dash-filters select {
  font-family: var(--sans);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 5px 10px;
}
.filter-tag {
  margin-left: auto;
  font-size: 9px;
  font-family: var(--mono);
  color: var(--text-muted);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  letter-spacing: 0.02em;
}

/* ═══════════ PLAN DE CHARGE TABLE ═══════════ */
.pdc-wrap { overflow-x: auto; overflow-y: auto; }
.pdc-table { border-collapse: collapse; width: max-content; min-width: 100%; }
.pdc-table th, .pdc-table td {
  border: 1px solid var(--border);
  padding: 5px 8px;
  font-size: 11px;
  white-space: nowrap;
  text-align: center;
  max-width: none;
  overflow: visible;
  text-overflow: clip;
}
.pdc-table th {
  background: var(--surface2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 10px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.pdc-table td.res-name {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 3;
  text-align: left;
  font-weight: 600;
  min-width: 150px;
}
.pdc-table th.res-hdr { position: sticky; left: 0; z-index: 8; }
.pdc-table .pdc-val {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  min-width: 64px;
  padding-left: 6px;
  padding-right: 6px;
}
.pdc-total-row td { font-weight: 700; background: var(--surface2) !important; }
.pdc-total-row .res-name { background: var(--surface2) !important; }
.pdc-now { border-left: 2px solid var(--red) !important; border-right: 2px solid var(--red) !important; }
.pdc-now-hdr { border-left: 2px solid var(--red) !important; border-right: 2px solid var(--red) !important; background: var(--red-dim) !important; color: var(--red) !important; }
.cap-input {
  width: 36px; text-align: center;
  font-family: var(--mono); font-size: 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 3px; color: var(--text); padding: 2px;
}

/* ═══════════ PLANNING GANTT ═══════════ */
.planning-toolbar {
  padding: 10px 20px;
  display: flex;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.planning-toolbar-filters {
  background: rgba(108,140,255,0.18);
  border-bottom: 2px solid var(--accent);
  border-top: 2px solid var(--accent);
  padding: 10px 20px;
  box-shadow: inset 0 -1px 0 var(--accent), 0 2px 10px rgba(108,140,255,0.15);
}
.planning-legend {
  margin-left: auto;
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 10px;
  color: var(--text-muted);
}
.pl-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  margin-right: 2px;
  vertical-align: middle;
}
.pl-dot-done { background: var(--green); }
.pl-dot-progress { background: var(--accent); }
.pl-dot-planned { background: var(--orange); opacity: 0.7; }
.pl-dot-abandoned { background: var(--red); opacity: 0.4; }
.pl-marker-now {
  color: var(--red);
  font-weight: 600;
  font-size: 9px;
  margin-left: 8px;
}
.planning-scroll {
  overflow: auto;
  flex: 1;
  padding: 0;
}

/* Gantt table */
.gantt-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
}
.gantt-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 9px;
  font-family: var(--mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 2px;
  text-align: center;
  white-space: nowrap;
}
.gantt-table th.gantt-frozen {
  position: sticky;
  left: 0;
  z-index: 15;
  text-align: left;
  padding: 4px 10px;
  min-width: 280px;
  font-size: 10px;
}
.gantt-table td {
  border: 1px solid var(--border);
  padding: 0;
  height: 34px;
  min-width: 28px;
  position: relative;
}
.gantt-table td.gantt-frozen {
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--surface);
  padding: 2px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
  min-width: 280px;
}
.gantt-frozen .gantt-code {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  margin-right: 6px;
}
.gantt-frozen .gantt-desc {
  font-size: 10px;
  color: var(--text-dim);
}
.gantt-frozen .gantt-res {
  font-size: 9px;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
}

/* Week header rows */
.gantt-week-hdr {
  font-weight: 700 !important;
  font-size: 9px !important;
  min-width: 28px;
}
.gantt-week-now {
  background: var(--red-dim) !important;
  color: var(--red) !important;
}
.gantt-day-hdr {
  font-size: 8px !important;
  color: var(--text-muted) !important;
  min-width: 28px;
}
.gantt-day-we {
  background: var(--surface3) !important;
  opacity: 0.4;
}

/* Gantt bars */
.gantt-bar {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 1px;
  right: 1px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.gantt-bar-label {
  font-size: 8px;
  font-family: var(--mono);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  pointer-events: none;
  letter-spacing: 0.02em;
}
/* En cours — bleu */
.gantt-bar-progress {
  background: linear-gradient(135deg, #3b6fd4 0%, #5b8fff 100%);
  box-shadow: 0 1px 4px rgba(67,97,238,0.35);
}
.gantt-bar-progress .gantt-bar-label { color: rgba(255,255,255,0.9); }

/* Planifié — orange */
.gantt-bar-planned {
  background: linear-gradient(135deg, #c47a00 0%, #f0a030 100%);
  box-shadow: 0 1px 4px rgba(200,120,0,0.30);
}
.gantt-bar-planned .gantt-bar-label { color: rgba(255,255,255,0.9); }

/* Terminé — vert */
.gantt-bar-done {
  background: linear-gradient(135deg, #0a8a5c 0%, #1ec991 100%);
  box-shadow: 0 1px 4px rgba(15,168,122,0.30);
}
.gantt-bar-done .gantt-bar-label { color: rgba(255,255,255,0.9); }

/* Absence — orange pâle */
.gantt-bar-absence {
  background: rgba(255,169,64,0.25);
  border: 1px dashed rgba(255,169,64,0.6);
}
.gantt-bar-absence .gantt-bar-label { color: var(--orange); font-size: 10px; }
.gantt-absent-cell { background: rgba(255,169,64,0.06) !important; }

/* Jour férié */
.gantt-bar-holiday {
  background: rgba(255,107,107,0.15);
  border: 1px dashed rgba(255,107,107,0.5);
}
.gantt-hol-cell { background: rgba(255,107,107,0.04) !important; }
.gantt-hol-hdr { background: rgba(255,107,107,0.10) !important; color: var(--red) !important; }

/* Abandonné — rouge */
.gantt-bar-abandoned {
  background: linear-gradient(135deg, #a32020 0%, #ef5f5f 100%);
  box-shadow: 0 1px 4px rgba(220,53,69,0.25);
  opacity: 0.6;
}
.gantt-bar-abandoned .gantt-bar-label { color: rgba(255,255,255,0.8); }

/* Today marker */
.gantt-today {
  border-left: 2px solid var(--red) !important;
}
.gantt-today-hdr {
  background: var(--red-dim) !important;
  color: var(--red) !important;
  font-weight: 700 !important;
}

/* Type group header */
.gantt-group td {
  background: var(--surface2) !important;
  border-color: var(--border);
}
.gantt-group .gantt-frozen {
  background: var(--surface2) !important;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.gantt-group-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

/* Row hover */
.gantt-table tr:not(.gantt-group):hover td { background: rgba(108,140,255,0.04); }
.gantt-table tr:not(.gantt-group):hover td.gantt-frozen { background: var(--surface2); }
.gantt-row-done td { opacity: 0.5; }
.gantt-row-abandoned td { opacity: 0.25; }

/* ═══════════ AUTH / LOGIN ═══════════ */
.login-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.login-overlay.hidden { display: none; }
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 380px;
  max-width: 95vw;
  text-align: center;
}
.login-box .logo { font-size: 28px; margin-bottom: 8px; }
.login-box p { font-size: 12px; color: var(--text-muted); margin-bottom: 24px; }
.login-box .form-group { margin-bottom: 14px; text-align: left; }
.login-box .form-input { width: 100%; }
.login-box .btn-accent { width: 100%; padding: 10px; font-size: 14px; }
.login-error { color: var(--red); font-size: 11px; margin-top: 10px; min-height: 16px; }

/* User badge in topbar */
.user-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-dim);
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
}
.user-badge:hover { border-color: var(--accent); }
.user-role {
  font-size: 9px; font-family: var(--mono);
  padding: 1px 5px; border-radius: 3px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.role-admin { background: var(--pink-dim); color: var(--pink); }
.role-cp { background: var(--accent-dim); color: var(--accent); }
.role-dev { background: var(--green-dim); color: var(--green); }
.role-viewer { background: var(--surface3); color: var(--text-muted); }

/* User dropdown */
.user-dropdown {
  position: absolute; top: 100%; right: 0; margin-top: 4px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px; min-width: 160px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4); z-index: 200;
  display: none;
}
.user-dropdown.open { display: block; }
.user-dropdown button {
  display: block; width: 100%; text-align: left;
  padding: 7px 12px; font-size: 12px; color: var(--text-dim);
  border: none; background: none; cursor: pointer;
  font-family: var(--sans); border-radius: 4px;
}
.user-dropdown button:hover { background: var(--surface3); color: var(--text); }
.user-dropdown .danger:hover { color: var(--red); background: var(--red-dim); }

/* Admin panel */
.admin-users { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.admin-user-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.admin-user-item .name { flex: 1; font-size: 12px; }
.admin-user-item .meta { font-size: 10px; color: var(--text-muted); font-family: var(--mono); }
