:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #eef2f6;
  --text: #17202a;
  --muted: #657181;
  --line: #d8dee7;
  --accent: #2454d6;
  --accent-strong: #1b3f9f;
  --success: #157a4b;
  --radius: 8px;
  --shadow: 0 18px 40px rgba(18, 28, 45, 0.08);
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 48px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.panel h2,
.scope-item h3,
.option-item h3 {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.1;
}

.mobile-decision-bar {
  display: none;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
}

button.primary {
  color: #ffffff;
  background: var(--accent);
}

button.primary:hover {
  background: var(--accent-strong);
}

button.ghost {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 18px;
  padding: 24px clamp(18px, 4vw, 48px) 48px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.pricing-panel,
.summary-panel {
  grid-column: span 1;
}

.panel:nth-of-type(2),
.panel:nth-of-type(3) {
  grid-column: 1;
}

.summary-panel {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: start;
  position: sticky;
  top: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.panel-header.compact {
  align-items: center;
  margin-bottom: 18px;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  background: var(--surface-muted);
  border-radius: 8px;
}

.segmented button {
  min-height: 36px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.segmented button[aria-selected="true"] {
  color: #ffffff;
  background: var(--accent);
}

.positioning {
  max-width: 760px;
  margin: 18px 0;
  color: var(--muted);
  line-height: 1.55;
}

.price-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 12px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: #ffffff;
}

input:focus {
  outline: 3px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-color: var(--accent);
}

.calculated-price {
  display: grid;
  gap: 5px;
  min-height: 44px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.calculated-price span,
.calculated-price small,
.option-price {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.calculated-price strong,
.option-price strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.calculated-price small {
  font-size: 12px;
  font-weight: 600;
}

.fixed-tax {
  background: var(--surface-muted);
}

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

.totals div,
.summary-list div {
  padding: 14px;
  background: var(--surface-muted);
  border-radius: 7px;
}

.totals span,
.summary-list dt {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.totals strong,
.summary-list dd {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.grand-total {
  color: #ffffff;
  background: var(--accent) !important;
}

.grand-total span {
  color: rgba(255, 255, 255, 0.78);
}

.scope-list,
.options-list {
  display: grid;
  gap: 10px;
}

.scope-item,
.option-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.scope-item {
  overflow: hidden;
}

.scope-item summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(120px, 180px);
  gap: 14px;
  align-items: center;
  padding: 14px;
  cursor: pointer;
  list-style: none;
}

.scope-item summary::-webkit-details-marker {
  display: none;
}

.scope-item[open] summary {
  border-bottom: 1px solid var(--line);
}

.scope-code {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
}

.scope-item p,
.option-item p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.scope-total {
  justify-self: end;
  font-size: 17px;
}

.option-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(130px, 180px);
  gap: 14px;
  align-items: center;
  padding: 14px;
}

.switch {
  display: inline-block;
  width: 48px;
  height: 28px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  display: block;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #c7d0dc;
  position: relative;
  transition: background 0.2s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  top: 3px;
  left: 3px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease;
}

.switch input:checked + span {
  background: var(--success);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.option-copy small {
  display: inline-block;
  margin-top: 8px;
  color: var(--success);
  font-weight: 700;
}

.detail-panel {
  margin-top: 10px;
}

.detail-panel summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px 14px 14px 70px;
  list-style: none;
}

.detail-panel .detail-list {
  padding: 10px 0 0;
}

.detail-list li {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 76px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.detail-thumb {
  width: 64px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: contain;
  background: #ffffff;
}

.detail-thumb-placeholder {
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.detail-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.detail-list strong {
  color: var(--text);
  font-weight: 800;
}

.detail-description {
  color: var(--text);
}

.detail-meta {
  color: var(--muted);
  font-size: 12px;
}

.detail-link {
  justify-self: end;
  min-width: max-content;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--accent-strong);
  background: #ffffff;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

a.detail-link:hover {
  color: #ffffff;
  background: var(--accent);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 12%, #ffffff);
  font-size: 12px;
  font-weight: 800;
}

.summary-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

@media (max-width: 980px) {
  .topbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .mobile-decision-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(120px, auto);
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 28px rgba(18, 28, 45, 0.12);
    backdrop-filter: blur(10px);
  }

  .mobile-decision-bar > div {
    display: grid;
    gap: 3px;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 7px;
    background: var(--surface-muted);
  }

  .mobile-decision-bar span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .mobile-decision-bar strong {
    overflow: hidden;
    color: var(--text);
    font-size: 14px;
    font-weight: 850;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-line-control {
    align-content: start;
  }

  .mobile-line-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    padding: 3px;
    background: #dfe6ef;
  }

  .mobile-line-tabs button {
    min-height: 31px;
    padding: 0 8px;
    font-size: 13px;
  }

  .desktop-line-tabs {
    display: none;
  }

  .mobile-decision-bar .mobile-total {
    color: #ffffff;
    background: var(--accent);
  }

  .mobile-decision-bar .mobile-total span {
    color: rgba(255, 255, 255, 0.78);
  }

  .mobile-decision-bar .mobile-total strong {
    color: #ffffff;
  }

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

  .summary-panel,
  .panel:nth-of-type(2),
  .panel:nth-of-type(3) {
    grid-column: auto;
    grid-row: auto;
  }

  .summary-panel {
    position: static;
  }
}

@media (max-width: 680px) {
  .topbar {
    padding: 20px 16px;
  }

  .mobile-decision-bar {
    grid-template-columns: minmax(0, 1fr) minmax(120px, auto);
  }

  .mobile-decision-bar > div:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .shell {
    padding: 16px;
  }

  .price-grid,
  .totals,
  .option-item,
  .scope-item summary,
  .detail-list li {
    grid-template-columns: 1fr;
  }

  .detail-thumb,
  .detail-link {
    justify-self: start;
  }

  .scope-total {
    justify-self: start;
  }

  .detail-list {
    padding-left: 14px;
  }

  .segmented:not(.mobile-line-tabs) {
    grid-auto-flow: row;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .actions,
  .option-price,
  .switch {
    display: none;
  }

  .topbar,
  .panel {
    box-shadow: none;
  }

  .shell,
  .topbar {
    padding: 14px;
  }

  .summary-panel {
    position: static;
  }
}
