:root {
  --ink: #19221d;
  --muted: #65736b;
  --paper: #fbfaf5;
  --panel: #ffffff;
  --line: #dfe6dc;
  --sage: #375a46;
  --sage-2: #5f7f62;
  --mint: #dcecdc;
  --apple: #d9734e;
  --honey: #e7bd55;
  --berry: #8d5870;
  --shadow: 0 16px 40px rgba(35, 49, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 18px 14px 28px;
  background:
    radial-gradient(circle at top left, rgba(220, 236, 220, 0.9), transparent 28rem),
    linear-gradient(180deg, #f7f4ea 0%, #fbfaf5 44%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1060px;
  margin: 0 auto 18px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--sage);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22);
}

.basket-mark {
  position: relative;
  width: 27px;
  height: 22px;
  border-radius: 3px 3px 7px 7px;
  background: var(--paper);
}

.basket-mark::before {
  content: "";
  position: absolute;
  left: 6px;
  top: -13px;
  width: 15px;
  height: 18px;
  border: 4px solid var(--honey);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
}

.basket-mark::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 9px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--apple);
}

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

h1 {
  font-size: 1.35rem;
  line-height: 1.1;
}

h2 {
  font-size: clamp(1.55rem, 8vw, 3rem);
  line-height: 1;
}

h3 {
  font-size: 1.03rem;
}

.brand-lockup p,
.muted {
  color: var(--muted);
}

main {
  max-width: 1060px;
  margin: 0 auto;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(16px);
}

.tab {
  border: 0;
  border-radius: 6px;
  min-height: 42px;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: var(--sage);
  color: #fff;
}

.view {
  display: none;
  padding-top: 14px;
}

.view.active {
  display: grid;
  gap: 14px;
}

.hero-panel,
.section-block,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.hero-panel {
  min-height: 178px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(55, 90, 70, 0.96), rgba(95, 127, 98, 0.92)),
    url("icons/receipt-pattern.svg");
  color: #fff;
  overflow: hidden;
}

.hero-copy {
  margin-top: 12px;
  color: rgba(255, 255, 255, 0.86);
}

.eyebrow {
  color: var(--sage-2);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.hero-panel .eyebrow {
  color: #d9efd6;
}

.score-wheel {
  width: 94px;
  height: 94px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: conic-gradient(var(--honey) 0 80%, rgba(255, 255, 255, 0.22) 80%);
  border: 8px solid rgba(255, 255, 255, 0.24);
}

.score-wheel span {
  font-size: 2.1rem;
  font-weight: 800;
}

.score-wheel small {
  margin-top: -26px;
  opacity: 0.75;
}

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

.metric {
  min-height: 96px;
  padding: 16px;
}

.metric span,
.budget-row span,
.compact-stats,
.future-grid span,
label {
  color: var(--muted);
  font-size: 0.88rem;
}

.metric strong,
.budget-row strong {
  display: block;
  margin-top: 8px;
  font-size: 1.45rem;
}

.section-block {
  padding: 18px;
}

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

.status-pill,
.confidence {
  border-radius: 999px;
  background: var(--mint);
  color: var(--sage);
  padding: 5px 9px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.budget-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: end;
  gap: 10px;
  height: 170px;
  padding: 10px 0 4px;
}

.bar {
  display: grid;
  align-content: end;
  gap: 8px;
  height: 100%;
}

.bar-fill {
  min-height: 18px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--sage-2), var(--sage));
}

.bar span {
  color: var(--muted);
  text-align: center;
  font-size: 0.78rem;
}

.compact-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.breakdown-list,
.insight-list,
.essential-list {
  display: grid;
  gap: 10px;
}

.breakdown-item {
  display: grid;
  gap: 8px;
}

.breakdown-top,
.essential-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.track span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.insight,
.essential-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.scanner-block {
  display: grid;
  gap: 16px;
}

.scan-drop {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  border: 1.5px dashed #a9baac;
  border-radius: 8px;
  padding: 20px;
  background: #f5f8f2;
  text-align: center;
}

.scan-drop input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.scan-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sage);
  color: #fff;
  font-size: 1.4rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 11px;
  background: #fff;
  color: var(--ink);
}

.ocr-status {
  margin: 14px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f3efe2;
  color: #755c19;
  font-size: 0.88rem;
}

.items-editor {
  display: grid;
  gap: 8px;
}

.item-row {
  display: grid;
  grid-template-columns: 1fr 82px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.item-category {
  grid-column: 1 / -1;
}

.remove-item {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #f2e4df;
  color: #8b3f2b;
  font-size: 1.3rem;
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.primary,
.secondary,
.icon-button {
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  font-weight: 800;
}

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

.secondary,
.icon-button {
  background: var(--mint);
  color: var(--sage);
}

.icon-button {
  width: 44px;
}

.essential-card {
  display: grid;
  gap: 8px;
}

.essential-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.score-copy {
  color: var(--muted);
  line-height: 1.5;
}

.future-grid {
  display: grid;
  gap: 10px;
}

.future-grid button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f5f0;
  color: #6d756e;
  padding: 0 12px;
  text-align: left;
}

.settings-form {
  display: grid;
  gap: 14px;
}

@media (min-width: 680px) {
  .app-shell {
    padding: 26px 22px 42px;
  }

  .view.active {
    grid-template-columns: repeat(6, 1fr);
  }

  .hero-panel,
  .scanner-block {
    grid-column: span 6;
  }

  .metric-grid,
  .section-block {
    grid-column: span 3;
  }

  #dashboard .section-block:nth-of-type(2),
  #dashboard .section-block:nth-of-type(3) {
    grid-column: span 3;
  }

  #dashboard .section-block:nth-of-type(4),
  #dashboard .section-block:nth-of-type(5) {
    grid-column: span 3;
  }

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

  .budget-row,
  .form-grid,
  .actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .receipt-form,
  #settings .section-block,
  #essentials .section-block {
    grid-column: span 6;
  }

  .item-row {
    grid-template-columns: 1fr 96px 180px auto 36px;
  }

  .item-category {
    grid-column: auto;
  }
}

@media (min-width: 980px) {
  .hero-panel {
    grid-column: span 4;
  }

  .metric-grid {
    grid-column: span 2;
  }

  .scanner-block {
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }
}
