:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-strong: #eef3f8;
  --text: #1f2933;
  --muted: #64748b;
  --border: #d7e0ea;
  --blue: #27608f;
  --blue-dark: #193f61;
  --green: #1d7a58;
  --green-bg: #edf8f3;
  --amber: #a85f00;
  --amber-bg: #fff5e7;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(31, 41, 51, 0.08);
  font-family: Arial, Helvetica, sans-serif;
}

[data-theme="dark"] {
  --bg: #121821;
  --surface: #1c2430;
  --surface-strong: #263241;
  --text: #eef4fb;
  --muted: #a9b8c9;
  --border: #354456;
  --blue: #7cb4e4;
  --blue-dark: #d8ebff;
  --green: #35c48d;
  --green-bg: #17352c;
  --amber: #ff9d3d;
  --amber-bg: #3a2a17;
  --danger: #ff7b6d;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.section-label {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.05;
  letter-spacing: 0;
}

.lead {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.seo-intro {
  max-width: 760px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.model-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--blue-dark);
  font-size: 14px;
  font-weight: 700;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  min-height: 40px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
}

.theme-icon {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
}

.theme-icon::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--blue-dark);
}

.theme-icon::after {
  content: "";
  position: absolute;
  top: -2px;
  right: 5px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--surface);
}

html[data-theme="dark"] .theme-toggle {
  border-color: #335069;
  background: #0f1b26;
}

html[data-theme="dark"] .theme-icon::before {
  inset: 3px;
  background: #ff681f;
}

html[data-theme="dark"] .theme-icon::after {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}

.tool-grid {
  display: grid;
  grid-template-columns: 0.92fr 1.08fr;
  gap: 18px;
}

.input-panel,
.output-panel,
.method-panel,
.line-items-panel,
.bom-panel,
.what-if-panel,
.audit-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.input-panel,
.output-panel {
  padding: 20px;
}

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

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 20px;
}

[data-theme="dark"] .panel-heading h2 {
  color: var(--text);
}

.panel-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

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

.primary-button,
.print-button {
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  background: #ff681f;
  box-shadow: 0 16px 30px rgba(255, 104, 31, 0.22);
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  padding: 11px 24px;
  transition:
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.primary-button:hover,
.print-button:hover {
  background: #f45c16;
  box-shadow: 0 18px 34px rgba(255, 104, 31, 0.28);
  transform: translateY(-1px);
}

.ghost-button {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--blue-dark);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  padding: 9px 12px;
}

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

.hidden {
  display: none !important;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

label#schedule-field.schedule-active > span {
  color: var(--amber) !important;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
}

input[readonly] {
  background: var(--surface-strong);
  color: var(--blue-dark);
  cursor: default;
  font-weight: 800;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(39, 96, 143, 0.18);
  outline-offset: 1px;
}

.source-pill {
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 700;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.metric span,
.price-card span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

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

.price-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.price-card h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.factor-help {
  max-width: 280px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.price-card.median {
  background: var(--green-bg);
  border-color: rgba(29, 122, 88, 0.28);
}

.price-card.p90 {
  background: var(--amber-bg);
  border-color: rgba(168, 95, 0, 0.28);
}

.factor {
  margin-bottom: 14px;
  font-size: 34px;
  font-weight: 800;
}

.median .factor {
  color: var(--green);
}

.p90 .factor {
  color: var(--amber);
}

dl {
  margin: 0;
}

dl div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid rgba(100, 116, 139, 0.22);
}

dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

dd {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  text-align: right;
}

[data-theme="dark"] .metric strong,
[data-theme="dark"] .price-card h3,
[data-theme="dark"] dt,
[data-theme="dark"] dd {
  color: var(--text);
}

[data-theme="dark"] .price-card.median,
[data-theme="dark"] .price-card.p90 {
  background: var(--surface);
}

.warning {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--danger);
  font-weight: 700;
}

.success-message {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--amber);
  font-size: 14px;
  font-weight: 800;
}

.line-items-panel {
  margin-top: 18px;
  padding: 18px 20px;
}

.bom-panel {
  margin-top: 18px;
  padding: 18px 20px;
}

.bom-upload-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
}

.template-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 104, 31, 0.3);
  border-radius: 8px;
  background: var(--amber-bg);
}

.template-callout strong {
  display: block;
  margin-bottom: 5px;
  color: var(--blue-dark);
  font-size: 15px;
  font-weight: 800;
}

