:root {
  color-scheme: light;
  --bg: #f3f1ea;
  --panel: #ffffff;
  --panel-soft: #f9faf7;
  --ink: #202124;
  --muted: #666b73;
  --line: #dfe3dd;
  --accent: #146c63;
  --accent-strong: #0f514b;
  --gold: #b7791f;
  --red: #b3261e;
  --green: #16794f;
  --blue: #315a9a;
  --shadow: 0 14px 40px rgba(32, 33, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 20px;
  max-width: 1440px;
  margin: 0 auto;
}

.side-panel,
.panel,
.decision-band,
.empty-state,
.metric {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.side-panel {
  position: sticky;
  top: 24px;
  align-self: start;
  padding: 22px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 21px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 10px;
  font-size: 30px;
  line-height: 1.1;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
}

.analyze-form {
  display: grid;
  gap: 10px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  background: var(--panel-soft);
  color: var(--ink);
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 99, 0.14);
}

.input-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.input-with-unit input {
  border: 0;
  background: transparent;
}

.input-with-unit span {
  padding-right: 13px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

button {
  margin-top: 8px;
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.payment-panel {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.payment-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.payment-heading p {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.payment-heading strong {
  font-size: 20px;
}

.payment-heading span {
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef1f5;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.payment-panel button {
  margin-top: 0;
}

.payment-panel button + button {
  background: var(--ink);
}

.payment-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.payment-status.error {
  color: var(--red);
}

.status {
  margin-top: 18px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ecf5f2;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.status.error {
  background: #fcebea;
  color: var(--red);
}

.note-panel {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.note-panel p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.note-panel ul,
.signal-list,
.trigger-list {
  margin: 0;
  padding-left: 18px;
}

.note-panel li,
.signal-list li,
.trigger-list li {
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.45;
}

.results {
  min-width: 0;
}

.empty-state {
  min-height: calc(100vh - 48px);
  display: grid;
  align-content: center;
  padding: 42px;
}

.empty-state p:last-child {
  max-width: 560px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.result-view {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.hidden {
  display: none;
}

.decision-band {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  border-top: 5px solid var(--accent);
}

.result-view[data-decision="follow"] .decision-band {
  border-top-color: var(--green);
}

.result-view[data-decision="watch"] .decision-band {
  border-top-color: var(--blue);
}

.result-view[data-decision="reduce"] .decision-band {
  border-top-color: var(--gold);
}

.result-view[data-decision="avoid"] .decision-band {
  border-top-color: var(--red);
}

.summary {
  margin-bottom: 0;
  max-width: 760px;
  color: var(--muted);
  line-height: 1.5;
}

.score-stack {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.score-pill {
  min-width: 86px;
  padding: 12px;
  border-radius: 8px;
  background: #edf7f1;
  text-align: center;
}

.score-pill.risk {
  background: #fff3df;
}

.score-pill span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.score-pill strong {
  display: block;
  margin-top: 4px;
  font-size: 30px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  padding: 16px;
  box-shadow: none;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.panel {
  padding: 20px;
  box-shadow: none;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.chip {
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef1f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.ai-thesis {
  display: grid;
  gap: 16px;
}

.ai-summary {
  display: grid;
  gap: 7px;
}

.ai-summary span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.ai-summary p,
.ai-muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.ai-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.ai-list strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

.ai-list ul {
  margin: 0;
  padding-left: 18px;
}

.ai-list li {
  margin: 7px 0;
  color: var(--muted);
  line-height: 1.45;
}

.allocation-main {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.allocation-main span,
.allocation-rows span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.allocation-main strong {
  font-size: 34px;
}

.allocation-rows {
  display: grid;
  gap: 12px;
  padding-top: 16px;
}

.allocation-rows div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.category-list {
  display: grid;
  gap: 13px;
}

.category-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(140px, 2fr) 48px;
  gap: 12px;
  align-items: center;
}

.category-row span,
.category-row em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
}

.category-row strong {
  display: block;
  margin-top: 2px;
}

.bar {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: #e6e9e2;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.risk-list li::marker {
  color: var(--red);
}

.trigger-list li::marker {
  color: var(--gold);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  color: var(--ink);
  font-size: 14px;
}

.positive {
  color: var(--green);
  font-weight: 800;
}

.negative {
  color: var(--red);
  font-weight: 800;
}

.empty-row {
  color: var(--muted);
  text-align: center;
}

.receipt-grid {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 10px 14px;
  margin: 0;
}

.receipt-grid dt {
  color: var(--muted);
  font-weight: 800;
}

.receipt-grid dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.source-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.source-status span {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.source-status .ok {
  background: #edf7f1;
  color: var(--green);
}

.source-status .bad {
  background: #fcebea;
  color: var(--red);
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }

  .metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ai-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 12px;
  }

  .side-panel,
  .panel,
  .decision-band,
  .empty-state {
    padding: 16px;
  }

  .decision-band,
  .two-column {
    grid-template-columns: 1fr;
    display: grid;
  }

  .score-stack {
    width: 100%;
  }

  .score-pill {
    flex: 1;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .category-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

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