:root {
  color-scheme: light;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  color: #243447;
  background: #f5f7f9;
  font-synthesis: none;
  letter-spacing: 0;
  --navy: #193a56;
  --blue: #2b5b7f;
  --teal: #147d73;
  --teal-soft: #e4f3f0;
  --blue-soft: #eaf3f8;
  --amber: #fff2cc;
  --red: #b42318;
  --red-soft: #fce8e6;
  --green: #2e7d32;
  --green-soft: #e8f5e9;
  --border: #c9d5df;
  --muted: #647482;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: #f5f7f9;
}

button, input, select { font: inherit; letter-spacing: 0; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 84px;
  padding: 16px clamp(18px, 3.5vw, 56px);
  color: #fff;
  background: var(--navy);
  border-bottom: 4px solid var(--teal);
}

.app-header h1 {
  margin: 3px 0 0;
  font-size: 22px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0;
  color: #728595;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.app-header .eyebrow { color: #b9cbd7; }

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.header-meta span { color: #b9cbd7; }

.reset-button {
  height: 34px;
  margin-left: 12px;
  padding: 0 14px;
  color: #fff;
  background: transparent;
  border: 1px solid #7791a5;
  border-radius: 5px;
  cursor: pointer;
}

.reset-button:hover { background: #274b66; }

main { width: 100%; }

.control-band,
.activity-band,
.results-band,
.matrix-band {
  padding: 22px clamp(18px, 3.5vw, 56px);
  background: #fff;
  border-bottom: 1px solid #dce3e8;
}

.control-band { background: var(--blue-soft); }

.control-grid {
  display: grid;
  grid-template-columns: minmax(130px, .7fr) minmax(130px, .7fr) minmax(330px, 1.8fr) repeat(3, minmax(150px, .9fr));
  gap: 14px;
  max-width: 1680px;
  margin: 0 auto;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.control > span:first-child {
  font-size: 11px;
  font-weight: 700;
  color: #506473;
}

.control input,
.control select,
.number-field {
  width: 100%;
  height: 38px;
  border: 1px solid #d0b45d;
  border-radius: 5px;
  background: var(--amber);
  color: #263746;
}

.control input,
.control select { padding: 0 10px; }

.control select { cursor: pointer; }

.scene-detail {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 14px;
  min-height: 44px;
  padding-top: 11px;
  border-top: 1px solid #c9d8e2;
  color: #4c6170;
  font-size: 11px;
  line-height: 1.55;
}

.scene-detail strong { color: var(--navy); }

.number-field {
  display: flex;
  align-items: center;
  overflow: hidden;
}

.number-field b {
  padding: 0 0 0 10px;
  color: #745e16;
  font-weight: 700;
}

.number-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  height: 38px;
  overflow: hidden;
  border: 1px solid #b9c8d3;
  border-radius: 5px;
  background: #fff;
}

.segmented button {
  min-width: 0;
  padding: 0 8px;
  color: #4d6272;
  background: #fff;
  border: 0;
  border-right: 1px solid #d8e1e7;
  cursor: pointer;
}

.segmented button:last-child { border-right: 0; }

.segmented button[aria-pressed="true"] {
  color: #fff;
  background: var(--blue);
  font-weight: 700;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  max-width: 1680px;
  margin: 0 auto 15px;
}

.section-heading h2 {
  margin: 3px 0 0;
  font-size: 16px;
  color: var(--navy);
}

.section-heading > p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.activity-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 22px;
  max-width: 1680px;
  margin: 0 auto;
}

.activity-group {
  min-width: 0;
  border-top: 3px solid var(--blue);
}

.activity-group.cross { border-top-color: var(--teal); }

.activity-group h3 {
  margin: 0;
  padding: 9px 0 7px;
  font-size: 12px;
  color: var(--navy);
  border-bottom: 1px solid var(--border);
}

.activity-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 48px 54px;
  align-items: center;
  min-height: 35px;
  gap: 10px;
  border-bottom: 1px solid #e4e9ed;
  font-size: 12px;
}

.activity-row > span:last-child {
  color: var(--blue);
  font-weight: 700;
  text-align: right;
}

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  justify-self: end;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 11px;
  background: #aebcc6;
  cursor: pointer;
  transition: background 140ms ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .22);
  transition: transform 140ms ease;
}

.switch input:checked + .switch-track { background: var(--teal); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid #3f83aa; outline-offset: 2px; }

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 1px;
  padding: 0 clamp(18px, 3.5vw, 56px);
  background: #ccd7df;
  border-bottom: 1px solid #ccd7df;
}

.kpi-strip > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  min-height: 64px;
  gap: 12px;
  padding: 15px 20px;
  background: #fff;
}

.kpi-strip span { color: var(--muted); font-size: 11px; }
.kpi-strip strong { color: var(--teal); font-size: 18px; }

