:root {
  --ink: #1c1914;
  --muted: #6b645a;
  --paper: #f3efe6;
  --panel: rgba(255, 252, 246, 0.88);
  --line: rgba(28, 25, 20, 0.12);
  --accent: #0f6b4c;
  --accent-2: #c45c26;
  --warn: #9a3412;
  --ok: #0f6b4c;
  --shadow: 0 18px 50px rgba(28, 25, 20, 0.08);
  --radius: 18px;
  --font-sans: "DM Sans", sans-serif;
  --font-display: "Fraunces", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(196, 92, 38, 0.14), transparent 34%),
    radial-gradient(circle at 88% 0%, rgba(15, 107, 76, 0.12), transparent 30%),
    linear-gradient(180deg, #efe8d8 0%, var(--paper) 45%, #e7e0d2 100%);
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(28, 25, 20, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 25, 20, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 85%);
}

.site-header,
main,
.site-footer {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 0 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  width: 3rem;
  height: 3rem;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #f7f1e4;
  font-family: var(--font-display);
  font-size: 1.45rem;
}

.brand-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-tag,
.muted {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.3rem;
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.7);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
}

.tab.active {
  background: var(--ink);
  color: #f7f1e4;
}

.panel {
  display: none;
  margin: 0.5rem 0 2rem;
  padding: 1.4rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.panel.active {
  display: block;
  animation: rise 0.35s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  letter-spacing: -0.03em;
}

select,
input,
button {
  font: inherit;
}

select,
input {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
}

button[type="submit"] {
  align-self: end;
  border: 0;
  border-radius: 12px;
  padding: 0.8rem 1.1rem;
  background: var(--accent);
  color: #f4fff9;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

button[type="submit"]:hover {
  transform: translateY(-1px);
  background: #0c573e;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.2rem;
}

.stat {
  padding: 1rem;
  border-radius: 14px;
  background: linear-gradient(180deg, #fffdf8, #f4eee2);
  border: 1px solid var(--line);
}

.stat .label {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0 0 0.35rem;
}

.stat .value {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
}

.stage-list,
.card-grid {
  display: grid;
  gap: 0.75rem;
}

.stage-row,
.stage-card,
.material-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf8;
  padding: 1rem;
}

.stage-row {
  display: grid;
  grid-template-columns: 2.2fr 1fr 1fr 1fr;
  gap: 0.75rem;
  align-items: center;
}

.stage-row.current {
  outline: 2px solid rgba(15, 107, 76, 0.35);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.completed {
  background: rgba(15, 107, 76, 0.12);
  color: var(--ok);
}

.badge.in_progress {
  background: rgba(196, 92, 38, 0.14);
  color: var(--accent-2);
}

.badge.pending {
  background: rgba(28, 25, 20, 0.06);
  color: var(--muted);
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(28, 25, 20, 0.08);
  overflow: hidden;
  margin-top: 0.55rem;
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #1f9a6d);
  border-radius: inherit;
}

.card-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.stage-card h3,
.material-card h3 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.estimate-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.estimate-form label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.estimate-result .hero-cost {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0.2rem 0 0.8rem;
}

.breakdown {
  display: grid;
  gap: 0.55rem;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 1.6fr 0.6fr 0.8fr;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(28, 25, 20, 0.03);
  font-size: 0.92rem;
}

.suppliers {
  margin-top: 0.55rem;
  padding-left: 1rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.site-footer {
  padding: 0 0 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  background: rgba(28, 25, 20, 0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

.overview-section {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.section-title-row h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

/* Flowchart */
.flowchart {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.flow-step {
  animation: rise 0.4s ease both;
}

.flow-step:nth-child(1) { animation-delay: 0.02s; }
.flow-step:nth-child(2) { animation-delay: 0.05s; }
.flow-step:nth-child(3) { animation-delay: 0.08s; }
.flow-step:nth-child(4) { animation-delay: 0.11s; }
.flow-step:nth-child(5) { animation-delay: 0.14s; }

.flow-main {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 0.85rem;
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf8, #f7f1e6);
}

.flow-step.current .flow-main {
  outline: 2px solid rgba(15, 107, 76, 0.35);
  background: linear-gradient(180deg, #f4fff9, #fffdf8);
}

.flow-step.status-completed .flow-index {
  background: var(--ok);
}

.flow-step.status-in_progress .flow-index {
  background: var(--accent-2);
}

.flow-index {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #f7f1e4;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
}

.flow-title-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.substage-flow {
  margin-top: 0.85rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: rgba(28, 25, 20, 0.035);
  border: 1px dashed rgba(28, 25, 20, 0.12);
}

.substage-node {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 0.55rem;
  align-items: start;
}

.substage-node strong {
  font-size: 0.92rem;
}

.labour-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.labour-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.labour-chip.cat-trade {
  background: rgba(15, 107, 76, 0.12);
  color: #0c573e;
  border-color: rgba(15, 107, 76, 0.18);
}

.labour-chip.cat-professional {
  background: rgba(196, 92, 38, 0.12);
  color: #8a3d14;
  border-color: rgba(196, 92, 38, 0.2);
}

.labour-chip.cat-general {
  background: rgba(28, 25, 20, 0.08);
  color: #4a453d;
  border-color: rgba(28, 25, 20, 0.12);
}

.labour-chip.cat-equipment {
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.18);
}

.gantt-label .labour-chips {
  margin-top: 0.25rem;
  padding-left: 0.85rem;
}

.gantt-label .labour-chip {
  font-size: 0.65rem;
  padding: 0.12rem 0.4rem;
}

.gantt-row.sub .gantt-label,
.gantt-row.sub .gantt-track {
  min-height: 52px;
}

.sub-dot {
  width: 10px;
  height: 10px;
  margin-top: 0.35rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 107, 76, 0.12);
}

.substage-connector {
  width: 2px;
  height: 10px;
  margin: 0.15rem 0 0.15rem 4px;
  background: rgba(15, 107, 76, 0.28);
}

.flow-arrow {
  display: flex;
  justify-content: center;
  padding: 0.25rem 0 0.25rem 24px;
}

.flow-arrow span {
  width: 2px;
  height: 22px;
  background: linear-gradient(180deg, rgba(28, 25, 20, 0.35), rgba(28, 25, 20, 0.08));
  position: relative;
}

.flow-arrow span::after {
  content: "";
  position: absolute;
  left: -4px;
  bottom: -1px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid rgba(28, 25, 20, 0.35);
}

/* Gantt */
.gantt-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffdf8;
}

.gantt {
  min-width: 760px;
}

.gantt-header,
.gantt-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
}

.gantt-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f4eee2;
  border-bottom: 1px solid var(--line);
}

.gantt-label {
  padding: 0.65rem 0.85rem;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.15rem;
}

.gantt-label.head {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
}

.gantt-indent {
  padding-left: 0.85rem;
  font-size: 0.86rem;
  color: var(--muted);
}

.gantt-months {
  display: flex;
  min-height: 42px;
}

.gantt-month {
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  border-right: 1px solid rgba(28, 25, 20, 0.08);
}

.gantt-body {
  position: relative;
}

.gantt-block {
  border-bottom: 1px solid rgba(28, 25, 20, 0.08);
}

.gantt-block.current {
  background: rgba(15, 107, 76, 0.04);
}

.gantt-row.sub .gantt-label,
.gantt-row.sub .gantt-track {
  min-height: 34px;
}

.gantt-row.main .gantt-label,
.gantt-row.main .gantt-track {
  min-height: 46px;
}

.gantt-track {
  position: relative;
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent calc(100% / 12 - 1px),
    rgba(28, 25, 20, 0.05) calc(100% / 12 - 1px),
    rgba(28, 25, 20, 0.05) calc(100% / 12)
  );
}

.gantt-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  padding: 0 0.45rem;
  color: #fffdf8;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  box-shadow: 0 6px 14px rgba(28, 25, 20, 0.12);
  transition: transform 0.15s ease;
}

.gantt-bar:hover {
  transform: translateY(-50%) scaleY(1.08);
  z-index: 1;
}

.gantt-bar.main {
  height: 22px;
}

.gantt-bar.sub {
  height: 12px;
  opacity: 0.85;
}

.gantt-bar.status-completed {
  background: linear-gradient(90deg, #0c573e, #1f9a6d);
}

.gantt-bar.status-in_progress {
  background: linear-gradient(90deg, #a34a1c, #d9783a);
}

.gantt-bar.status-pending {
  background: linear-gradient(90deg, #6b645a, #9a9184);
}

.gantt-today-layer {
  position: absolute;
  inset: 0 0 0 240px;
  pointer-events: none;
  z-index: 3;
}

.gantt-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #b42318;
}

.gantt-today::before {
  content: "Today";
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #b42318;
  background: rgba(255, 253, 248, 0.92);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}

.gantt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  padding: 0.75rem 0.9rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.gantt-legend .swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-right: 0.35rem;
  vertical-align: -1px;
}

.gantt-legend .swatch.completed { background: #1f9a6d; }
.gantt-legend .swatch.in_progress { background: #d9783a; }
.gantt-legend .swatch.pending { background: #9a9184; }
.gantt-legend .swatch.today { background: #b42318; border-radius: 2px; width: 3px; }

@media (max-width: 860px) {
  .stat-row,
  .estimate-form,
  .stage-row,
  .breakdown-row {
    grid-template-columns: 1fr 1fr;
  }

  .stage-row {
    align-items: start;
  }

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

  button[type="submit"] {
    grid-column: 1 / -1;
  }

  .gantt-header,
  .gantt-row {
    grid-template-columns: 180px 1fr;
  }

  .gantt-today-layer {
    inset: 0 0 0 180px;
  }
}

@media (max-width: 560px) {
  .stat-row,
  .estimate-form,
  .stage-row,
  .breakdown-row {
    grid-template-columns: 1fr;
  }

  .tabs {
    width: 100%;
    overflow-x: auto;
  }

  .flow-main {
    grid-template-columns: 40px 1fr;
  }

  .flow-index {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
}

/* Tracker */
.tracker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 0.5rem;
}

.tracker-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf8;
}

.tracker-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.tracker-card label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.lookup-hint,
.form-status {
  margin: 0;
  min-height: 1.1em;
  font-size: 0.8rem;
  color: var(--accent);
}

.hidden {
  display: none !important;
}

.form-status {
  color: var(--accent-2);
}

.progress-stage {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
  margin-bottom: 0.55rem;
  padding: 0.7rem 0.85rem;
}

.progress-stage summary {
  cursor: pointer;
  list-style: none;
  display: grid;
  gap: 0.25rem;
}

.progress-stage summary::-webkit-details-marker {
  display: none;
}

.progress-subs {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.55rem;
}

.progress-sub {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 0.75rem;
  padding: 0.65rem 0.7rem;
  border-radius: 10px;
  background: rgba(28, 25, 20, 0.03);
  align-items: center;
}

.progress-pct {
  text-align: right;
}

.tracker-activity {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.4rem;
}

.tracker-activity h3 {
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
}

.activity-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}

.activity-amt {
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .tracker-grid,
  .tracker-activity {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .progress-sub,
  .form-row {
    grid-template-columns: 1fr;
  }
}
