/* ===== FINN APP — CSS ===== */

:root {
  --navy: #0B1426;
  --navy2: #152338;
  --navy3: #1A2E4A;
  --teal: #00D4B4;
  --teal2: #00B49A;
  --amber: #F5A623;
  --amber2: #E0941A;
  --cream: #FFF8F0;
  --cream2: #F0E9DF;
  --text: #0B1426;
  --text2: #4A6080;
  --text3: #8AA0B8;
  --white: #ffffff;
  --surface: #F7F3EF;
  --border: #E2D9D0;
  --danger: #E53E3E;
  --success: #38A169;
  --warning: #DD6B20;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(11,20,38,0.12);
  --shadow-lg: 0 8px 40px rgba(11,20,38,0.2);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'DM Sans', sans-serif;
  background: var(--navy);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ===== UTILITY ===== */
.hidden { display: none !important; }
.active { display: flex; }

/* ===== SPLASH ===== */
.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  transition: opacity 0.5s, transform 0.5s;
}

.splash.fade-out {
  opacity: 0;
  transform: scale(0.96);
  pointer-events: none;
}

.splash-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 60% at 30% 20%, rgba(0,212,180,0.18) 0%, transparent 70%),
    radial-gradient(ellipse 50% 50% at 80% 80%, rgba(245,166,35,0.12) 0%, transparent 70%);
}

.splash-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
}

.mascot-hero {
  width: 180px;
  height: 200px;
  margin-bottom: 16px;
  filter: drop-shadow(0 16px 48px rgba(0,212,180,0.35));
  animation: floatOwl 3s ease-in-out infinite;
}

@keyframes floatOwl {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.finn-svg { width: 100%; height: 100%; }

.splash-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 3rem;
  font-weight: 700;
  color: var(--cream);
  letter-spacing: -0.02em;
}

.splash-sub {
  font-size: 1.1rem;
  color: var(--teal);
  font-weight: 500;
}

