:root {
  --bg: #fff9fd;
  --paper: #ffffff;
  --wash: #fbf2f8;
  --ink: #2c1730;
  --muted: #75647a;
  --line: rgba(77, 39, 78, 0.14);
  --line-strong: rgba(77, 39, 78, 0.24);
  --plum: #7b4384;
  --plum-dark: #3b1d41;
  --lavender: #9b78d4;
  --rose: #e75f7d;
  --coral: #f07b65;
  --amber: #f3a44c;
  --teal: #4aa9a5;
  --sage: #83a95b;
  --blue: #7f9bdc;
  --success: #348b61;
  --warning: #ad6b16;
  --danger: #ba4058;
  --shadow: 0 18px 50px rgba(69, 34, 70, 0.13);
  --shadow-soft: 0 8px 26px rgba(69, 34, 70, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  scroll-behavior: smooth;
}

body {
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(231, 95, 125, 0.1), transparent 28%),
    radial-gradient(circle at 86% 14%, rgba(74, 169, 165, 0.08), transparent 24%),
    linear-gradient(180deg, #fffafd 0%, #fff 45%, #fcf7fb 100%);
  font-family: "Quicksand", "Avenir Next Rounded", ui-rounded, system-ui, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(155, 120, 212, 0.45);
  outline-offset: 2px;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tracker-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100svh;
}

.side-nav {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100svh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(253, 244, 250, 0.9)),
    rgba(255, 255, 255, 0.76);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.brand {
  display: grid;
  gap: 3px;
}

.brand span {
  font-family: "Parisienne", cursive;
  color: var(--plum-dark);
  font-size: 2rem;
  line-height: 1;
}

.brand small,
.topbar p,
.panel-top p,
.mini-label,
.budget-meter span,
.budget-meter small,
.review-card small,
.stat-grid span,
th,
.subtle {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.nav-list {
  display: grid;
  gap: 7px;
}

.nav-list a,
.side-link {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #4b3650;
  font-size: 0.9rem;
  font-weight: 800;
}

.nav-list a.is-active,
.nav-list a:hover,
.side-link:hover {
  border-color: rgba(123, 67, 132, 0.14);
  background: rgba(123, 67, 132, 0.09);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--plum);
  font-size: 0.95rem;
}

.budget-meter {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
}

.budget-meter strong {
  font-size: 1.1rem;
}

.meter-ring {
  display: grid;
  place-items: center;
  width: 76px;
  aspect-ratio: 1;
  margin: 4px auto;
  border-radius: 50%;
  background:
    radial-gradient(circle, #fff 55%, transparent 56%),
    conic-gradient(var(--plum) var(--progress), rgba(123, 67, 132, 0.13) 0);
}

.meter-ring b {
  color: var(--plum-dark);
  font-size: 0.94rem;
}

.tracker-main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  color: var(--plum-dark);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(2.1rem, 3vw, 3.15rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.topbar p {
  margin: 4px 0 0;
}

.mobile-back {
  display: none;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.filters label,
.form-grid label,
.notes-field,
.item-editor-row label {
  display: grid;
  gap: 5px;
}

.filters span,
.form-grid span,
.notes-field span,
.item-editor-row span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.filters input,
.filters select,
.form-grid input,
.notes-field textarea,
.item-editor-row input,
.item-editor-row select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  padding: 0 12px;
  font-weight: 800;
}

.search-field {
  min-width: 190px;
}

.capture-hero,
.panel,
.review-card,
.receipt-dialog,
.category-dialog,
.classification-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(255, 248, 252, 0.82)),
    var(--paper);
  box-shadow: var(--shadow-soft);
}

.capture-hero {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 146px;
  margin-bottom: 20px;
  padding: 22px;
  overflow: hidden;
}

.capture-hero::after {
  position: absolute;
  inset: auto 0 0 auto;
  width: 310px;
  height: 145px;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.48)),
    url("../../assets/calm-bills-hero.png") center bottom / cover no-repeat;
  opacity: 0.28;
}

