/* Self-hosted Plus Jakarta Sans (same-origin woff2 in /fonts — NOT an external
   CDN, so the app stays fully self-contained). Only fetched by pages that
   actually set font-family: 'Plus Jakarta Sans' (the marketing landing); the
   app pages keep their system-ui stack and never download these. */
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/plus-jakarta-400.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/plus-jakarta-500.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/plus-jakarta-600.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/plus-jakarta-700.woff2') format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 800; font-display: swap; src: url('/fonts/plus-jakarta-800.woff2') format('woff2'); }
@font-face { font-family: 'Baloo 2'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/baloo2-700.woff2') format('woff2'); }
@font-face { font-family: 'Baloo 2'; font-style: normal; font-weight: 800; font-display: swap; src: url('/fonts/baloo2-800.woff2') format('woff2'); }

/* Shared color tokens — Light (default) + Dark (via [data-theme="dark"]).
   Applied by /js/theme.js (sets document.documentElement[data-theme]).
   Every page's own inline <style> block should reference these vars, never
   hardcode a hex color, so a single toggle re-themes the whole app. */
:root {
  --bg: #f5f7f4;
  --card: #ffffff;
  --card-alt: #eef1ee;
  --border: #e4e9e4;
  --text: #0f1c2e;
  --text-secondary: #5c6b62;
  --muted: #8a968e;
  --muted-2: #98a49b;
  --brand: #2fbf57;
  --brand-light: #1e9e45;
  --on-brand: #ffffff;
  --danger-bg: #fcebeb;
  --danger-text: #c0392b;
  --danger-border: #f3c9c4;
  --success-bg: #eaf7ee;
  --success-text: #1e9e45;
  --warn-bg: #fdf3e3;
  --warn-text: #b8791c;
  --warn-border: #f2ddb6;
  --info-bg: #eef3fb;
  --info-text: #2f6fd6;
  --badge-info-bg: #dfeafd;
  --badge-warn-bg: #fdf3e3;
  --badge-success-bg: #eaf7ee;
  --nav-bg: rgba(255, 255, 255, 0.9);
  --nav-border: rgba(15, 28, 46, 0.08);
  --hero-grad-start: #16283f;
  --hero-grad-end: #0f1c2e;
  --avatar-bg: #eaf7ee;
  --avatar-text: #1e9e45;
  --pill-neutral-bg: #eef1ee;
  --pill-neutral-text: #5c6b62;
  --progress-track: #eaeeea;
  --card-radius: 20px;
  --card-shadow: 0 2px 10px rgba(15, 28, 46, 0.05);
  /* Pro promo card (docs/design/pro-upgrade/HANDOFF.md, Screen 1). The pill
     bg/text pairing doesn't map onto any existing generic token (it's
     brand-dark-on-white in light, brand-on-near-black in dark), and the
     hairline border only exists in light theme to stop the card-alt price
     bar from bleeding into the page background — so both get their own
     theme-scoped tokens here, same convention as --avatar-bg/--avatar-text.
     The pill/CTA backgrounds below reference --brand-light and --brand
     rather than repeating their hex — each theme block still redefines the
     token to a DIFFERENT source var, which is the normal way to do this. */
  --promo-pill-bg: var(--brand-light);
  --promo-pill-text: #ffffff;
  --promo-card-border: rgba(15, 28, 46, 0.08);
  /* Pro upgrade bottom sheet (docs/design/pro-upgrade/HANDOFF.md, Screen 2).
     Backdrop tint and top shadow are theme-specific rgba values called out
     explicitly in the handoff, so they get their own tokens rather than
     reusing --card-shadow (which is a different, smaller shadow). */
  --sheet-backdrop: rgba(15, 28, 46, 0.45);
  --sheet-shadow: 0 -8px 30px rgba(15, 28, 46, 0.15);
  --sheet-grabber: #d7ddd8;
  --sheet-check-glyph: #ffffff;
  /* Handoff wants brand-dark in light theme, plain brand in dark — each
     theme block below points this at the matching source token. */
  --sheet-cta-bg: var(--brand-light);
}

:root[data-theme="dark"] {
  --bg: #0b1522;
  --card: #16283f;
  --card-alt: #1c3350;
  --border: #24405f;
  --text: #e6edf3;
  --text-secondary: #b3c2cf;
  --muted: #8ea0b0;
  --muted-2: #6b7f90;
  --brand: #34c866;
  --brand-light: #56d67f;
  --on-brand: #04220f;
  --danger-bg: #3d1414;
  --danger-text: #f2a49a;
  --danger-border: #6e2a24;
  --success-bg: #0f3a22;
  --success-text: #74d391;
  --warn-bg: #3d2a0e;
  --warn-text: #e6b45c;
  --warn-border: #6b4b1a;
  --info-bg: #16294a;
  --info-text: #8fb6f0;
  --badge-info-bg: #16294a;
  --badge-warn-bg: #3d2a0e;
  --badge-success-bg: #0f3a22;
  --nav-bg: rgba(18, 33, 52, 0.9);
  --nav-border: rgba(255, 255, 255, 0.08);
  --hero-grad-start: #1b3150;
  --hero-grad-end: #0f1c2e;
  --avatar-bg: #0f3a22;
  --avatar-text: #74d391;
  --pill-neutral-bg: #1c3350;
  --pill-neutral-text: #b3c2cf;
  --progress-track: #24405f;
  --card-radius: 20px;
  --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  --promo-pill-bg: var(--brand);
  --promo-pill-text: #06120a;
  --promo-card-border: transparent;
  --sheet-backdrop: rgba(0, 0, 0, 0.55);
  --sheet-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
  --sheet-grabber: #33475f;
  --sheet-check-glyph: #06120a;
  --sheet-cta-bg: var(--brand);
}

/* Shared wallet-app components (avatar circle, neutral pill, progress bar) —
   used by the dashboard's human loan cards and the borrower status card. */
.avatar-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--avatar-bg);
  color: var(--avatar-text);
  font-weight: 700;
  font-size: 0.95rem;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.status-pill.neutral { background: var(--pill-neutral-bg); color: var(--pill-neutral-text); }