.splash-tagline {
  font-size: 0.82rem;
  color: var(--text3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}

.btn-start {
  margin-top: 32px;
  background: var(--teal);
  color: var(--navy);
  border: none;
  border-radius: 50px;
  padding: 16px 48px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 32px rgba(0,212,180,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-start:active {
  transform: scale(0.97);
  box-shadow: 0 4px 16px rgba(0,212,180,0.3);
}

/* ===== APP SHELL ===== */
.app {
  position: fixed;
  inset: 0;
  background: var(--surface);
  flex-direction: column;
  overflow: hidden;
}

/* ===== HEADER ===== */
.app-header {
  background: var(--navy);
  padding: calc(var(--safe-top) + 12px) 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(11,20,38,0.3);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-finn {
  width: 38px;
  height: 38px;
  background: var(--navy3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid var(--teal);
}

.mini-finn svg { width: 44px; height: 44px; }

.header-brand {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--cream);
}

.header-month {
  display: block;
  font-size: 0.72rem;
  color: var(--text3);
  font-weight: 400;
  margin-top: -2px;
}

.btn-add-header {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--teal);
  color: var(--navy);
  border: none;
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  line-height: 1;
}

.btn-add-header:active { transform: scale(0.9); }

/* ===== SUMMARY STRIP ===== */
.summary-strip {
  background: var(--navy2);
  display: flex;
  gap: 0;
  flex-shrink: 0;
  padding: 0 4px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.summary-strip::-webkit-scrollbar { display: none; }

.sum-card {
  flex: 1;
  min-width: 100px;
  padding: 14px 16px;
  text-align: center;
  border-right: 1px solid rgba(255,255,255,0.06);
}

.sum-card:last-child { border-right: none; }

.sum-card.accent .sum-value { color: var(--amber); }

.sum-label {
  font-size: 0.65rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.sum-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--teal);
}

/* ===== TAB NAV (desktop) ===== */
.tab-nav {
  display: none;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* ===== CONTENT ===== */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px calc(var(--safe-bottom) + 80px);
  scrollbar-width: thin;
}

.tab-panel { display: none; flex-direction: column; }
.tab-panel.active { display: flex; }

/* ===== SECTION HEAD ===== */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.section-count {
  font-size: 0.78rem;
  color: var(--text3);
}

.btn-sec {
  background: var(--teal);
  color: var(--navy);
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

/* ===== ITEM LIST ===== */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 2px 8px rgba(11,20,38,0.06);
  border-left: 4px solid transparent;
}

.item-card:active { transform: scale(0.98); box-shadow: var(--shadow); }

.item-card.overdue { border-left-color: var(--danger); }
.item-card.due-soon { border-left-color: var(--amber); }
.item-card.ok { border-left-color: var(--success); }
.item-card.loan-card { border-left-color: var(--teal); }

.item-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.item-icon.cat-housing { background: #EBF8FF; }
.item-icon.cat-utilities { background: #FFFFF0; }
.item-icon.cat-transport { background: #F0FFF4; }
.item-icon.cat-food { background: #FFF5F5; }
.item-icon.cat-entertainment { background: #FAF0FE; }
.item-icon.cat-health { background: #F0FFF4; }
.item-icon.cat-finance { background: #EBF8FF; }
.item-icon.cat-other { background: var(--surface); }

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

.item-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  font-size: 0.75rem;
  color: var(--text3);
  margin-top: 2px;
}

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

.item-amount {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.item-due {
  font-size: 0.72rem;
  margin-top: 2px;
}

.item-due.overdue { color: var(--danger); font-weight: 600; }
.item-due.due-soon { color: var(--warning); font-weight: 600; }
.item-due.ok { color: var(--success); }

/* LOAN CARD SPECIFIC */
.loan-progress {
  margin-top: 8px;
  background: var(--surface);
  border-radius: 99px;
  height: 5px;
  overflow: hidden;
}

.loan-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--teal2));
  border-radius: 99px;
  transition: width 0.4s;
}

.loan-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text3);
  margin-top: 3px;
}

/* EMPTY STATE */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--text3);
  font-size: 0.88rem;
  text-align: center;
}

.empty-finn { font-size: 2.5rem; }

.btn-empty {
  background: var(--teal);
  color: var(--navy);
  border: none;
  border-radius: 20px;
  padding: 10px 24px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  margin-top: 8px;
}

/* ===== CHART ===== */
.chart-wrap {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(11,20,38,0.06);
}

#pieChart { max-width: 200px; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text2);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 4px calc(var(--safe-bottom) + 8px);
  box-shadow: 0 -4px 20px rgba(11,20,38,0.08);
  z-index: 10;
}

.bnav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 10px;
  transition: background 0.12s;
  flex: 1;
}

.bnav-btn:active { background: var(--surface); }

.bnav-icon {
  font-size: 1.3rem;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.bnav-label {
  font-size: 0.64rem;
  color: var(--text3);
  font-weight: 500;
  transition: color 0.15s;
}

.bnav-btn.active .bnav-icon { opacity: 1; }
.bnav-btn.active .bnav-label { color: var(--teal2); font-weight: 700; }

.bnav-btn.add-center {
  background: var(--teal);
  border-radius: 50%;
  width: 52px;
  height: 52px;
  min-width: 52px;
  margin-top: -20px;
  padding: 0;
  flex: 0 0 52px;
  box-shadow: 0 4px 16px rgba(0,212,180,0.5);
  border: 3px solid var(--white);
}

.bnav-add {
  font-size: 1.8rem;
  color: var(--navy);
  font-weight: 700;
  line-height: 1;
  margin-top: -2px;
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(11,20,38,0.6);
  z-index: 50;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal.active { display: flex; }

.modal-sheet {
  background: var(--white);
  border-radius: 24px 24px 0 0;
  padding: 8px 20px calc(var(--safe-bottom) + 24px);
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  margin: 6px auto 16px;
}

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

.modal-head h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: var(--surface);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* TYPE SELECTOR */
.type-select {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.type-btn {
  flex: 1;
  padding: 10px 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text2);
}

.type-btn.active {
  background: var(--navy);
  color: var(--cream);
  border-color: var(--navy);
}

/* FORM */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--teal);
  background: var(--white);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group { flex: 1; }

.btn-save {
  width: 100%;
  padding: 16px;
  background: var(--navy);
  color: var(--cream);
  border: none;
  border-radius: var(--radius);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s, transform 0.12s;
  box-shadow: 0 4px 16px rgba(11,20,38,0.25);
}

.btn-save:active {
  transform: scale(0.98);
  background: var(--navy3);
}

.loan-progress-preview {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.lp-label {
  font-size: 0.72rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.lp-val {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--teal2);
}

/* DETAIL MODAL */
.detail-block {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child { border-bottom: none; }

.detail-label {
  font-size: 0.8rem;
  color: var(--text3);
}

.detail-val {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

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

.btn-edit, .btn-delete {
  flex: 1;
  padding: 13px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s;
}

.btn-edit:active, .btn-delete:active { transform: scale(0.97); }

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

.btn-delete {
  background: #FFF5F5;
  color: var(--danger);
  border: 1.5px solid #FED7D7;
}

/* ===== DESKTOP MEDIA ===== */
@media (min-width: 640px) {
  .app {
    max-width: 480px;
    margin: 0 auto;
    border-radius: 0;
    box-shadow: 0 0 60px rgba(0,0,0,0.4);
  }

  html, body {
    background: #080F1E;
    display: flex;
    justify-content: center;
  }
}