.capture-hero > * {
  position: relative;
  z-index: 1;
}

.camera-button {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  place-items: center;
  width: 108px;
  aspect-ratio: 1;
  border: 7px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  color: #fff;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.23), transparent 38%),
    linear-gradient(145deg, #a46aba, #774083);
  box-shadow: 0 16px 34px rgba(123, 67, 132, 0.25);
}

.camera-button svg {
  width: 48px;
  fill: currentColor;
}

.capture-hero > div:not(.capture-actions) {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}

.capture-actions {
  grid-column: 3;
  grid-row: 1;
}

.ocr-status {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  justify-self: start;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid rgba(123, 67, 132, 0.13);
  border-radius: var(--radius);
  color: var(--plum-dark);
  background: rgba(255, 255, 255, 0.74);
  font-size: 0.8rem;
  font-weight: 900;
}

.ocr-status[hidden] {
  display: none;
}

.ocr-status[data-tone="success"] {
  color: var(--success);
  border-color: rgba(52, 139, 97, 0.18);
  background: rgba(52, 139, 97, 0.09);
}

.ocr-status[data-tone="warning"] {
  color: var(--warning);
  border-color: rgba(173, 107, 22, 0.18);
  background: rgba(243, 164, 76, 0.12);
}

.ocr-status__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(123, 67, 132, 0.08);
}

.capture-hero h2,
.panel h2,
.review-strip h2 {
  margin: 0;
  color: var(--plum-dark);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.7rem;
  line-height: 1;
}

.capture-hero p {
  max-width: 420px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.capture-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button,
.segmented button {
  min-height: 40px;
  border-radius: var(--radius);
  font-weight: 900;
}

.primary-button {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--plum), var(--rose));
  padding: 0 16px;
}

.secondary-button,
.text-button,
.segmented button {
  border: 1px solid var(--line);
  color: var(--plum-dark);
  background: rgba(255, 255, 255, 0.8);
  padding: 0 14px;
}

.secondary-button:hover,
.text-button:hover,
.segmented button:hover {
  border-color: var(--line-strong);
  background: #fff;
}

.text-button {
  min-height: 34px;
  color: var(--plum);
  background: transparent;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  border: 1px solid var(--line);
  color: var(--plum);
  background: rgba(255, 255, 255, 0.74);
  font-size: 1.25rem;
}

.section-heading,
.panel-top,
.items-editor__top,
.dialog-top,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.review-strip {
  margin-bottom: 20px;
}

.review-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(196px, 230px);
  gap: 12px;
  overflow-x: auto;
  padding: 10px 2px 4px;
  scroll-snap-type: x proximity;
}

.review-card {
  display: grid;
  gap: 8px;
  min-height: 134px;
  padding: 14px;
  scroll-snap-align: start;
}

.review-card__top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.store-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #fff;
  background: var(--plum);
  font-size: 0.78rem;
  font-weight: 950;
}

.review-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-card b {
  color: var(--plum-dark);
  font-size: 1.22rem;
}

.status-chip {
  justify-self: start;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid rgba(173, 107, 22, 0.2);
  border-radius: var(--radius);
  color: var(--warning);
  background: rgba(243, 164, 76, 0.13);
  font-size: 0.78rem;
  font-weight: 900;
}

.status-chip.is-ready {
  border-color: rgba(52, 139, 97, 0.18);
  color: var(--success);
  background: rgba(52, 139, 97, 0.1);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.85fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.summary-panel,
.landscape-panel,
.table-panel {
  grid-column: span 1;
}

.table-panel {
  grid-column: 1 / -1;
}

.panel-top {
  margin-bottom: 14px;
}

.panel-top h2 {
  font-size: 1.26rem;
}

.panel-top p {
  margin: 4px 0 0;
}

.delta,
#reviewBadge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: var(--radius);
  color: var(--success);
  background: rgba(52, 139, 97, 0.09);
  font-size: 0.78rem;
  font-weight: 900;
}

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

