:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-gradient: linear-gradient(170deg, #dbeafe 0%, #f3f7ff 58%, #e7edf7 100%);
  --surface: #ffffff;
  --surface-strong: #eff6ff;
  --ink: #172033;
  --muted: #607089;
  --line: #dbe6f3;
  --line-strong: #b9cdea;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eaf2ff;
  --coral: #d85a44;
  --amber: #b8781f;
  --indigo: #3f63a8;
  --warning-yellow-rgb: 214, 164, 43;
  --danger-red-rgb: 205, 61, 61;
  --shadow: 0 18px 48px rgba(23, 32, 51, 0.08);
  --shadow-soft: 0 10px 28px rgba(23, 32, 51, 0.07);
  --page-width: 1180px;
  --page-gutter: 32px;
  --card-radius: 14px;
  --control-radius: 999px;
  --control-radius-compact: 12px;
  --border-color: rgba(219, 230, 243, 0.82);
  --border-color-strong: rgba(185, 205, 234, 0.78);
  --card-padding: 18px;
  --panel-padding: 22px;
  --upload-panel-inline-padding: 20px;
  --row-padding: 14px 16px;
  --control-height: 44px;
  --control-height-small: 42px;
  --font-small: 0.85rem;
  --font-base: 1rem;
  --font-heading: 1.35rem;
  --font-display: clamp(2rem, 4vw, 4rem);
  --text-main: var(--ink);
  --text-muted: var(--muted);
  --text-accent: var(--blue-dark);
  --text-inverse: #ffffff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  position: relative;
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 100dvh;
  min-width: 320px;
  color: var(--text-main);
  background: #ffffff;
  font-family:
    Manrope, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at -120px 80px, rgba(63, 99, 168, 0.14), transparent 300px),
    radial-gradient(circle at calc(100% + 120px) 120px, rgba(216, 90, 68, 0.11), transparent 320px),
    var(--bg-gradient);
}

body > * {
  position: relative;
  z-index: 1;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

code {
  padding: 2px 6px;
  border-radius: 5px;
  background: #ffffff;
  color: var(--text-main);
  font-size: var(--font-small);
}

.ui-card {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  background: #ffffff;
  box-shadow: none;
}

.ui-card--metric {
  min-height: 138px;
  padding: 20px;
  text-align: left;
}

.ui-panel {
  padding: var(--panel-padding);
}

.ui-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: var(--row-padding);
}

.ui-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-height);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  font-weight: 500;
  white-space: nowrap;
}

.ui-button--primary {
  background: var(--blue);
  color: var(--text-inverse);
}

.ui-button--secondary {
  border-color: rgba(219, 230, 243, 0.9);
  background: #ffffff;
  color: var(--text-muted);
}

.ui-icon-button {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(29, 78, 216, 0.18);
  border-radius: 50%;
  background: #ffffff;
  color: var(--text-accent);
  font-size: var(--font-small);
  font-weight: 600;
  line-height: 1;
}

.ui-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: max-content;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--control-radius-compact);
  background: transparent;
  font-weight: 500;
  white-space: nowrap;
}

.ui-field {
  width: 100%;
  min-height: var(--control-height-small);
  padding: 0 12px;
  border: 1px solid var(--border-color-strong);
  border-radius: var(--control-radius-compact);
  background: #ffffff;
  color: var(--text-main);
}

.ui-field:focus {
  outline: 3px solid rgba(37, 99, 235, 0.16);
  border-color: var(--blue);
}

.ui-empty-state {
  width: 100%;
  padding: var(--card-padding);
  border: 1px dashed rgba(185, 205, 234, 0.95);
  border-radius: var(--card-radius);
  background: #ffffff;
  color: var(--text-muted);
}

.ui-list {
  display: grid;
  gap: 10px;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg-gradient);
}

.auth-card {
  display: grid;
  gap: 18px;
  width: min(460px, 100%);
  padding: 28px;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: var(--font-heading);
  line-height: 1.1;
}

.auth-card p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(219, 230, 243, 0.9);
  border-radius: var(--control-radius-compact);
  background: var(--blue-soft);
}

.auth-tab {
  min-height: var(--control-height-small);
  border-radius: 10px;
  background: transparent;
  color: var(--text-main);
}