.template-callout p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.template-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  min-width: 260px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--blue-dark);
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.template-download:hover {
  border-color: #ff681f;
  box-shadow: 0 12px 24px rgba(255, 104, 31, 0.16);
  transform: translateY(-1px);
}

.template-download svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.file-drop {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 210px;
  padding: 36px 18px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--blue-dark);
  cursor: pointer;
  text-align: center;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.file-drop:hover,
.file-drop.drag-over {
  border-color: #ff681f;
  background: var(--amber-bg);
  transform: translateY(-1px);
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 52px;
  color: var(--muted);
}

.upload-icon svg {
  width: 58px;
  height: 58px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3.2;
}

.file-drop strong {
  color: var(--blue-dark);
  font-size: 18px;
  font-weight: 800;
}

.file-drop small {
  color: #ff681f;
  font-size: 14px;
  font-weight: 700;
}

.file-drop input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  opacity: 0;
}

.bom-help {
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-strong);
}

.bom-help summary {
  color: var(--blue-dark);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.bom-help p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.bom-status {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.bom-status.success {
  color: var(--green);
}

.bom-status.error {
  color: var(--danger);
}

.report-actions {
  align-items: center;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  min-height: 26px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  line-height: 1.15;
  padding: 0;
  text-transform: uppercase;
}

.sort-button span {
  color: var(--blue);
  font-size: 12px;
  line-height: 1;
}

.sort-button:hover {
  color: var(--blue-dark);
}

.empty-row td {
  text-align: left;
}

.text-column {
  width: 15%;
  text-align: center;
  word-break: break-word;
}

.empty-row td {
  color: var(--muted);
  font-weight: 700;
}

.remove-line {
  border: 1px solid rgba(180, 35, 24, 0.28);
  border-radius: 6px;
  background: #fff7f6;
  color: var(--danger);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 7px;
}

.remove-line:hover {
  background: #ffe8e5;
}

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

.summary-strip article {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.summary-strip span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-strip strong {
  color: var(--blue-dark);
  font-size: 20px;
}

.category-review {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.category-review-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.category-review-heading h3 {
  margin-bottom: 5px;
  color: var(--blue-dark);
  font-size: 17px;
}

.category-review-heading p,
.category-table-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.category-review-badges {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.audit-line-check {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.audit-line-check-warning {
  border-color: rgba(190, 18, 60, 0.35);
  background: rgba(190, 18, 60, 0.08);
  color: #be123c;
}

.category-review-details {
  margin-top: 12px;
}

.category-review-details > summary {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 16px 30px rgba(29, 122, 88, 0.22);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 18px;
  transition:
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.category-review-details > summary:hover {
  background: #168054;
  box-shadow: 0 18px 34px rgba(29, 122, 88, 0.28);
  transform: translateY(-1px);
}

.category-review-details[open] > summary {
  margin-bottom: 12px;
}

.category-tables {
  display: grid;
  gap: 14px;
}

.category-table-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.category-table-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.category-table-title h4 {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  margin: 0 0 5px;
  background: rgba(29, 122, 88, 0.1);
  color: var(--green);
  font-size: 16px;
}

.category-summary-rs {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 104, 31, 0.1);
  color: var(--orange);
  font-weight: 800;
}

.category-heading-carbon {
  background: rgba(39, 96, 143, 0.12) !important;
  color: var(--blue-dark) !important;
}

.category-heading-lowtemp {
  background: rgba(39, 96, 143, 0.08) !important;
  color: var(--blue) !important;
}

.category-heading-alloy {
  background: rgba(255, 104, 31, 0.13) !important;
  color: #c94f12 !important;
}

.category-heading-stainless {
  background: rgba(29, 122, 88, 0.12) !important;
  color: var(--green) !important;
}

.category-heading-duplex {
  background: rgba(123, 92, 214, 0.13) !important;
  color: #6b4fd6 !important;
}

.category-heading-nonferrous {
  background: rgba(168, 95, 0, 0.14) !important;
  color: #8a5200 !important;
}

.category-heading-unclassified {
  background: rgba(100, 116, 139, 0.14) !important;
  color: var(--muted) !important;
}

.category-heading-default {
  background: rgba(29, 122, 88, 0.1) !important;
  color: var(--green) !important;
}

.category-table {
  min-width: 860px;
}

.category-table .text-column {
  width: 20%;
}

.category-audit-details {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.category-audit-details summary {
  display: inline-flex;
  align-items: center;
  width: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  transform: none;
}

.category-audit-details summary:hover {
  background: transparent;
  box-shadow: none;
  color: var(--blue-dark);
  transform: none;
}

.category-audit-details[open] summary {
  margin-bottom: 10px;
  color: var(--blue-dark);
}

.category-audit-table {
  min-width: 720px;
}

.category-audit-table th,
.category-audit-table td {
  font-size: 12px;
}

.what-if-panel {
  margin-top: 18px;
  padding: 18px 20px;
  box-shadow: none;
}

.what-if-details {
  margin-top: 12px;
}

.what-if-details summary {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 16px 30px rgba(29, 122, 88, 0.22);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 18px;
  transition:
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.what-if-details summary:hover {
  background: #168054;
  box-shadow: 0 18px 34px rgba(29, 122, 88, 0.28);
  transform: translateY(-1px);
}

.what-if-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.what-if-controls > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.what-if-controls label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 700;
}

.what-if-controls input {
  display: grid;
  place-content: center;
  width: 17px;
  height: 17px;
  min-height: 0;
  margin: 0;
  appearance: none;
  border: 1px solid #ff681f;
  border-radius: 4px;
  background: var(--surface);
}

.what-if-controls input:checked {
  background: #ff681f;
}

.what-if-controls input:checked::before {
  content: "";
  width: 5px;
  height: 9px;
  margin-bottom: 1px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg);
}

.what-if-slider {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.what-if-slider label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
}

.what-if-slider span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.what-if-slider strong {
  color: #ff681f;
  font-size: 18px;
}

.slider-rate {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid rgba(255, 104, 31, 0.22);
  border-radius: 6px;
  background: rgba(255, 104, 31, 0.08);
  color: var(--blue-dark);
  font-size: 14px;
  font-weight: 800;
}

.slider-rate span {
  color: var(--blue-dark);
  font-size: 13px;
  text-transform: none;
}

.slider-rate #raw-steel-slider-value {
  font-size: 18px;
}

.slider-rate strong {
  font-size: 18px;
}

.slider-rate [data-tone="negative"] {
  color: var(--green) !important;
}

.slider-rate [data-tone="base"] {
  color: var(--blue-dark) !important;
}

.slider-rate [data-tone="positive"] {
  color: #ff681f !important;
}

.slider-divider {
  color: var(--muted) !important;
}

.slider-track-wrap {
  position: relative;
  padding: 8px 0 32px;
}

.what-if-slider input[type="range"] {
  --slider-tone-color: var(--blue-dark);
  position: relative;
  z-index: 3;
  width: 100%;
  min-height: 24px;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  accent-color: var(--slider-tone-color);
  background: transparent;
  cursor: pointer;
}

.what-if-slider input[type="range"][data-tone="negative"] {
  --slider-tone-color: var(--green);
}

.what-if-slider input[type="range"][data-tone="base"] {
  --slider-tone-color: var(--blue-dark);
}

.what-if-slider input[type="range"][data-tone="positive"] {
  --slider-tone-color: #ff681f;
}

.what-if-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--slider-tone-color);
}

.what-if-slider input[type="range"]::-webkit-slider-thumb {
  width: 26px;
  height: 26px;
  margin-top: -10px;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  opacity: 0;
}

.what-if-slider input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--slider-tone-color);
}

.what-if-slider input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: 0;
  background: transparent;
  opacity: 0;
}