.stat-grid div {
  display: grid;
  gap: 7px;
  min-height: 86px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.stat-grid strong {
  font-size: clamp(1.28rem, 2vw, 1.92rem);
  color: var(--plum-dark);
}

.trend-wrap {
  margin-top: 16px;
}

.trend-chart {
  width: 100%;
  height: 180px;
  overflow: visible;
}

.trend-chart path.line {
  fill: none;
  stroke: var(--lavender);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-chart path.area {
  fill: url(#trendFill);
}

.trend-chart line {
  stroke: rgba(77, 39, 78, 0.12);
}

.trend-chart text {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.category-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.donut-chart {
  width: 100%;
  max-width: 220px;
}

.donut-chart text {
  fill: var(--plum-dark);
  font-weight: 900;
}

.legend {
  display: grid;
  gap: 8px;
}

.legend-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  text-align: left;
  color: var(--muted);
  background: transparent;
  font-size: 0.83rem;
  font-weight: 800;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot-color);
}

.legend-row strong {
  color: var(--ink);
}

.legend-row span:nth-child(2) {
  min-width: 0;
  overflow-wrap: anywhere;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.58);
}

.segmented button {
  min-height: 30px;
  border: 0;
  background: transparent;
  font-size: 0.78rem;
}

.segmented button.is-active {
  color: #fff;
  background: var(--plum);
}

.landscape {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  align-items: end;
  gap: 18px;
  min-height: 252px;
  padding: 28px 18px 18px;
  border: 1px solid rgba(77, 39, 78, 0.08);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(251, 242, 248, 0.54)),
    repeating-linear-gradient(90deg, rgba(77, 39, 78, 0.04) 0 1px, transparent 1px 48px);
  overflow: hidden;
}

.landscape.is-3d {
  perspective: 900px;
}

.landform {
  display: grid;
  justify-items: center;
  gap: 7px;
  min-width: 0;
}

.land-stack {
  position: relative;
  display: grid;
  align-items: end;
  width: 66px;
  height: 128px;
  transform-style: preserve-3d;
}

.landscape.is-3d .land-stack {
  transform: rotateX(58deg) rotateZ(-34deg) translateY(18px);
}

.land-block {
  width: 58px;
  min-height: 8px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0)),
    var(--bar-color);
  box-shadow: 0 8px 16px rgba(69, 34, 70, 0.12);
}

.landscape.is-3d .land-block {
  transform: translateZ(var(--z));
}

.landform strong,
.landform span {
  max-width: 96px;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.landform strong {
  color: var(--plum-dark);
  font-size: 0.84rem;
}

.landform span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.store-bars,
.insight-list,
.top-items {
  display: grid;
  gap: 10px;
}

.store-row {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) minmax(120px, 2fr) auto;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 800;
}

.bar-track,
.item-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(123, 67, 132, 0.1);
}

.bar-fill,
.item-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--plum), var(--lavender));
}

.insight-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.insight-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #fff;
  background: var(--icon-color);
  font-size: 0.9rem;
  font-weight: 950;
}

.insight-card strong {
  color: var(--plum-dark);
}

.insight-card p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

.top-item-row {
  display: grid;
  grid-template-columns: 34px minmax(130px, 1fr) 48px minmax(120px, 1.4fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.top-item-row .store-mark {
  width: 34px;
  height: 34px;
  font-size: 0.7rem;
}

.top-item-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-percent {
  display: grid;
  place-items: center;
  min-height: 26px;
  border-radius: var(--radius);
  color: var(--plum);
  background: rgba(123, 67, 132, 0.1);
  font-size: 0.78rem;
  font-weight: 900;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.7);
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(77, 39, 78, 0.1);
  text-align: left;
  white-space: nowrap;
}

td {
  color: #45314a;
  font-size: 0.83rem;
  font-weight: 750;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: rgba(123, 67, 132, 0.05);
}

.confidence {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.confidence::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--confidence-color);
  content: "";
}

