:root {
  --bg-a: #fbf7ef;
  --bg-b: #f0e8db;
  --ink: #1f2a37;
  --ink-soft: #49566a;
  --card: #fffdf8;
  --line: #d9c8b2;
  --accent: #0f7b6c;
  --accent-soft: #d9f0ea;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1400px 700px at 85% -10%, rgba(15, 123, 108, 0.16), transparent 60%),
    linear-gradient(140deg, var(--bg-a), var(--bg-b));
}

.shell {
  min-height: calc(100vh - 70px);
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.app-layout {
  width: min(1240px, 100%);
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  align-items: start;
}

.panel {
  width: 100%;
  background: color-mix(in oklab, var(--card), white 18%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.4rem;
  box-shadow: 0 16px 40px rgba(24, 39, 57, 0.08);
}

.eyebrow {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.76rem;
  color: var(--accent);
}

h1 {
  margin: 0.3rem 0 0.5rem;
  font-size: clamp(1.45rem, 1.2rem + 1.4vw, 2rem);
}

.intro {
  margin: 0;
  color: var(--ink-soft);
}

.context-note {
  margin: 0.55rem 0 0;
  font-size: 0.9rem;
  color: #35516a;
}

.controls {
  margin-top: 1rem;
  display: grid;
  gap: 0.75rem;
  max-width: 560px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.control-item {
  display: grid;
  gap: 0.4rem;
}

.control-item-wide {
  grid-column: 1 / -1;
}

.metrics-layout {
  margin-top: 1.1rem;
  display: grid;
  gap: 0.9rem;
  grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
  align-items: start;
}

.fact-side {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  background: color-mix(in oklab, var(--card), white 24%);
  box-shadow: 0 16px 40px rgba(24, 39, 57, 0.08);
}

.fact-section {
  margin-top: 0;
  display: grid;
  gap: 0.5rem;
}

.fact-section .stat-card {
  background: linear-gradient(180deg, #fafdff, #eef6ff);
  border-color: #bfd5e8;
}

label {
  font-weight: 600;
  font-size: 0.93rem;
}

select,
input[type="number"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid #a7b6c8;
  border-radius: 12px;
  background: white;
  font: inherit;
}

input[type="number"] {
  border-color: #b9c6d4;
  background: #fff;
  color: var(--ink);
  font-weight: 500;
  box-shadow: none;
}

input[type="number"]::placeholder {
  color: #7a8797;
}

input[type="number"]:focus-visible {
  outline: none;
  border-color: #2f7eab;
  box-shadow: 0 0 0 2px rgba(47, 126, 171, 0.14);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
}

.salary-input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid #b8c5d3;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fbfe);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.salary-input-wrap:focus-within {
  border-color: #2f7eab;
  box-shadow: 0 0 0 2px rgba(47, 126, 171, 0.14);
}

.salary-input-prefix {
  padding: 0.72rem 0.35rem 0.72rem 0.75rem;
  font-weight: 600;
  color: #516173;
  letter-spacing: 0.01em;
  user-select: none;
}

#salaryInput {
  border: 0;
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
  padding: 0.72rem 0.8rem 0.72rem 0.2rem;
  color: var(--ink);
  font-weight: 600;
  -moz-appearance: textfield;
  appearance: textfield;
}

#salaryInput:focus-visible {
  outline: none;
  box-shadow: none;
}

#salaryInput::-webkit-outer-spin-button,
#salaryInput::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

select:disabled,
input[type="number"]:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.main-stats {
  display: grid;
  gap: 0.9rem;
}

.stats-row {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: minmax(0, 1fr);
}

.row-label {
  margin: 0;
  align-self: start;
  justify-self: start;
  width: auto;
  text-align: center;
  white-space: nowrap;
  line-height: 1.12;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0.34rem 0.42rem;
  border: 1px solid #c6d5e3;
  border-radius: 11px;
  background: linear-gradient(180deg, #f7fbff, #edf4fb);
  color: #1f5676;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.stats-row-cards {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats-row-cards-single {
  grid-template-columns: minmax(0, 1fr);
}

.stats-row-cards-cpi {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, white, #fef9f1);
  border-radius: 14px;
  padding: 0.85rem;
}

.stat-card h2 {
  margin: 0;
  font-size: 0.84rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  font-weight: 600;
}

.stat-card p {
  margin: 0.45rem 0 0;
  font-size: clamp(1.1rem, 0.9rem + 1.1vw, 1.5rem);
  font-weight: 700;
}

.stat-meta {
  margin-top: 0.45rem;
  font-size: 0.81rem;
  line-height: 1.35;
  color: var(--ink-soft);
}

.fact-card {
  display: grid;
  gap: 0.65rem;
}

.fact-timeline {
  margin: 0.05rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.42rem;
}

.fact-timeline li {
  display: grid;
  gap: 0.5rem;
  align-items: center;
  grid-template-columns: 52px minmax(90px, 1fr) auto;
}

.timeline-year {
  font-size: 0.8rem;
  color: #446076;
  font-weight: 600;
}

.timeline-bar {
  position: relative;
  height: 0.5rem;
  border-radius: 999px;
  background: #e6eef7;
  overflow: hidden;
}

.timeline-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #267fb0, #1ea681);
}

.timeline-value {
  font-size: 0.82rem;
  color: #2f4254;
  font-weight: 600;
}

.fact-hook {
  margin: 0.2rem 0 0;
  padding: 0.55rem 0.6rem;
  border: 1px solid #c4d6e6;
  border-radius: 10px;
  background: #f3f9ff;
  color: #174766;
  font-size: 0.83rem;
  line-height: 1.35;
}

.fact-refresh-button {
  width: 100%;
  border: 1px solid #95b8d2;
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  background: linear-gradient(180deg, #ffffff, #eaf4fc);
  color: #1e587c;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.fact-refresh-button:hover {
  filter: brightness(0.98);
}

.fact-refresh-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(47, 126, 171, 0.2);
  border-color: #2f7eab;
}

.awote-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #f7fbff, #ecf3fb);
  padding: 0.85rem;
  display: grid;
  gap: 0.75rem;
}

