:root {
  --ink: #17211f;
  --paper: #f7f8f5;
  --cream: #eef2ee;
  --surface: #ffffff;
  --teal: #0f3f3b;
  --teal-soft: #e5f1ef;
  --gold: #c98512;
  --gold-soft: #fff4dc;
  --coral: #e55d3f;
  --coral-soft: #ffede7;
  --green: #2f8a61;
  --line: #d6ded8;
  --muted: #5d6964;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--paper);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:where(a, button, input, select, textarea):focus-visible {
  outline: 3px solid rgba(36, 91, 89, 0.35);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 12px 22px;
  backdrop-filter: blur(12px);
}

.logo-link,
.topbar nav,
.summary-strip,
.export-actions,
.section-heading,
.cost-summary span,
.inline-input {
  display: flex;
  align-items: center;
}

.logo-link {
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
}

.logo-link img {
  width: 168px;
  height: 46px;
  object-fit: contain;
}

.logo-link span {
  border-left: 1px solid var(--line);
  padding-left: 12px;
  color: var(--teal);
  font-size: 1rem;
}

.topbar nav {
  justify-content: center;
  gap: 6px;
}

.topbar nav a,
.side-nav a {
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.topbar nav a {
  padding: 9px 10px;
}

.topbar nav a:hover,
.side-nav a:hover,
.side-nav a.active {
  background: var(--teal-soft);
  color: var(--teal);
}

.workspace {
  display: grid;
  grid-template-columns: 188px minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 72px);
}

.side-nav {
  position: sticky;
  top: 72px;
  align-self: start;
  display: grid;
  gap: 6px;
  height: calc(100vh - 72px);
  border-right: 1px solid var(--line);
  background: var(--cream);
  padding: 18px 12px;
}

.side-nav a {
  padding: 10px 12px;
}

.work-area {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 22px;
}

.work-area > *,
.panel,
.scope-layout,
.scope-panel,
.table-wrap,
.room-table-wrap,
.export-panel {
  min-width: 0;
}

.project-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #f7f8f5 68%, #e5f1ef 100%);
  padding: clamp(20px, 4vw, 34px);
}

.project-band h1,
.project-band p,
.panel h2,
.panel p,
.export-panel h2,
.export-panel p {
  margin: 0;
}

.product-name {
  margin-bottom: 8px;
  color: var(--teal);
  font-size: 0.84rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.project-band h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1;
  letter-spacing: 0;
}

.project-band p,
.panel p,
.export-panel p,
.suggestion span,
.licence-note {
  color: var(--muted);
  line-height: 1.5;
}

.summary-strip {
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.summary-strip span {
  display: grid;
  gap: 3px;
  min-width: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.summary-strip strong {
  color: var(--ink);
  font-size: 1.2rem;
}

.panel,
.export-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(36, 31, 26, 0.06);
}

.panel {
  padding: 18px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span,
th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

textarea {
  min-height: 56px;
  resize: vertical;
}

.inline-input {
  gap: 6px;
}

.inline-input em {
  min-width: 28px;
  color: var(--muted);
  font-style: normal;
  font-weight: 900;
}

.section-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.button-group,
.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.section-heading h2,
.ai-panel h2,
.export-panel h2 {
  font-size: 1.25rem;
  line-height: 1.2;
}

.preset-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 14px;
  align-items: end;
}

.preset-note {
  border: 1px solid #ead79c;
  border-radius: 8px;
  background: var(--gold-soft);
  padding: 11px 12px;
  color: #715a19;
  font-weight: 800;
}

.scope-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid #eadfc9;
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--cream);
}

.scope-table {
  min-width: 1880px;
}

.rooms-table {
  min-width: 1120px;
}

.area-cost-table {
  min-width: 720px;
}

.scope-table textarea {
  min-height: 68px;
}

.scope-table small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.35;
}

.money-cell {
  min-width: 90px;
  color: var(--teal);
  font-weight: 900;
  white-space: nowrap;
}

.source-pill {
  display: inline-flex;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #715a19;
  padding: 5px 8px;
  font-size: 0.76rem;
  font-weight: 900;
  white-space: nowrap;
}

.source-pill.ai {
  background: var(--teal-soft);
  color: var(--teal);
}

.source-pill.auto {
  background: var(--gold-soft);
  color: #715a19;
}

.source-pill.consolidated {
  background: var(--coral-soft);
  color: var(--coral);
}

.compact-button {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 0.78rem;
}

input:disabled,
textarea:disabled {
  background: #f3f5f1;
  color: var(--muted);
  opacity: 1;
}

.spec-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.spec-grid h3 {
  margin: 0 0 10px;
  font-size: 0.98rem;
}

.standard-list {
  display: grid;
  gap: 10px;
}

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

.standard-card strong {
  color: var(--teal);
  line-height: 1.25;
}

.standard-card span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.ai-panel {
  display: grid;
  grid-template-columns: minmax(260px, 0.4fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.suggestions {
  display: grid;
  gap: 10px;
}

.suggestion,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

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

.suggestion strong {
  line-height: 1.25;
}

.export-panel {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 260px minmax(300px, 360px);
  gap: 18px;
  align-items: center;
  padding: 18px;
}

.account-panel {
  display: grid;
  gap: 14px;
}

.account-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.cost-summary {
  display: grid;
  gap: 6px;
}

.cost-summary span {
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #eadfc9;
  padding-bottom: 6px;
}

.cost-summary .total {
  border: 0;
  color: var(--teal);
  font-size: 1.1rem;
}

.export-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.version-history {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.version-history h3 {
  margin: 0;
  font-size: 0.92rem;
}

.version-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 130px 100px minmax(180px, 1.6fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.version-row strong {
  color: var(--teal);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.version-row em,
.version-row small {
  color: var(--muted);
  font-style: normal;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--teal);
}

.ghost-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.icon-button {
  min-width: 36px;
  border: 1px solid var(--line);
  background: var(--coral-soft);
  color: var(--coral);
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.full-width {
  width: 100%;
}

.status-line {
  min-height: 24px;
  color: var(--teal);
  font-weight: 800;
}

.loading-panel {
  width: min(760px, calc(100% - 32px));
  margin: 80px auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 28px;
}

@media (max-width: 1180px) {
  .project-grid,
  .preset-grid,
  .account-grid,
  .scope-layout,
  .export-panel,
  .project-band,
  .spec-grid {
    grid-template-columns: 1fr;
  }

  .ai-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr;
  }

  .topbar nav {
    justify-content: flex-start;
    overflow-x: auto;
  }

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

  .side-nav {
    position: static;
    display: flex;
    height: auto;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .work-area {
    padding: 14px;
  }

  .version-row {
    grid-template-columns: 1fr;
  }

  .logo-link img {
    width: 138px;
  }
}