.status-pill.success { background: var(--badge-success-bg); color: var(--brand-light); }
.status-pill.warn { background: var(--badge-warn-bg); color: var(--warn-text); }
.status-pill.danger { background: var(--danger-bg); color: var(--danger-text); }
.progress-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--progress-track);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
  transition: width 0.2s ease;
}

/* Mobile bottom nav — shared across every logged-in app page (dashboard,
   new-debt, debt, settings). Hidden on desktop; each page hard-codes which
   tab (if any) is .active and includes this markup itself. */
.busy-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 18px;
  height: 14px;
  margin-right: 7px;
  color: currentColor;
  vertical-align: -0.12em;
}

.busy-spinner span {
  width: 4px;
  height: 12px;
  border-radius: 999px;
  background: currentColor;
  animation: singilinmo-loader-bars 0.9s infinite cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.busy-spinner span:nth-child(2) {
  animation-delay: 0.1s;
}

.busy-spinner span:nth-child(3) {
  animation-delay: 0.2s;
}

@keyframes singilinmo-loader-bars {
  0%, 100% {
    height: 3px;
    transform: rotate(0deg);
    opacity: 0.65;
  }
  25% {
    height: 12px;
    opacity: 1;
  }
  50% {
    height: 12px;
    transform: rotate(-8deg);
  }
  75% {
    height: 12px;
    transform: rotate(8deg);
  }
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  align-items: center;
  max-width: 440px;
  margin: 0 auto;
  min-height: 66px;
  padding: 8px 14px;
  background: var(--nav-bg);
  border: 1px solid var(--nav-border);
  border-radius: 26px;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 16px 34px rgba(15, 28, 46, 0.16);
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 48px;
  color: var(--muted-2);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: 16px;
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.bottom-nav-item svg,
.bottom-nav-fab svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.bottom-nav-item:hover {
  color: var(--text);
  background: rgba(15, 28, 46, 0.05);
}
.bottom-nav-item.active {
  color: var(--brand-light);
  background: rgba(47, 191, 87, 0.14);
}
.bottom-nav-fab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-top: -30px;
  border-radius: 20px;
  background: linear-gradient(150deg, #2fbf57, #1e9e45);
  color: #ffffff;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 14px 26px rgba(47, 191, 87, 0.4), 0 10px 22px rgba(15, 28, 46, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.bottom-nav-fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(47, 191, 87, 0.46), 0 12px 28px rgba(15, 28, 46, 0.24);
}

.notification-fab {
  position: fixed;
  right: 18px;
  top: calc(14px + env(safe-area-inset-top, 0px));
  z-index: 220;
}
.notification-button {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  display: grid;
  place-items: center;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
  cursor: pointer;
}
.notification-button svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2.15;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 0.68rem;
  font-weight: 800;
  border: 2px solid var(--card);
}
.notification-badge.show { display: flex; }
.notification-panel {
  position: absolute;
  top: 50px;
  right: 0;
  width: min(360px, calc(100vw - 28px));
  max-height: min(520px, calc(100vh - 96px));
  overflow: auto;
  display: none;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.24);
}
.notification-panel.open { display: block; }
.notification-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.notification-head strong { font-size: 0.95rem; }
.notification-head button {
  border: none;
  background: transparent;
  color: var(--brand-light);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}
.notification-list { display: flex; flex-direction: column; }
.notification-empty {
  padding: 28px 18px;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}
.notification-item {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}
.notification-item:last-child { border-bottom: 0; }
.notification-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 999px;
  background: transparent;
}
.notification-item.unread .notification-dot { background: var(--brand); }
.notification-item strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 3px;
}
.notification-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}
.notification-time {
  display: block;
  margin-top: 7px;
  color: var(--muted-2);
  font-size: 0.72rem;
  font-weight: 700;
}

/* Bottom nav is shown on desktop too now — reserve space for it and retire the
   redundant desktop header nav group (new-debt/settings/logout all stay reachable
   via the nav + Settings). Detail-page back links/titles are untouched. */
body { padding-bottom: 108px; }
body > header .header-actions { display: none !important; }

@media (max-width: 768px) {
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 8px 12px;
  }
  .bottom-nav-item {
    min-width: 0;
    padding: 0 4px;
    font-size: 0.63rem;
  }
  .bottom-nav-fab {
    width: 48px;
    height: 48px;
    justify-self: center;
  }
  body { padding-bottom: 104px; }
  body > header {
    justify-content: center;
    text-align: center;
  }
  body > header a,
  body > header .header-actions {
    display: none !important;
  }
}
