:root {
  color-scheme: dark;
  --bg: #050505;
  --surface: #101112;
  --surface-muted: #181a1b;
  --text: #f5f5f2;
  --muted: #a8aaa6;
  --line: #262a29;
  --line-strong: #3b413f;
  --primary: #00a885;
  --primary-strong: #00c79d;
  --primary-soft: #092b25;
  --accent: #ff8159;
  --accent-soft: #321a13;
  --blue: #85bdff;
  --blue-soft: #102235;
  --yellow: #ffd46b;
  --yellow-soft: #33270b;
  --danger: #ff6477;
  --danger-soft: #331018;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(0, 168, 133, 0.18), transparent 28%),
    radial-gradient(circle at 84% 8%, rgba(255, 129, 89, 0.12), transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
}

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

.ti {
  width: 1.1em;
  height: 1.1em;
  display: inline-grid;
  place-items: center;
  font-style: normal;
  font-weight: 800;
  line-height: 1;
}

.ti::before {
  content: "*";
}

.ti-receipt::before,
.ti-file-invoice::before,
.ti-receipt-off::before {
  content: "R";
}

.ti-layout-dashboard::before {
  content: "#";
}

.ti-alert-circle::before {
  content: "!";
}

.ti-circle-check::before,
.ti-check::before,
.ti-checkbox::before {
  content: "/";
}

.ti-send::before {
  content: ">";
}

.ti-mail::before {
  content: "@";
}

.ti-plus::before,
.ti-camera-plus::before {
  content: "+";
}

.ti-search::before {
  content: "?";
}

.ti-square-x::before,
.ti-x::before {
  content: "x";
}

.ti-pencil::before {
  content: "E";
}

.ti-trash::before {
  content: "D";
}

.ti-device-floppy::before {
  content: "S";
}

.icon {
  width: 1.1em;
  height: 1.1em;
  display: inline-block;
  flex: 0 0 auto;
  vertical-align: -0.16em;
}

.app-shell {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 100vh;
}

.paywall {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 20% 15%, rgba(0, 168, 133, 0.24), transparent 28%),
    radial-gradient(circle at 82% 20%, rgba(255, 129, 89, 0.16), transparent 28%),
    #020303;
}

.paywall-card {
  width: min(560px, 100%);
  padding: 26px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(16, 17, 18, 0.96), rgba(5, 5, 5, 0.96));
  box-shadow: var(--shadow);
}

.paywall-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  margin-bottom: 24px;
}

.paywall h1 {
  margin: 10px 0 12px;
  font-size: clamp(36px, 10vw, 62px);
  line-height: 0.95;
  letter-spacing: 0;
}