.auth-tab.is-active {
  background: #ffffff;
  color: var(--text-accent);
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-form label {
  color: var(--text-muted);
  font-weight: 600;
}

.auth-button {
  margin-top: 6px;
  min-height: var(--control-height-small);
  padding: 0 16px;
}

.auth-button--light {
  margin-top: 0;
  white-space: nowrap;
}

.auth-message {
  font-size: var(--font-small);
}

.auth-message {
  min-height: 20px;
  color: var(--text-muted);
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(var(--page-width), 100%);
  margin: 0 auto;
  padding: 22px 20px 14px;
  background: #ffffff;
}

.topbar h1 {
  margin: 0;
  font-size: var(--font-display);
  line-height: 0.95;
  letter-spacing: 0;
}

.brand-title {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
}

.demo-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: -2px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text-accent);
  font-size: var(--font-small);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow:
    0 0 0 1px rgba(37, 99, 235, 0.16),
    0 6px 16px rgba(23, 32, 51, 0.05);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--text-accent);
  font-size: var(--font-small);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar__status {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(185, 205, 234, 0.78);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text-muted);
  box-shadow: 0 8px 22px rgba(23, 32, 51, 0.05);
  white-space: nowrap;
}

.session-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(var(--page-width), calc(100% - var(--page-gutter)));
  margin: 0 auto 4px;
  padding: 0;
  color: var(--text-muted);
  font-size: var(--font-small);
  line-height: 1.2;
}

.session-footer strong {
  color: var(--text-main);
}

.sign-out-button {
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--coral);
}

.sign-out-button:focus-visible {
  outline: 2px solid rgba(216, 90, 68, 0.28);
  outline-offset: 3px;
}

.layout {
  position: relative;
  z-index: 2;
  flex: 1 0 auto;
  width: min(var(--page-width), calc(100% - var(--page-gutter)));
  margin: 0 auto 18px;
}

.upload-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 28px;
  row-gap: 16px;
  align-items: center;
  padding: 2px var(--upload-panel-inline-padding) 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.upload-panel h2,
.insight-band h2,
.section-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.upload-panel h2 {
  max-width: 780px;
  font-size: var(--font-display);
  line-height: 1;
}

.upload-actions {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  justify-content: center;
  justify-items: center;
  justify-self: center;
  width: min(420px, 100%);
  align-items: center;
  min-width: 0;
}

.receipt-upload-control {
  position: relative;
  display: inline-flex;
  width: 100%;
  min-width: 0;
}

.receipt-upload-control .ui-button {
  width: 100%;
  min-width: 0;
}

.manual-receipt-button {
  justify-self: center;
  width: 100%;
  min-width: 0;
  padding-inline: 12px;
}

#receiptFile,
#receiptPhotoFile,
#bankStatementFile {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.primary-button {
  position: relative;
  z-index: 1;
  width: fit-content;
  padding: 0 22px;
  transform: translateZ(0);
}

.receipt-upload-control--wide {
  grid-column: 1 / -1;
  justify-self: center;
}

.upload-helper {
  grid-column: 1 / -1;
  justify-self: stretch;
  width: 100%;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: var(--font-small);
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
}

.primary-button.is-disabled,
.secondary-button.is-disabled {
  opacity: 0.58;
  cursor: wait;
  pointer-events: none;
}

.primary-button--small {
  min-height: var(--control-height-small);
  padding: 0 14px;
}

.secondary-button--small {
  min-height: var(--control-height-small);
  padding: 0 14px;
}

.secondary-button {
  padding: 0 18px;
}

.info-button {
  position: absolute;
  top: -7px;
  right: -7px;
  z-index: 2;
  width: 22px;
  height: 22px;
}

.info-button:focus-visible {
  border-color: var(--blue-dark);
  outline: none;
}

.info-tooltip {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: min(320px, calc(100vw - 32px));
  padding: 10px 12px;
  border: 1px solid rgba(219, 230, 243, 0.9);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--font-small);
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
}

.receipt-upload-control:focus-within + .info-tooltip {
  opacity: 1;
  pointer-events: auto;
}

.text-button {
  min-height: var(--control-height);
  padding: 0 12px;
  background: transparent;
  color: var(--text-accent);
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 500;
}

