:root {
  --primary: #0b5ed7;
  --primary-dark: #0a4eb3;
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --text: #1c2230;
  --text-muted: #707684;
  --danger: #e0383f;
  --success: #1aa260;
  --warning: #f0a500;
  --radius: 16px;
  --nav-height: 64px;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: calc(var(--nav-height) + 16px);
  -webkit-tap-highlight-color: transparent;
}

a { text-decoration: none; color: inherit; }

/* ---------- Top bar ---------- */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.topbar-title { font-size: 1.05rem; font-weight: 600; }
.topbar-back, .topbar-icon { font-size: 1.2rem; color: #fff; padding: 4px; }

.app-main { max-width: 600px; margin: 0 auto; padding: 14px 14px 8px; }

/* ---------- Cards ---------- */
.card-tile {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 3px rgba(20,30,60,.08);
  border: 1px solid rgba(20,30,60,.04);
}

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(20,30,60,.08);
}
.stat-card .stat-label { font-size: .75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-card .stat-value { font-size: 1.35rem; font-weight: 700; margin-top: 2px; }
.stat-card.accent-income .stat-value { color: var(--success); }
.stat-card.accent-expense .stat-value { color: var(--danger); }
.stat-card.accent-pending .stat-value { color: var(--warning); }
.stat-card.accent-profit .stat-value { color: var(--primary); }

.section-title {
  font-size: .95rem;
  font-weight: 700;
  margin: 22px 0 10px;
  color: var(--text);
}

/* ---------- Quick action buttons (dashboard) ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick-btn {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 12px 4px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(20,30,60,.08);
  font-size: .72rem;
  font-weight: 600;
  color: var(--text);
}
.quick-btn i { font-size: 1.35rem; display: block; margin-bottom: 4px; color: var(--primary); }

/* ---------- List rows (trips, ledger, etc.) ---------- */
.list-row {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(20,30,60,.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.list-row .lr-title { font-weight: 600; font-size: .92rem; }
.list-row .lr-sub { font-size: .76rem; color: var(--text-muted); }
.list-row .lr-amount { font-weight: 700; font-size: .95rem; white-space: nowrap; }

.badge-status { font-size: .68rem; padding: 3px 8px; border-radius: 20px; font-weight: 600; }
.badge-paid { background: rgba(26,162,96,.12); color: var(--success); }
.badge-partial { background: rgba(240,165,0,.14); color: #9c6f00; }
.badge-pending { background: rgba(224,56,63,.12); color: var(--danger); }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .85rem; }
.form-control, .form-select {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: .95rem;
}
.btn-primary { background: var(--primary); border-color: var(--primary); border-radius: 12px; font-weight: 600; padding: 11px; }
.btn-primary:hover, .btn-primary:active { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-save-bar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding-top: 16px; padding-bottom: 8px; }

/* ---------- Bottom Navigation ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: #fff;
  display: flex;
  align-items: stretch;
  box-shadow: 0 -1px 8px rgba(0,0,0,.08);
  z-index: 1040;
  padding-bottom: env(safe-area-inset-bottom);
}
.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: .68rem;
  color: var(--text-muted);
  font-weight: 600;
  gap: 2px;
}
.bn-item i { font-size: 1.25rem; }
.bn-item.active { color: var(--primary); }
.bn-spacer { flex: 1; }

/* ---------- Floating Action Button ---------- */
.fab-wrap {
  position: fixed;
  right: 18px;
  bottom: calc(var(--nav-height) + 14px);
  z-index: 1060;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.fab-btn {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 1.5rem;
  box-shadow: 0 4px 14px rgba(11,94,215,.45);
  transition: transform .2s ease;
}
.fab-btn.open { transform: rotate(45deg); }

.fab-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all .18s ease;
}
.fab-menu.open { opacity: 1; pointer-events: auto; transform: translateY(0); }

.fab-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  padding: 8px 14px 8px 8px;
  border-radius: 30px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
}
.fab-item-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1rem;
}

.fab-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,15,30,.35);
  z-index: 1050;
}
.fab-overlay.open { display: block; }

/* ---------- Login page ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 20px;
  padding: 32px 26px;
  box-shadow: 0 4px 24px rgba(20,30,60,.1);
}
.login-logo {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 16px;
}

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 40px 10px; color: var(--text-muted); }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: 10px; opacity: .5; }
.scroll-x { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip {
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: 20px;
  background: #fff;
  font-size: .8rem;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(20,30,60,.08);
}
.chip.active { background: var(--primary); color: #fff; }