.bottom-nav {
  display: none;
}

.receipt-dialog,
.category-dialog,
.classification-dialog {
  width: min(980px, calc(100vw - 28px));
  max-height: calc(100svh - 28px);
  padding: 0;
  color: var(--ink);
}

.category-dialog,
.classification-dialog {
  width: min(640px, calc(100vw - 28px));
}

.receipt-dialog::backdrop,
.category-dialog::backdrop,
.classification-dialog::backdrop {
  background: rgba(44, 23, 48, 0.35);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.receipt-dialog form,
.category-dialog form,
.classification-dialog form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.dialog-top {
  align-items: start;
}

.dialog-top h2 {
  margin: 0;
  color: var(--plum-dark);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 2rem;
}

.dialog-top p {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 750;
}

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

.notes-field textarea {
  min-height: 84px;
  padding: 11px 12px;
  resize: vertical;
}

.ocr-text-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

.ocr-text-panel[hidden] {
  display: none;
}

.ocr-text-panel summary {
  min-height: 42px;
  padding: 11px 12px;
  color: var(--plum);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 900;
}

.ocr-text-panel textarea {
  width: calc(100% - 24px);
  min-height: 118px;
  margin: 0 12px 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #45314a;
  background: rgba(255, 255, 255, 0.72);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  resize: vertical;
}

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

.items-editor__top {
  flex-wrap: wrap;
}

.remember-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.learning-status {
  color: var(--success);
  border-color: rgba(52, 139, 97, 0.16);
  background: rgba(52, 139, 97, 0.09);
}

.item-filter-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.58);
}

.item-filter-tabs button {
  min-height: 30px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted);
  background: transparent;
  padding: 0 10px;
  font-size: 0.76rem;
  font-weight: 900;
}

.item-filter-tabs button.is-active {
  color: #fff;
  background: var(--plum);
}

#itemEditorRows {
  display: grid;
  gap: 8px;
}

.item-editor-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.3fr) 76px 90px 92px minmax(140px, 1fr) minmax(150px, 1fr) 42px;
  align-items: end;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.item-editor-row.is-unknown,
.item-editor-row.needs-category {
  border-color: rgba(186, 64, 88, 0.28);
  background: rgba(186, 64, 88, 0.06);
}

.item-editor-row small {
  min-height: 16px;
  color: var(--danger);
  font-size: 0.68rem;
  font-weight: 900;
}

.dialog-actions {
  flex-wrap: wrap;
}

.dialog-spacer {
  flex: 1;
}

.classification-list {
  display: grid;
  gap: 8px;
  max-height: min(420px, calc(100svh - 230px));
  overflow: auto;
}

.classification-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) minmax(150px, 0.9fr);
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.classification-row span {
  display: inline-flex;
  justify-content: center;
  min-height: 28px;
  padding: 6px 8px;
  border-radius: var(--radius);
  color: var(--success);
  background: rgba(52, 139, 97, 0.09);
  font-size: 0.74rem;
  font-weight: 900;
}

.classification-row strong,
.classification-row em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.classification-row em {
  color: var(--muted);
  font-style: normal;
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #fff;
  background: rgba(59, 29, 65, 0.94);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
  font-weight: 800;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 110px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 850;
  text-align: center;
}

@media (max-width: 1180px) {
  .tracker-shell {
    grid-template-columns: 1fr;
  }

  .side-nav {
    display: none;
  }

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

  .category-panel,
  .stores-panel,
  .insights-panel {
    grid-column: auto;
  }
}

@media (min-width: 1181px) {
  .capture-hero {
    min-height: 124px;
    margin-bottom: 14px;
    padding: 18px;
  }

  .camera-button {
    width: 96px;
  }

  .camera-button svg {
    width: 42px;
  }

  .review-strip {
    margin-bottom: 14px;
  }

  .review-list {
    padding-top: 6px;
  }

  .review-card {
    min-height: 126px;
  }

  .dashboard-grid {
    gap: 14px;
  }

  .summary-panel,
  .category-panel {
    padding: 16px;
  }

  .stat-grid div {
    min-height: 72px;
    padding: 10px 12px;
  }

  .trend-wrap {
    margin-top: 10px;
  }

  .trend-chart {
    height: 136px;
  }
}

