:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-muted: #eef3f1;
  --ink: #17211d;
  --muted: #62706a;
  --line: #d8e0dd;
  --accent: #0d6b57;
  --accent-strong: #094a3e;
  --gold: #b38736;
  --danger: #9d2f2f;
  --shadow: 0 20px 60px rgba(23, 33, 29, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(13, 107, 87, 0.08), transparent 36%),
    linear-gradient(315deg, rgba(179, 135, 54, 0.12), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 44px;
}

.hero {
  min-height: 220px;
  display: flex;
  align-items: end;
  padding: 42px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, rgba(9, 46, 40, 0.98), rgba(13, 107, 87, 0.86));
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: #d8c28f;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 12ch;
  font-size: 58px;
  line-height: 1.06;
}

h2 {
  font-size: 20px;
}

.notice {
  max-width: 760px;
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 15px;
  line-height: 1.7;
}

.workspace {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 22px;
  margin-top: 22px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 40px rgba(23, 33, 29, 0.07);
}

.form-panel,
.result-panel {
  padding: 22px;
}

.report-card {
  display: grid;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.report-title {
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  color: var(--ink);
}

.summary-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-bar > div {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.summary-bar span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-bar strong {
  font-size: 18px;
}

.report-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
}

.report-summary > div {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.report-summary span,
.report-section h3 {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.report-summary strong {
  font-size: 16px;
  line-height: 1.45;
}

.report-section {
  display: grid;
  gap: 8px;
}

.report-section h3 {
  margin: 0;
  font-size: 17px;
  color: var(--ink);
}

.unit-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.export-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: -1;
}

#export-image {
  white-space: nowrap;
}

.export-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.export-status {
  min-width: 88px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.export-preview {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.export-preview[hidden] {
  display: none;
}

.export-preview img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.panel-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 13px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 107, 87, 0.14);
}

.defaults,
.result-grid {
  display: grid;
  gap: 10px;
}

.defaults {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.defaults div,
.result-grid div,
.metric-strip div {
  display: grid;
  gap: 4px;
}

.defaults span,
.result-grid span,
.metric-strip span {
  color: var(--muted);
  font-size: 13px;
}

.defaults strong,
.result-grid strong,
.metric-strip strong {
  font-size: 18px;
}

.hibor-override {
  margin-bottom: 10px;
}

.status,
.data-warning {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.inline-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  font-weight: 500;
}

.data-warning {
  color: var(--danger);
}

.primary-button,
.ghost-button,
.text-button {
  border: 0;
  cursor: pointer;
  font-weight: 760;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  min-height: 36px;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--accent);
  background: rgba(13, 107, 87, 0.1);
}

.text-button {
  width: fit-content;
  padding: 0;
  color: var(--accent);
  background: transparent;
  text-align: left;
}

.product-pill {
  max-width: 280px;
  border: 1px solid rgba(13, 107, 87, 0.18);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--accent);
  background: rgba(13, 107, 87, 0.08);
  font-size: 13px;
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 20px;
}

.result-grid div,
.metric-strip div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.table-wrap {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: max-content;
  min-width: 680px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  background: #f1f5f3;
  color: var(--muted);
  font-size: 14px;
}

td {
  font-size: 15px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.metric-strip strong {
  color: var(--gold);
  font-size: 30px;
}

.report-footer {
  padding-top: 2px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 18px, 720px);
    padding-top: 18px;
  }

  .hero {
    min-height: 210px;
    padding: 28px;
  }

  h1 {
    max-width: 10ch;
    font-size: 40px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-bar {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 560px) {
  body {
    overflow-x: hidden;
  }

  .app-shell {
    width: calc(100% - 12px);
    padding: 0 0 20px;
  }

  .hero {
    border-radius: 0;
    min-height: 170px;
    padding: 22px 14px;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
  }

  h1 {
    max-width: 9ch;
    font-size: 30px;
    line-height: 1.12;
  }

  .workspace {
    margin-top: 10px;
    gap: 10px;
  }

  .panel {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .form-panel,
  .result-panel {
    padding: 14px;
  }

  .panel-head {
    align-items: flex-start;
    gap: 8px;
  }

  .product-pill {
    max-width: 180px;
  }

  .result-grid,
  .metric-strip {
    grid-template-columns: 1fr;
  }

  .metric-strip strong {
    font-size: 28px;
  }

  .report-card {
    padding: 10px;
    gap: 12px;
  }

  .report-title {
    font-size: 24px;
  }

  .report-summary > div,
  .result-grid div,
  .metric-strip div {
    padding: 12px;
  }

  .report-summary strong,
  .defaults strong,
  .result-grid strong,
  .metric-strip strong {
    font-size: 16px;
    overflow-wrap: anywhere;
  }

  th,
  td {
    padding: 12px 13px;
  }

  th {
    font-size: 13px;
  }

  td {
    font-size: 14px;
  }
}

@media (max-width: 420px) {
  h1 {
    max-width: 8.5ch;
    font-size: 28px;
  }

  .notice {
    font-size: 14px;
  }

  .field {
    font-size: 13px;
  }
}
