:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --danger: #b91c1c;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.4;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  gap: 20px;
}

.header h1 {
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.header p {
  margin: 0;
  color: var(--muted);
}

.content {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(320px, 1fr);
  gap: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.inputs-card {
  background: #e8e8e8;
  border-color: #d1d5db;
}

.results-card {
  background: #ece8dd;
  border-color: #d6cfbf;
}

h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 10px 12px;
  align-items: center;
}

label {
  font-size: 0.93rem;
}

.info-tip {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
  background: #eff6ff;
  cursor: help;
  vertical-align: middle;
}

.info-tip-text {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  min-width: 220px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #111827;
  color: #f9fafb;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 10;
}

.info-tip:hover .info-tip-text {
  opacity: 1;
  visibility: visible;
}

input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
}

select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
}

input[type="number"]:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

button:hover {
  border-color: #cbd5e1;
}

.preset {
  background: #f8fafc;
}

.reset {
  margin-left: auto;
  background: #fff7ed;
  border-color: #fed7aa;
}

.scenario-message {
  margin-top: 8px;
  min-height: 18px;
  font-size: 0.86rem;
  color: var(--muted);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 10px;
}

.stacked-chart {
  margin-top: 8px;
}

.stacked-bar {
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: #e5e7eb;
  border: 1px solid #cbd5e1;
}

.segment {
  height: 100%;
  width: 0%;
  min-width: 0;
}

.segment-travel {
  background: #3b82f6;
}

.segment-line {
  background: #22c55e;
}

.segment-unit {
  background: #f59e0b;
}

.segment-allowance {
  background: #a78bfa;
}

.segment-congestion {
  background: #ef4444;
}

.chart-legend {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.legend-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--muted);
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.metric {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fcfdff;
}

.metric .name {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.metric .value {
  margin: 4px 0 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.section-title {
  margin: 18px 0 10px;
  font-size: 1rem;
}

.validation {
  margin-top: 12px;
  min-height: 20px;
  color: var(--danger);
  font-size: 0.9rem;
}

.assumptions {
  font-size: 0.9rem;
  color: var(--muted);
}

.assumptions-toggle > summary {
  cursor: pointer;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.assumptions-toggle[open] > summary {
  margin-bottom: 14px;
}

.assumptions p {
  margin: 0 0 8px;
}

.assumptions ul {
  margin: 0;
  padding-left: 18px;
}

.footnote {
  margin-top: 14px;
  font-size: 0.88rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

@media (max-width: 900px) {
  .content {
    grid-template-columns: 1fr;
  }

  .reset {
    margin-left: 0;
  }
}
