:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-strong: #f9fafb;
  --text: #172033;
  --muted: #667085;
  --line: #d8dde6;
  --line-soft: #eceff4;
  --green: #1f8a5b;
  --green-bg: #dff3ea;
  --yellow: #b7791f;
  --yellow-bg: #fff2cc;
  --red: #c2413a;
  --red-bg: #fde2df;
  --blue: #2f6fab;
  --blue-bg: #dcecff;
  --gray: #6b7280;
  --gray-bg: #eef0f3;
  --shadow: 0 12px 32px rgba(16, 24, 40, 0.08);
  --left-width: 300px;
  --week-width: 74px;
  --row-height: 66px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

body.day-mode {
  --week-width: 154px;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.top-actions,
.legend,
.control-panel,
.timeline-toolbar,
.section-head,
.panel-header {
  display: flex;
  align-items: center;
}

.top-actions {
  gap: 8px;
}

.icon-button,
.close-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  min-width: 64px;
  min-height: 36px;
  border-radius: 8px;
  font-weight: 700;
}

.primary-action {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.icon-button:hover,
.close-button:hover {
  border-color: #9aa4b2;
}

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

.control-panel {
  gap: 12px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.search-label {
  flex: 1;
}

.timeline-card,
.decision-dock > article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.timeline-card {
  overflow: hidden;
}

.timeline-toolbar {
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.calendar-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.calendar-summary span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--panel-strong);
}

.calendar-summary strong {
  color: var(--text);
  font-size: 14px;
}

.legend {
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.legend span,
.status-pill,
.risk-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

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

.yellow {
  background: var(--yellow);
}

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

.blue {
  background: var(--blue);
}

.gantt-shell {
  display: grid;
  grid-template-columns: var(--left-width) minmax(0, 1fr);
  max-height: calc(100vh - 214px);
  min-height: 520px;
}

.gantt-left {
  border-right: 1px solid var(--line);
  background: var(--panel-strong);
  overflow: hidden;
}

.left-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 72px;
  padding: 15px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.left-head__label {
  min-width: 0;
}

.add-project-button {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.add-project-button:hover {
  filter: brightness(1.08);
}

.add-project-button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.project-labels,
.gantt-grid {
  display: grid;
  position: relative;
}

.project-slot,
.gantt-slot {
  position: relative;
  will-change: transform;
}

.is-reordering .project-slot:not(.is-dragging),
.is-reordering .gantt-slot:not(.is-dragging) {
  transition: transform 200ms cubic-bezier(0.2, 0, 0, 1);
}

.project-slot.is-dragging {
  z-index: 6;
}

.project-slot.is-dragging .project-label {
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(16, 24, 40, 0.18);
}

.gantt-slot.is-dragging {
  z-index: 5;
  filter: drop-shadow(0 8px 20px rgba(16, 24, 40, 0.12));
}

.project-slot.is-dragging,
.gantt-slot.is-dragging {
  transition: none;
}

body.is-reordering {
  cursor: grabbing;
  user-select: none;
}

body.is-reordering .project-label {
  cursor: grabbing;
}

.project-label {
  width: 100%;
  height: var(--row-height);
  padding: 6px 8px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 10px;
  line-height: 1.2;
}

.project-label:hover,
.project-label.active {
  background: #eef5ff;
}



.project-label.dimmed,
.gantt-row.dimmed {
  opacity: 0.35;
}

.project-main {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.drag-handle {
  flex: none;
  color: #9aa4b2;
  cursor: grab;
  font-size: 11px;
  line-height: 1;
  touch-action: none;
  padding: 1px 2px;
  border-radius: 4px;
  margin-top: 1px;
}

.drag-handle:hover {
  color: #667085;
  background: rgba(47, 111, 171, 0.08);
}

.drag-handle:active,
body.is-reordering .drag-handle {
  cursor: grabbing;
}

.project-title {
  flex: 1;
  min-width: 0;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.project-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.2;
}

.project-sub-meta {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  flex: none;
  min-width: 30px;
  justify-content: center;
  border-radius: 999px;
  padding: 1px 5px;
  font-size: 9px;
  font-weight: 800;
}

.status-gron {
  background: var(--green-bg);
  color: var(--green);
}

.status-gul {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.status-rod {
  background: var(--red-bg);
  color: var(--red);
}

.status-gra {
  background: var(--gray-bg);
  color: var(--gray);
}

.gantt-right {
  position: relative;
  overflow: auto;
  background: #fff;
}

.month-axis,
.week-axis,
.gantt-row {
  position: relative;
  min-width: calc(var(--week-width) * var(--week-count));
}

.month-axis {
  display: grid;
  grid-template-columns: repeat(var(--week-count), var(--week-width));
  height: 36px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
}

.month-cell {
  padding: 10px 8px;
  border-right: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.week-axis {
  display: grid;
  grid-template-columns: repeat(var(--week-count), var(--week-width));
  height: 36px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.week-cell {
  padding: 10px 8px;
  border-right: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.gantt-row {
  height: var(--row-height);
  border-bottom: 1px solid var(--line-soft);
  background-image: linear-gradient(to right, var(--line-soft) 1px, transparent 1px);
  background-size: var(--week-width) 100%;
  isolation: isolate;
}

.gantt-row:hover {
  background-color: #f8fbff;
}

.gantt-row.selected {
  background-color: #f2f7ff;
}

.bar {
  position: absolute;
  top: 17px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  box-shadow: 0 6px 16px rgba(16, 24, 40, 0.12);
  overflow: hidden;
  z-index: 2;
}

.bar span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}

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

.bar.yellow {
  background: var(--yellow);
}

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

.bar.gray {
  background: var(--gray);
}

.bar.procurement {
  top: 50px;
  height: 7px;
  border-radius: 999px;
  background: var(--blue);
  padding: 0;
  z-index: 1;
}

.gate-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.gate-marker {
  position: absolute;
  top: 12px;
  transform: translateX(-50%);
  z-index: 1;
}

.gate-marker__pill {
  display: inline-flex;
  align-items: center;
  max-width: 92px;
  padding: 4px 8px;
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.22);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gate-marker--test .gate-marker__pill {
  background: #b45309;
}

.gate-marker--bom .gate-marker__pill {
  background: #5b4bb7;
}

.gate-marker--ship .gate-marker__pill {
  background: var(--green);
}

.gate-marker--milestone .gate-marker__pill {
  background: #1f2937;
}

.gate-marker::before {
  content: "";
  position: absolute;
  top: 24px;
  left: 50%;
  width: 2px;
  height: 14px;
  transform: translateX(-50%);
  background: currentColor;
  opacity: 0.55;
}

.gate-marker--test {
  color: #b45309;
}

.gate-marker--bom {
  color: #5b4bb7;
}

.gate-marker--ship {
  color: var(--green);
}

.gate-marker--milestone {
  color: #1f2937;
}

.today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 4;
  width: 2px;
  background: #111827;
}

.today-line::before {
  content: "Idag";
  position: absolute;
  top: 4px;
  left: 4px;
  padding: 2px 5px;
  border-radius: 4px;
  background: #111827;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.project-detail-label {
  height: 210px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #eef5ff;
  overflow: hidden;
}

.detail-label-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.detail-label-top strong {
  font-size: 14px;
}

.mini-button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.detail-label-grid {
  display: grid;
  gap: 6px;
}

.detail-label-grid span {
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-label-grid b {
  display: block;
  color: var(--text);
  font-size: 10px;
  text-transform: uppercase;
}

.day-detail-row {
  position: relative;
  height: 210px;
  min-width: calc(var(--week-width) * var(--week-count));
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(to right, rgba(47, 111, 171, 0.12) 1px, transparent 1px),
    linear-gradient(to right, var(--line-soft) 1px, transparent 1px),
    #fbfdff;
  background-size:
    calc(var(--week-width) / 7) 100%,
    var(--week-width) 100%,
    auto;
  isolation: isolate;
}

.day-detail-row .row-day-shades {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.day-detail-row .day-shade {
  position: absolute;
  top: 0;
  bottom: 0;
}

.day-detail-row .day-shade--weekend {
  background: rgba(194, 65, 58, 0.08);
}

.day-detail-row .day-shade--holiday {
  background: rgba(194, 65, 58, 0.18);
  box-shadow: inset 0 0 0 1px rgba(194, 65, 58, 0.22);
}

.day-project-window {
  position: absolute;
  top: 12px;
  bottom: 18px;
  border: 1px solid rgba(47, 111, 171, 0.25);
  border-radius: 8px;
  background: rgba(47, 111, 171, 0.05);
}

.day-cell {
  position: absolute;
  top: 15px;
  height: 35px;
  border-right: 1px solid rgba(47, 111, 171, 0.12);
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.day-cell span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  min-height: 18px;
  border-radius: 999px;
  background: #fff;
  font-weight: 800;
}

.day-cell.monday span {
  background: #111827;
  color: #fff;
}

.day-cell.friday span {
  border: 1px solid var(--line);
}

.day-cell--weekend {
  background: rgba(194, 65, 58, 0.06);
}

.day-cell--holiday {
  background: rgba(194, 65, 58, 0.14);
}

.day-cell--weekend span,
.day-cell--holiday span {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(194, 65, 58, 0.25);
}

.day-band {
  position: absolute;
  top: 78px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 0 9px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
}

.procurement-band {
  background: var(--blue);
}

.day-milestone {
  position: absolute;
  top: 122px;
  width: 2px;
  height: 52px;
  background: #111827;
}

.day-milestone span {
  position: absolute;
  top: 0;
  left: 5px;
  max-width: 120px;
  border-radius: 5px;
  padding: 3px 6px;
  background: #111827;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-milestone.red {
  background: var(--red);
}

.day-milestone.red span {
  background: var(--red);
}

.day-milestone.yellow {
  background: var(--yellow);
}

.day-milestone.yellow span {
  background: var(--yellow);
}

.day-milestone.gate {
  background: #111827;
}

.decision-dock {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.decision-dock > article {
  padding: 14px;
  min-height: 168px;
}

.section-head {
  justify-content: space-between;
  margin-bottom: 10px;
}

.stack-list {
  display: grid;
  gap: 8px;
}

.risk-card,
.detail-card {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.risk-card {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.risk-card.red {
  border-left-color: var(--red);
}

.risk-card.yellow {
  border-left-color: var(--yellow);
}

.risk-card.blue {
  border-left-color: var(--blue);
}

.detail-card.red {
  border-left-color: var(--red);
}

.detail-card.yellow {
  border-left-color: var(--yellow);
}

.detail-card.blue {
  border-left-color: var(--blue);
}

.risk-card strong,
.detail-card strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.risk-card p,
.detail-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  width: min(440px, 100vw);
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 40px rgba(16, 24, 40, 0.18);
  transform: translateX(105%);
  transition: transform 160ms ease;
  display: flex;
  flex-direction: column;
}

.detail-panel.open {
  transform: translateX(0);
}

.panel-header {
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  font-size: 20px;
}

.close-button {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  font-size: 24px;
  line-height: 1;
}

.panel-body {
  overflow: auto;
  padding: 16px 18px 22px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.fact {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-strong);
}

.fact span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.fact strong {
  font-size: 13px;
}

.panel-section {
  margin-top: 16px;
}

.panel-section h3 {
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

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

.project-dialog {
  width: min(720px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.project-dialog::backdrop {
  background: rgba(16, 24, 40, 0.32);
}

.project-form {
  padding: 18px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head {
  margin-bottom: 16px;
}

.dialog-head h2 {
  font-size: 22px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.form-grid input,
.form-grid select {
  width: 100%;
}

.form-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.dialog-actions {
  margin-top: 16px;
}

.risk-chip {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--gray-bg);
  color: var(--gray);
  font-size: 11px;
  font-weight: 800;
}

.risk-chip.blue {
  background: var(--blue-bg);
  color: var(--blue);
}

.risk-chip.yellow {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.risk-chip.red {
  background: var(--red-bg);
  color: var(--red);
}

@media (max-width: 980px) {
  :root {
    --left-width: 240px;
    --week-width: 66px;
  }

  .decision-dock {
    grid-template-columns: 1fr 1fr;
  }

  .timeline-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .calendar-summary {
    margin-left: 0;
  }
}

@media (max-width: 720px) {
  .topbar,
  .control-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .decision-dock {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding: 0 12px 16px;
  }

  .gantt-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