.hint {
  grid-column: 1 / -1;
  margin-top: -10px;
  font-size: var(--font-small);
}

.upload-result {
  grid-column: 1 / -1;
  display: grid;
  gap: 4px;
  width: calc(100% + (var(--upload-panel-inline-padding) * 2));
  margin: 0 calc(-1 * var(--upload-panel-inline-padding));
  padding: 12px 14px;
  border-color: rgba(219, 230, 243, 0.88);
  border-radius: var(--control-radius-compact);
}

.upload-result strong,
.upload-result span {
  display: block;
}

.upload-result span {
  color: var(--text-muted);
  line-height: 1.45;
}

.upload-result--success {
  border-color: rgba(37, 99, 235, 0.35);
  background: #ffffff;
}

.upload-result--warning {
  border-color: rgba(var(--warning-yellow-rgb), 0.68);
  background: #ffffff;
}

.upload-result--danger {
  border-color: rgba(var(--danger-red-rgb), 0.56);
  background: #ffffff;
}

.analysis-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  max-width: 100%;
  margin-top: 12px;
  padding: 12px 14px;
  backdrop-filter: blur(14px);
}

.analysis-toast strong,
.analysis-toast span span {
  display: block;
}

.analysis-toast span span {
  color: var(--text-muted);
}

.loading-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(37, 99, 235, 0.18);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
  flex: 0 0 auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.window-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-top: 0;
  overflow-x: auto;
  padding: 6px 18px;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
  scroll-padding-inline: 18px;
}

.window-nav::-webkit-scrollbar {
  display: none;
}

.window-tab {
  flex: 1 0 0;
  gap: 7px;
  color: var(--text-main);
}

.window-tab span {
  font-size: var(--font-base);
  line-height: 1;
}

.window-tab.is-active {
  border-color: rgba(37, 99, 235, 0.18);
  background: #ffffff;
  color: var(--text-accent);
}

.window-tab.is-active {
  color: var(--text-main);
}

.window-tab--custom,
.window-tab--custom.is-active {
  color: var(--text-accent);
}

.app-window {
  margin-top: 0;
}

.initial-state {
  margin-top: 8px;
}

.initial-state h2 {
  margin: 0;
  font-size: var(--font-heading);
  line-height: 1.2;
}

.initial-state p:last-child {
  max-width: 620px;
  margin: 10px 0 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
  margin-top: 18px;
}

.window-period-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0 12px;
}

.panel,
.insight-band {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.period-card {
  width: 100%;
}

.metric-card--button {
  display: grid;
  align-content: start;
  justify-items: stretch;
  width: 100%;
}

.metric-card--button:focus-visible {
  border-color: rgba(29, 78, 216, 0.62);
  outline: 3px solid rgba(37, 99, 235, 0.18);
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--text-muted);
}

.metric-card .metric-card__topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 24px;
  width: 100%;
}

#savingMetricLabel {
  min-width: 0;
  overflow-wrap: anywhere;
}

.metric-card__arrow {
  position: relative;
  display: inline-flex;
  flex: 0 0 24px;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  line-height: 1;
}

.metric-card__arrow::before {
  content: "";
  position: absolute;
  transition: transform 160ms ease;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transform-origin: center;
}

.metric-card--button[aria-expanded="true"] .metric-card__arrow::before {
  transform: rotate(225deg);
}

.metric-card strong {
  display: block;
  margin: 12px 0 8px;
  font-size: var(--font-heading);
  line-height: 1;
  letter-spacing: 0;
}

.period-picker {
  position: relative;
  z-index: 3;
  display: inline-flex;
  margin-top: 10px;
}

.period-picker__button {
  min-height: 38px;
  padding: 0 12px;
  border-color: var(--border-color-strong);
  border-radius: var(--control-radius-compact);
  color: var(--text-accent);
}

.period-picker__button:focus-visible {
  border-color: rgba(37, 99, 235, 0.38);
  outline: none;
}

.period-picker__button span:first-child {
  font-size: var(--font-base);
  line-height: 1;
}

