:root {
  --ink: #17313b;
  --muted: #668088;
  --line: #c9e1e6;
  --panel: #ffffff;
  --surface: #eaf6f8;
  --nav: #dff1f5;
  --teal: #078fa3;
  --cyan: #64c5d4;
  --blue: #0f7898;
  --green: #177c58;
  --amber: #d77818;
  --red: #be3a34;
  --gray: #7c8794;
  --shadow: 0 16px 42px rgba(7, 143, 163, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 78% 8%, rgba(244, 156, 40, 0.14), transparent 28%),
    linear-gradient(180deg, #f5fbfc 0%, var(--surface) 44%, #f7fbfb 100%);
  font-family: Arial, Helvetica, sans-serif;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

body:not(.authenticated) {
  display: block;
}

body:not(.authenticated) .app-ui {
  display: none;
}

body.authenticated .login-screen {
  display: none;
}

button,
input,
select {
  font: inherit;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  background:
    linear-gradient(90deg, rgba(235, 248, 250, 0.94), rgba(235, 248, 250, 0.68)),
    url("assets/fond-montagne.png") center bottom / cover no-repeat;
}

.login-visual {
  min-height: 100vh;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: #17313b;
}

.login-visual img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.92);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: auto;
}

.login-visual p {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-visual h1 {
  max-width: 680px;
  margin: 0;
  font-size: 54px;
  line-height: 1.02;
}

.login-card {
  align-self: center;
  margin: 32px;
  padding: 30px;
  display: grid;
  gap: 16px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  box-shadow: 0 28px 70px rgba(7, 143, 163, 0.2);
}

.login-card h2 {
  margin: 0;
  font-size: 30px;
}

.login-card p {
  margin: 0;
  color: var(--muted);
}

.login-help {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: #e6f5f8;
  color: #285864;
  font-size: 13px;
}

.login-error {
  min-height: 18px;
  color: var(--red);
  font-weight: 700;
}

.sidebar {
  min-height: 100vh;
  background: var(--nav);
  color: var(--ink);
  padding: 24px 18px;
  position: sticky;
  top: 0;
  border-right: 1px solid rgba(7, 143, 163, 0.16);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-logo {
  width: 70px;
  height: 70px;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 7px;
  box-shadow: 0 10px 26px rgba(7, 143, 163, 0.16);
}

.brand h1,
.brand p,
.panel h3,
.side-panel h2,
.topbar h2,
.eyebrow {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p,
.side-panel,
.nav-button {
  color: #58737b;
}

.nav {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.nav-button {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  cursor: pointer;
  color: #385961;
  font-weight: 700;
}

.nav-button:hover,
.nav-button.active {
  background: #ffffff;
  color: var(--teal);
  box-shadow: 0 8px 20px rgba(7, 143, 163, 0.1);
}

.side-panel {
  border-top: 1px solid rgba(7, 143, 163, 0.18);
  padding-top: 18px;
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.side-panel h2 {
  color: #24505a;
  font-size: 13px;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 6px;
  color: inherit;
  font-size: 13px;
}

select,
input {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

.sidebar select {
  border-color: #b9dce3;
  background: #fff;
  color: var(--ink);
}

.app-shell {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--teal);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
}

.topbar h2 {
  font-size: 28px;
  margin-top: 4px;
}

.actions {
  display: flex;
  gap: 10px;
}

.primary-button,
.secondary-button,
.side-button,
.icon-button {
  border: 1px solid transparent;
  min-height: 38px;
  padding: 8px 14px;
  cursor: pointer;
}

.primary-button {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 10px 22px rgba(7, 143, 163, 0.22);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.84);
  border-color: var(--line);
  color: var(--ink);
}

.side-button {
  background: #ffffff;
  border-color: #b9dce3;
  color: var(--teal);
  font-weight: 700;
}

.toggle-line {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: #385961;
}

.toggle-line input {
  min-height: auto;
}

.icon-button {
  width: 36px;
  padding: 0;
  background: #fff;
  border-color: var(--line);
  font-size: 24px;
  line-height: 1;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.hero-panel {
  min-height: 190px;
  margin-bottom: 18px;
  padding: 28px 30px;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(0, 113, 130, 0.92), rgba(0, 147, 166, 0.66) 52%, rgba(241, 136, 28, 0.2)),
    url("assets/fond-montagne.png") center 42% / cover no-repeat;
  box-shadow: 0 22px 48px rgba(7, 143, 163, 0.18);
}

.hero-panel::after {
  content: "";
  position: absolute;
  inset: auto -8% -58px -8%;
  height: 96px;
  background: #f5fbfc;
  border-radius: 50% 50% 0 0;
  opacity: 0.94;
}

.hero-panel > * {
  position: relative;
  z-index: 1;
}

.hero-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.hero-panel h3 {
  max-width: 620px;
  margin: 0;
  font-size: 30px;
  line-height: 1.08;
}

.hero-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hero-stats span {
  min-width: 54px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--teal);
  font-weight: 800;
  text-align: center;
  box-shadow: 0 10px 20px rgba(5, 78, 91, 0.12);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 5px;
  height: 100%;
  background: linear-gradient(180deg, var(--teal), var(--cyan));
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.kpi strong {
  display: block;
  font-size: 30px;
  margin-top: 8px;
  color: #17313b;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.weekly-panel {
  margin-bottom: 18px;
}

.weekly-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px;
}

.weekly-day {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 8px 18px rgba(7, 143, 163, 0.06);
}

.weekly-day header {
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  background: #dff1f5;
  color: #285864;
}

.weekly-day header strong {
  font-size: 14px;
}

.weekly-day header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.weekly-load {
  padding: 8px 12px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  border-bottom: 1px solid var(--line);
}

.weekly-load.amber {
  color: var(--amber);
}

.weekly-task-list {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.weekly-task {
  width: 100%;
  min-height: 58px;
  border: 1px solid #b8dce4;
  background: #f7fbfc;
  color: var(--ink);
  padding: 9px;
  text-align: left;
  cursor: pointer;
}

.weekly-task:hover {
  border-color: var(--teal);
  box-shadow: 0 8px 18px rgba(7, 143, 163, 0.12);
}

.weekly-task strong,
.weekly-task span {
  display: block;
}

.weekly-task strong {
  font-size: 12px;
  line-height: 1.2;
}

.weekly-task span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.weekly-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.compact-panel {
  margin-bottom: 18px;
}

.panel-heading {
  min-height: 58px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(226, 246, 249, 0.8), rgba(255, 255, 255, 0));
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.panel-heading h3 {
  font-size: 17px;
  color: #17313b;
}

.panel-heading span {
  color: var(--muted);
  font-size: 13px;
}

.task-stack,
.alert-stack,
.project-grid {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.task-card,
.alert-card,
.project-card {
  border: 1px solid var(--line);
  padding: 12px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(7, 143, 163, 0.06);
}

.task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.task-card h4,
.project-card h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

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

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  background: #e6f5f8;
  color: #285864;
  font-size: 12px;
  font-weight: 700;
}

.tag.green {
  background: #dff3ea;
  color: var(--green);
}

.tag.amber {
  background: #fff0d9;
  color: var(--amber);
}

.tag.red {
  background: #ffe2df;
  color: var(--red);
}

.tag.blue {
  background: #ddf4f8;
  color: var(--teal);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1080px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: #285864;
  background: #dff1f5;
  font-size: 12px;
  text-transform: uppercase;
}

.workload-grid {
  display: grid;
  grid-template-columns: 180px repeat(12, minmax(86px, 1fr));
  overflow: auto;
}

.capacity-editor {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  padding: 14px;
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  padding: 14px;
}

.forecast-card {
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px;
  box-shadow: 0 10px 22px rgba(7, 143, 163, 0.08);
}

.forecast-card header,
.forecast-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.forecast-card header strong {
  color: #17313b;
}

.forecast-card header span,
.forecast-sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.forecast-main {
  margin-top: 12px;
  font-size: 28px;
  font-weight: 800;
  color: #17313b;
}

.forecast-foot {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 800;
}

.forecast-card.green .forecast-foot {
  color: var(--green);
}

.forecast-card.amber .forecast-foot {
  color: var(--amber);
}

.forecast-card.red .forecast-foot {
  color: var(--red);
}

.forecast-card.amber {
  border-color: #f0c174;
}

.forecast-card.red {
  border-color: #efaaa6;
}

.capacity-card {
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px;
  box-shadow: 0 10px 22px rgba(7, 143, 163, 0.08);
}

.capacity-card strong {
  display: block;
  margin-bottom: 4px;
}

.capacity-card input {
  width: 100%;
  margin-top: 8px;
}

.capacity-card .row-actions {
  margin-top: 10px;
}

.workload-cell,
.workload-head,
.person-cell {
  min-height: 58px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 9px;
  background: #fff;
}

.workload-head,
.person-cell {
  background: #dff1f5;
  font-weight: 700;
}

.load-bar {
  height: 8px;
  background: #dbe5ef;
  margin-top: 8px;
}

.load-bar span {
  display: block;
  height: 100%;
  max-width: 100%;
  background: var(--green);
}

.load-bar span.amber {
  background: var(--amber);
}

.load-bar span.red {
  background: var(--red);
}

.project-grid {
  grid-template-columns: repeat(3, minmax(230px, 1fr));
}

.gantt-controls {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) repeat(3, minmax(150px, 1fr));
  gap: 12px;
  padding: 14px;
  background: #f7fbfc;
  border-bottom: 1px solid var(--line);
}

.gantt-grid {
  overflow: auto;
}

.gantt-table {
  display: grid;
  min-width: 980px;
}

.gantt-head,
.gantt-subhead,
.gantt-track,
.gantt-left {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-height: 50px;
  padding: 9px;
  background: #fff;
}

.gantt-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #dff1f5;
  color: #285864;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.gantt-subhead {
  position: sticky;
  top: 50px;
  z-index: 2;
  background: #eef9fb;
  color: #285864;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.gantt-group {
  min-height: 42px;
  display: grid;
  place-items: center;
  background: linear-gradient(90deg, rgba(7, 143, 163, 0.14), rgba(100, 197, 212, 0.2));
}

.gantt-corner {
  min-height: 42px;
}

.gantt-head span,
.gantt-subhead span {
  color: var(--muted);
  font-weight: 700;
  text-transform: none;
}

.gantt-left {
  position: sticky;
  left: 0;
  z-index: 2;
}

.gantt-left.gantt-head,
.gantt-left.gantt-subhead {
  z-index: 3;
  text-align: left;
}

.gantt-person-row {
  min-height: 42px;
  padding: 10px 12px;
  background: linear-gradient(90deg, rgba(7, 143, 163, 0.12), rgba(255, 255, 255, 0.92));
  border-bottom: 1px solid var(--line);
  color: #17313b;
}

.gantt-person-row strong {
  margin-right: 10px;
}

.gantt-person-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.gantt-task,
.gantt-person-cell {
  display: grid;
  gap: 5px;
  align-content: center;
}

.gantt-task strong,
.gantt-person-cell strong {
  font-size: 13px;
}

.gantt-task span,
.gantt-person-cell span {
  color: var(--muted);
  font-size: 12px;
}

.gantt-person-cell {
  min-height: 74px;
  background: #f7fbfc;
}

.gantt-person-cell.merged {
  align-content: start;
  padding-top: 14px;
  background: linear-gradient(180deg, #f7fbfc, #eef9fb);
  border-bottom: 1px solid var(--line);
}

.gantt-track {
  position: relative;
  min-height: 74px;
  padding: 13px 8px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(201, 225, 230, 0.58) 0,
      rgba(201, 225, 230, 0.58) 1px,
      transparent 1px,
      transparent calc(100% / var(--gantt-cols))
    ),
    #ffffff;
}

.gantt-bar {
  display: block;
  position: absolute;
  left: calc((100% / var(--gantt-cols)) * (var(--bar-start) - 1) + 6px);
  width: calc((100% / var(--gantt-cols)) * var(--bar-span) - 10px);
  top: 13px;
  min-height: 34px;
  padding: 6px 9px;
  color: #fff;
  background: var(--teal);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  white-space: nowrap;
  box-shadow: 0 6px 14px rgba(7, 143, 163, 0.18);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.gantt-bar.dragging {
  cursor: grabbing;
  opacity: 0.88;
  z-index: 5;
  box-shadow: 0 12px 28px rgba(7, 143, 163, 0.28);
}

.gantt-bar small {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  opacity: 0.88;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gantt-handle {
  position: absolute;
  top: 0;
  width: 12px;
  height: 100%;
  background: rgba(255, 255, 255, 0.35);
  cursor: ew-resize;
}

.gantt-left-handle {
  left: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.48);
}

.gantt-right-handle {
  right: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.48);
}

.context-menu {
  position: fixed;
  z-index: 1000;
  width: 190px;
  padding: 6px;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: 0 18px 46px rgba(7, 79, 92, 0.2);
}

.context-menu button {
  width: 100%;
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}

.context-menu button:hover {
  background: #e6f5f8;
  color: var(--teal);
}

.context-menu button:disabled {
  color: #9aa9ad;
  cursor: not-allowed;
}

.gantt-bar.green {
  background: var(--green);
}

.gantt-bar.amber {
  background: var(--amber);
}

.gantt-bar.red {
  background: var(--red);
}

dialog {
  border: 1px solid var(--line);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  box-shadow: 0 22px 60px rgba(7, 143, 163, 0.22);
}

dialog::backdrop {
  background: rgba(7, 79, 92, 0.25);
}

form {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-heading h3 {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.mini-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-height: 30px;
  padding: 5px 8px;
  cursor: pointer;
  font-size: 12px;
}

.mini-button.danger {
  color: var(--red);
  border-color: #f3b8b5;
}

menu {
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 980px) {
  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: auto;
    padding: 30px 24px;
  }

  .login-visual h1 {
    font-size: 34px;
  }

  .login-card {
    margin: 0 24px 32px;
  }

  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
  }

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

  .split-layout,
  .project-grid,
  .kpi-grid,
  .weekly-board,
  .forecast-grid,
  .gantt-controls {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media print {
  @page {
    size: A3 landscape;
    margin: 10mm;
  }

  body,
  body.authenticated {
    display: block;
    background: #ffffff;
    color: #111827;
  }

  .login-screen,
  .sidebar,
  .actions,
  .gantt-controls,
  .context-menu,
  dialog {
    display: none !important;
  }

  .app-shell {
    padding: 0;
  }

  .topbar {
    display: block;
    margin-bottom: 10px;
    border-bottom: 2px solid #078fa3;
    padding-bottom: 8px;
  }

  .eyebrow {
    color: #078fa3;
  }

  .view {
    display: none !important;
  }

  .view.active-view {
    display: block !important;
  }

  .panel {
    box-shadow: none;
    border-color: #b8dce4;
    break-inside: avoid;
  }

  .panel-heading {
    background: #eef9fb;
  }

  .gantt-grid,
  .table-wrap {
    overflow: visible;
  }

  .gantt-table {
    min-width: 0;
    width: 100%;
  }

  .gantt-left,
  .gantt-head,
  .gantt-subhead {
    position: static;
  }

  .gantt-bar {
    box-shadow: none;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .gantt-handle,
  .mini-button {
    display: none !important;
  }
}