.paywall-copy {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.paywall-price {
  display: flex;
  align-items: end;
  gap: 12px;
  margin: 24px 0;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.paywall-price strong {
  font-size: 54px;
  line-height: 0.9;
}

.paywall-price span,
.paywall-note {
  color: var(--muted);
}

.paywall-actions {
  display: grid;
  gap: 10px;
}

.paywall-actions .btn {
  min-height: 52px;
  text-decoration: none;
  font-weight: 800;
}

.btn-ghost {
  background: transparent;
}

.unlock-form {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.unlock-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.unlock-row input {
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #050505;
  color: var(--text);
  padding: 9px 11px;
  text-transform: uppercase;
}

.unlock-message {
  min-height: 18px;
  color: var(--danger);
  font-size: 12px;
}

.paywall-note {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: #050606;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: inline-grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 24px;
}

.brand h1,
.topbar h2,
.panel-heading h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.15;
}

.brand p,
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.nav-tabs {
  display: grid;
  gap: 6px;
}

.nav-tab {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-tab:hover,
.nav-tab.is-active {
  background: rgba(0, 168, 133, 0.12);
  color: var(--text);
}

.nav-tab.is-active {
  border-color: rgba(0, 168, 133, 0.32);
}

.nav-tab .ti {
  font-size: 20px;
}

.sidebar-card,
.install-card {
  margin-top: auto;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  gap: 8px;
}

.install-card {
  margin-top: 0;
}

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

.sidebar-card strong,
.install-card strong {
  font-size: 28px;
}

.install-card strong {
  font-size: 18px;
}

.sidebar-card span:last-of-type,
.install-card span:last-of-type {
  color: rgba(248, 251, 247, 0.72);
  font-size: 13px;
}

.workspace {
  padding: 28px;
  min-width: 0;
}

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

.topbar h2 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.02;
}

.btn,
.icon-btn {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn:hover,
.icon-btn:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--primary-strong);
}

.btn-danger {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-block {
  width: 100%;
  margin-top: 8px;
}

.icon-btn {
  width: 40px;
  padding: 0;
}

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

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 108px;
  box-shadow: 0 8px 24px rgba(31, 47, 38, 0.05);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
  letter-spacing: 0;
}

.metric small {
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 160px;
  gap: 10px;
  margin-bottom: 18px;
}

.offline-install-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid rgba(0, 168, 133, 0.38);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(0, 168, 133, 0.16), rgba(255, 129, 89, 0.08));
  box-shadow: var(--shadow);
}

.offline-install-banner h3,
.offline-install-banner p {
  margin: 0;
}

.offline-install-banner h3 {
  margin-top: 4px;
  font-size: 18px;
}

.offline-install-banner p:not(.eyebrow) {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.4;
}

.search {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 12px;
}

.search input,
.toolbar select,
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  min-height: 42px;
  padding: 9px 11px;
}