.wage-title {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #24536d;
  font-weight: 700;
}

.wage-source-note {
  margin: 0;
  padding: 0.55rem 0.6rem;
  border: 1px solid #bcd0df;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.35;
  color: #2b536d;
  background: #f5faff;
}

.wage-source-note.is-fallback {
  border-color: #d8c5a1;
  color: #6a4721;
  background: #fff7ea;
}

.status {
  margin: 1rem 0 0;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #0f4f47;
  background: var(--accent-soft);
}

.status.error {
  color: #6a1c1c;
  background: #f9e6e6;
}

.source {
  margin: 0.8rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.app-footer {
  padding: 0.75rem 1rem 1.25rem;
  text-align: center;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.app-footer a {
  color: #10517b;
  font-weight: 600;
}

.coffee-fab {
  display: inline-block;
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #c9b08c;
  background: linear-gradient(180deg, #fff7ea, #ffeecf);
  color: #6a4721;
  text-decoration: none;
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  box-shadow: 0 10px 24px rgba(24, 39, 57, 0.15);
}

.coffee-fab:hover {
  filter: brightness(0.98);
}

.sources-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.sources-panel {
  width: min(860px, 100%);
  background: color-mix(in oklab, var(--card), white 18%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.4rem;
  box-shadow: 0 16px 40px rgba(24, 39, 57, 0.08);
}

.sources-list {
  margin: 1rem 0 0;
  padding-left: 1.1rem;
}

.sources-list li {
  margin: 0.45rem 0;
}

.sources-list a {
  color: #10517b;
}

.source a {
  color: #10517b;
}

@media (max-width: 960px) {
  .metrics-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .panel {
    padding: 1rem;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .stats-row-cards,
  .stats-row-cards-cpi {
    grid-template-columns: 1fr;
  }

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

  .coffee-fab {
    right: 0.75rem;
    bottom: 0.75rem;
  }

  .fact-timeline li {
    grid-template-columns: 42px minmax(76px, 1fr) auto;
    gap: 0.4rem;
  }
}