.slider-rupee-thumb {
  position: absolute;
  top: 6px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--blue-dark);
  box-shadow: 0 8px 18px rgba(31, 41, 51, 0.22);
  color: #fff !important;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 4;
}

.slider-rupee-thumb[data-tone="negative"] {
  background: var(--green);
}

.slider-rupee-thumb[data-tone="base"] {
  background: var(--blue-dark);
}

.slider-rupee-thumb[data-tone="positive"] {
  background: #ff681f;
}

.slider-mid-marker {
  position: absolute;
  left: 50%;
  bottom: 0;
  display: grid;
  justify-items: center;
  gap: 3px;
  min-width: 150px;
  transform: translateX(-50%);
  pointer-events: none;
}

.slider-mid-marker span {
  width: 2px;
  height: 13px;
  border-radius: 999px;
  background: var(--blue-dark);
}

.slider-mid-marker strong {
  color: var(--blue-dark);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.what-if-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.what-if-summary article {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.what-if-summary span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.what-if-summary strong {
  color: var(--blue-dark);
  font-size: 18px;
}

.scenario-base {
  --scenario-color: #27608f;
  --scenario-bg: rgba(39, 96, 143, 0.12);
  --scenario-border: rgba(39, 96, 143, 0.35);
}

.scenario-low {
  --scenario-color: #1d7a58;
  --scenario-bg: rgba(29, 122, 88, 0.12);
  --scenario-border: rgba(29, 122, 88, 0.34);
}

.scenario-high {
  --scenario-color: #ff681f;
  --scenario-bg: rgba(255, 104, 31, 0.12);
  --scenario-border: rgba(255, 104, 31, 0.34);
}

.scenario-range {
  --scenario-color: #7a4f01;
  --scenario-bg: rgba(168, 95, 0, 0.12);
  --scenario-border: rgba(168, 95, 0, 0.3);
}

.scenario-driver {
  --scenario-color: #ff681f;
  --scenario-bg: rgba(255, 104, 31, 0.12);
  --scenario-border: rgba(255, 104, 31, 0.34);
}

.scenario-standard {
  --scenario-color: #9aa6b2;
  --scenario-bg: rgba(148, 163, 184, 0.08);
  --scenario-border: rgba(148, 163, 184, 0.16);
}

.what-if-summary article[class^="scenario-"] {
  background: var(--scenario-bg);
  border-color: var(--scenario-border);
}

.what-if-summary article[class^="scenario-"] strong {
  color: var(--scenario-color);
}

.what-if-chart {
  display: grid;
  gap: 9px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.scenario-bar {
  display: grid;
  grid-template-columns: minmax(110px, 150px) 1fr minmax(90px, auto);
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.scenario-bar span {
  color: var(--muted);
  font-weight: 700;
}

.scenario-bar.scenario-base span,
.scenario-bar.scenario-low span,
.scenario-bar.scenario-high span {
  color: var(--scenario-color);
}

.scenario-bar strong {
  color: var(--blue-dark);
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

.scenario-bar.scenario-base strong,
.scenario-bar.scenario-low strong,
.scenario-bar.scenario-high strong {
  color: var(--scenario-color);
}

.bar-track {
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--scenario-color, #2f6f8f);
}

.what-if-table-wrap {
  margin-bottom: 12px;
}

.what-if-table {
  min-width: 860px;
}

.whatif-sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  padding: 0;
  text-transform: uppercase;
}

.whatif-sort-button:hover,
.whatif-sort-button[aria-sort="asc"],
.whatif-sort-button[aria-sort="desc"] {
  color: var(--blue-dark);
}

.what-if-table tbody tr {
  background: var(--scenario-bg, var(--surface));
}

.what-if-table tbody tr td:first-child {
  color: var(--scenario-color, var(--blue-dark));
  font-weight: 800;
}

.empty-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.audit-panel {
  margin-top: 18px;
  padding: 18px 20px;
  box-shadow: none;
}

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

.audit-grid article {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.audit-grid h3 {
  margin-bottom: 8px;
  color: var(--blue-dark);
  font-size: 16px;
}

.audit-grid p,
.audit-grid ul,
.audit-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.audit-grid ul {
  margin: 0;
  padding-left: 18px;
}

.audit-grid li {
  margin: 3px 0;
}

.override-value {
  color: var(--danger);
  font-weight: 800;
}

.audit-note {
  margin: 14px 0 0;
  font-weight: 700;
}

.method-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  gap: 18px;
  margin-top: 18px;
  padding: 18px 20px;
  box-shadow: none;
}

.method-panel h2 {
  margin-bottom: 8px;
  font-size: 18px;
}

.method-panel p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.method-panel .formula-line {
  display: inline-block;
  margin: 10px 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--blue-dark);
  font-weight: 800;
}

.formula-notes {
  margin: 0 0 10px;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.formula-notes li {
  margin: 2px 0;
}

.method-points {
  display: grid;
  gap: 8px;
}

.method-points span {
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--blue-dark);
  font-size: 14px;
  font-weight: 700;
}

.site-footer {
  margin-top: 18px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

@media (max-width: 920px) {
  .app-header,
  .tool-grid,
  .method-panel {
    grid-template-columns: 1fr;
  }

  .tool-grid {
    display: grid;
  }

  .app-header {
    display: block;
  }

  .header-actions {
    margin-top: 14px;
  }

  .metrics,
  .price-columns,
  .summary-strip,
  .what-if-summary,
  .audit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .field-grid,
  .metrics,
  .price-columns,
  .summary-strip,
  .what-if-summary,
  .bom-upload-grid,
  .audit-grid {
    grid-template-columns: 1fr;
  }

  .scenario-bar {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .scenario-bar strong {
    text-align: left;
  }

  .what-if-controls {
    align-items: flex-start;
    flex-direction: column;
  }

  .what-if-slider label {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .slider-rate {
    justify-content: flex-start;
  }

  .slider-track-wrap {
    padding-bottom: 42px;
  }

  .slider-mid-marker strong {
    white-space: normal;
  }

  .template-callout {
    align-items: stretch;
    flex-direction: column;
  }

  .template-download {
    min-width: 0;
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
  }

  .line-items-panel table,
  .what-if-table,
  .line-items-panel thead,
  .what-if-table thead,
  .line-items-panel tbody,
  .what-if-table tbody,
  .line-items-panel tr,
  .what-if-table tr,
  .line-items-panel th,
  .what-if-table th,
  .line-items-panel td,
  .what-if-table td {
    display: block;
    width: 100%;
  }

  .line-items-panel thead tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }

  .line-items-panel th {
    padding: 0;
    border: 0;
  }

  .line-items-panel th:last-child {
    display: none;
  }

  .what-if-table thead {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
  }

  .what-if-table thead tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .what-if-table th {
    padding: 0;
    border: 0;
  }

  .whatif-sort-button {
    min-height: 36px;
    padding: 8px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-strong);
    font-size: 11px;
  }

  .sort-button {
    min-height: 36px;
    padding: 8px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-strong);
    font-size: 11px;
  }

  .line-items-panel tbody,
  .what-if-table tbody {
    display: grid;
    gap: 12px;
  }

  .line-items-panel tbody tr,
  .what-if-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
  }

  .line-items-panel tbody td,
  .what-if-table tbody td {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3px;
    min-width: 0;
    padding: 0;
    border: 0;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.25;
    text-align: left;
    white-space: normal;
  }

  .line-items-panel tbody td::before,
  .what-if-table tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
  }

  .line-items-panel tbody td.text-column,
  .line-items-panel tbody td[data-label="Material"],
  .line-items-panel tbody td[data-label="Action"],
  .what-if-table tbody td[data-label="Scenario"] {
    grid-column: 1 / -1;
    text-align: left;
  }

  .line-items-panel .empty-row,
  .what-if-table .empty-row {
    display: block;
  }

  .line-items-panel .empty-row td,
  .what-if-table .empty-row td {
    display: block;
    padding: 4px;
    text-align: center;
  }

  .line-items-panel .empty-row td::before,
  .what-if-table .empty-row td::before {
    content: "";
  }

  .remove-line {
    justify-self: start;
    min-height: 34px;
    padding: 7px 11px;
  }
}

@page {
  size: A4 landscape;
  margin: 10mm;
}

@media print {
  :root,
  [data-theme="dark"] {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-strong: #eef3f8;
    --text: #1f2933;
    --muted: #64748b;
    --border: #d7e0ea;
    --blue-dark: #193f61;
    --green-bg: #edf8f3;
    --amber-bg: #fff5e7;
  }

  body {
    background: #fff;
    color: var(--text);
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .app-header,
  .input-panel,
  .output-panel,
  .line-items-panel,
  .bom-panel,
  .what-if-panel,
  .audit-panel,
  .method-panel,
  .site-footer {
    box-shadow: none;
    break-inside: avoid;
  }

  .panel-actions,
  .bom-panel,
  .remove-line,
  .theme-toggle,
  .category-review-details > summary,
  .success-message,
  .warning {
    display: none !important;
  }

  .category-review-details > * {
    display: block !important;
  }

  .table-wrap {
    overflow: visible;
  }

  .tool-grid,
  .audit-grid,
  .what-if-summary,
  .summary-strip {
    grid-template-columns: 1fr 1fr;
  }

  table {
    table-layout: fixed;
    width: 100%;
    min-width: 0;
    font-size: 10.5px;
    line-height: 1.25;
  }

  th,
  td {
    padding: 5px;
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: normal;
  }

  td:nth-child(1),
  td:nth-child(2),
  td:nth-child(3),
  td:nth-child(5),
  td:nth-child(6),
  td:nth-child(7),
  td:nth-child(8),
  td:nth-child(9) {
    white-space: nowrap;
  }

  th:last-child,
  td:last-child {
    display: none;
  }

  .category-table th:last-child,
  .category-table td:last-child {
    display: table-cell;
  }
}