.results-layout {
  display: grid;
  grid-template-columns: minmax(760px, 1.35fr) minmax(420px, .65fr);
  gap: 28px;
  max-width: 1680px;
  margin: 0 auto;
  align-items: start;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 11px;
}

th {
  height: 38px;
  padding: 7px 9px;
  color: #fff;
  background: var(--blue);
  border-right: 1px solid #d8e6ee;
  text-align: center;
  white-space: nowrap;
}

.net-header span {
  display: block;
  margin-top: 2px;
  color: #dcebf2;
  font-size: 9px;
  font-weight: 400;
}

td {
  height: 36px;
  padding: 7px 9px;
  border-bottom: 1px solid #dbe3e8;
  text-align: right;
  white-space: nowrap;
}

td:first-child {
  min-width: 164px;
  font-weight: 700;
  text-align: left;
}

.discount-cell { font-weight: 700; }

.net-cell {
  min-width: 176px;
  white-space: normal;
}

.net-cell strong {
  display: block;
  color: var(--teal);
  font-size: 12px;
}

.net-cell small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.25;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  height: 23px;
  padding: 0 8px;
  border-radius: 4px;
  font-weight: 700;
}

.status.safe { color: var(--green); background: var(--green-soft); }
.status.risk { color: var(--red); background: var(--red-soft); }

.chart-panel {
  min-width: 0;
  padding-left: 20px;
  border-left: 1px solid #dbe3e8;
}

.chart-panel h3 {
  margin: 0 0 13px;
  font-size: 12px;
  color: var(--navy);
}

.bar-chart { display: grid; gap: 8px; }

.bar-row {
  display: grid;
  grid-template-columns: minmax(118px, 1.15fr) minmax(110px, 2fr) 45px;
  align-items: center;
  gap: 9px;
  min-height: 23px;
  font-size: 10px;
}

.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 13px;
  background: #e8edf0;
  border-radius: 2px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  background: var(--teal);
}

.bar-value { text-align: right; font-weight: 700; color: var(--teal); }

.matrix-band { border-top: 5px solid #eef2f4; }
.matrix-table { min-width: 720px; }
.time-matrix { min-width: 1180px; }
.matrix-table td { text-align: center; font-weight: 700; }
.matrix-table td:first-child { text-align: left; }

.heat-deep { background: #9ecfbe; color: #124f48; }
.heat-strong { background: #d2e5c8; color: #365b34; }
.heat-mid { background: #fff0c7; color: #6c5410; }
.heat-light { background: #f5d4cc; color: #7c2d24; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  padding: 18px clamp(18px, 3.5vw, 56px) 28px;
  color: #687986;
  background: #f5f7f9;
  font-size: 10px;
}

footer p { margin: 0; max-width: 760px; }

@media (max-width: 1180px) {
  .control-grid { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
  .control-wide { grid-column: span 2; }
  .results-layout { grid-template-columns: 1fr; }
  .chart-panel { padding: 18px 0 0; border-left: 0; border-top: 1px solid #dbe3e8; }
}

@media (max-width: 760px) {
  .app-header { align-items: flex-start; padding: 14px 16px; }
  .app-header h1 { font-size: 19px; }
  .header-meta { flex-wrap: wrap; justify-content: flex-end; }
  .header-meta span { display: none; }
  .reset-button { margin-left: 0; }
  .control-band, .activity-band, .results-band, .matrix-band { padding: 18px 14px; }
  .control-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .control-wide { grid-column: 1 / -1; }
  .segmented { grid-template-columns: repeat(2, 1fr); height: 76px; }
  .segmented button:nth-child(2) { border-right: 0; }
  .segmented button:nth-child(-n+2) { border-bottom: 1px solid #d8e1e7; }
  .activity-groups { grid-template-columns: 1fr; gap: 16px; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 14px; }
  .kpi-strip > div { min-height: 58px; padding: 12px; flex-direction: column; gap: 4px; }
  .kpi-strip strong { font-size: 16px; }
  .section-heading { align-items: flex-start; }
  .section-heading > p { max-width: 48%; }
  .results-layout { display: block; }
  .results-layout table { min-width: 1060px; }
  .chart-panel { margin-top: 20px; }
  .bar-row { grid-template-columns: minmax(98px, 1fr) minmax(90px, 1.6fr) 42px; }
  footer { flex-direction: column; padding: 16px 14px 24px; }
}

@media (max-width: 420px) {
  .app-header { gap: 10px; }
  .header-meta strong { display: none; }
  .control-grid { grid-template-columns: 1fr; }
  .control-wide { grid-column: auto; }
  .scene-detail { grid-template-columns: 1fr; gap: 3px; }
  .kpi-strip { grid-template-columns: 1fr 1fr; }
  .section-heading { display: block; }
  .section-heading > p { max-width: none; margin-top: 7px; text-align: left; }
}