.period-picker__popover {
  position: absolute;
  z-index: 55;
  top: calc(100% + 8px);
  left: 0;
  width: 280px;
  padding: 12px;
  border: 1px solid rgba(219, 230, 243, 0.9);
  border-radius: var(--card-radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.period-picker__popover p {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: var(--font-small);
  line-height: 1.35;
}

.calendar {
  display: grid;
  gap: 10px;
}

.calendar__top {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: center;
}

.calendar__top strong {
  text-align: center;
}

.calendar__nav,
.calendar__day {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  font-weight: 500;
}

.calendar__nav {
  min-height: 34px;
  border-radius: 10px;
  color: var(--text-accent);
}

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

.calendar__weekdays span {
  color: var(--text-muted);
  font-size: var(--font-small);
  text-align: center;
}

.calendar__day {
  min-width: 0;
  min-height: 34px;
  border-radius: 10px;
}

.calendar__nav:focus-visible,
.calendar__day:focus-visible {
  border-color: rgba(37, 99, 235, 0.28);
  background: var(--blue-soft);
  outline: none;
}

.calendar__day.is-muted {
  color: var(--text-muted);
}

.calendar__day.is-today {
  border-color: rgba(37, 99, 235, 0.38);
}

.calendar__day.is-in-range {
  background: var(--blue-soft);
  color: var(--text-accent);
}

.calendar__day.is-selected {
  background: var(--blue);
  color: var(--text-inverse);
}

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

.metric-card--accent {
  border-color: rgba(29, 78, 216, 0.24);
  background: var(--blue);
  color: var(--text-inverse);
}

.metric-card--accent span,
.metric-card--accent small {
  color: var(--text-inverse);
}

.saving-report {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.36);
}

.saving-report__heading {
  color: var(--text-inverse);
  font-size: var(--font-small);
  font-weight: 600;
  text-transform: uppercase;
}

.saving-report__title {
  color: var(--text-inverse);
  font-weight: 600;
  line-height: 1.25;
}

.saving-report__note {
  margin: 0;
  color: var(--text-inverse);
  line-height: 1.5;
}

.saving-report__list {
  display: grid;
  gap: 10px;
}

.saving-report__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.24);
}

.saving-report__row:first-child {
  border-top: 0;
}

.saving-report__name {
  color: var(--text-inverse);
  font-weight: 600;
}

.saving-report__copy {
  margin: 6px 0 0;
  color: var(--text-inverse);
  line-height: 1.45;
}

.saving-report__row strong {
  color: var(--text-inverse);
  white-space: nowrap;
}

.insight-band {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 28px;
  align-items: center;
  margin-top: 18px;
  padding: 24px;
  background: transparent;
  border-color: transparent;
}

.insight-band h2 {
  font-size: var(--font-heading);
  line-height: 1.05;
}

.insight-band p:last-child {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--font-base);
  line-height: 1.55;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
}

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

.section-heading h2 {
  font-size: var(--font-heading);
  line-height: 1.2;
}

.section-heading--compact {
  margin-bottom: 14px;
}

.section-heading--controls {
  justify-content: flex-end;
  margin-bottom: 12px;
}

.section-heading--controls:has([hidden]) {
  margin-bottom: 0;
}

.waster-list,
.side-stack {
  display: grid;
  gap: 12px;
}

.panel .waster-list,
.panel .category-table,
.panel .savings-grid,
.panel .recommendation-list,
.panel .receipt-list {
  width: calc(100% + (var(--panel-padding) * 2));
  margin-inline: calc(-1 * var(--panel-padding));
}

.waster-list > .ui-empty-state,
.category-table > .ui-empty-state,
.savings-grid > .ui-empty-state,
.receipt-list > .ui-empty-state {
  grid-column: 1 / -1;
}

.waster-card {
  position: relative;
  padding: 18px 42px 18px 18px;
}

.waster-card__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}

.waster-card h3 {
  margin: 0;
  font-size: var(--font-base);
}

.waster-card p {
  margin: 6px 0 0;
  color: var(--text-muted);
  line-height: 1.45;
}

.waster-card strong {
  color: var(--text-accent);
  font-size: var(--font-base);
  white-space: nowrap;
}

.waster-card__remove {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-base);
  line-height: 1;
}

.waster-card__remove:focus-visible {
  outline: 2px solid rgba(216, 90, 68, 0.28);
  outline-offset: 2px;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 32, 51, 0.24);
}

