:root{
  --navy:#0C3042; --navy-light:#123B4F; --teal:#13769D; --teal-light:#E5F1F5;
  --orange:#FF8C00; --white:#FFFFFF; --bg:#F5F7FA; --grey:#8A9098; --mgrey:#D9DEE3;
  --lgrey:#F0F2F5;
  --f-color:#DCEEDC; --f-border:#7CBF7C;
  --i-color:#DCE9F5; --i-border:#6FA8D8;
  --c-color:#EADCF5; --c-border:#B487D9;
  --d-color:#FFFFFF;
  --off-color:#C7CBD1;
}
*{box-sizing:border-box;}
body{
  margin:0; font-family:'Segoe UI', system-ui, -apple-system, sans-serif;
  background:var(--bg); color:#1c2733;
}
/* ---------- HEADER ---------- */
header{
  background:linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color:var(--white); padding:0 28px; display:flex; align-items:center;
  justify-content:space-between; height:64px; box-shadow:0 2px 8px rgba(0,0,0,.15);
  position:sticky; top:0; z-index:50;
}
.brand{display:flex; align-items:center; gap:12px;}
.wordmark{
  font-family:'Avenir Next','Avenir','Century Gothic','Futura','Segoe UI',system-ui,sans-serif;
  font-size:27px;font-weight:500;letter-spacing:.2px;line-height:1;color:var(--white);
  text-transform:lowercase;display:inline-flex;align-items:flex-start;
}
.wordmark .pace-dot{width:.46em;height:.46em;margin-left:.05em;margin-top:.03em;flex-shrink:0;display:block;}
.login-card .wordmark{color:#111;justify-content:center;font-size:38px;margin-bottom:10px;}
.user-switch{display:flex; align-items:center; gap:8px;}
.user-switch-label{font-size:10.5px; color:#9FC4D6; text-transform:uppercase; letter-spacing:.4px; font-weight:700;}
.user-name{font-size:12.5px; font-weight:600; color:var(--white);}
.role-badge{
  font-size:10.5px; font-weight:700; padding:4px 10px; border-radius:20px; letter-spacing:.3px;
  white-space:nowrap;
}
.role-badge.admin{background:var(--orange); color:var(--white);}
.role-badge.readonly{background:rgba(255,255,255,.15); color:#D8E6EC;}
.logout-btn{
  background:rgba(255,255,255,.08); color:#D8E6EC; border:1px solid rgba(255,255,255,.2);
  border-radius:8px; padding:7px 12px; font-size:12px; font-weight:600; cursor:pointer; transition:.15s;
}
.logout-btn:hover{background:rgba(255,255,255,.16); color:var(--white);}
nav{display:flex; gap:4px;}
nav button{
  background:transparent; border:none; color:#BBD3DE; padding:10px 18px; font-size:13.5px;
  font-weight:600; border-radius:8px; cursor:pointer; transition:.15s; letter-spacing:.2px;
}
nav button:hover{background:rgba(255,255,255,.08); color:var(--white);}
nav button.active{background:var(--teal); color:var(--white);}

main{padding:24px 28px 60px; max-width:1600px; margin:0 auto;}
.panel{display:none;}
.panel.active{display:block; animation:fade .25s ease;}
@keyframes fade{from{opacity:0; transform:translateY(4px);} to{opacity:1; transform:translateY(0);}}

h1.page-title{font-size:22px; color:var(--navy); margin:0 0 4px; font-weight:700;}
p.page-sub{color:var(--grey); font-size:13px; margin:0 0 22px;}

/* ---------- CARDS / TOOLBAR ---------- */
.toolbar{
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  background:var(--white); border-radius:12px; padding:14px 18px; margin-bottom:16px;
  box-shadow:0 1px 3px rgba(12,48,66,.08); flex-wrap:wrap;
}
.month-nav{display:flex; align-items:center; gap:10px;}
.month-nav button{
  background:var(--lgrey); border:1px solid var(--mgrey); width:32px; height:32px; border-radius:8px;
  cursor:pointer; font-size:15px; color:var(--navy); font-weight:700; transition:.15s;
}
.month-nav button:hover{background:var(--teal); color:var(--white); border-color:var(--teal);}
.month-label{font-size:16px; font-weight:700; color:var(--navy); min-width:150px; text-align:center;}
.legend{display:flex; gap:14px; align-items:center; flex-wrap:wrap;}
.legend-item{display:flex; align-items:center; gap:6px; font-size:12px; color:#425063; font-weight:600;}
.swatch{width:14px; height:14px; border-radius:4px; border:1px solid rgba(0,0,0,.08);}

.btn{
  border:none; border-radius:8px; padding:9px 16px; font-size:13px; font-weight:700; cursor:pointer;
  transition:.15s; display:inline-flex; align-items:center; gap:6px;
}
.btn-primary{background:var(--orange); color:var(--white);}
.btn-primary:hover{background:#e67e00;}
.btn-secondary{background:var(--teal-light); color:var(--teal);}
.btn-secondary:hover{background:#d3e9f0;}
.btn-ghost{background:transparent; color:var(--grey); border:1px solid var(--mgrey);}
.btn-ghost:hover{background:var(--lgrey);}
.btn-danger{background:#FCEBEA; color:#C0392B;}
.btn-danger:hover{background:#f8d7d5;}

/* ---------- GRID ---------- */
.grid-wrap{
  background:var(--white); border-radius:12px; overflow:auto; box-shadow:0 1px 3px rgba(12,48,66,.08);
  max-height:74vh;
}
table.grid{border-collapse:separate; border-spacing:0; width:100%; font-size:12.5px;}
table.grid thead th{
  position:sticky; top:0; background:var(--navy); color:var(--white); z-index:5;
  padding:9px 6px; font-weight:700; text-align:center; font-size:11.5px; border-right:1px solid rgba(255,255,255,.08);
}
table.grid thead th.day-off{background:var(--navy-light); color:#9FC4D6;}
table.grid thead th.corner{position:sticky; left:0; z-index:6; text-align:left; padding-left:12px;}
table.grid thead th.corner.c2{left:150px;}
table.grid thead th.corner.c3{left:250px;}
table.grid tbody td.rowhead{
  position:sticky; left:0; background:var(--white); z-index:3; padding:7px 12px; font-weight:700;
  color:var(--navy); border-right:1px solid var(--mgrey); border-bottom:1px solid var(--lgrey);
  white-space:nowrap; font-size:12.5px;
}
table.grid tbody td.rowhead.c2{left:150px; font-weight:500; color:#54606f;}
table.grid tbody td.rowhead.c3{left:250px; font-weight:500; color:#54606f; border-right:2px solid var(--mgrey);}
table.grid tbody tr:nth-child(even) td.rowhead{background:#FBFCFD;}
table.grid tbody tr.buffer-row td.rowhead{background:#FAFAFA; color:var(--grey); font-style:italic;}
table.grid tbody td.cell{
  border-bottom:1px solid var(--lgrey); border-right:1px solid var(--lgrey); text-align:center;
  cursor:pointer; min-width:64px; height:34px; transition:.1s; position:relative; white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis; padding:0 4px; color:#1c2733; font-weight:600;
}
table.grid tbody td.cell:hover{outline:2px solid var(--teal); outline-offset:-2px; z-index:2;}
table.grid tbody td.cell.readonly{cursor:default;}
table.grid tbody td.cell.readonly:hover{outline:none;}
table.grid tbody td.cell.off{background:var(--off-color); cursor:default;}
table.grid tbody td.cell.off:hover{outline:none;}
table.grid tbody td.cell.type-F{background:var(--f-color); border-left:3px solid var(--f-border);}
table.grid tbody td.cell.type-I{background:var(--i-color); border-left:3px solid var(--i-border);}
table.grid tbody td.cell.type-C{background:var(--c-color); border-left:3px solid var(--c-border);}
table.grid tbody td.cell.type-D{background:var(--d-color);}
table.grid tbody tr.rate-row td{
  background:var(--teal-light); font-weight:700; color:var(--teal); border-top:2px solid var(--teal);
  position:sticky; bottom:0;
}
table.grid tbody tr.rate-row td.rowhead{background:var(--teal); color:var(--white); position:sticky; bottom:0; left:0; z-index:4;}
table.grid tbody tr.rate-row td.rowhead.c2, table.grid tbody tr.rate-row td.rowhead.c3{background:var(--teal); color:var(--white);}
.add-row-cell{padding:10px 12px !important; color:var(--teal) !important; cursor:pointer; font-weight:700 !important;}
.add-row-cell:hover{text-decoration:underline;}

/* mini heat strip in row head */
.heat{display:inline-block; width:36px; height:6px; border-radius:3px; background:var(--lgrey); margin-left:8px; vertical-align:middle; overflow:hidden;}
.heat i{display:block; height:100%; background:var(--teal);}

/* ---------- Popover picker ---------- */
.picker{
  position:fixed; background:var(--white); border-radius:10px; box-shadow:0 8px 30px rgba(12,48,66,.25);
  padding:8px; z-index:100; min-width:220px; border:1px solid var(--mgrey);
}
.picker .picker-title{font-size:11px; color:var(--grey); font-weight:700; padding:4px 8px; text-transform:uppercase; letter-spacing:.5px;}
.picker button.opt{
  display:flex; align-items:center; gap:8px; width:100%; text-align:left; background:none; border:none;
  padding:8px 8px; border-radius:6px; cursor:pointer; font-size:13px; font-weight:600; color:#1c2733;
}
.picker button.opt:hover{background:var(--lgrey);}
.picker button.opt .dot{width:10px; height:10px; border-radius:3px; flex-shrink:0;}
.picker .clear{color:#C0392B; border-top:1px solid var(--lgrey); margin-top:4px; padding-top:8px;}

/* ---------- Dashboard ---------- */
.kpi-row{display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:20px;}
.kpi-card{background:var(--white); border-radius:12px; padding:18px 20px; box-shadow:0 1px 3px rgba(12,48,66,.08);}
.kpi-card .kpi-label{font-size:11.5px; color:var(--grey); font-weight:700; text-transform:uppercase; letter-spacing:.4px;}
.kpi-card .kpi-value{font-size:30px; font-weight:800; color:var(--navy); margin-top:6px;}
.kpi-card .kpi-note{font-size:12px; color:var(--grey); margin-top:4px;}
.kpi-card.accent{border-left:4px solid var(--orange);}
.chart-row{display:grid; grid-template-columns:1.4fr 1fr; gap:16px; margin-bottom:16px;}
.card{background:var(--white); border-radius:12px; padding:18px 20px; box-shadow:0 1px 3px rgba(12,48,66,.08);}
.card h3{margin:0 0 14px; font-size:14.5px; color:var(--navy); font-weight:700;}
table.simple{width:100%; border-collapse:collapse; font-size:12.5px;}
table.simple th{text-align:left; color:var(--grey); font-weight:700; font-size:11px; text-transform:uppercase;
  padding:6px 8px; border-bottom:2px solid var(--lgrey);}
table.simple td{padding:8px; border-bottom:1px solid var(--lgrey);}
.bar-mini{background:var(--lgrey); border-radius:4px; height:8px; width:100%; overflow:hidden;}
.bar-mini i{display:block; height:100%; background:var(--teal); border-radius:4px;}
.tag{font-size:10.5px; padding:2px 8px; border-radius:20px; font-weight:700;}
.tag.interne{background:var(--teal-light); color:var(--teal);}
.tag.externe{background:#FFF1DE; color:var(--orange);}

/* ---------- Missions / Consultants tables ---------- */
.data-table{background:var(--white); border-radius:12px; overflow:hidden; box-shadow:0 1px 3px rgba(12,48,66,.08);}
.data-table table{width:100%; border-collapse:collapse; font-size:13px;}
.data-table thead th{background:var(--navy); color:var(--white); text-align:left; padding:11px 14px; font-size:11.5px; text-transform:uppercase; letter-spacing:.3px;}
.data-table tbody td{padding:10px 14px; border-bottom:1px solid var(--lgrey);}
.data-table tbody tr:hover{background:var(--lgrey);}
.data-table input, .data-table select{
  width:100%; border:1px solid transparent; background:transparent; padding:6px 8px; border-radius:6px;
  font-size:13px; font-family:inherit; color:#1c2733;
}
.data-table input:hover, .data-table select:hover{border-color:var(--mgrey); background:var(--white);}
.data-table input:focus, .data-table select:focus{outline:none; border-color:var(--teal); background:var(--white);}
.type-pill{display:inline-flex; align-items:center; gap:6px; font-size:11.5px; font-weight:700; padding:4px 10px; border-radius:20px;}
.type-pill.F{background:var(--f-color); color:#2E7D32;}
.type-pill.I{background:var(--i-color); color:#1565A8;}
.type-pill.C{background:var(--c-color); color:#6A1B9A;}
.type-pill.D{background:var(--lgrey); color:var(--grey);}
.link-btn{background:none;border:none;cursor:pointer;color:var(--teal);font-weight:700;font-size:12px;padding:2px 4px;}
.link-btn:hover{text-decoration:underline;}
.row-actions button{background:none; border:none; cursor:pointer; color:var(--grey); font-size:15px; padding:4px 6px; border-radius:6px;}
.row-actions button:hover{background:#FCEBEA; color:#C0392B;}

.banner{
  background:linear-gradient(90deg, var(--teal-light), #fff); border-left:4px solid var(--teal);
  border-radius:8px; padding:12px 16px; font-size:12.5px; color:#345; margin-bottom:18px; line-height:1.5;
}
.banner b{color:var(--navy);}
.footer-note{text-align:center; color:var(--grey); font-size:11.5px; margin-top:30px; padding-top:16px; border-top:1px solid var(--mgrey);}

#toast{
  position:fixed;bottom:24px;left:50%;transform:translateX(-50%);background:var(--navy);color:#fff;
  padding:12px 20px;border-radius:10px;font-size:13px;font-weight:600;box-shadow:0 6px 20px rgba(0,0,0,.25);
  opacity:0;pointer-events:none;transition:.25s;z-index:200;
}

/* ---------- Login ---------- */
.login-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;
  background:linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);padding:20px;}
.login-card{background:var(--white);border-radius:16px;padding:36px 34px;width:100%;max-width:380px;
  box-shadow:0 20px 60px rgba(0,0,0,.3);}
.login-card .login-logo{display:block;height:34px;width:auto;margin:0 auto 22px;}
.login-card h1{font-size:18px;color:var(--navy);margin:0 0 4px;text-align:center;font-weight:700;}
.login-card p.sub{font-size:12.5px;color:var(--grey);text-align:center;margin:0 0 24px;}
.field{margin-bottom:16px;}
.field label{display:block;font-size:11.5px;font-weight:700;color:#425063;text-transform:uppercase;
  letter-spacing:.4px;margin-bottom:6px;}
.field input{width:100%;padding:11px 12px;border:1px solid var(--mgrey);border-radius:9px;font-size:14px;
  font-family:inherit;color:#1c2733;}
.field input:focus{outline:none;border-color:var(--teal);box-shadow:0 0 0 3px var(--teal-light);}
.login-card .btn{width:100%;justify-content:center;padding:12px;font-size:14px;margin-top:6px;}
.login-error{background:#FCEBEA;color:#C0392B;border-radius:9px;padding:10px 12px;font-size:12.5px;
  font-weight:600;margin-bottom:16px;display:none;}
.login-error.show{display:block;}
