:root {
  color-scheme: dark;
  --ink: #f5fbff;
  --muted: #a9bac8;
  --line: rgba(225, 245, 255, 0.18);
  --paper: #071016;
  --panel: rgba(14, 28, 38, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.18);
  --glass-soft: rgba(255, 255, 255, 0.08);
  --green: #49f0b6;
  --green-dark: #19ba8a;
  --blue: #7cf7d1;
  --yellow: #ffd166;
  --red: #ff6d78;
  --pink: #ff8fcf;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --glow-x: 50%;
  --glow-y: 12%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at var(--glow-x) var(--glow-y), rgba(73, 240, 182, 0.22), transparent 28rem),
    linear-gradient(125deg, rgba(72, 220, 170, 0.18), transparent 34%),
    linear-gradient(310deg, rgba(255, 209, 102, 0.12), transparent 38%),
    #071016;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
}

body::before {
  z-index: -2;
  background:
    conic-gradient(from 180deg at 50% 50%, rgba(73, 240, 182, 0.22), rgba(72, 220, 170, 0.18), rgba(255, 143, 207, 0.1), rgba(255, 209, 102, 0.1), rgba(73, 240, 182, 0.22)),
    linear-gradient(180deg, rgba(7, 16, 22, 0.15), #071016 78%);
  filter: blur(42px) saturate(1.35);
  opacity: 0.74;
  transform: scale(1.18);
  animation: liquidDrift 22s ease-in-out infinite alternate;
}

body::after {
  z-index: -1;
  background:
    linear-gradient(rgba(255, 255, 255, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.032) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 80%);
  opacity: 0.42;
}

@keyframes liquidDrift {
  0% {
    transform: scale(1.18) rotate(-7deg) translate3d(-2%, -1%, 0);
  }

  100% {
    transform: scale(1.24) rotate(8deg) translate3d(2%, 2%, 0);
  }
}

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

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 calc(84px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 32px);
  background: rgba(7, 16, 22, 0.56);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(28px) saturate(1.45);
}

.top-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.account-filter {
  min-width: 148px;
}

.account-pill {
  display: inline-grid;
  min-width: 78px;
  place-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 850;
}

.account-pill.company {
  background: rgba(73, 240, 182, 0.16);
  color: var(--green);
}

.account-pill.personal {
  background: rgba(124, 247, 209, 0.13);
  color: var(--blue);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(73, 240, 182, 0.44);
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.05;
  text-wrap: balance;
}

h2 {
  margin-bottom: 4px;
  font-size: 1rem;
}

main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 28px) 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: viewIn 0.32s ease both;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.metric,
.panel {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.05)),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform:
    perspective(900px)
    rotateX(var(--tilt-x, 0deg))
    rotateY(var(--tilt-y, 0deg))
    translateY(var(--lift, 0));
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
  backdrop-filter: blur(24px) saturate(1.45);
}

.metric::before,
.panel::before,
.week::before,
.trip-metric::before,
.timeline-item::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at var(--spot-x, 50%) var(--spot-y, 0%), rgba(255, 255, 255, 0.34), transparent 26%),
    linear-gradient(135deg, rgba(73, 240, 182, 0.14), rgba(72, 220, 170, 0.05) 42%, rgba(255, 143, 207, 0.06));
  opacity: var(--spot-opacity, 0.4);
  transition: opacity 180ms ease;
  content: "";
}

.metric::after,
.panel::after {
  position: absolute;
  inset: 1px;
  z-index: -1;
  border-radius: 7px;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.24), transparent 24%, transparent 64%, rgba(255, 255, 255, 0.08)),
    linear-gradient(315deg, transparent 0 72%, rgba(73, 240, 182, 0.12));
  opacity: 0.58;
  content: "";
}

.metric:hover,
.panel:hover {
  --lift: -3px;
  --spot-opacity: 0.78;
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.42),
    0 0 32px rgba(73, 240, 182, 0.1);
}

.metric {
  min-height: 112px;
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1;
  text-shadow: 0 0 20px rgba(73, 240, 182, 0.2);
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.panel {
  margin-bottom: 14px;
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.quick-form,
.settings-grid,
.report-controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

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

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(5, 12, 18, 0.44);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  background: rgba(8, 20, 28, 0.78);
  box-shadow:
    0 0 0 3px rgba(73, 240, 182, 0.15),
    0 0 28px rgba(73, 240, 182, 0.1);
  transform: translateY(-1px);
}

input::placeholder {
  color: rgba(169, 186, 200, 0.72);
}

.primary,
.secondary,
.danger,
.file-button,
.icon-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 850;
  position: relative;
  overflow: hidden;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.primary::before,
.secondary::before,
.danger::before,
.file-button::before,
.icon-button::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.34), transparent);
  transform: translateX(-115%);
  transition: transform 420ms ease;
  content: "";
}

.primary:hover::before,
.secondary:hover::before,
.danger:hover::before,
.file-button:hover::before,
.icon-button:hover::before {
  transform: translateX(115%);
}

.primary:active,
.secondary:active,
.danger:active,
.file-button:active,
.icon-button:active,
.delete-row:active,
.bottom-nav button:active {
  transform: scale(0.97);
}

