body { background: var(--bg-tint); }
button, input { accent-color: var(--blue); }
button:disabled { cursor: default; }
.top, .workspace, .mobile-notice { padding-inline: clamp(16px, 3vw, 48px); }
.top {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px 24px;
  padding-block: 14px 16px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.identity { display: grid; gap: 6px; }
.back { justify-self: start; color: var(--blue-dark); font-size: 13px; }
.back:hover { text-decoration: underline; text-underline-offset: 3px; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand img { height: 34px; width: auto; flex: none; }
.brand > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; }
.brand h1 { font-size: clamp(15px, 1.35vw, 20px); line-height: 1.36; }
.version { color: var(--blue-dark); font-size: 12px; font-weight: 650; white-space: nowrap; }
.roles {
  display: inline-flex; padding: 3px; border: 1px solid var(--blue-line); border-radius: 999px;
  background: var(--bg-tint); width: max-content; max-width: 100%;
}
.roles button {
  border: 0; border-radius: 999px; background: transparent; min-height: 36px;
  padding-inline: 13px; font-size: 13px; white-space: nowrap; font-weight: 650; color: var(--ink-2);
}
.roles button:hover { color: var(--blue-dark); background: var(--bg-stage); }
.roles button[aria-pressed="true"] { background: var(--blue); color: var(--bg); }
.top-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.isolation { color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.isolation.is-safe { color: var(--teal-dark); background: #E9F7F5; padding: 5px 9px; border-radius: 8px; font-weight: 650; }
.isolation.is-safe::before, .margin-state::before {
  content: ""; display: inline-block; vertical-align: 1px; width: 7px; height: 7px; margin-right: 6px;
  border-radius: 50%; background: var(--teal);
}
.isolation.is-warning { color: var(--orange-deep); }
.button {
  display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--blue-line);
  border-radius: 8px; padding: 7px 12px; min-height: 36px; background: var(--bg); color: var(--blue-dark);
  font-size: 13px; font-weight: 650; transition: background .18s, border-color .18s;
}
.button:hover { background: var(--bg-stage); border-color: var(--blue); }
.button:active, .roles button:active { translate: 0 1px; }
.button.primary { background: var(--blue); border-color: var(--blue); color: var(--bg); }
.button.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.button:disabled { background: var(--bg-tint); color: var(--ink-3); border-color: var(--line); }
.mobile-notice { display: none; }

.workspace { max-width: 1540px; margin-inline: auto; padding-block: 30px 52px; }
.project { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: 10px 18px; }
.project-id { font-size: 13px; color: var(--ink-2); }
.project-id span { color: var(--blue-dark); font-weight: 700; margin-left: 6px; }
.project h2 { margin-top: 5px; font-size: clamp(22px, 2.6vw, 36px); line-height: 1.3; }
.sample-label { color: #914000; background: var(--bg-warm); border-radius: 6px; padding: 5px 10px; font-size: 12px; }
.steps {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
  padding: 0; margin: 23px 0 20px; list-style: none;
}
.steps li { position: relative; min-width: 0; }
.steps li + li::before {
  content: ""; position: absolute; width: 14px; height: 2px; top: calc(50% - 1px); right: 100%; background: var(--blue-line);
}
.steps button {
  display: flex; align-items: center; gap: 9px; width: 100%; height: 100%; min-height: 54px;
  padding: 8px 13px; border: 1px solid var(--blue-line); border-radius: 9px; background: var(--bg);
  color: var(--ink-2); font-size: 14px; font-weight: 650; text-align: left;
}
.steps button span { color: var(--blue-dark); font-size: 13px; }
.steps button:hover { border-color: var(--blue); color: var(--blue-dark); }
.steps button[aria-current] { background: var(--blue); border-color: var(--blue); color: var(--bg); }
.steps button[aria-current] span { color: #E0EAFF; }

.panel { min-width: 0; padding: 23px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; margin-bottom: 17px; }
.panel-head h2, dialog h2 { font-size: 22px; line-height: 1.3; }
.panel-head p, .caption { color: var(--ink-2); font-size: 13px; margin-top: 5px; }
.metrics {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 17px; border: 1px solid var(--blue-line);
  border-radius: 10px; background: var(--bg-tint);
}
.metrics > div { padding: 10px 14px 12px; }
.metrics > div + div { border-left: 1px solid var(--blue-line); }
.metrics dt { font-size: 12px; color: var(--ink-2); }
.metrics dd { font-size: 26px; line-height: 1.3; font-weight: 700; color: var(--blue-dark); }
.metrics .warn dd { color: var(--orange-deep); }
.notice { padding: 9px 12px; margin-bottom: 13px; color: #914000; background: var(--bg-warm); border-radius: 7px; font-size: 13px; }

.table-scroll {
  width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 9px;
  scrollbar-width: thin; scrollbar-color: #A6BADE var(--bg-tint);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
thead { white-space: nowrap; background: var(--bg-stage); }
thead th { color: var(--blue-dark); font-size: 12px; }
tbody th { font-weight: 650; }
tbody tr:last-child > * { border-bottom: 0; }
tbody tr:hover { background: var(--bg-tint); }
.number { text-align: right; white-space: nowrap; }
.item-name, .nowrap { white-space: nowrap; }
.item-name small { display: block; color: var(--ink-2); font-weight: 500; }
.spec { min-width: 178px; color: var(--ink-2); }
.plan { display: flex; align-items: center; gap: 7px; color: var(--ink-2); white-space: nowrap; }
.plan img { width: 48px; height: 32px; border: 1px solid var(--blue-line); border-radius: 4px; }
.review .button { margin-right: 7px; }
.review small { color: #914000; white-space: nowrap; }
.ok-text { color: var(--teal-dark); }
.inquiry-grid { display: grid; grid-template-columns: minmax(225px, .75fr) minmax(0, 2fr); align-items: start; gap: 17px; }
.factory-list { display: grid; gap: 8px; }
.factory-card {
  display: grid; gap: 3px; text-align: left; background: var(--bg-tint); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 12px; transition: background .18s, border-color .18s;
}
.factory-card:hover, .factory-card[aria-pressed="true"] { background: var(--bg-stage); border-color: var(--blue); }
.factory-card > span { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 9px; }
.factory-card small { color: var(--ink-2); }
.factory-card .ok-text { color: var(--teal-dark); }
.preview { min-width: 0; padding: 12px 15px 15px; border: 1px solid var(--line); border-radius: 10px; }
.preview h3 { font-size: 17px; }
.preview .table-scroll { margin-top: 12px; }
.access-card { padding: 20px; border: 1px solid var(--blue-line); border-radius: 10px; background: var(--bg-tint); }
.access-card h3 { margin-bottom: 4px; color: var(--blue-dark); font-size: 17px; }
.access-card p { color: var(--ink-2); }

.matrix th, .matrix td { padding: 7px 8px; }
.matrix th:first-child, .matrix td:first-child { padding-left: 12px; }
.matrix td:not(:first-child) { text-align: center; }
.matrix thead th:not(:first-child) { text-align: center; }
.matrix thead small { display: block; font-weight: 500; color: var(--ink-2); }
.price {
  border: 1px solid var(--blue-line); background: var(--bg); color: var(--blue-dark); border-radius: 7px;
  min-width: 72px; min-height: 32px; font-weight: 600; white-space: nowrap;
}
.price:not(:disabled):hover, .price[aria-pressed="true"] { border-color: var(--blue); background: var(--bg-stage); }
.price[aria-pressed="true"] { box-shadow: inset 0 -2px var(--blue); color: var(--blue-dark); }
.price:disabled { background: var(--bg-tint); border-color: var(--line); color: var(--ink-3); }
.price.awaiting { background: #FFF3CF; border-color: #F6D98A; color: #794700; }
.cost-summary { color: var(--blue-dark); font-size: 15px; font-weight: 650; }
.cost-summary strong { font-size: 19px; }
.compare-actions { display: flex; gap: 8px 18px; flex-wrap: wrap; align-items: center; }
.quote-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.quote-controls {
  display: grid; grid-template-columns: minmax(190px, 1.4fr) 1fr 1fr; align-items: center; gap: 14px 22px;
  margin-bottom: 14px; padding: 12px 15px; background: var(--bg-tint); border: 1px solid var(--blue-line); border-radius: 10px;
}
.quote-controls label { font-weight: 650; font-size: 13px; }
.factor { display: grid; gap: 5px; }
.factor span { display: flex; justify-content: space-between; gap: 10px; }
.factor output { color: var(--blue-dark); }
.factor input { width: 100%; margin: 0; }
.switch { display: flex; gap: 7px; align-items: center; }
.switch input { width: 16px; height: 16px; }
.quote-totals {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
  padding: 10px 15px; margin-bottom: 14px; background: var(--bg-stage); border-radius: 9px;
}
.quote-totals dt { color: var(--ink-2); font-size: 12px; }
.quote-totals dd { color: var(--blue-dark); font-weight: 650; font-size: 17px; overflow-wrap: anywhere; }
.quote-totals .total dd { font-size: 21px; font-weight: 750; }
.margin-state { color: var(--teal-dark); white-space: nowrap; }
.margin-state.warn { color: #914000; }
.margin-state.warn::before { background: var(--orange); }

dialog {
  width: min(640px, 100% - 24px); max-height: calc(100% - 24px); margin: auto 0 auto auto; padding: 0;
  border: 1px solid var(--line); border-radius: 14px 0 0 14px; color: var(--ink); background: var(--bg);
}
dialog::backdrop { background: rgba(11, 19, 36, .47); }
.dialog-body { padding: 20px; }
.dialog-body header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.dialog-body .table-scroll { margin-top: 14px; }
.toast {
  position: fixed; bottom: 14px; left: 50%; translate: -50% 0; z-index: 2; max-width: calc(100% - 24px);
  width: max-content; padding: 8px 14px; color: var(--bg); background: var(--blue-dark);
  border-radius: 8px; font-size: 13px;
}
.toast:empty { display: none; }
.copy-target { position: fixed; inset: 0 auto auto 0; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 760px) {
  .top { gap: 9px; }
  .brand { gap: 9px; }
  .brand img { height: 29px; }
  .roles { flex-basis: 100%; justify-content: stretch; }
  .roles button { flex: 1; padding-inline: 5px; }
  .top-actions { width: 100%; justify-content: space-between; gap: 6px; }
  .mobile-notice {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-block: 8px;
    background: var(--bg-warm); color: #794000; font-size: 12px;
  }
  .mobile-notice .button { flex: none; min-height: 34px; padding: 4px 8px; font-size: 12px; }
  .workspace { padding-top: 17px; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-block: 13px; }
  .steps li + li::before { width: 7px; }
  .steps li:nth-child(3)::before { display: none; }
  .steps button { min-height: 43px; padding: 6px 8px; gap: 6px; font-size: 12px; }
  .steps button span { font-size: 11px; }
  .panel { padding: 12px; }
  .panel-head { margin-bottom: 11px; }
  .panel-head h2, dialog h2 { font-size: 18px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 11px; }
  .metrics > div { padding: 6px 10px; }
  .metrics > div:nth-child(3) { border-left: 0; }
  .metrics > div:nth-child(n+3) { border-top: 1px solid var(--blue-line); }
  .metrics dd { font-size: 22px; }
  .inquiry-grid { grid-template-columns: minmax(0, 1fr); }
  .factory-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .factory-card { min-width: 0; }
  .quote-controls, .quote-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
  .factor { grid-column: span 2; }
  .quote-totals dd { font-size: 15px; }
  .quote-totals .total dd { font-size: 17px; }
  dialog { margin: auto; border-radius: 12px; }
  .dialog-body { padding: 13px; }
}
@media print {
  body { background: white; }
  .top, .mobile-notice, nav, .sample-label, .quote-controls, .quote-actions, .internal-column { display: none !important; }
  .workspace, .panel { padding: 0; }
  .table-scroll { overflow: visible; }
  th, td { padding: 5px; }
}
