:root {
  --burgundy: #6B1D2A;
  --burgundy-deep: #431016;
  --burgundy-soft: #8B3340;
  --gold: #C9A227;
  --gold-soft: #E8D5A3;
  --cream: #F7F1E8;
  --paper: #FFFBF5;
  --ink: #2A221E;
  --muted: #6B5E55;
  --line: #E4D8C8;
  --success: #2F6B4F;
  --success-bg: #E5F2EA;
  --danger: #A33B32;
  --danger-bg: #F8E8E6;
  --warn: #9A6B1F;
  --warn-bg: #F8EED8;
  --info: #3D5A73;
  --info-bg: #E7EEF4;
  --shadow: 0 18px 50px rgba(67, 16, 22, 0.08);
  --radius: 22px;
  --font-serif: "Fraunces", Georgia, serif;
  --font-sans: "Source Sans 3", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 18px; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--cream);
  color: var(--ink);
  line-height: 1.5;
  background-image:
    radial-gradient(circle at top left, rgba(201,162,39,.12), transparent 28%),
    radial-gradient(circle at top right, rgba(107,29,42,.08), transparent 24%);
}

img { max-width: 100%; }
a { color: var(--burgundy); }
h1, h2, h3, .display { font-family: var(--font-serif); font-weight: 560; letter-spacing: -0.02em; line-height: 1.15; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 .4rem; }
h2 { font-size: 1.4rem; margin: 0 0 .6rem; }
.lede { color: var(--muted); font-size: 1.05rem; margin: 0 0 1.2rem; }

.app-header {
  background: linear-gradient(160deg, var(--burgundy-deep), var(--burgundy) 55%, #8a2a38);
  color: #fff;
  padding: 1rem 1.1rem .95rem;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 10px 30px rgba(67,16,22,.25);
}
.app-header::after {
  content: "";
  display: block;
  height: 7px;
  margin: .85rem -1.1rem -0.95rem;
  background:
    repeating-linear-gradient(90deg, var(--gold) 0 14px, transparent 14px 22px),
    var(--burgundy-deep);
  opacity: .9;
}
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
.brand img { width: 46px; height: 46px; border-radius: 14px; border: 1px solid rgba(232,213,163,.5); }
.brand-kicker { display: block; font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--gold-soft); }
.brand-name { display: block; font-family: var(--font-serif); font-size: 1.15rem; }
.header-actions { display: flex; gap: .5rem; align-items: center; }
.header-actions .ghost { color: #fff; border-color: rgba(255,255,255,.25); }

.wrap { width: min(1120px, calc(100% - 1.5rem)); margin: 1.25rem auto 7rem; }
.auth-wrap { width: min(460px, calc(100% - 1.5rem)); margin: 2rem auto 3rem; }

.panel, .card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card + .card, .panel + .panel { margin-top: 1rem; }
.hero-card {
  background:
    linear-gradient(135deg, rgba(107,29,42,.94), rgba(67,16,22,.92)),
    var(--burgundy);
  color: #fff;
  border: 0;
}
.hero-card .lede { color: rgba(255,255,255,.82); }
.eyebrow { font-size: .75rem; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); font-weight: 700; }

.btn, button.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  min-height: 52px;
  padding: .85rem 1.25rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--burgundy); color: #fff; box-shadow: 0 10px 24px rgba(107,29,42,.25); }
