:root {
  color-scheme: light;
  --ink: #182025;
  --muted: #5d6a72;
  --line: #d8e0e4;
  --surface: #ffffff;
  --surface-2: #f4f7f8;
  --accent: #0d6b68;
  --accent-dark: #074845;
  --warning: #8a4d00;
  --danger: #9b1c31;
  --shadow: 0 12px 30px rgba(22, 42, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface-2);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 56px);
  background: #143642;
  color: #fff;
}

.eyebrow {
  margin: 0 0 4px;
  color: #b9d9d4;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.6rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 1rem;
  letter-spacing: 0;
}

.header-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.workspace {
  display: grid;
  gap: 18px;
  padding: 18px clamp(14px, 3vw, 36px) 38px;
}

.control-surface,
.results-main,
.side-panel,
.source-section {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.control-surface {
  padding: 18px;
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select {
  min-height: 42px;
  width: 100%;
  border: 1px solid #bac7cc;
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}

input:focus,
select:focus {
  outline: 3px solid rgba(13, 107, 104, 0.18);
  border-color: var(--accent);
}

.form-actions {
  grid-column: span 2;
  align-self: end;
}

.primary-btn,
.secondary-btn {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 14px;
  font-weight: 800;
  cursor: pointer;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover {
  background: var(--accent-dark);
}

.secondary-btn {
  background: #e5f0ef;
  color: var(--accent-dark);
  border-color: #b9d4d1;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.data-band {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--line);
}

.data-band > div {
  min-height: 74px;
  padding: 14px;
  background: #fff;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.data-band strong {
  display: block;
  margin-top: 4px;
  font-size: 0.96rem;
}

.results-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.results-main,
.side-panel,
.source-section {
  padding: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#statusText {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.metric {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.35rem;
}

.metric small {
  color: var(--muted);
}

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

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  background: #fff;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

th {
  background: #eef4f4;
  color: #25414a;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.compact td,
.compact th {
  font-size: 0.82rem;
  padding: 8px;
}

.sensitivity {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.sensitivity h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 72px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  position: relative;
  height: 28px;
  background: #edf2f3;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.bar-zero {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #6f7d84;
}

.bar-low,
.bar-high {
  position: absolute;
  top: 5px;
  height: 16px;
  border-radius: 4px;
}

.bar-low {
  right: 50%;
  background: #c95f39;
}

.bar-high {
  left: 50%;
  background: #0d6b68;
}

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

.source-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.source-item a {
  color: var(--accent-dark);
  font-weight: 800;
}

.source-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.warnings {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.warning {
  border-left: 4px solid var(--warning);
  background: #fff8ec;
  padding: 10px 12px;
  color: var(--warning);
  font-weight: 700;
}

.error {
  border-left-color: var(--danger);
  color: var(--danger);
  background: #fff0f3;
}

@media (max-width: 1100px) {
  .input-grid,
  .metric-grid,
  .data-band,
  .source-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .results-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .input-grid,
  .metric-grid,
  .data-band,
  .source-list {
    grid-template-columns: 1fr;
  }

  .form-actions {
    grid-column: span 1;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }
}
