:root {
  --navy: #0B1326;
  --navy-surface: #15203B;
  --bg: #F5F7FB;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --text: #0F172A;
  --muted: #64748B;
  --emerald: #047857;
  --emerald-bright: #34D399;
  --emerald-track: #DDF7EB;
  --coral: #BE123C;
  --coral-bright: #FB7185;
  --coral-track: #FFE4E9;
  --amber: #9A3412;
  --amber-bright: #FBBF24;
  --amber-track: #FEF3C7;
  --violet: #4328B8;
  --violet-track: #EDE9FE;
  --surface-subtle: #F1F5F9;
  --radius: 18px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
}

.hidden {
  display: none !important;
}

button, input, select {
  font: inherit;
}

/* Auth View */
.auth-screen {
  min-height: 100dvh;
  background: linear-gradient(160deg, var(--navy), var(--navy-surface) 60%, #0E1D3A);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  padding: 24px;
  backdrop-filter: blur(12px);
}

.brand-badge {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(39, 194, 129, 0.18);
  color: var(--emerald);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 22px;
  margin: 0 auto 12px;
}

.auth-title {
  text-align: center;
  margin: 0 0 4px;
  font-size: 26px;
}

.auth-subtitle {
  text-align: center;
  margin: 0 0 18px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 14px;
}

.segmented button {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  padding: 10px;
  border-radius: 9px;
  font-weight: 600;
  cursor: pointer;
}

.segmented button.active {
  background: var(--emerald);
  color: var(--navy);
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--muted);
}

.auth-card .field label {
  color: rgba(255, 255, 255, 0.78);
}

.field input, .field select {
  width: 100%;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

.auth-card .field input {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.24);
  color: #fff;
}

.btn {
  border: 0;
  border-radius: 13px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--emerald);
  color: #fff;
}

.btn-dark {
  background: var(--navy);
  color: #fff;
}

.btn-google {
  background: #fff;
  color: var(--navy);
  margin-top: 10px;
}

.btn-demo {
  background: transparent;
  color: var(--emerald);
  border: 1px solid rgba(39, 194, 129, 0.55);
  margin-top: 10px;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-danger-ghost {
  background: var(--coral-track);
  color: var(--coral);
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 4px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
}

.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
}

.alert-box {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 10px;
}

.alert-error {
  background: rgba(244, 63, 94, 0.18);
  color: #fecdd3;
}

.alert-info {
  background: rgba(39, 194, 129, 0.18);
  color: #bbf7d0;
}

/* App Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.top-header {
  background: linear-gradient(180deg, var(--navy), var(--navy-surface));
  color: #fff;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.top-row {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.month-bar {
  max-width: 960px;
  margin: 10px auto 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-pill {
  flex: 1;
  background: #fff;
  color: var(--navy);
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  font-weight: 700;
}

.month-pill button {
  border: 0;
  background: transparent;
  color: var(--navy);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
}

.demo-banner {
  background: var(--amber-track);
  color: var(--navy);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.main-content {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px 150px;
}

/* Cards & Grids */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.hero-card {
  background: var(--navy);
  color: #fff;
  border-radius: 22px;
  padding: 20px;
  margin-bottom: 14px;
}

.hero-amount {
  font-size: 32px;
  font-weight: 800;
  color: var(--emerald-bright);
  margin: 4px 0;
}

.hero-grid {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.chip-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 8px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.hero-card .chip {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.hero-card .chip.active,
.chip.active {
  background: #10B981;
  border-color: #10B981;
  color: var(--navy);
  font-weight: 800;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-box {
  background: var(--surface-subtle);
  border: 1px solid #CBD5E1;
  border-radius: 12px;
  padding: 10px;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
}

.stat-val {
  font-size: 15px;
  font-weight: 800;
  margin-top: 3px;
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 8px;
  background: #fff;
}

.item-row.paid {
  background: #F0FDF7;
  border-color: #A7F3D0;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

/* Calendar Grid */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-head {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 0;
}

.cal-cell {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  font-weight: 600;
}

.cal-cell.selected {
  background: var(--navy);
  color: #fff;
}

.cal-cell.today:not(.selected) {
  border-color: var(--emerald);
}

.dot-row {
  display: flex;
  gap: 3px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 25;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav button {
  border: 0;
  background: transparent;
  padding: 10px 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.bottom-nav button.active {
  color: var(--violet);
}

/* Floating AI Button */
.ai-fab {
  position: fixed;
  right: 16px;
  bottom: calc(74px + env(safe-area-inset-bottom));
  background: var(--violet);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 13px 18px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(109, 74, 255, 0.35);
  cursor: pointer;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 19, 38, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.modal-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  overflow-y: auto;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 20px;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 16px;
  }
  .modal-sheet {
    border-radius: 22px;
  }
}

.chat-log {
  max-height: 44dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0;
}

.bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  max-width: 90%;
}

.bubble.user {
  align-self: flex-end;
  background: var(--navy);
  color: #fff;
}

.bubble.ai {
  align-self: flex-start;
  background: #F1F5F9;
  color: var(--text);
}
