:root {
  color-scheme: light;
  --ink: #171716;
  --muted: #686660;
  --line: #dedbd4;
  --paper: #f3f1ec;
  --panel: #ffffff;
  --brand: #111111;
  --brand-2: #9c7a45;
  --accent: #7f8584;
  --soft: #ebe8e1;
  --warning: #f8ecd8;
  --warning-line: #b88745;
  --shadow: 0 14px 40px rgba(20, 20, 18, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(243, 241, 236, 0.94)),
    repeating-linear-gradient(105deg, rgba(20, 20, 18, 0.035) 0 1px, transparent 1px 22px),
    var(--paper);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 22px;
  background: #111111;
  color: #f8f6f1;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.brand img {
  width: 150px;
  height: auto;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: #cac4b8;
  font-size: 0.86rem;
}

.tabs {
  display: grid;
  gap: 7px;
}

.tab {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 12px;
  background: transparent;
  color: #ebe8e1;
  text-align: left;
  cursor: pointer;
}

.tab:hover,
.tab.active {
  background: #f8f6f1;
  color: #111111;
}

.install-panel {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #d8d0c3;
}

.install-panel button {
  border: 0;
  border-radius: 7px;
  padding: 8px 10px;
  background: #c3a36e;
  color: #111111;
  cursor: pointer;
}

.install-panel button:disabled {
  opacity: 0.45;
  cursor: default;
}

main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 2rem;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.06rem;
}

p {
  margin: 7px 0 0;
  color: var(--muted);
}

.project-fields,
.shared-inputs,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 12px;
}

.primary-action {
  align-self: end;
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 10px 14px;
  background: var(--brand);
  color: #f8f6f1;
  font-weight: 800;
  cursor: pointer;
}

.primary-action:hover {
  filter: brightness(0.95);
}

.shared-inputs {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.79rem;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #d3d0c8;
  border-radius: 7px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font-weight: 600;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.metric-grid,
.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric,
.result {
  min-height: 106px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric span,
.result span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong,
.result strong {
  display: block;
  margin-top: 10px;
  font-size: 1.45rem;
}

.metric small,
.result small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.split,
.dual {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.dual {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.split > section,
.dual > section,
#adhesive,
#grout,
#spacers,
#countertops,
#data {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

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

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--soft);
  color: #33302b;
  font-size: 0.76rem;
  text-transform: uppercase;
}

.num {
  text-align: right;
}

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

.advice {
  border-left: 4px solid var(--brand);
  border-radius: 7px;
  padding: 11px 12px;
  background: var(--soft);
  line-height: 1.45;
}

.advice.warn {
  border-left-color: var(--warning-line);
  background: var(--warning);
}

.compact {
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  margin-bottom: 16px;
}

.edit-table input,
.edit-table select {
  min-width: 86px;
}

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

.data-grid > section {
  min-width: 0;
}

.data-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}

.data-list span {
  display: block;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  color: #33302b;
  font-size: 0.88rem;
  line-height: 1.3;
}

#printReport {
  display: none;
}

.report-page {
  color: #171716;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 3px solid #111111;
}

.report-header img {
  width: 180px;
  height: auto;
}

.report-basis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.report-basis div {
  border: 1px solid #dedbd4;
  border-radius: 6px;
  padding: 10px;
}

.report-basis strong,
.report-basis span {
  display: block;
}

.report-basis strong {
  margin-bottom: 5px;
  color: #686660;
  font-size: 0.76rem;
  text-transform: uppercase;
}

.report-advice {
  margin-top: 18px;
}

.report-advice p {
  margin: 8px 0;
  color: #171716;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .topbar,
  .split,
  .dual,
  .data-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .shared-inputs,
  .metric-grid,
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  main {
    padding: 16px;
  }

  .tabs,
  .project-fields,
  .shared-inputs,
  .form-grid,
  .compact,
  .metric-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 1.55rem;
  }
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  body {
    background: #fff;
  }

  body.printing-report .app-shell {
    display: none;
  }

  body.printing-report #printReport {
    display: block;
  }

  table {
    min-width: 0;
    page-break-inside: auto;
  }

  th,
  td {
    padding: 7px 6px;
    font-size: 10px;
  }

  .report-page h1 {
    font-size: 20px;
  }
}