.btn-primary:hover { background: var(--burgundy-soft); }
.btn-gold { background: var(--gold); color: var(--burgundy-deep); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost, .ghost {
  background: transparent;
  color: var(--burgundy);
  border: 1.5px solid var(--line);
}
.btn-block { width: 100%; }
.btn-row { display: flex; gap: .7rem; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 160px; }

label { display: block; font-weight: 700; margin: 0 0 .35rem; }
.hint { color: var(--muted); font-size: .92rem; font-weight: 500; margin: -.15rem 0 .45rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], select, textarea {
  width: 100%;
  min-height: 52px;
  border: 1.5px solid #d8cbb8;
  border-radius: 16px;
  background: #fff;
  padding: .7rem .9rem;
  font: inherit;
  color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(201,162,39,.45);
  border-color: var(--gold);
}
.field { margin-bottom: 1rem; }
.grid-2 { display: grid; gap: .9rem; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: .2rem .65rem;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.chip-submitted { background: var(--warn-bg); color: var(--warn); }
.chip-approved { background: var(--success-bg); color: var(--success); }
.chip-rejected { background: var(--danger-bg); color: var(--danger); }
.chip-pending { background: var(--info-bg); color: var(--info); }
.chip-muted { background: #f0e9de; color: var(--muted); }

.flash { border-radius: 16px; padding: .9rem 1rem; margin-bottom: 1rem; font-weight: 600; }
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-error { background: var(--danger-bg); color: var(--danger); }
.flash ul { margin: .3rem 0 0 1.1rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .98rem; }
th, td { text-align: left; padding: .7rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
tr:hover td { background: #fcf7ef; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; }
@media (min-width: 800px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 1rem; }
.stat b { display: block; font-family: var(--font-serif); font-size: 1.45rem; }

.budget-row { margin: .85rem 0 1.1rem; }
.budget-meta { display: flex; justify-content: space-between; gap: 1rem; font-size: .92rem; margin-bottom: .35rem; }
.bar { height: 14px; background: #efe6d8; border-radius: 999px; overflow: hidden; position: relative; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--burgundy), var(--gold)); }
.bar.over > span { background: var(--danger); }

.expense-list { display: grid; gap: .75rem; }
.expense-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .4rem 1rem;
  padding: 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  text-decoration: none;
  color: inherit;
}
.expense-item strong { font-size: 1.08rem; }
.amount { font-family: var(--font-serif); font-size: 1.25rem; }

.nav-bottom {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fffaf3;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(var(--tabs, 3), 1fr);
  padding: .35rem .4rem calc(.45rem + env(safe-area-inset-bottom));
  z-index: 30;
}
.nav-bottom a {
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  padding: .45rem .2rem;
  border-radius: 14px;
}
.nav-bottom a.active, .nav-bottom a:hover { color: var(--burgundy); background: #f6ebe0; }
.nav-bottom span { display: block; font-size: 1.15rem; }

.admin-nav { display: flex; gap: .45rem; flex-wrap: wrap; margin: 0 0 1rem; }
.admin-nav a {
  text-decoration: none;
  color: var(--burgundy);
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: .45rem .8rem;
  font-weight: 700;
  font-size: .92rem;
}
.admin-nav a.active { background: var(--burgundy); color: #fff; border-color: var(--burgundy); }

.suggest {
  margin-top: .55rem;
  padding: .8rem;
  border-radius: 16px;
  background: var(--warn-bg);
}
.suggest button { margin-top: .5rem; }
.preview-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .6rem; }
.preview-grid img { width: 100%; height: 92px; object-fit: cover; border-radius: 12px; }

.receipts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; }
.receipts a { display: block; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.receipts img { width: 100%; height: 140px; object-fit: cover; display: block; }

.check-list { display: flex; flex-wrap: wrap; gap: .6rem 1rem; }
.check-list label { display: flex; align-items: center; gap: .45rem; font-weight: 650; min-height: 44px; }
.check-list input { width: 22px; height: 22px; }

.auth-hero { text-align: center; margin-bottom: 1.2rem; }
.auth-hero img { width: 72px; height: 72px; border-radius: 20px; }
.fine { color: var(--muted); font-size: .92rem; }

.install-banner {
  display: none;
  position: sticky;
  bottom: 76px;
  margin: 0 auto 1rem;
  width: min(1120px, calc(100% - 1.5rem));
  background: var(--burgundy);
  color: #fff;
  border-radius: 18px;
  padding: .9rem 2.6rem .9rem 1rem;
  box-shadow: var(--shadow);
  gap: .8rem;
  align-items: center;
  justify-content: space-between;
}
.install-banner.show { display: flex; }
.install-close {
  position: absolute;
  top: .35rem;
  right: .45rem;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.app-footer {
  width: min(1120px, calc(100% - 1.5rem));
  margin: 0 auto 6.5rem;
  text-align: center;
}
.app-footer a {
  color: var(--muted);
  font-size: .92rem;
}
@media (min-width: 900px) {
  .app-footer { margin-bottom: 2rem; }
}

@media (min-width: 900px) {
  .nav-bottom { display: none; }
  .wrap { margin-bottom: 3rem; }
  .desktop-nav { display: flex !important; }
}
.desktop-nav { display: none; gap: .7rem; flex-wrap: wrap; }
.desktop-nav a { color: #fff; text-decoration: none; font-weight: 700; opacity: .86; }
.desktop-nav a:hover, .desktop-nav a.active { opacity: 1; border-bottom: 2px solid var(--gold); }

.other-box { display: none; margin-top: .6rem; }
.other-box.open { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
