:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-soft: #edf3f0;
  --primary: #065f46;
  --primary-dark: #064e3b;
  --primary-light: #d1fae5;
  --accent: #d97706;
  --accent-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0284c7;
  --info-soft: #e0f2fe;
  --text: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --border: #dce5e0;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 2px 8px rgba(6, 78, 59, 0.06);
  --shadow-md: 0 10px 26px rgba(6, 78, 59, 0.1);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100%;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
}

body.has-host-badge .app-shell {
  padding-bottom: calc(148px + env(safe-area-inset-bottom));
}

/* Top Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(6, 78, 59, 0.18);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.topbar-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.topbar-title {
  font-weight: 800;
  font-size: 1.02rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-sub {
  font-size: 0.76rem;
  color: #a7f3d0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.mode-pill.cloud {
  background: #fef3c7;
  color: #92400e;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Content Area */
.main-content {
  padding: 16px;
  flex: 1;
}

/* Login Screen */
.auth-wrapper {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(60px + env(safe-area-inset-bottom));
  background: radial-gradient(circle at top, #065f46 0%, #042f2e 55%, #022c22 100%);
}

.auth-hero {
  text-align: center;
  color: #fff;
  margin-bottom: 18px;
  max-width: 420px;
}

.auth-hero img {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  margin-bottom: 10px;
}

.auth-hero h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-hero p {
  margin: 0;
  font-size: 0.88rem;
  color: #a7f3d0;
}

.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border-radius: 22px;
  padding: 22px 20px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.32);
}

.tab-Segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-soft);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 18px;
  gap: 4px;
}

.tab-Segment button {
  border: none;
  background: transparent;
  padding: 10px 8px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-Segment button.active {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

/* Cards & Grid */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.hero-balance-card {
  background: linear-gradient(135deg, #064e3b 0%, #047857 100%);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.hero-balance-card::after {
  content: '';
  position: absolute;
  right: -30px;
  top: -30px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(252, 211, 77, 0.12);
  pointer-events: none;
}

.hero-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a7f3d0;
  font-weight: 700;
}

.hero-amount {
  font-size: 2.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 4px 0 12px;
}

.last-saving-box {
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  padding: 12px 14px;
  backdrop-filter: blur(6px);
}

.last-saving-title {
  font-size: 0.75rem;
  color: #fde68a;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.last-saving-main {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.last-saving-date {
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
}

.last-saving-amt {
  font-size: 1.08rem;
  font-weight: 800;
  color: #fde68a;
}

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

@media (min-width: 720px) {
  .stats-grid.four {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 13px 14px;
  box-shadow: var(--shadow-sm);
}

.stat-box .label {
  font-size: 0.76rem;
  color: var(--text-light);
  font-weight: 600;
  margin-bottom: 4px;
}

.stat-box .value {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--text);
}

.stat-box.green .value { color: var(--primary); }
.stat-box.amber .value { color: var(--accent); }
.stat-box.red .value { color: var(--danger); }
.stat-box.blue .value { color: var(--info); }

/* Quick Action Buttons */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 16px;
}

.qa-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease, background 0.15s ease;
}

.qa-btn:active {
  transform: scale(0.97);
}

.qa-btn .qa-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  background: var(--primary-light);
  color: var(--primary-dark);
}

.qa-btn.amber .qa-icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.qa-btn.blue .qa-icon {
  background: var(--info-soft);
  color: var(--info);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: 11px;
  padding: 11px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
  text-decoration: none;
}

.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 11px; font-size: 0.8rem; border-radius: 9px; }
.btn-xs { padding: 5px 9px; font-size: 0.74rem; border-radius: 7px; }

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

.btn-whatsapp {
  background: #16a34a;
  color: #fff;
}

.btn-amber {
  background: var(--accent);
  color: #fff;
}

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

.btn-soft {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-ghost-light {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 7px 11px;
  font-size: 0.8rem;
}

/* Forms */
.form-group {
  margin-bottom: 13px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 5px;
}

input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
}

.hint {
  font-size: 0.76rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* Pills & Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 700;
}

.badge-green { background: var(--primary-light); color: var(--primary-dark); }
.badge-amber { background: var(--accent-soft); color: #92400e; }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-blue { background: var(--info-soft); color: #0369a1; }
.badge-gray { background: #e2e8f0; color: #334155; }

/* Pocket Selector Chips */
.pocket-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.pocket-chip {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.83rem;
  white-space: nowrap;
  cursor: pointer;
}

.pocket-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* 12-Month Compliance Grid */
.months-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 10px;
}

@media (min-width: 560px) {
  .months-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.month-cell {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 6px;
  text-align: center;
  background: #f8fafc;
}

.month-cell.met {
  background: #ecfdf5;
  border-color: #6ee7b7;
}

.month-cell.pending-now {
  background: #fffbeb;
  border-color: #fcd34d;
}

.month-cell .m-name {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
}

.month-cell.met .m-name { color: var(--primary-dark); }

.month-cell .m-val {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-light);
  margin-top: 2px;
}

.month-cell.met .m-val { color: #047857; }

/* Lists & Rows */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.list-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.list-item-main {
  min-width: 0;
  flex: 1;
}

.list-item-title {
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.list-item-sub {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 2px;
}

.list-item-right {
  text-align: right;
  flex-shrink: 0;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

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

th {
  font-size: 0.74rem;
  text-transform: uppercase;
  color: var(--text-light);
  font-weight: 800;
  background: var(--surface-soft);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.06);
}

.bottom-nav-inner {
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}

body.has-host-badge .bottom-nav-inner {
  padding-bottom: calc(56px + env(safe-area-inset-bottom));
}

.nav-item {
  border: none;
  background: transparent;
  padding: 6px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-light);
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  position: relative;
}

.nav-item .nav-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.nav-item.active {
  color: var(--primary);
}

.nav-dot {
  position: absolute;
  top: 3px;
  right: calc(50% - 16px);
  background: var(--danger);
  color: #fff;
  font-size: 0.63rem;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 4px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.56);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 20px;
  }
}

.modal-sheet {
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: 22px 22px 0 0;
  padding: 20px 18px 26px;
  box-shadow: 0 -10px 35px rgba(0, 0, 0, 0.22);
}

@media (min-width: 640px) {
  .modal-sheet {
    border-radius: 22px;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.close-btn {
  border: none;
  background: var(--surface-soft);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
}

/* Alerts & Banners */
.banner {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.banner-amber {
  background: var(--accent-soft);
  border: 1px solid #fcd34d;
  color: #78350f;
}

.banner-green {
  background: var(--primary-light);
  border: 1px solid #6ee7b7;
  color: var(--primary-dark);
}

.banner-red {
  background: var(--danger-soft);
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.section-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.amount-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.amount-chip {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--primary-dark);
}

.toast {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.code-box {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  overflow-x: auto;
  white-space: pre-wrap;
}

.empty-state {
  text-align: center;
  padding: 26px 14px;
  color: var(--text-light);
}