@media (max-width: 760px) {
  body {
    background:
      linear-gradient(180deg, rgba(255, 249, 253, 0.68), rgba(255, 255, 255, 0.3)),
      url("../../assets/calm-bills-hero.png") center top / cover fixed no-repeat,
      var(--bg);
  }

  .tracker-main {
    width: 100%;
    max-width: 430px;
    margin: 0 auto;
    padding: calc(18px + env(safe-area-inset-top)) 10px calc(92px + env(safe-area-inset-bottom));
  }

  .topbar {
    display: grid;
    gap: 12px;
  }

  .topbar > div:first-child {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 10px;
  }

  .mobile-back {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.68);
    color: var(--plum);
    font-size: 1.8rem;
    font-weight: 900;
  }

  .topbar h1 {
    font-size: 2.08rem;
  }

  .topbar p {
    grid-column: 2;
  }

  .filters {
    justify-content: stretch;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .capture-hero {
    grid-template-columns: 80px minmax(0, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 100%;
    min-height: 150px;
    padding: 14px 12px;
  }

  .capture-actions {
    grid-row: 2;
    grid-column: 1 / -1;
    justify-content: stretch;
    min-width: 0;
  }

  .capture-actions button {
    flex: 1;
    min-width: 0;
    padding-right: 8px;
    padding-left: 8px;
  }

  .camera-button {
    width: 78px;
  }

  .camera-button svg {
    width: 36px;
  }

  .capture-hero h2 {
    font-size: 1.52rem;
  }

  .capture-hero p {
    font-size: 0.82rem;
    line-height: 1.28;
  }

  .review-list {
    grid-auto-columns: 196px;
  }

  .panel {
    padding: 14px;
  }

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

  .stat-grid div {
    min-height: 78px;
  }

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

  .donut-chart {
    justify-self: center;
    max-width: 188px;
  }

  .landscape {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    min-height: 230px;
    padding: 18px 10px 12px;
  }

  .land-stack {
    width: 54px;
    height: 116px;
  }

  .land-block {
    width: 48px;
  }

  .store-row {
    grid-template-columns: minmax(88px, 1fr) minmax(86px, 1.4fr) auto;
  }

  .top-item-row {
    grid-template-columns: 34px minmax(0, 1fr) 44px;
  }

  .top-item-row .item-track,
  .top-item-row b {
    grid-column: 2 / -1;
  }

  .table-wrap {
    display: none;
  }

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

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

  .item-editor-row label:first-child,
  .item-editor-row label:nth-child(5),
  .item-editor-row label:nth-child(6) {
    grid-column: 1 / -1;
  }

  .item-editor-row .icon-button {
    grid-column: 2;
    justify-self: end;
  }

  .classification-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .classification-row span {
    justify-content: start;
    width: max-content;
  }

  .bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: end;
    min-height: 74px;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(77, 39, 78, 0.12);
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 -12px 34px rgba(69, 34, 70, 0.1);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
  }

  .bottom-nav a,
  .bottom-nav button {
    display: grid;
    place-items: center;
    min-height: 46px;
    border: 0;
    color: var(--muted);
    background: transparent;
    font-size: 0.72rem;
    font-weight: 900;
  }

  .bottom-nav button {
    align-self: center;
    width: 64px;
    height: 64px;
    margin: -26px auto 0;
    border: 6px solid rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, #a46aba, #774083);
    box-shadow: 0 12px 24px rgba(123, 67, 132, 0.22);
  }
}

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

  .section-heading,
  .panel-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-top .segmented {
    align-self: stretch;
  }

  .segmented button {
    flex: 1;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .landscape.is-3d .land-stack {
    transform: none;
  }
}
