:root {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-2: #111c33;
  --card: #1e293b;
  --card-2: #243247;
  --accent: #10b981;
  --accent-2: #f59e0b;
  --text: #ffffff;
  --muted: #cbd5e1;
  --soft: #94a3b8;
  --line: rgba(148, 163, 184, 0.2);
  --line-strong: rgba(203, 213, 225, 0.28);
  --danger: #fb7185;
  --warning-bg: rgba(245, 158, 11, 0.14);
  --shadow: 0 22px 55px rgba(0, 0, 0, 0.26);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(16, 185, 129, 0.18), transparent 32rem),
    radial-gradient(circle at 85% 12%, rgba(245, 158, 11, 0.12), transparent 26rem),
    var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 18px 12px;
}

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

.brand-mark {
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.22), rgba(30, 41, 59, 0.95));
  box-shadow: var(--shadow);
}

.bag-shape {
  width: 25px;
  height: 27px;
  border: 3px solid var(--accent);
  border-top: 0;
  border-radius: 5px 5px 7px 7px;
}

.bag-shape::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 18px;
  width: 12px;
  height: 8px;
  border: 3px solid var(--accent);
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
}

.graph-spark {
  position: absolute;
  right: 11px;
  bottom: 13px;
  width: 17px;
  height: 12px;
  border-left: 3px solid var(--accent-2);
  border-bottom: 3px solid var(--accent-2);
  transform: skew(-16deg);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 0;
  font-size: 1.8rem;
  line-height: 1;
}

main {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 0 14px 34px;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  padding: 10px 0 14px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(16px);
}

.tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.78);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.tab.is-active {
  border-color: rgba(16, 185, 129, 0.62);
  background: var(--accent);
  color: #062016;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 12px 0 16px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 1.45rem;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: right;
}

.hero-card,
.stat-card,
.prediction-card,
.panel,
.upload-panel,
.review-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(155deg, rgba(30, 41, 59, 0.98), rgba(17, 28, 51, 0.96));
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 22px;
  overflow: hidden;
}

.metric-label,
.stat-card span,
.trend-stats span {
  display: block;
  margin-bottom: 7px;
  color: var(--soft);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.score-line {
  display: flex;
  align-items: end;
  gap: 8px;
}

.score-line strong {
  font-size: clamp(3rem, 18vw, 5.4rem);
  line-height: 0.9;
}

.score-line span {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 850;
}

.hero-copy {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 750;
}

.score-ring {
  display: grid;
  width: 116px;
  height: 116px;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--card) 58%, transparent 60%),
    conic-gradient(var(--accent) 0deg, var(--accent) 331deg, rgba(203, 213, 225, 0.16) 331deg);
}

.score-ring span {
  color: var(--text);
  font-size: 1.9rem;
  font-weight: 950;
}

.hero-metrics {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 4px 0 0;
}

.hero-metrics div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.42);
}

dt {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

dd {
  margin: 0;
  color: var(--text);
  font-weight: 900;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.stat-card {
  min-height: 108px;
  padding: 16px;
}

.stat-card strong {
  display: block;
  font-size: 1.55rem;
}

.prediction-card {
  margin-bottom: 14px;
  padding: 18px;
  border-color: rgba(245, 158, 11, 0.34);
}

.prediction-card strong {
  display: block;
  color: var(--text);
  font-size: 1.04rem;
  line-height: 1.45;
}

.panel {
  margin-top: 14px;
  padding: 18px;
}

.panel-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-title h2 {
  margin-bottom: 0;
  font-size: 1.12rem;
}

.panel-title span {
  color: var(--soft);
  font-size: 0.82rem;
  text-align: right;
}

.insight-grid,
.achievement-list,
.history-list,
.breakdown-list {
  display: grid;
  gap: 11px;
}

.insight,
.achievement,
.history-item,
.breakdown-row {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.insight {
  padding: 15px;
  color: var(--muted);
  line-height: 1.42;
}

.insight strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 0.96rem;
}

.achievement {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px;
  color: var(--text);
  font-weight: 800;
}

.achievement span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.16);
}

.breakdown-row {
  display: grid;
  gap: 9px;
  padding: 14px;
}

.breakdown-row header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-weight: 850;
}

.bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(203, 213, 225, 0.12);
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.trend-chart {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  min-height: 210px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.42);
}

.trend-bar {
  display: grid;
  gap: 9px;
  align-items: end;
  min-width: 0;
  height: 178px;
}

