@import url("https://fonts.googleapis.com/css2?family=Fraunces:wght@300;500;700&family=Spline+Sans:wght@300;400;500;600&display=swap");

:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --card: #fffdf9;
  --ink: #1f1b17;
  --muted: #6f655d;
  --accent: #b6572f;
  --accent-dark: #7c3b1d;
  --border: #e2d8cd;
  --shadow: 0 20px 45px rgba(26, 20, 15, 0.12);
  --shadow-soft: 0 12px 30px rgba(36, 28, 21, 0.08);
  font-family: "Spline Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 244, 226, 0.7), transparent 55%),
    radial-gradient(circle at 90% 20%, rgba(237, 214, 190, 0.55), transparent 50%),
    linear-gradient(135deg, #f9f4ec 0%, #f4efe7 40%, #efe3d6 100%);
  color: var(--ink);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

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

body::before {
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.35), transparent 55%),
    radial-gradient(circle at 80% 70%, rgba(187, 110, 71, 0.08), transparent 60%);
}

body::after {
  background-image: url("data:image/svg+xml,%3Csvg width='120' height='120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.07'/%3E%3C/svg%3E");
  opacity: 0.4;
  mix-blend-mode: multiply;
}

.app-shell {
  display: flex;
  justify-content: center;
  padding: 32px 16px 64px;
  max-height: 100vh;
}

.device {
  --top-strip-height: 56px;
  width: min(430px, 100%);
  border-radius: 36px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(180, 160, 140, 0.4);
  box-shadow: 0 30px 60px rgba(28, 20, 14, 0.18);
  overflow: hidden;
  backdrop-filter: blur(14px);
  position: relative;
  display: flex;
  flex-direction: column;
  height: min(900px, 100vh - 64px);
}

.page {
  padding: calc(var(--top-strip-height) + 10px) 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
  position: relative;
  overflow-y: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  transition: box-shadow 0.2s ease;
}

.page::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.page.page--can-scroll-down {
  box-shadow: inset 0 -16px 16px -14px rgba(124, 59, 29, 0.2);
}

.page.page--can-scroll-up {
  box-shadow: inset 0 14px 14px -12px rgba(124, 59, 29, 0.22);
}

.page.page--can-scroll-up.page--can-scroll-down {
  box-shadow:
    inset 0 14px 14px -12px rgba(124, 59, 29, 0.22),
    inset 0 -16px 16px -14px rgba(124, 59, 29, 0.2);
}

.month-float {
  position: absolute;
  top: 10px;
  right: 16px;
  z-index: 4;
  display: flex;
  gap: 8px;
  align-items: center;
}

.help-trigger {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  padding: 0;
  font-weight: 700;
  box-shadow: 0 8px 14px rgba(20, 12, 8, 0.12);
}

.month-float select {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 8px 12px;
  border: 1px solid rgba(182, 87, 47, 0.25);
  box-shadow: 0 10px 18px rgba(20, 12, 8, 0.12);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 10px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 36px);
  font-weight: 600;
  font-family: "Fraunces", serif;
  letter-spacing: -0.02em;
}

.subhead {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  max-width: 320px;
}

h2 {
  margin: 0 0 12px;
  font-size: 19px;
  font-family: "Fraunces", serif;
  font-weight: 500;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
  animation: rise 0.6s ease both;
  margin: 12px 0;
}

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

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.4), transparent 50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.card:hover::after {
  opacity: 0.6;
}

.card--highlight {
  border-color: rgba(182, 87, 47, 0.3);
  box-shadow: var(--shadow);
}

.card--media {
  padding: 0;
  overflow: hidden;
  display: grid;
  gap: 0;
}

.media-panel {
  min-height: 170px;
  background-image: url("/images/photo-1509042239860-f550ce710b93.avif");
  background-size: cover;
  background-position: center;
}

.media-panel--home {
  background-image: url("/images/photo-1509042239860-f550ce710b93.avif");
}

.media-panel--expenses {
  background-image: url("/images/photo-1504674900247-0877df9cc836.avif");
}

.media-panel--analysis {
  background-image: url("/images/photo-1459257868276-5e65389e2722.avif");
}

.media-panel--backup {
  background-image: url("/images/photo-1495474472287-4d71bcdd2085.avif");
}