.primary {
  background:
    linear-gradient(135deg, rgba(73, 240, 182, 0.95), rgba(124, 247, 209, 0.86));
  color: #041015;
  box-shadow:
    0 14px 32px rgba(73, 240, 182, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.primary:hover {
  background:
    linear-gradient(135deg, rgba(111, 255, 204, 0.98), rgba(168, 255, 220, 0.92));
  box-shadow:
    0 18px 42px rgba(73, 240, 182, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.secondary,
.file-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.danger {
  border: 1px solid rgba(255, 109, 120, 0.24);
  background: rgba(255, 109, 120, 0.14);
  color: var(--red);
}

.icon-button {
  width: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font-size: 1.2rem;
}

.table-wrap {
  width: 100%;
  margin-top: 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: rgba(4, 12, 18, 0.2);
}

th,
td {
  border-bottom: 1px solid rgba(225, 245, 255, 0.1);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: rgba(11, 27, 38, 0.88);
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  backdrop-filter: blur(16px);
}

tbody tr {
  transition:
    background 140ms ease,
    transform 140ms ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.06);
}

td input,
td select {
  min-width: 120px;
  min-height: 38px;
  padding: 7px 9px;
}

.money {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.delete-row {
  min-width: 38px;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 109, 120, 0.14);
  color: var(--red);
  font-weight: 900;
  transition:
    transform 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.delete-row:hover {
  background: rgba(255, 109, 120, 0.22);
  box-shadow: 0 0 24px rgba(255, 109, 120, 0.15);
}

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

.week {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: grid;
  gap: 8px;
  min-height: 130px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(18px) saturate(1.35);
  transform:
    perspective(760px)
    rotateX(var(--tilt-x, 0deg))
    rotateY(var(--tilt-y, 0deg))
    translateY(var(--lift, 0));
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.week:hover {
  --lift: -2px;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
}

.week strong {
  font-size: 0.95rem;
}

.week span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

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

.savings-card {
  display: grid;
  gap: 10px;
  min-height: 190px;
}

.savings-card > span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.savings-card strong {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  line-height: 1;
}

.savings-card-lines {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.savings-card-lines div,
.allocation-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.055);
}

.savings-card-lines span,
.allocation-line span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

.allocation-stack {
  display: grid;
  gap: 9px;
}

.status-good {
  border-color: rgba(73, 240, 182, 0.34) !important;
  box-shadow:
    inset 4px 0 0 rgba(73, 240, 182, 0.72),
    0 0 26px rgba(73, 240, 182, 0.08);
}

.status-warn {
  border-color: rgba(255, 209, 102, 0.34) !important;
  box-shadow:
    inset 4px 0 0 rgba(255, 209, 102, 0.72),
    0 0 24px rgba(255, 209, 102, 0.08);
}

.status-danger {
  border-color: rgba(255, 109, 120, 0.34) !important;
  box-shadow:
    inset 4px 0 0 rgba(255, 109, 120, 0.72),
    0 0 24px rgba(255, 109, 120, 0.08);
}

.status-good strong,
.status-good b,
.status-good.report-line strong {
  color: var(--green);
}

.status-warn strong,
.status-warn b,
.status-warn.report-line strong {
  color: var(--yellow);
}

.status-danger strong,
.status-danger b,
.status-danger.report-line strong {
  color: var(--red);
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(7, 16, 22, 0.62);
  border-top: 1px solid var(--line);
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(28px) saturate(1.45);
}

.bottom-nav button {
  min-width: 0;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: clamp(0.68rem, 2vw, 0.82rem);
  font-weight: 850;
  transition:
    transform 160ms ease,
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.bottom-nav button.active {
  background:
    linear-gradient(135deg, rgba(73, 240, 182, 0.24), rgba(124, 247, 209, 0.16));
  color: var(--ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 26px rgba(73, 240, 182, 0.14);
}

.bottom-nav button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

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

.timeline-item {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(18px);
}

.timeline-item strong {
  display: block;
}

.timeline-item p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.trip-list {
  display: grid;
  gap: 14px;
}

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

.trip-metric {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(18px);
  transform:
    perspective(760px)
    rotateX(var(--tilt-x, 0deg))
    rotateY(var(--tilt-y, 0deg))
    translateY(var(--lift, 0));
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.trip-metric:hover {
  --lift: -2px;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
}

.trip-metric span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.trip-metric strong {
  display: block;
  margin-top: 7px;
}

.report-preview {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

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

.report-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid rgba(225, 245, 255, 0.12);
  padding: 9px 0;
  color: var(--muted);
}

.report-line strong {
  color: var(--ink);
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

textarea {
  min-height: 240px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.empty {
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

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

@media (max-width: 860px) {
  .summary-grid,
  .week-stack,
  .savings-grid,
  .trip-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-form,
  .settings-grid,
  .report-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-form .primary,
  .report-controls .primary,
  .report-controls .secondary {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
  }

  .top-actions {
    display: grid;
    min-width: 128px;
  }

  .summary-grid,
  .week-stack,
  .savings-grid,
  .trip-metrics,
  .quick-form,
  .settings-grid,
  .report-controls,
  .report-preview-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .panel-heading {
    display: grid;
  }

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

  table {
    min-width: 620px;
  }
}
