:root {
  --bg: #f4f7fb;
  --card: #fff;
  --text: #172033;
  --muted: #64748b;
  --line: #dbe2ea;
  --primary: #1f2a44;
  --primary2: #314166;
  --green: #dcfce7;
  --greenText: #166534;
  --orange: #ffedd5;
  --orangeText: #9a3412;
  --red: #fee2e2;
  --redText: #991b1b;
  --over: #4c1d95;
  --overText: #ffffff;
  --blue: #dbeafe;
  --blueText: #1d4ed8;
  --purple: #ede9fe;
  --purpleText: #6d28d9;
  --gray: #e2e8f0;
  --grayText: #334155;
  --teal: #ccfbf1;
  --tealText: #0f766e;
  --indigo: #e0e7ff;
  --indigoText: #3730a3;
  --rose: #ffe4e6;
  --roseText: #be123c;
  --amber: #fef9c3;
  --amberText: #854d0e;
  --cyan: #cffafe;
  --cyanText: #155e75;
  --weekend: #f8fafc;

  --surface: #eef2f7;
  --bg-header: #fff;
  --bg-sidebar: #fff;
  --border-strong: #b0b0b0;
  --accent: var(--primary);
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

[data-theme="dark"] {
  --bg: #14141a;
  --card: #20212b;
  --surface: #262837;
  --text: #eef1f6;
  --muted: #94a3b8;
  --line: #333648;
  --weekend: #1b1d27;
  --bg-header: #1b1c25;
  --bg-sidebar: #1b1c25;
  --border-strong: #4b4f63;
  --primary: #7d97e0;
  --primary2: #5f7bc9;
  --accent: #7d97e0;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ===== Header ===== */
.app-header {
  height: 64px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
}

.btn-burger {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 6px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 8px;
  color: var(--text);
}

.btn-burger:hover {
  background: var(--surface);
}

.app-logo-wrap {
  background: #fff;
  border-radius: 8px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.app-logo {
  height: 24px;
  width: auto;
  display: block;
}

.app-title-block {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  overflow: hidden;
}

.app-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-subtitle {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-toggle {
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: all .15s ease;
}

.btn-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#help-btn {
  width: 34px;
  padding: 8px 0;
  text-align: center;
}

/* ===== App layout: sidebar + main ===== */
.app-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: calc(100vh - 64px);
}

.app-sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  overflow-y: auto;
}

.app-main {
  padding: 22px;
  max-width: 1700px;
  margin: 0 auto;
  width: 100%;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* ===== Sidebar navigation (page tabs) ===== */
.tabs {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

button,
label.fileBtn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.tab {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px 10px 14px;
  border: none;
  border-radius: 0 8px 8px 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}

.tab-icon {
  flex-shrink: 0;
  width: 20px;
  font-size: 14px;
  line-height: 1;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab-label {
  flex: 1 1 auto;
  line-height: 1.2;
}

.tab:hover {
  background: var(--surface);
}

.tab.active {
  background: var(--surface);
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  padding: 10px 12px 4px 14px;
  margin: 0;
}

.nav-section-title:first-child {
  padding-top: 0;
}

.linksList {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.linksList li {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.linksList a {
  display: block;
  padding: 12px 14px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.linksList a:hover {
  text-decoration: underline;
}

button.secondary,
label.fileBtn.secondary {
  background: var(--card);
  color: var(--primary);
  border: 1px solid var(--line);
}

button.danger {
  background: #b91c1c;
}

button.smallBtn {
  padding: 6px 9px;
  border-radius: 9px;
  font-size: 12px;
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid5 {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
  margin-bottom: 16px;
}

.card h2,
.card h3 {
  margin-top: 0;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.space {
  justify-content: space-between;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.small {
  font-size: 12px;
}

.grow {
  flex: 1;
}

.hidden {
  display: none !important;
}

input,
select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 8px 10px;
  background: var(--card);
  color: var(--text);
  min-width: 120px;
}

input[type=file] {
  display: none;
}

.tableWrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  max-height: 680px;
  background: var(--card);
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 14px;
}

th,
td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: center;
  white-space: nowrap;
  vertical-align: top;
}

th {
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 3;
}

td:first-child,
th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--card);
  text-align: left;
  font-weight: 700;
}

th:first-child {
  z-index: 4;
  background: var(--surface);
}

.pill {
  display: inline-flex;
  min-width: 38px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 800;
  font-size: 13px;
  margin: 1px;
}

.v05 {
  background: var(--green);
  color: var(--greenText);
  border-color: #86efac;
}

.v025 {
  background: var(--cyan);
  color: var(--cyanText);
  border-color: #67e8f9;
}

.v075 {
  background: var(--amber);
  color: var(--amberText);
  border-color: #fde68a;
}

.vPART {
  background: var(--orange);
  color: var(--orangeText);
  border-color: #fdba74;
}

.v1 {
  background: var(--red);
  color: var(--redText);
  border-color: #fca5a5;
}

.vOVER {
  background: var(--over);
  color: var(--overText);
  border-color: #7e22ce;
}

.vC {
  background: var(--blue);
  color: var(--blueText);
  border-color: #93c5fd;
}

.vF {
  background: var(--purple);
  color: var(--purpleText);
  border-color: #c4b5fd;
}

.vND {
  background: var(--gray);
  color: var(--grayText);
  border-color: #cbd5e1;
}

.vCP {
  background: var(--indigo);
  color: var(--indigoText);
  border-color: #a5b4fc;
}

.vRTT {
  background: var(--teal);
  color: var(--tealText);
  border-color: #5eead4;
}

.vAM {
  background: var(--rose);
  color: var(--roseText);
  border-color: #fda4af;
}

.empty {
  color: #cbd5e1;
}

.ok {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  border-radius: 14px;
  padding: 12px;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.calHeader {
  text-align: center;
  font-weight: 800;
  color: #475569;
  padding: 8px;
}

.calDay {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 9px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.calDay:hover {
  outline: 2px solid #93c5fd;
}

.calDay.weekend {
  background: var(--weekend);
  color: #94a3b8;
  cursor: not-allowed;
}

.calDay.other {
  opacity: .25;
}

.calNum {
  font-weight: 900;
}

.calState {
  font-size: 13px;
  font-weight: 900;
}

.calTip {
  font-size: 11px;
  color: var(--muted);
}

.actDay {
  min-height: 128px;
  align-items: stretch;
  justify-content: flex-start;
  overflow-y: auto;
}

.actLines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.actLine {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.actLine .pill {
  font-size: 10px;
  padding: 2px 6px;
  min-height: 0;
  min-width: 0;
  margin: 0;
}

.actLine button {
  padding: 2px 6px;
  font-size: 10px;
  border-radius: 6px;
  min-height: 0;
}

.quickTypes {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.btnProject,
.btnProjectIndispo,
.btnValue {
  border: 1px solid transparent;
}

.btnProject {
  background: var(--purple);
  color: var(--purpleText);
  border-color: #c4b5fd;
}

.btnProject.selected {
  background: var(--purpleText);
  color: #fff;
  border-color: var(--purpleText);
}

.btnProjectIndispo {
  background: var(--orange);
  color: var(--orangeText);
  border-color: #fdba74;
}

.btnProjectIndispo.selected {
  background: var(--orangeText);
  color: #fff;
  border-color: var(--orangeText);
}

.btnValue.v025 {
  background: var(--cyan);
  color: var(--cyanText);
  border-color: #67e8f9;
}

.btnValue.v025.selected {
  background: var(--cyanText);
  color: #fff;
  border-color: var(--cyanText);
}

.btnValue.v05 {
  background: var(--green);
  color: var(--greenText);
  border-color: #86efac;
}

.btnValue.v05.selected {
  background: var(--greenText);
  color: #fff;
  border-color: var(--greenText);
}

.btnValue.v075 {
  background: var(--amber);
  color: var(--amberText);
  border-color: #fde68a;
}

.btnValue.v075.selected {
  background: var(--amberText);
  color: #fff;
  border-color: var(--amberText);
}

.btnValue.v1 {
  background: var(--red);
  color: var(--redText);
  border-color: #fca5a5;
}

.btnValue.v1.selected {
  background: var(--redText);
  color: #fff;
  border-color: var(--redText);
}

.kpi {
  font-size: 26px;
  font-weight: 900;
}

#kpis {
  gap: 10px;
}

#kpis .card {
  padding: 10px 14px;
  margin-bottom: 0;
}

#kpis .muted {
  font-size: 12px;
}

#kpis .kpi {
  font-size: 20px;
}

.projectTag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  padding: 7px 10px;
  margin: 4px;
}

.legend span {
  margin-right: 12px;
}

.notice {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  border-radius: 14px;
  padding: 12px;
}

#view-pilote label {
  display: inline-block;
  min-width: 110px;
}

.sidebar-collab-picker {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.sidebar-collab-picker .nav-section-title {
  display: block;
  padding: 0 0 4px;
}

.sidebar-collab-picker select {
  width: 100%;
  min-width: 0;
}

.footer {
  font-size: 12px;
  color: var(--muted);
  margin-top: 20px;
}

.monthSeparator {
  border-left: 3px solid #94a3b8 !important;
}

.today {
  background: var(--accent) !important;
}

th.today {
  color: #fff;
}

.warning {
  color: #991b1b;
  font-weight: 800;
}

.statusBar {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 14px;
}

.statusBar.loading {
  background: var(--surface);
  color: var(--primary);
}

.statusBar.error {
  background: var(--red);
  color: var(--redText);
  border-color: #fca5a5;
}

.statusBar.ok {
  background: var(--green);
  color: var(--greenText);
  border-color: #86efac;
}

.powerbiWrap {
  position: relative;
  width: 100%;
  max-width: 1140px;
  aspect-ratio: 1140 / 541.25;
}

.powerbiWrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 14px;
}

/* ===== Help modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-panel {
  background: var(--card);
  color: var(--text);
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}

.modal-panel h2 {
  margin-top: 0;
}

.modal-close {
  float: right;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
}

.modal-panel ul {
  padding-left: 18px;
  margin: 10px 0;
}

.modal-panel li {
  margin-bottom: 6px;
}

.modal-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin: 16px 0 6px;
}

.modal-section-title:first-of-type {
  margin-top: 12px;
}

@media (max-width: 900px) {
  .app-main {
    padding: 14px;
  }
  .grid2,
  .grid5 {
    grid-template-columns: 1fr;
  }
  .row > * {
    flex: 1;
  }
  .tableWrap {
    max-height: 520px;
  }
  .calendar {
    grid-template-columns: repeat(2, 1fr);
  }
  .calHeader {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .app-sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: min(80vw, 280px);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 18px rgba(0, 0, 0, .18);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .btn-burger {
    display: inline-flex;
  }
  .app-subtitle {
    display: none;
  }
  .app-header {
    padding: 0 12px;
    gap: 8px;
  }
  .app-header-actions {
    gap: 6px;
  }
  .btn-toggle {
    padding: 8px 10px;
    font-size: 11px;
  }
}
