:root {
  --bg: #e8edf1;
  --panel: #fbfcfd;
  --ink: #16232d;
  --muted: #64727e;
  --line: #bfccd5;
  --steel: #26323d;
  --steel-dark: #17212a;
  --blueprint: #1f5f83;
  --blueprint-dark: #173f59;
  --teal: #1f5f83;
  --teal-dark: #173f59;
  --orange: #df7626;
  --orange-dark: #a94e14;
  --soft: #eef6f8;
  --warn: #fff3d9;
  --bad: #ffe6e0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(31, 95, 131, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(31, 95, 131, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, #f2f5f7 0%, var(--bg) 100%);
  background-size: 28px 28px, 28px 28px, auto;
  font-family: Arial, Helvetica, sans-serif;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background:
    linear-gradient(180deg, #27333f 0%, #16222c 54%, #101922 100%);
  color: white;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08), 6px 0 24px rgba(17, 28, 37, 0.16);
}

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

.mark {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, var(--orange) 0%, #f7a33b 42%, var(--blueprint) 43%, #244b65 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 8px 22px rgba(0, 0, 0, 0.24);
  font-weight: 800;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 18px;
}

.brand p,
.topbar p,
.muted {
  color: var(--muted);
}

.sidebar .brand p {
  color: #b9c8d1;
}

nav {
  display: grid;
  gap: 8px;
}

nav button,
button {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}

nav button {
  background: transparent;
  color: white;
  text-align: left;
  border-color: rgba(255, 255, 255, 0.12);
}

nav button.active {
  background: linear-gradient(90deg, rgba(223, 118, 38, 0.22), rgba(31, 95, 131, 0.2));
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow: inset 4px 0 0 var(--orange);
}

nav button:disabled {
  color: #8294a0;
  cursor: default;
}

.sidebar-user {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  display: grid;
  gap: 6px;
  color: #d7e4ea;
  font-size: 13px;
}

.sidebar-user strong {
  color: white;
}

.sidebar-user button {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-color: rgba(255, 255, 255, 0.22);
}