.media-panel-body {
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.month-select {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(182, 87, 47, 0.2);
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: 0 10px 18px rgba(20, 12, 8, 0.08);
}

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

select,
input {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  background: #fffaf4;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Hide native number spinners to keep mobile-style inputs clean */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

select:focus,
input:focus {
  outline: none;
  border-color: rgba(182, 87, 47, 0.7);
  box-shadow: 0 0 0 3px rgba(182, 87, 47, 0.15);
}

button {
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 12px 20px rgba(182, 87, 47, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 24px rgba(182, 87, 47, 0.3);
}

.action-link {
  display: inline-flex;
  align-items: center;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(182, 87, 47, 0.25);
  background: #fffaf4;
  color: var(--accent-dark);
  text-decoration: none;
  box-shadow: 0 8px 16px rgba(20, 12, 8, 0.08);
}

.action-link:hover {
  border-color: var(--accent);
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.summary {
  display: grid;
  gap: 12px;
}

.summary div {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  border-bottom: 1px dashed rgba(180, 160, 140, 0.35);
  padding-bottom: 6px;
}

.summary strong {
  font-size: 18px;
  font-family: "Fraunces", serif;
}

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.expense-form,
.backup-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.field--wide {
  flex: 1 1 220px;
}

.field--amount {
  flex: 0 0 140px;
}

.field input,
.field select {
  width: 100%;
}

.expense-form .checkbox {
  margin-top: 28px;
}

.inline-form .field--wide {
  min-width: 180px;
}

.backup-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

th,
td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 11px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}

.action-button {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid transparent;
  padding: 6px 10px;
  box-shadow: none;
}

.action-button:hover {
  border-color: var(--accent);
}

.icon-button {
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff5ea;
  color: var(--accent-dark);
  border: 1px solid rgba(182, 87, 47, 0.25);
  box-shadow: 0 10px 18px rgba(20, 12, 8, 0.08);
}

.icon-button.listening {
  background: linear-gradient(135deg, #f0b48c, #e07a3f);
  color: #fff;
  box-shadow: 0 12px 20px rgba(182, 87, 47, 0.35);
}

.ghost-button {
  border-radius: 12px;
  padding: 9px 14px;
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid rgba(182, 87, 47, 0.3);
  box-shadow: none;
}

.ghost-button:hover {
  background: rgba(182, 87, 47, 0.08);
}

.suggestions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.suggestions button {
  background: #fffaf4;
  color: var(--accent-dark);
  border: 1px solid rgba(182, 87, 47, 0.25);
  box-shadow: none;
  padding: 6px 10px;
  border-radius: 999px;
}

@media (max-width: 720px) {
  .device {
    border-radius: 28px;
  }

  .inline-form,
  .expense-form,
  .backup-form {
    flex-direction: column;
  }

  .expense-form .field,
  .backup-form .field,
  .inline-form .field,
  .expense-form input,
  .expense-form select,
  .expense-form button,
  .backup-form input,
  .backup-actions button,
  .action-link {
    width: 100%;
  }

  .expense-form .checkbox {
    margin-top: 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-card {
  background: rgba(255, 253, 249, 0.94);
  border-radius: 18px;
  padding: 16px 18px;
  border: 1px solid rgba(180, 160, 140, 0.35);
  box-shadow: 0 12px 24px rgba(20, 12, 8, 0.1);
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  position: relative;
  width: 100%;
  border-radius: 0;
  background: rgba(255, 253, 249, 0.95);
  border-top: 1px solid rgba(180, 160, 140, 0.35);
  backdrop-filter: blur(12px);
  z-index: 3;
  flex-shrink: 0;
  box-shadow: 0 -8px 20px rgba(20, 12, 8, 0.1);
}

.tab {
  border-radius: 14px;
  border: 1px solid rgba(182, 87, 47, 0.2);
  background: rgba(255, 253, 249, 0.9);
  padding: 10px 8px;
  font-size: 13px;
  color: var(--muted);
  box-shadow: 0 8px 16px rgba(20, 12, 8, 0.08);
}

.tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-color: transparent;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.expense-list,
.analysis-list {
  display: grid;
  gap: 12px;
}

.analysis-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.analysis-mode {
  border: 1px solid rgba(182, 87, 47, 0.25);
  border-radius: 12px;
  background: rgba(255, 253, 249, 0.92);
  color: var(--muted);
  padding: 10px 12px;
  box-shadow: none;
}

.analysis-mode.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-color: transparent;
}

.analysis-charts {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.chart-wrap {
  border: 1px solid rgba(180, 160, 140, 0.35);
  border-radius: 16px;
  background: rgba(255, 253, 249, 0.96);
  padding: 10px;
  box-shadow: 0 10px 18px rgba(20, 12, 8, 0.08);
}

#analysisChart,
#analysisPieChart {
  display: block;
  width: 100%;
  height: 260px;
}

.expense-item,
.analysis-item {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(180, 160, 140, 0.35);
  background: rgba(255, 253, 249, 0.95);
  box-shadow: 0 10px 18px rgba(20, 12, 8, 0.08);
  display: grid;
  gap: 6px;
}

.empty-state {
  padding: 16px;
  border-radius: 16px;
  border: 1px dashed rgba(180, 160, 140, 0.55);
  background: rgba(255, 253, 249, 0.86);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.expense-item-header,
.analysis-item-header {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
}

.expense-item-meta,
.analysis-item-meta {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.splash {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, rgba(249, 240, 229, 0.95), rgba(233, 218, 198, 0.98));
  display: grid;
  place-items: center;
  z-index: 20;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.splash.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-card {
  width: min(360px, 86vw);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 28px;
  border: 1px solid rgba(182, 87, 47, 0.2);
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(20, 12, 8, 0.2);
  animation: rise 0.8s ease both;
}

.splash-photo {
  min-height: 220px;
  background-color: #e5b18d;
  background-image: url("/brand/splash-photo.svg");
  background-size: cover;
  background-position: center;
}

.splash-content {
  padding: 18px 20px 24px;
  text-align: left;
}

.brand-lockup {
  display: block;
  width: min(300px, 100%);
  height: auto;
  margin-bottom: 12px;
  filter: drop-shadow(0 8px 14px rgba(20, 12, 8, 0.1));
}

.splash-button {
  width: 100%;
  margin-top: 16px;
  border-radius: 14px;
}

.toast-host {
  position: absolute;
  top: calc(var(--top-strip-height) + 6px);
  left: 14px;
  right: 14px;
  display: grid;
  gap: 8px;
  z-index: 6;
  pointer-events: none;
}

.toast {
  background: rgba(255, 253, 249, 0.98);
  border: 1px solid rgba(180, 160, 140, 0.35);
  border-left: 4px solid var(--accent);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 12px 20px rgba(20, 12, 8, 0.14);
  font-size: 13px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast--success {
  border-left-color: #1f8f52;
}

.toast--error {
  border-left-color: #b91c1c;
}

.toast--info {
  border-left-color: var(--accent);
}

.lock-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  background: rgba(20, 14, 10, 0.62);
  padding: 20px;
}

.lock-overlay.hidden {
  display: none;
}

.lock-card {
  width: min(360px, 100%);
  background: rgba(255, 253, 249, 0.98);
  border: 1px solid rgba(180, 160, 140, 0.35);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 18px 30px rgba(20, 12, 8, 0.24);
  display: grid;
  gap: 10px;
}

.lock-actions button {
  flex: 1;
}

.tour-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 14, 10, 0.58);
  display: grid;
  place-items: center;
  z-index: 8;
  padding: 20px;
}

.tour-overlay.hidden {
  display: none;
}

.tour-card {
  width: min(360px, 100%);
  background: rgba(255, 253, 249, 0.98);
  border: 1px solid rgba(180, 160, 140, 0.35);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 18px 30px rgba(20, 12, 8, 0.22);
}

.tour-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.tour-actions button {
  flex: 1;
}

.tour-target {
  position: relative;
  z-index: 9;
  outline: 3px solid rgba(255, 238, 220, 0.95);
  outline-offset: 3px;
  border-radius: 12px;
}

.privacy-shell {
  padding-top: 24px;
  padding-bottom: 24px;
}

.privacy-device {
  width: min(760px, 100%);
  height: auto;
  min-height: min(900px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
}

.privacy-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(180, 160, 140, 0.35);
  background: rgba(255, 253, 249, 0.92);
}

.privacy-logo {
  width: min(230px, 56%);
  height: auto;
}

.privacy-back {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(182, 87, 47, 0.3);
  color: var(--accent-dark);
  background: #fffaf4;
  text-decoration: none;
  padding: 8px 14px;
  box-shadow: 0 8px 14px rgba(20, 12, 8, 0.08);
}

.privacy-content {
  padding: 22px;
  display: grid;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.privacy-content::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.privacy-hero {
  border-color: rgba(182, 87, 47, 0.28);
  box-shadow: var(--shadow);
}

.privacy-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  display: grid;
  gap: 6px;
}

.privacy-content p {
  margin: 0;
  line-height: 1.6;
}

.privacy-content .card {
  overflow: visible;
}

@media (max-width: 720px) {
  .privacy-device {
    border-radius: 28px;
  }

  .privacy-topbar {
    flex-wrap: wrap;
  }

  .privacy-logo {
    width: 100%;
    max-width: 240px;
  }
}