.search input {
  border: 0;
  min-height: 40px;
  padding: 0;
  outline: 0;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.receipt-panel,
.detail-panel {
  background: rgba(16, 17, 18, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-heading {
  min-height: 72px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h3 {
  font-size: 18px;
}

.receipt-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.receipt-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.receipt-item.is-expanded {
  border-color: var(--primary);
  box-shadow: 0 12px 30px rgba(0, 107, 91, 0.1);
}

.receipt-row {
  display: grid;
  grid-template-columns: 34px 52px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
  width: 100%;
}

.receipt-row:hover,
.receipt-row.is-focused {
  outline: 0;
  background: var(--surface-muted);
}

.receipt-row.is-selected {
  background: var(--primary-soft);
}

.check {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  color: transparent;
}

.receipt-row.is-selected .check {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.thumb {
  width: 52px;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-muted);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 24px;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.receipt-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.receipt-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.receipt-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.amount {
  text-align: right;
  font-size: 18px;
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-needs-review {
  color: var(--yellow);
  background: var(--yellow-soft);
}

.status-ready {
  color: var(--primary);
  background: var(--primary-soft);
}

.status-sent {
  color: var(--blue);
  background: var(--blue-soft);
}

.cat-meals {
  color: #814316;
  background: var(--accent-soft);
}

.cat-travel {
  color: var(--blue);
  background: var(--blue-soft);
}

.cat-office {
  color: var(--primary);
  background: var(--primary-soft);
}

.cat-software {
  color: #513c88;
  background: #ede7fa;
}

.receipt-expanded {
  border-top: 1px solid var(--line);
  padding: 12px;
  background: #0c0d0e;
}

.expanded-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.expanded-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
}

.expanded-photos img {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  object-fit: cover;
  background: var(--surface-muted);
}

.no-photo {
  min-height: 108px;
  display: grid;
  place-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.no-photo .icon,
.no-photo .ti {
  font-size: 28px;
  color: var(--primary);
}

.expanded-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.detail-panel {
  position: sticky;
  top: 28px;
  padding: 18px;
}

.detail-empty {
  min-height: 340px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.detail-empty .ti {
  display: block;
  margin-bottom: 12px;
  font-size: 40px;
}

.detail-panel h3 {
  margin: 0 0 6px;
  font-size: 22px;
}

.detail-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.detail-line strong {
  color: var(--text);
  text-align: right;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.image-strip {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  overflow-x: auto;
}

.image-strip img {
  width: 78px;
  height: 78px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.empty-state {
  min-height: 280px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 32px;
}

.empty-state i {
  font-size: 42px;
  display: block;
  margin-bottom: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 25, 20, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 20;
}

.modal {
  width: min(720px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal-header h3 {
  margin: 0;
}

.modal-body {
  padding: 18px;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field-full {
  grid-column: 1 / -1;
}

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

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.drop-zone {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 138px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

.photo-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
}

.drop-zone.is-dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.drop-zone i {
  font-size: 32px;
  color: var(--primary);
}

.preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-card {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-muted);
}

.preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-scan-line {
  position: absolute;
  inset-inline: 0;
  top: -30%;
  height: 34%;
  background: linear-gradient(180deg, transparent, rgba(0, 107, 91, 0.24), transparent);
  opacity: 0;
}

.preview-card.is-scanning .preview-scan-line {
  opacity: 1;
  animation: scanSweep 1.1s ease-in-out infinite;
}

.scan-panel {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--text);
}

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

.scan-panel strong,
.scan-panel span {
  display: block;
}

.scan-panel span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.scan-visual {
  position: relative;
  height: 72px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  color: var(--primary);
  font-size: 30px;
}

.scan-beam {
  position: absolute;
  inset-inline: 0;
  height: 18px;
  background: linear-gradient(180deg, transparent, rgba(0, 107, 91, 0.28), transparent);
  animation: scanBeam 1.15s ease-in-out infinite;
}

.scan-meter {
  height: 7px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 107, 91, 0.16);
}

.scan-meter span {
  width: 0;
  height: 100%;
  margin: 0;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.25s ease;
}

.field input.is-autofilled,
.field select.is-autofilled,
.field textarea.is-autofilled {
  animation: autofillPulse 1.25s ease;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  z-index: 30;
}

.toast {
  min-width: 220px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #0a0b0b;
  color: var(--text);
  box-shadow: var(--shadow);
}

@keyframes scanBeam {
  0% {
    transform: translateY(-40px);
  }
  50% {
    transform: translateY(40px);
  }
  100% {
    transform: translateY(-40px);
  }
}

@keyframes scanSweep {
  0% {
    transform: translateY(-30%);
  }
  50% {
    transform: translateY(260%);
  }
  100% {
    transform: translateY(-30%);
  }
}

@keyframes autofillPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 107, 91, 0.28);
    border-color: var(--primary);
    background: var(--surface);
  }
  55% {
    box-shadow: 0 0 0 5px rgba(0, 107, 91, 0.14);
    background: var(--primary-soft);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 107, 91, 0);
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-tab {
    justify-content: center;
  }

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

  .detail-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  body {
    background: var(--bg);
  }

  .workspace,
  .sidebar {
    padding: 14px;
  }

  .sidebar {
    gap: 16px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

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

  .offline-install-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-tabs {
    grid-template-columns: 1fr 1fr;
  }

  .receipt-row {
    grid-template-columns: 30px 46px minmax(0, 1fr);
    gap: 10px;
    padding: 11px;
  }

  .receipt-row .amount {
    grid-column: 2 / -1;
    text-align: left;
  }

  .receipt-meta {
    white-space: normal;
  }

  .receipt-expanded {
    padding: 11px;
  }

  .expanded-photos {
    grid-template-columns: 1fr;
  }

  .expanded-photos img {
    aspect-ratio: 3 / 4;
    max-height: 520px;
  }

  .expanded-actions,
  .detail-actions {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    display: none;
  }

  .modal-backdrop {
    align-items: stretch;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .drop-zone {
    min-height: 170px;
  }

  .photo-actions,
  .photo-actions .btn {
    width: 100%;
  }
}