.trend-bar-fill {
  align-self: end;
  min-height: 12px;
  border-radius: 999px 999px 10px 10px;
  background: linear-gradient(180deg, var(--accent), #087f5f);
  box-shadow: 0 12px 24px rgba(16, 185, 129, 0.2);
}

.trend-bar-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.trend-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.trend-stats article {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.42);
}

.trend-stats strong {
  font-size: 1.15rem;
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.flow-steps li {
  min-height: 48px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(30, 41, 59, 0.8);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.flow-steps li.is-current {
  border-color: rgba(16, 185, 129, 0.54);
  color: var(--accent);
}

.upload-panel,
.review-panel {
  padding: 16px;
}

.upload-panel {
  display: grid;
  gap: 10px;
}

.receipt-upload {
  display: grid;
  gap: 6px;
  min-height: 132px;
  place-items: center;
  border: 1px dashed rgba(16, 185, 129, 0.58);
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.08);
  text-align: center;
}

.receipt-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.receipt-upload span {
  color: var(--text);
  font-weight: 900;
}

.receipt-upload small {
  max-width: 290px;
  color: var(--muted);
}

.scan-status,
.warning {
  margin: 12px 0;
  padding: 13px;
  border-radius: 16px;
  font-weight: 800;
}

.scan-status {
  border: 1px solid rgba(16, 185, 129, 0.38);
  background: rgba(16, 185, 129, 0.1);
  color: var(--text);
}

.warning {
  border: 1px solid rgba(245, 158, 11, 0.48);
  background: var(--warning-bg);
  color: #fde68a;
}

.form-grid,
.item-row {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.68);
  color: var(--text);
  padding: 10px 11px;
}

input,
select {
  min-height: 46px;
}

textarea {
  resize: vertical;
}

.text-review {
  margin-bottom: 10px;
}

.reparse-button {
  width: 100%;
  margin-bottom: 14px;
}

.items-header,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.items-header {
  margin-top: 18px;
}

.items-header h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.items-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 18px;
}

.item-row {
  position: relative;
  grid-template-columns: 1fr;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.icon-button,
.primary-button,
.secondary-button {
  min-height: 44px;
  border-radius: 14px;
  font-weight: 850;
}

.icon-button {
  width: 44px;
  border: 1px solid var(--line);
  background: rgba(30, 41, 59, 0.88);
  color: var(--text);
  font-size: 1.15rem;
}

.remove-item {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  min-height: 38px;
  color: var(--danger);
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #062016;
  padding: 0 15px;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: rgba(30, 41, 59, 0.92);
  color: var(--text);
  padding: 0 15px;
}

.history-item {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.history-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.history-item strong {
  color: var(--text);
}

.history-item small,
.history-items,
.settings-panel p {
  color: var(--muted);
}

.history-item small {
  display: block;
  margin-top: 3px;
}

.settings-panel h2 {
  margin-bottom: 8px;
}

@media (min-width: 680px) {
  .app-header {
    width: min(100%, 1040px);
    margin: 0 auto;
    padding-inline: 14px;
  }

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

  .hero-metrics div {
    display: grid;
  }

  .quick-grid {
    grid-template-columns: repeat(4, 1fr);
  }

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

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

  .form-grid,
  .item-row {
    grid-template-columns: 1.3fr 0.8fr 1fr auto;
    align-items: end;
  }

  .form-grid {
    grid-template-columns: 1.2fr 0.9fr 0.9fr;
  }

  .remove-item {
    position: static;
  }
}

.install-diagnostics {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.48);
  color: var(--muted);
  font-size: 0.86rem;
}

.install-diagnostics strong {
  color: var(--text);
  font-size: 0.95rem;
}

.install-diagnostics span {
  display: block;
}
.diagnostic-install-button {
  width: 100%;
  margin-top: 8px;
}
.install-pill,
.install-card-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #062016;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(16, 185, 129, 0.22);
}

.install-pill {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
}

.install-card-button {
  width: 100%;
  min-height: 54px;
  margin: 0 0 14px;
  border-radius: 18px;
  font-size: 1rem;
}

.install-sheet[hidden] {
  display: none;
}

.install-sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-items: end;
}

.install-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
}

.install-sheet-panel {
  position: relative;
  margin: 12px;
  padding: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 26px;
  background: var(--card);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.48);
}

.install-sheet-panel h2 {
  margin-bottom: 10px;
}

.install-sheet-panel p,
.install-sheet-panel li {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.install-sheet-panel ol {
  margin: 14px 0;
  padding-left: 22px;
}

.install-sheet-panel strong {
  color: var(--text);
}

.install-sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.install-sheet-note {
  margin-bottom: 0;
  color: var(--soft);
}

.sheet-open {
  overflow: hidden;
}