.receipt-camera-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(23, 32, 51, 0.82);
}

.receipt-camera-dialog {
  display: grid;
  gap: 14px;
  width: min(720px, 100%);
  max-height: calc(100dvh - 32px);
  padding: 16px;
  overflow-y: auto;
}

.receipt-camera-message {
  margin: 0;
  color: var(--text-main);
  line-height: 1.4;
}

.receipt-camera-video {
  display: block;
  width: 100%;
  max-height: 65dvh;
  border-radius: var(--control-radius-compact);
  background: #111827;
  object-fit: contain;
}

.receipt-camera-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.manual-receipt-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(23, 32, 51, 0.58);
  overflow-y: auto;
}

.manual-receipt-dialog {
  width: min(720px, 100%);
  margin-top: 0;
  padding: 18px;
}

.manual-receipt-dialog h2 {
  margin: 0 0 14px;
  font-size: var(--font-heading);
  line-height: 1.2;
}

.manual-receipt-message {
  margin: -4px 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(var(--danger-red-rgb), 0.56);
  border-radius: var(--control-radius-compact);
  background: #ffffff;
  color: var(--text-muted);
  font-size: var(--font-small);
  line-height: 1.4;
}

.confirm-dialog {
  display: grid;
  gap: 12px;
  width: min(360px, 100%);
  padding: 18px;
  border-color: rgba(219, 230, 243, 0.9);
}

.confirm-dialog h3,
.confirm-dialog p {
  margin: 0;
}

.confirm-dialog p {
  color: var(--text-muted);
  line-height: 1.45;
}

.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.bar {
  height: 10px;
  margin: 14px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--blue-soft);
}

.bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--bar-start, var(--blue)), var(--bar-end, var(--amber)));
}

details {
  color: var(--text-muted);
}

summary {
  cursor: pointer;
  font-weight: 600;
}

details ul {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding-left: 18px;
}

details li {
  padding-right: 6px;
  color: var(--text-muted);
  line-height: 1.4;
}

.position-list {
  display: grid;
  margin-top: 12px;
}

.position-row {
  border-top: 1px solid var(--line);
  color: var(--text-main);
}

.position-row:first-child {
  border-top: 0;
}

.position-row > summary {
  list-style: none;
}

.position-row > summary::-webkit-details-marker {
  display: none;
}

.position-row__summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: var(--control-height);
  padding: 12px 0;
}

.position-row__summary strong {
  color: var(--text-accent);
  white-space: nowrap;
}