.primary {
  background: linear-gradient(180deg, #ee8a34, var(--orange));
  color: white;
  border-color: var(--orange-dark);
  box-shadow: 0 2px 0 var(--orange-dark);
}

.app {
  min-width: 0;
}

.topbar {
  min-height: 84px;
  padding: 18px 22px;
  background: linear-gradient(180deg, #ffffff, #f4f7f9);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.action-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.action-strip button:not(.primary) {
  background: #edf2f5;
}

.action-strip button.active,
.step-tabs button.active {
  background: linear-gradient(180deg, #2f759c, var(--blueprint));
  border-color: var(--blueprint-dark);
  color: white;
}

.workspace {
  padding: 18px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(18, 34, 45, 0.08);
}

.hidden {
  display: none !important;
}

.wide {
  grid-column: 1 / -1;
}

.document-panel {
  grid-column: 1 / -1;
  border-top: 4px solid var(--orange);
  background: linear-gradient(180deg, #ffffff, #fafcfd);
}

.document-grid {
  display: grid;
  grid-template-columns: 1.3fr 1.3fr 0.9fr 0.85fr repeat(4, 0.75fr);
  gap: 10px;
  align-items: end;
}

.document-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.document-actions-left,
.document-actions-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.document-actions-right {
  justify-content: flex-end;
}

.saved-document-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 140px;
  gap: 8px;
  margin-bottom: 12px;
}

.saved-document-table-wrap {
  max-height: min(60vh, 560px);
}

.saved-document-table-wrap tr.active-row td {
  background: #fff7eb;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(15, 25, 34, 0.58);
}

.modal-panel {
  width: min(980px, 100%);
  max-height: 86vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  box-shadow: 0 24px 70px rgba(12, 31, 44, 0.34);
  padding: 18px;
}

.saved-documents-modal .panel-header {
  margin-bottom: 14px;
}

.confirm-modal {
  width: min(460px, 100%);
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(23, 33, 42, 0.94), rgba(31, 95, 131, 0.86)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: auto, 34px 34px, 34px 34px;
}

.login-card {
  width: min(460px, 100%);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: white;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.login-brand {
  margin-bottom: 18px;
}

.login-brand p {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form button {
  margin-top: 4px;
}

.users-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(360px, 1fr);
  gap: 16px;
  align-items: start;
}

.compact-header {
  margin-bottom: 10px;
}

.compact-header h4 {
  margin: 0;
}

.users-list {
  display: grid;
  gap: 8px;
}

.user-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
  text-align: left;
  font-weight: 400;
}

.user-card.active {
  border-color: var(--orange);
  background: #fff7eb;
}

.user-card strong {
  display: block;
}

.user-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.user-edit-form {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.check-row {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 700;
}

.check-row input {
  width: auto;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

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

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

.spring-results-header {
  align-items: flex-start;
}

.embedded-spring-results {
  margin-top: 14px;
  border-top: 2px solid #d9a056;
  padding-top: 14px;
}

.embedded-spring-results .panel-header {
  margin-bottom: 10px;
}

.spring-table-wrap {
  max-height: 360px;
}

.spring-table-wrap table {
  min-width: 760px;
}

.spring-table-wrap th,
.spring-table-wrap td {
  padding: 7px 8px;
  white-space: nowrap;
}

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.segmented-control button {
  border: 0;
  border-radius: 0;
  background: white;
  color: var(--ink);
}

.segmented-control button.active {
  background: var(--blueprint);
  color: white;
}

.duplex-settings {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f7f8;
}

.duplex-settings.hidden {
  display: none;
}

.duplex-settings .cost-preview {
  background: #fff0d6;
  font-weight: 800;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

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

.step-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 4px;
}

.step-tabs button {
  background: #e9eef2;
  padding: 9px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.workflow-step {
  display: none;
}

.workflow-step.active {
  display: block;
}

.workflow-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.detail {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: linear-gradient(180deg, #ffffff, #f3f6f8);
}

.detail span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.detail strong {
  font-size: 14px;
}

.step-callout {
  margin-top: 14px;
  border: 1px solid #9abed1;
  border-radius: 6px;
  background: #eef7fb;
  color: var(--blueprint-dark);
  padding: 12px;
  font-size: 13px;
  font-weight: 700;
}

.option-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 10px;
  background: linear-gradient(180deg, #ffffff, #f4f7f9);
}

legend {
  color: var(--blueprint-dark);
  font-size: 12px;
  font-weight: 800;
  padding: 0 6px;
}

label {
  color: #405669;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  gap: 5px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: white;
  font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(223, 118, 38, 0.28);
  border-color: var(--orange);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px;
  background: linear-gradient(180deg, #ffffff, #f4f7f9);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.metric strong {
  font-size: 18px;
}

.cost-summary .metric strong {
  font-size: 17px;
}

.badge {
  background: #eef7fb;
  color: var(--blueprint-dark);
  border: 1px solid #9abed1;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge.warn {
  background: var(--warn);
  color: #8a5b00;
  border-color: #f1ca72;
}

.badge.bad {
  background: var(--bad);
  color: #a12b12;
  border-color: #efa18f;
}

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

.table-wrap.compact {
  max-height: 310px;
  margin-top: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 13px;
}

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

td small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

th {
  background: #e3e9ee;
  color: #314653;
  font-size: 12px;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr.selectable-row {
  cursor: pointer;
}

tbody tr.selectable-row:hover td {
  background: #fffaf2;
}

tbody tr.selected-row td {
  background: #fff5e8;
  box-shadow: inset 0 1px 0 #e8b06a, inset 0 -1px 0 #e8b06a;
}

.spring-group-row td {
  background: #eef4f8;
  color: var(--blueprint-dark);
  font-weight: 800;
  letter-spacing: 0;
}

.spring-side-badge {
  display: inline-flex;
  align-items: center;
  min-width: 54px;
  justify-content: center;
  border: 1px solid #9abed1;
  border-radius: 999px;
  padding: 2px 8px;
  background: #f7fbfd;
  color: var(--blueprint-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.fit {
  color: #176835;
  font-weight: 800;
}

.no-fit {
  color: #b13b1d;
  font-weight: 800;
}

.deflection-result {
  margin-top: 12px;
  border: 1px solid #9abed1;
  border-left: 5px solid var(--blueprint);
  border-radius: 8px;
  padding: 12px 14px;
  background: #eef7fb;
  color: var(--text);
  font-weight: 700;
}

.deflection-result strong {
  display: block;
  margin-bottom: 4px;
}

.deflection-result.bad {
  border-color: #efa18f;
  border-left-color: #b13b1d;
  background: var(--bad);
}

.deflection-result.hidden {
  display: none;
}

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

.data-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.data-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 14px;
}

.data-table-wrap {
  max-height: 520px;
}

.data-table-wrap tr.active-row td {
  background: var(--soft);
}

.data-table-wrap td {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-edit-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(180deg, #ffffff, #f4f7f9);
}

.defaults-warning {
  border: 1px solid #efc36b;
  background: #fff8e6;
  color: #6b4a00;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 700;
  margin-bottom: 14px;
}

.defaults-form,
.settings-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.defaults-form label,
.settings-form label {
  background: linear-gradient(180deg, #ffffff, #f4f7f9);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.defaults-form input,
.settings-form input {
  margin-top: 6px;
}

.defaults-footer {
  margin-top: 14px;
}

.edit-fields {
  display: grid;
  gap: 10px;
  max-height: 430px;
  overflow: auto;
  padding-right: 4px;
}

.edit-fields textarea {
  width: 100%;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: white;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  resize: vertical;
}

.print-preview {
  background: #eef2f5;
}

.print-document {
  background: white;
  color: #111;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}

.print-document header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 3px solid var(--blueprint);
  padding-bottom: 14px;
  margin-bottom: 18px;
}

.print-document header.quote-header {
  align-items: flex-start;
}

.company-print-block {
  max-width: 58%;
}

.company-tagline {
  font-style: italic;
  font-weight: 700;
  text-decoration: underline;
}

.quote-to-block {
  border-bottom: 1px solid #111;
  padding-bottom: 12px;
}

.print-document h2,
.print-document h3 {
  margin: 0 0 8px;
}

.print-document p {
  margin: 3px 0;
}

.print-document section {
  margin-top: 18px;
}

.print-document table {
  width: 100%;
  border-collapse: collapse;
}

.print-document th,
.print-document td {
  border-bottom: 1px solid #d7e2e8;
  padding: 7px 6px;
  text-align: left;
  vertical-align: top;
}

.print-totals {
  margin-left: auto;
  max-width: 320px;
  border-top: 2px solid var(--orange);
  padding-top: 10px;
}

.end-marker {
  margin-top: 24px;
  text-align: center;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.legacy-shop-order {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.12;
  padding: 16px 18px;
}

.legacy-shop-order .shop-order-header {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 2px 18px;
  border: 0;
  border-bottom: 1px solid #111;
  padding: 0 0 2px;
  margin: 0;
  font-size: 17px;
}

.legacy-shop-order .shop-order-title-line {
  grid-column: 1 / -1;
  font-weight: 800;
}

.legacy-shop-order .shop-section {
  border-bottom: 1px solid #111;
  margin: 0;
  padding: 8px 0 6px;
}

.legacy-shop-order .shop-section h3 {
  font-size: 20px;
  line-height: 1;
  margin: 0 0 2px;
}

.legacy-shop-order p {
  margin: 1px 0;
}

.legacy-shop-order .shop-grid {
  display: grid;
  column-gap: 24px;
  row-gap: 0;
}

.legacy-shop-order .shop-grid.two {
  grid-template-columns: 1fr 1fr;
}

.legacy-shop-order .shop-grid.three {
  grid-template-columns: 1fr 1fr 1fr;
}

.legacy-shop-order .shop-notes {
  margin-top: 16px;
  text-decoration: underline;
}

.legacy-shop-order .options-shop-section {
  border-bottom: 0;
}

.installer-setup-document {
  min-height: 720px;
  font-family: Arial, Helvetica, sans-serif;
}

.installer-setup-document h2 {
  text-align: center;
  letter-spacing: 0.02em;
}

.installer-setup-document section {
  border-top: 1px solid #111;
  padding-top: 18px;
  margin-top: 24px;
}

.installer-setup-values {
  display: grid;
  gap: 14px;
  font-size: 18px;
}

.installer-setup-values div {
  font-size: 22px;
  font-weight: 800;
}

.installer-setup-document footer {
  margin-top: 160px;
  text-align: center;
  font-size: 12px;
}

@media print {
  body {
    background: white;
  }

  .sidebar,
  .topbar,
  .workspace > :not(.print-preview),
  .no-print {
    display: none !important;
  }

  .layout,
  .app,
  .workspace {
    display: block;
  }

  .print-preview {
    display: block !important;
    border: 0;
    padding: 0;
  }

  .print-document {
    border: 0;
    padding: 0;
  }
}

@media (max-width: 1100px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

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

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

  .detail-grid,
  .field-grid,
  .field-grid.thirds,
  .option-groups,
    .data-toolbar,
    .data-layout,
    .defaults-form,
    .settings-form {
      grid-template-columns: 1fr;
    }
  }
