:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --ink: #17202f;
  --muted: #687386;
  --line: #dde3ee;
  --brand: #ed1c24;
  --brand-2: #7a3b1f;
  --accent: #f8b400;
  --danger: #dc2626;
  --shadow: 0 18px 45px rgba(31, 41, 55, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  cursor: pointer;
  min-height: 40px;
  padding: 0 16px;
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(237, 28, 36, 0.22);
}

.ghost {
  background: #fff0f1;
  color: var(--ink);
  border: 1px solid rgba(237, 28, 36, 0.18);
}

.compact {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.topbar {
  min-height: 176px;
  padding: 34px clamp(18px, 4vw, 54px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background:
    linear-gradient(115deg, rgba(237, 28, 36, 0.96), rgba(122, 59, 31, 0.88)),
    radial-gradient(circle at 80% 30%, rgba(255, 255, 255, 0.26), transparent 34%);
  background-size: cover;
  background-position: center;
  color: white;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-logo {
  width: 104px;
  height: 104px;
  object-fit: contain;
  border-radius: 8px;
  background: white;
  padding: 10px;
  box-shadow: 0 18px 34px rgba(88, 20, 13, 0.22);
}

.eyebrow,
.subtitle {
  margin: 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 800;
  opacity: 0.86;
  color: white;
}

h1,
h2 {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1;
  letter-spacing: 0;
}

.subtitle {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 16px;
}

.actions,
.view-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

main {
  padding: 22px clamp(14px, 3vw, 34px) 44px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin: -56px 0 18px;
  position: relative;
  z-index: 2;
}

.section-nav {
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
  overflow-x: auto;
  padding: 4px 0 10px;
}

.section-nav a {
  flex: 0 0 auto;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 14px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
  white-space: nowrap;
}

.section-nav a:hover {
  background: var(--brand);
  color: white;
}

.save-status {
  position: sticky;
  top: 10px;
  z-index: 12;
  width: fit-content;
  margin: -6px 0 16px auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 10px 26px rgba(31, 41, 55, 0.08);
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.save-status.is-saved {
  background: #ecfdf5;
  color: #047857;
  transform: translateY(-2px);
}

.kpi {
  background: var(--panel);
  border: 1px solid rgba(221, 227, 238, 0.82);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

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

.kpi strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
}

.kpi small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
}

.filters,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(31, 41, 55, 0.07);
}

.filters {
  padding: 16px;
  align-self: start;
  position: sticky;
  top: 14px;
  overflow: hidden;
}

.filters::before {
  content: "";
  display: block;
  height: 5px;
  margin: -16px -16px 14px;
  background: linear-gradient(90deg, var(--brand), var(--accent), var(--brand-2));
}

.panel-title,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-title {
  margin-bottom: 16px;
  font-weight: 800;
}

.panel-title small,
.panel-head span {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.save-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.save-actions span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

label {
  display: grid;
  gap: 7px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

select,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  min-height: 40px;
  padding: 0 10px;
  color: var(--ink);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

select:focus,
input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(237, 28, 36, 0.1);
  outline: none;
}

.filter-hint {
  margin-top: 18px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.main-panels {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.panel {
  padding: 16px;
  min-width: 0;
  scroll-margin-top: 18px;
}

.chart-row {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 18px;
}

.chart {
  min-height: 260px;
  margin-top: 12px;
  overflow: hidden;
}

.chart svg,
.gantt svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.pie-slice {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.pie-slice:hover {
  transform: scale(1.045);
  filter: drop-shadow(0 10px 12px rgba(237, 28, 36, 0.2));
}

.milestone-strip {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.milestone {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
  box-shadow: 0 8px 22px rgba(31, 41, 55, 0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.milestone:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 34px rgba(237, 28, 36, 0.12);
}

.milestone b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-bottom: 10px;
  border-radius: 999px;
  background: #fff0f1;
  color: var(--brand);
  font-size: 12px;
}

.milestone strong {
  display: block;
  font-size: 13px;
  min-height: 38px;
}

.milestone span {
  display: block;
  margin-top: 8px;
  color: var(--brand);
  font-weight: 800;
}

.scroll-chart {
  max-height: 330px;
  overflow-y: auto;
  padding-right: 8px;
}

.contractor-chart {
  min-height: 240px;
}

.active-view {
  background: var(--brand);
  color: white;
}

.gantt-range {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.gantt {
  margin-top: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  min-height: 320px;
}

.gantt svg {
  min-width: 920px;
}

.bar-task {
  cursor: grab;
  transition: opacity 0.18s ease, filter 0.18s ease;
  touch-action: none;
}

.bar-task:hover {
  filter: brightness(1.08);
}

.bar-task:active {
  cursor: grabbing;
}

.resize-handle {
  fill: rgba(255, 255, 255, 0.45);
  stroke: rgba(23, 32, 47, 0.24);
  stroke-width: 1;
  cursor: ew-resize;
  touch-action: none;
}

.resize-handle:hover {
  fill: rgba(255, 255, 255, 0.82);
}

.table-wrap {
  margin-top: 12px;
  overflow: auto;
  max-height: 460px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 940px;
}

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

th {
  position: sticky;
  top: 0;
  background: #f2f5f9;
  z-index: 1;
  color: #405066;
  font-weight: 900;
}

td input,
td select {
  min-height: 34px;
  border-radius: 6px;
  font-size: 13px;
}

.money,
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 26px;
  border-radius: 999px;
  color: white;
  font-weight: 900;
}

.tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(23, 32, 47, 0.95);
  color: white;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: var(--shadow);
  transform: translate(-50%, -115%);
  white-space: normal;
  max-width: min(420px, calc(100vw - 28px));
  z-index: 20;
}

@media (max-width: 1050px) {
  .workspace,
  .chart-row {
    grid-template-columns: 1fr;
  }

  .filters {
    position: static;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-block {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .kpi-grid,
  .milestone-strip {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .kpi-grid,
  .milestone-strip {
    grid-template-columns: 1fr;
  }
}