.position-row__title {
  min-width: 0;
  color: var(--text-main);
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

.position-row__summary small {
  color: var(--text-muted);
  white-space: nowrap;
}

.purchase-list {
  display: grid;
  padding-bottom: 12px;
}

.purchase-row {
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 8px 0 0;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  line-height: 1.35;
}

.purchase-row strong {
  color: var(--text-main);
  white-space: nowrap;
}

.empty-state--compact {
  padding: 12px;
}

.custom-form {
  display: grid;
  gap: 8px;
}

.panel.custom-category-panel {
  padding-inline: 0;
}

.custom-form label {
  color: var(--text-muted);
  font-weight: 600;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.custom-form .input-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.custom-add-button:disabled {
  border-color: rgba(185, 205, 234, 0.62);
  background: #fff;
  color: var(--text-muted);
  cursor: default;
  opacity: 1;
}

.custom-result {
  margin-top: 16px;
}

.custom-result > h3 {
  margin: 0 0 8px;
  font-size: var(--font-base);
}

.custom-result > p {
  margin: 0 0 10px;
  color: var(--text-muted);
  line-height: 1.45;
}

.custom-result__rationale {
  margin: 0 0 10px;
}

.categories-panel {
  margin-top: 18px;
}

.category-table--wide {
  gap: 12px;
}

.category-row.waster-card {
  padding-right: 18px;
}

.category-row details {
  margin-top: 10px;
}

.receipts-panel {
  margin-top: 0;
  padding-top: 6px;
}

.savings-panel {
  margin-top: 0;
}

.window-period-grid + .panel {
  margin-top: 0;
  padding-top: 0;
}

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

.savings-card {
  min-height: 130px;
  padding: 18px;
}

.savings-card span,
.savings-card small {
  display: block;
  color: var(--text-muted);
}

.savings-card strong {
  display: block;
  margin: 10px 0 8px;
  font-size: var(--font-heading);
  line-height: 1;
}

.savings-card--warning {
  border-color: rgba(216, 90, 68, 0.42);
  background: #ffffff;
}

.savings-alert {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--coral);
  color: var(--text-inverse);
  font-size: var(--font-heading);
  font-weight: 600;
}

.recommendation-list {
  gap: 10px;
  margin-top: 14px;
}

.recommendation-item {
  position: relative;
  padding: 12px 14px;
  padding-right: 48px;
  border-radius: var(--control-radius-compact);
  color: var(--text-muted);
  line-height: 1.45;
}

.source-info-link {
  position: absolute;
  top: 10px;
  right: 10px;
  text-decoration: none;
}

.source-info-link:focus-visible {
  border-color: var(--blue-dark);
  outline: none;
}

.receipt-list {
  position: relative;
  gap: 10px;
  max-height: min(900px, calc(100vh - 120px));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  contain: paint;
  --receipt-list-fade: 28px;
}

.receipt-list--scrollable {
  -webkit-mask-image: linear-gradient(
    to bottom,
    #000000 0,
    #000000 calc(100% - var(--receipt-list-fade)),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    #000000 0,
    #000000 calc(100% - var(--receipt-list-fade)),
    transparent 100%
  );
}

.receipt-list--scrolled-top.receipt-list--scrolled-bottom {
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000000 var(--receipt-list-fade),
    #000000 calc(100% - var(--receipt-list-fade)),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000000 var(--receipt-list-fade),
    #000000 calc(100% - var(--receipt-list-fade)),
    transparent 100%
  );
}

.receipt-list--scrolled-top:not(.receipt-list--scrolled-bottom) {
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000000 var(--receipt-list-fade),
    #000000 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000000 var(--receipt-list-fade),
    #000000 100%
  );
}

.receipt-card {
  position: relative;
  overflow: hidden;
}

.receipt-card--ocr-problem {
  border-color: rgba(var(--danger-red-rgb), 0.7);
}

.receipt-card--ocr-timestamp-problem {
  border-color: rgba(var(--warning-yellow-rgb), 0.68);
}

.receipt-card > summary {
  list-style: none;
}

.receipt-card > summary::-webkit-details-marker {
  display: none;
}

.receipt-card__summary {
  position: relative;
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) minmax(0, 1.25fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
}

.receipt-card--editable > summary {
  padding-right: 56px;
}

.receipt-card__summary time,
.receipt-card__meta {
  color: var(--text-muted);
}

.receipt-card__merchant {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.receipt-card__merchant strong {
  overflow-wrap: anywhere;
}

.receipt-card__total {
  color: var(--text-accent);
  font-size: var(--font-base);
  white-space: nowrap;
}

.receipt-card__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.receipt-edit-trigger {
  position: absolute;
  top: 14px;
  right: 12px;
  z-index: 2;
}

.receipt-edit-button {
  width: 32px;
  height: 32px;
  font: inherit;
  cursor: pointer;
}

.receipt-edit-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.receipt-edit-button:focus-visible {
  border-color: var(--blue-dark);
  outline: none;
}

.receipt-card__body {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
}

.receipt-image a {
  display: inline-flex;
  width: fit-content;
  text-decoration: none;
}

.receipt-item span {
  display: block;
  color: var(--text-muted);
  font-size: var(--font-small);
}

.receipt-items {
  display: grid;
  gap: 6px;
}

.receipt-item {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 8px 0 0;
  border-top: 1px solid var(--border-color);
}

.receipt-item b {
  overflow-wrap: anywhere;
}

.receipt-item strong {
  white-space: nowrap;
}

.receipt-edit {
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.receipt-edit__form {
  display: grid;
  gap: 10px;
}

.receipt-edit__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 0.35fr);
  gap: 10px;
}

.receipt-edit__item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 0.35fr);
  gap: 10px;
  align-items: end;
  padding-right: 28px;
}

.receipt-edit label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.receipt-edit label span {
  color: var(--text-muted);
  font-size: var(--font-small);
}

