:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #64748b;
  --line: #d9e2ec;
  --panel: rgba(255, 255, 255, 0.86);
  --paper: #f7f9fc;
  --teal: #0f766e;
  --teal-soft: #d9f3ef;
  --coral: #d95f43;
  --gold: #b7791f;
  --blue: #2f6fed;
  --green: #23845c;
  --shadow: 0 20px 60px rgba(30, 41, 59, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.12), transparent 34%),
    linear-gradient(250deg, rgba(217, 95, 67, 0.12), transparent 32%),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 3.1rem);
  line-height: 1;
  letter-spacing: 0;
}

.subhead {
  max-width: 780px;
  margin: 10px 0 0;
  color: var(--muted);
}

.shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 18px;
  align-items: start;
}

.card,
.story,
.unit-card,
.panel {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.story {
  position: relative;
  overflow: hidden;
  padding: 20px;
  margin-bottom: 16px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.95), rgba(31, 41, 55, 0.94)),
    #0f766e;
  color: white;
}

.story::after {
  content: "7D";
  position: absolute;
  right: 18px;
  bottom: -22px;
  color: rgba(255, 255, 255, 0.08);
  font-size: 8rem;
  font-weight: 900;
}

.story h2,
.section-title h2 {
  margin: 0;
  font-size: 1.05rem;
}

.story p {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 10px 0 0;
  font-size: clamp(1.18rem, 2vw, 1.8rem);
  font-weight: 760;
  line-height: 1.25;
}

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

.kpi {
  padding: 16px;
}

.kpi span,
.label,
label span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.25rem, 2.2vw, 2rem);
}

.kpi small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.project-card {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.4fr;
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.project-card strong {
  display: block;
  margin-top: 6px;
  line-height: 1.25;
}

.project-card a {
  color: var(--teal);
  text-decoration: none;
}

.project-card a:hover {
  text-decoration: underline;
}

.disclaimer {
  margin: -4px 0 16px;
  border: 1px solid #f4c66a;
  border-radius: 8px;
  padding: 11px 13px;
  color: #713f12;
  background: #fff7d6;
  font-size: 0.92rem;
  font-weight: 650;
}

.phase-timeline {
  padding: 16px;
  margin-bottom: 16px;
}

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

.timeline-head {
  margin-bottom: 12px;
}

.timeline-head strong {
  display: block;
  margin-top: 5px;
}

.timeline-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.timeline-card {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.timeline-card span {
  color: var(--muted);
  font-size: 0.86rem;
}

.timeline-track {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.timeline-track i {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--coral));
}

.progress-card {
  padding: 14px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  font-weight: 800;
}

.bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #46b3a8);
}

.creator {
  position: sticky;
  top: 18px;
  padding: 16px;
}

.creator h2,
.panel h3 {
  margin: 0 0 14px;
  font-size: 1rem;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 11px;
}

