:root {
  color-scheme: dark;
  --base: #0c0f14;
  --sunken: #090b10;
  --surface: #12161d;
  --surface-2: #171c25;
  --surface-3: #1d242f;
  --text: #e9eef5;
  --text-secondary: #9eabbd;
  --accent: #4f9cf5;
  --teal: #2dd4bf;
  --cyan: #38bdf8;
  --border: #222a35;
  --border-strong: #334155;
  --border-focus: var(--cyan);
  --danger: #f87171;
  --amber: #fbbf24;
  --orange: #fb923c;
  --violet: #a78bfa;
  --emerald: #34d399;
  --slate: #94a3b8;
  --bg-base: var(--base);
  --bg-sunken: var(--sunken);
  --accent-ring: rgba(56, 189, 248, 0.18);
  --font-sans: var(--sans);
  --r-sm: 8px;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
  --mono:
    "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  --sans:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--base);
  color: var(--text);
  font-family: var(--sans);
}

a {
  color: inherit;
}

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

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.mono,
.amount,
time {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--border);
  background: var(--sunken);
}

.brand {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
}

.brand-mark {
  width: 12px;
  height: 30px;
  display: inline-block;
  border: 1px solid rgba(56, 189, 248, 0.8);
  background: #123046;
  box-shadow: inset 0 -11px 0 rgba(45, 212, 191, 0.45);
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.nav-list a {
  min-height: 44px;
  display: flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text-secondary);
  text-decoration: none;
}

.nav-list a:hover,
.nav-list a:focus-visible {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.app-main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 15, 20, 0.92);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  min-height: 66px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
}

.topbar-spacer {
  flex: 1;
}

.brand-mobile {
  display: none;
}

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

.user-chip {
  max-width: 34vw;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page {
  width: min(1180px, calc(100% - 56px));
  margin-inline: auto;
  padding-block: 34px 64px;
}

.page-heading {
  max-width: 760px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.page-heading h1,
.auth-panel h1 {
  margin: 0;
  color: var(--text);
  font-family: var(--serif);
  font-size: 3rem;
  line-height: 1.04;
  letter-spacing: 0;
}

.page-heading p,
.auth-panel p,
.card p {
  color: var(--text-secondary);
  line-height: 1.6;
}

.card,
.stat-card,
.auth-panel,
.transaction-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card {
  padding: 20px;
}

.stack {
  display: grid;
  gap: 14px;
}

.dashboard-layout,
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: start;
}

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

.stat-card {
  min-height: 136px;
  display: grid;
  align-content: space-between;
  gap: 16px;
  padding: 18px;
  border-top-color: var(--accent);
}

.stat-card:nth-child(2) {
  border-top-color: var(--teal);
}

.stat-card:nth-child(3) {
  border-top-color: var(--amber);
}

.stat-card:nth-child(4) {
  border-top-color: var(--emerald);
}

.metric-label,
.metric-note {
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.stat-card strong {
  font-size: 2.25rem;
  line-height: 1;
}

.action-row,
.form-actions,
.transaction-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.action-row {
  margin-top: 18px;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.button-primary {
  border-color: rgba(79, 156, 245, 0.9);
  background: #18558d;
  color: white;
}

.button-secondary {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.button-danger {
  border-color: rgba(248, 113, 113, 0.62);
  background: rgba(127, 29, 29, 0.55);
  color: #fecaca;
}

.button-subtle {
  border-color: var(--border);
  background: transparent;
  color: var(--text-secondary);
}

.button:hover {
  filter: brightness(1.12);
}

.button-full {
  width: 100%;
}

.message-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.message {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface-2);
  color: var(--text);
}

.message-error,
.message-danger {
  border-color: rgba(248, 113, 113, 0.65);
  color: #fecaca;
}

.message-success {
  border-color: rgba(52, 211, 153, 0.55);
  color: #bbf7d0;
}

.form-grid,
.filters-grid {
  display: grid;
  gap: 16px;
}

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

.filters-grid .field input,
.filters-grid .field select {
  height: 38px;
  min-height: 38px;
  padding: 0 12px;
}

.form-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

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

.field label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--sunken);
  color: var(--text);
  padding: 10px 12px;
}

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

input[type="date"] {
  color-scheme: dark;
  height: 38px;
  padding: 0 12px;
  background: var(--bg-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13.5px;
}

input[type="date"]:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-ring);
  background: var(--bg-base);
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
  cursor: pointer;
}

.field .errorlist {
  margin: 0;
  padding-left: 18px;
  color: #fecaca;
}

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

.section-title h2,
.card h2 {
  margin: 0;
  font-size: 1.05rem;
}

.section-title p {
  margin: 4px 0 0;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--text-secondary);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.data-table tr:hover td {
  background: rgba(79, 156, 245, 0.04);
}

.amount {
  text-align: right;
  white-space: nowrap;
}

.badge {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge-emerald,
.badge-status-tax_ready,
.badge-status-likely_deductible {
  border-color: rgba(52, 211, 153, 0.52);
  background: rgba(6, 78, 59, 0.42);
  color: #a7f3d0;
}

.badge-blue,
.badge-status-reviewed,
.badge-status-inventory_cogs {
  border-color: rgba(79, 156, 245, 0.55);
  background: rgba(30, 64, 175, 0.32);
  color: #bfdbfe;
}

.badge-cyan,
.badge-status-ask_accountant,
.badge-status-needs_accountant_review {
  border-color: rgba(56, 189, 248, 0.58);
  background: rgba(14, 116, 144, 0.28);
  color: #bae6fd;
}

.badge-violet,
.badge-status-missing_business_purpose,
.badge-status-capital_asset_review {
  border-color: rgba(167, 139, 250, 0.55);
  background: rgba(76, 29, 149, 0.32);
  color: #ddd6fe;
}

.badge-amber,
.badge-status-needs_review,
.badge-status-missing_documentation {
  border-color: rgba(251, 191, 36, 0.58);
  background: rgba(120, 53, 15, 0.32);
  color: #fde68a;
}

.badge-orange,
.badge-status-missing_receipt {
  border-color: rgba(251, 146, 60, 0.58);
  background: rgba(124, 45, 18, 0.32);
  color: #fed7aa;
}

.badge-slate,
.badge-status-personal_excluded,
.badge-status-probably_personal {
  border-color: rgba(148, 163, 184, 0.5);
  background: rgba(51, 65, 85, 0.38);
  color: #cbd5e1;
}

.status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  overflow: visible;
  margin-bottom: 16px;
}

.status-tabs a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
}

.status-tabs a.active,
.status-tabs a:hover {
  border-color: var(--accent);
  color: var(--text);
}

.mobile-card-list {
  display: none;
}

.transaction-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.transaction-card > div:first-child {
  display: grid;
  gap: 4px;
}

.blocker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-shell {
  min-height: calc(100vh - 140px);
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(100%, 420px);
  padding: 24px;
}

.auth-panel h1 {
  font-size: 2rem;
}

.auth-panel p {
  margin: 12px 0 24px;
}

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

  .sidebar {
    display: none;
  }

  .brand-mobile {
    display: inline-flex;
  }

  .metric-grid,
  .dashboard-layout,
  .detail-layout,
  .filters-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    min-height: 62px;
    padding: 0 14px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .user-chip {
    display: none;
  }

  .page {
    width: min(100% - 24px, 1180px);
    padding-block: 24px 44px;
  }

  .page-heading h1 {
    font-size: 2.2rem;
  }

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

  .desktop-table {
    display: none;
  }

  .mobile-card-list {
    display: grid;
    gap: 12px;
  }

  .section-title {
    display: grid;
  }
}