.receipt-price-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.receipt-price-field input {
  width: 100%;
}

.receipt-price-field > span {
  color: var(--text-muted);
  pointer-events: none;
}

.receipt-edit__timestamp {
  position: relative;
  display: grid;
  gap: 5px;
  min-width: 0;
}

.receipt-edit__timestamp > span:first-child {
  color: var(--text-muted);
  font-size: var(--font-small);
}

.receipt-edit__timestamp b {
  color: var(--coral);
  font-size: var(--font-small);
  font-weight: 600;
}

.receipt-datetime {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
}

.receipt-date-button {
  min-height: 40px;
  justify-content: flex-start;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--text-main);
}

.receipt-time-input {
  text-align: center;
}

.receipt-datetime__popover {
  position: static;
  z-index: auto;
  top: calc(100% + 6px);
  margin-top: 6px;
  width: min(280px, calc(100vw - 48px));
}

.receipt-edit input:not([type="hidden"]) {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(219, 230, 243, 0.9);
  border-radius: 10px;
  font: inherit;
}

.receipt-edit input[type="hidden"] {
  display: none;
}

.receipt-edit .receipt-edit__timestamp-input--warning {
  border-color: rgba(var(--warning-yellow-rgb), 0.78);
}

.receipt-edit .receipt-edit__field--ocr-problem {
  border-color: rgba(var(--danger-red-rgb), 0.78);
}

.receipt-edit__items {
  display: grid;
  gap: 8px;
}

.receipt-add-position {
  justify-self: center;
  width: fit-content;
}

.receipt-edit__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.receipt-edit__actions .primary-button,
.receipt-edit__actions .secondary-button {
  width: fit-content;
}

.receipt-delete-button {
  color: var(--coral);
}

.receipt-remove-position {
  position: absolute;
  top: 0;
  right: 0;
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: var(--coral);
  font-size: var(--font-base);
  cursor: pointer;
}

@media (max-width: 920px) {
  .topbar,
  .upload-panel,
  .insight-band {
    display: block;
  }

  .topbar__status {
    margin-top: 16px;
    width: fit-content;
  }

  .upload-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: center;
    min-width: 0;
    margin-top: 22px;
  }

  .upload-result {
    margin-top: 16px;
  }

  .summary-grid,
  .window-period-grid,
  .workspace,
  .savings-grid {
    grid-template-columns: 1fr;
  }

  .receipt-card__summary {
    display: block;
  }

  .receipt-card__total {
    margin-top: 0;
  }

  .receipt-card__actions {
    justify-content: space-between;
    width: 100%;
    margin-top: 12px;
  }

  .section-heading .period-picker {
    margin-top: 14px;
  }

  .receipt-card__merchant {
    margin-top: 10px;
  }

  .receipt-card--editable > summary {
    padding-right: 52px;
  }

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

  .receipt-remove-position {
    width: 24px;
  }

  .insight-band p:last-child {
    margin-top: 14px;
  }
}

@media (max-width: 560px) {
  :root {
    --panel-padding: 16px;
    --upload-panel-inline-padding: var(--panel-padding);
  }

  .layout {
    width: min(100% - 24px, 1180px);
  }

  .session-footer {
    width: min(100% - 24px, 1180px);
  }

  .upload-panel,
  .panel,
  .insight-band {
    padding: var(--panel-padding);
  }

  .input-row,
  .custom-form .input-row {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .custom-form .input-row input {
    grid-column: 1 / -1;
  }

  .custom-form .primary-button,
  .custom-form .secondary-button {
    width: 100%;
  }

  .secondary-button {
    width: 100%;
  }

  .receipt-edit__actions .secondary-button {
    width: fit-content;
  }

  .receipt-add-position {
    width: fit-content;
  }

  .receipt-list {
    max-height: calc(100vh - 96px);
  }

  .window-tab {
    flex: 0 0 auto;
  }

  .receipt-upload-control {
    width: 100%;
    min-width: 0;
  }

  .section-heading,
  .waster-card__top,
  .saving-report__row {
    display: block;
  }

  .waster-card strong,
  .saving-report__row strong {
    display: block;
    margin-top: 10px;
  }
}