label {
  display: grid;
  gap: 6px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.toggle-row input {
  width: 44px;
  height: 23px;
  accent-color: var(--teal);
}

.primary,
.ghost,
.tab,
.icon-button {
  border: 0;
  border-radius: 7px;
  min-height: 38px;
  padding: 9px 12px;
  font-weight: 800;
}

.primary {
  width: 100%;
  margin-top: 12px;
  color: white;
  background: var(--teal);
}

.helper {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.add-menu {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.ghost,
.tab,
.icon-button {
  color: var(--ink);
  background: #eef4f7;
}

.wide-button {
  width: 100%;
  margin-top: 8px;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.icon-button.danger {
  color: #991b1b;
  background: #fee2e2;
}

.tab.active {
  color: white;
  background: #17202a;
}

.workspace-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 16px;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 36px rgba(30, 41, 59, 0.08);
  backdrop-filter: blur(12px);
}

.workspace-tabs .tab {
  min-width: 96px;
}

.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 18px;
}

.report-panel {
  min-width: 0;
}

.report-panel h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.report-table {
  min-width: 920px;
}

.compact-report {
  min-width: 430px;
}

.report-table td:last-child,
.report-table th:last-child {
  text-align: right;
}

.document-disclaimer {
  margin: 0 0 14px;
  border: 1px solid #f4c66a;
  border-radius: 8px;
  padding: 12px 14px;
  color: #713f12;
  background: #fff7d6;
  font-size: 0.92rem;
  font-weight: 700;
}

.document-preview {
  display: grid;
  gap: 10px;
  color: #243244;
  line-height: 1.45;
}

.document-preview h4 {
  margin: 0;
  font-size: 1rem;
}

.document-preview p {
  margin: 0;
}

.document-preview ol,
.document-preview ul {
  margin: 0;
  padding-left: 22px;
}

.document-preview li {
  margin: 6px 0;
}

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

.units {
  display: grid;
  gap: 14px;
}

.unit-card {
  overflow: hidden;
}

.unit-head {
  padding: 16px;
}

.unit-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.title-input {
  min-width: min(340px, 100%);
  border-color: transparent;
  background: #f8fafc;
  font-size: 1.1rem;
  font-weight: 850;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  color: #0f172a;
  background: #e8eef6;
  font-size: 0.75rem;
  font-weight: 850;
  white-space: nowrap;
}

.badge.default {
  color: #075985;
  background: #dff2ff;
}

.badge.study {
  color: #7c2d12;
  background: #ffedd5;
}

.badge.good {
  color: #065f46;
  background: #dff7ed;
}

.badge.warn {
  color: #92400e;
  background: #fef3c7;
}

.badge.bad {
  color: #991b1b;
  background: #fee2e2;
}

.mini-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.inline-edit {
  display: flex;
  align-items: center;
  gap: 7px;
  width: min(360px, 100%);
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfdff;
}

.inline-edit span {
  white-space: nowrap;
}

.inline-edit input {
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 4px 0;
}

.structure-card {
  padding: 14px;
  margin: 10px 0 14px;
  max-height: 620px;
  overflow: auto;
}

.budget-grid-card {
  padding: 14px;
  margin: 10px 0 14px;
  box-shadow: none;
}

.budget-table {
  min-width: 1620px;
}

.budget-table td input {
  min-width: 110px;
}

.budget-table td:first-child input {
  min-width: 240px;
}

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

.location-editor {
  display: grid;
  grid-template-columns: 105px minmax(130px, 1fr);
  gap: 6px;
}

.location-editor select,
.location-editor input {
  min-width: 0;
}

.split-row td {
  background: #f8fafc;
}

.split-editor {
  display: grid;
  gap: 10px;
}

.split-editor-head,
.split-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.split-line {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.split-line:has(.badge.warn) {
  border-color: #f4c66a;
  background: #fffdf2;
}

.split-line input {
  min-width: 120px;
}

.split-line input:first-of-type {
  min-width: 180px;
}

.site-lines {
  display: grid;
  gap: 8px;
  margin: -2px 0 8px 34px;
  padding: 8px 0 8px 12px;
  border-left: 3px solid #cbd5e1;
}

.site-line {
  background: #fbfdff;
}

.structure-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
}

.structure-head h3 {
  margin: 0;
  font-size: 1rem;
}

.structure-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.structure-actions,
.structure-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.structure-list {
  flex-direction: column;
}

.structure-line {
  display: grid;
  grid-template-columns: 120px minmax(180px, 1fr) minmax(170px, 240px) auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.structure-line.phase {
  border-left: 5px solid var(--teal);
}

.structure-line.milestone {
  margin-left: 14px;
  border-left: 5px solid var(--blue);
}

.structure-line.budget-unit {
  margin-left: 28px;
}

.structure-line input {
  min-width: 0;
}

.structure-line.phase select,
.structure-line.phase .icon-button,
.structure-line.phase .badge.good,
.structure-line.phase .badge.bad,
.structure-line.milestone select,
.structure-line.milestone .icon-button,
.structure-line.milestone .badge.good,
.structure-line.milestone .badge.bad {
  display: none;
}

.unit-body {
  border-top: 1px solid var(--line);
  padding: 14px 16px 16px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

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

th,
td {
  border-bottom: 1px solid #e8edf3;
  padding: 9px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td input,
td select {
  min-width: 120px;
  padding: 8px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.toolbar label {
  min-width: 170px;
}

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

.detail-summary {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(320px, 1.2fr);
  gap: 12px;
}

.panel {
  padding: 14px;
  box-shadow: none;
}

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

.rollup-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #e8edf3;
}

.rollup-row:last-child {
  border-bottom: 0;
}

.warnings {
  display: grid;
  gap: 8px;
}

.warning {
  border-left: 4px solid var(--gold);
  border-radius: 7px;
  padding: 9px 10px;
  color: #713f12;
  background: #fff7d6;
  font-size: 0.9rem;
}

.empty {
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.ladder {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.ladder div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.compact-table table {
  min-width: 620px;
}

@media (max-width: 1040px) {
  .shell,
  .split-panel,
  .detail-summary,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .creator {
    position: static;
  }

  .grid-kpi,
  .progress-grid,
  .project-card,
  .timeline-grid,
  .rollups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app {
    width: min(100% - 20px, 1440px);
    padding-top: 18px;
  }

  .topbar,
  .section-title,
  .unit-head,
  .structure-head {
    align-items: stretch;
    flex-direction: column;
  }

  .grid-kpi,
  .progress-grid,
  .project-card,
  .timeline-grid,
  .rollups {
    grid-template-columns: 1fr;
  }

  .story p {
    font-size: 1.08rem;
  }

  .structure-line {
    grid-template-columns: 1fr;
  }

  .title-input,
  .inline-edit {
    width: 100%;
  }
}
