/* ============================================================
   ThriftNest — "The Circle & The Weave"
   Design language drawn from Nigerian ajo savings circles and
   woven market baskets: money grows the way a nest is built —
   many small contributions, woven together, taking turns.
   ============================================================ */

:root {
  /* ---- Palette ---- */
  --ink: #16241D;
  --ink-soft: #55604F;
  --ink-faint: #8A9282;
  --paper: #F2F4EC;
  --surface: #FFFFFF;
  --surface-sunken: #EBEEE1;
  --line: #DFE0D2;
  --line-strong: #C7CAB6;

  --jade: #146B4B;
  --jade-deep: #0E4E37;
  --jade-tint: #E3F0E8;

  --indigo: #2E3E82;
  --indigo-deep: #212D61;
  --indigo-tint: #E7E9F5;

  --ochre: #C98A2E;
  --ochre-deep: #9C6A1F;
  --ochre-tint: #FBF0DD;

  --brick: #A84632;
  --brick-deep: #833626;
  --brick-tint: #F7E7E2;

  /* ---- Type ---- */
  --font-display: 'Source Serif 4', Georgia, serif;
  --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', Consolas, monospace;

  /* ---- Shape / shadow ---- */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-card: 0 1px 2px rgba(22, 36, 29, 0.05), 0 6px 20px -8px rgba(22, 36, 29, 0.12);
  --shadow-pop: 0 12px 32px -8px rgba(22, 36, 29, 0.22);

  /* legacy aliases kept so any un-migrated markup still renders sanely */
  --color-primary: var(--jade);
  --color-primary-dark: var(--jade-deep);
  --color-accent: var(--indigo);
  --color-bg: var(--paper);
  --color-surface: var(--surface);
  --color-text: var(--ink);
  --color-text-muted: var(--ink-soft);
  --color-border: var(--line);
  --color-success: var(--jade);
  --color-warning: var(--ochre-deep);
  --color-danger: var(--brick);
  --color-info: var(--indigo);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; color: var(--ink); margin: 0; }
h1 { font-size: clamp(1.9rem, 4vw, 3rem); line-height: 1.08; }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); line-height: 1.15; }
h3 { font-size: 1.05rem; font-weight: 600; }

p { margin: 0 0 0.9rem; color: var(--ink-soft); }
a { color: var(--jade); text-decoration: none; }
a:hover { color: var(--jade-deep); text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--indigo); outline-offset: 2px;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 1.5rem; }

.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 26px; height: 26px; }

/* ================= Site header (public marketing) ================= */
.site-header {
  background: rgba(242, 244, 236, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.public-nav { display: flex; align-items: center; justify-content: space-between; height: 76px; }
.brand { display: flex; align-items: center; gap: 0.55rem; font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; color: var(--ink); }
.brand-badge {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--jade); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  flex-shrink: 0;
}
.public-nav-links { display: flex; align-items: center; gap: 2rem; }
.public-nav-links a { color: var(--ink); font-size: 0.9rem; font-weight: 500; }
.public-nav-links a:hover { color: var(--jade); text-decoration: none; }
.public-nav-links a.active { color: var(--jade); }
.header-actions { display: flex; align-items: center; gap: 0.65rem; }
.mobile-nav-toggle {
  display: none; width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  align-items: center; justify-content: center; cursor: pointer;
}

.mobile-nav-panel {
  display: none; position: fixed; inset: 76px 0 0 0; z-index: 39;
  background: var(--paper); padding: 1.5rem; overflow-y: auto;
}
.mobile-nav-panel.is-open { display: block; }
.mobile-nav-panel nav { display: flex; flex-direction: column; gap: 0.25rem; }
.mobile-nav-panel a { padding: 0.85rem 0.25rem; font-size: 1.05rem; border-bottom: 1px solid var(--line); color: var(--ink); }
.mobile-nav-panel .header-actions { flex-direction: column; margin-top: 1.5rem; display: flex; }
.mobile-nav-panel .btn { width: 100%; }

/* ================= Buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.7rem 1.25rem; border-radius: 999px;
  font-weight: 600; font-size: 0.88rem; font-family: var(--font-sans);
  border: 1px solid transparent; cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--jade); color: #fff; }
.btn-primary:hover { background: var(--jade-deep); color: #fff; box-shadow: 0 6px 16px -6px rgba(20, 107, 75, 0.5); }
.btn-accent { background: var(--indigo); color: #fff; }
.btn-accent:hover { background: var(--indigo-deep); color: #fff; box-shadow: 0 6px 16px -6px rgba(46, 62, 130, 0.5); }
.btn-outline { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover { border-color: var(--jade); color: var(--jade); background: var(--jade-tint); }
.btn-danger { background: var(--brick); color: #fff; }
.btn-danger:hover { background: var(--brick-deep); color: #fff; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* ================= Cards ================= */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
  padding: 1.5rem;
}

/* ================= Forms ================= */
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-weight: 600; font-size: 0.82rem; margin-bottom: 0.4rem; color: var(--ink); }
.form-control {
  width: 100%; padding: 0.75rem 0.95rem;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  font-size: 0.95rem; font-family: var(--font-sans); background: var(--surface); color: var(--ink);
}
.form-control:focus { outline: none; border-color: var(--jade); box-shadow: 0 0 0 3px var(--jade-tint); }
.form-error { color: var(--brick); font-size: 0.8rem; margin-top: 0.35rem; }
.form-hint { color: var(--ink-faint); font-size: 0.8rem; margin-top: 0.35rem; }

/* ================= Alerts ================= */
.alert { padding: 0.9rem 1.1rem; border-radius: var(--radius-sm); margin-bottom: 1.1rem; font-size: 0.88rem; border: 1px solid transparent; }
.alert-success { background: var(--jade-tint); color: var(--jade-deep); border-color: #bcdfc9; }
.alert-danger  { background: var(--brick-tint); color: var(--brick-deep); border-color: #e6c3b8; }
.alert-warning { background: var(--ochre-tint); color: var(--ochre-deep); border-color: #edd6a6; }
.alert-info    { background: var(--indigo-tint); color: var(--indigo-deep); border-color: #c6cae8; }

/* ================= Modal ================= */
.modal-backdrop { position: fixed; inset: 0; background: rgba(22, 36, 29, 0.5); display: none; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal-backdrop.is-open { display: flex; }
.modal-box { background: var(--surface); border-radius: var(--radius-lg); padding: 1.5rem; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.modal-close { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--ink-soft); }

/* ================= Footer ================= */
.site-footer { background: var(--ink); color: #C8CFC1; padding: 3.5rem 0 1.75rem; margin-top: 4rem; }
.site-footer .brand { color: #fff; }
.site-footer .brand-badge { background: var(--jade); }
.site-footer a { color: #C8CFC1; }
.site-footer a:hover { color: #fff; }
.site-footer h4 { color: #fff; font-family: var(--font-sans); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; margin-bottom: 0.85rem; }
.footer-grid { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 2rem; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,0.12); margin-top: 2.5rem; padding-top: 1.4rem; text-align: center; font-size: 0.8rem; color: #8A9282; }

@media (max-width: 768px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }

/* ==================== Woven divider (signature motif) ==================== */
.woven-divider { height: 28px; width: 100%; overflow: hidden; }
.woven-divider svg { width: 100%; height: 100%; display: block; }

/* ==================== Landing page ==================== */
.hero { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 3rem; align-items: center; padding: 4rem 0 3rem; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--jade-tint); color: var(--jade-deep);
  padding: 0.35rem 0.8rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; margin-bottom: 1.25rem;
}
.hero h1 { margin-bottom: 1.1rem; }
.hero h1 .accent { color: var(--jade); font-style: italic; }
.hero p.lead { color: var(--ink-soft); font-size: 1.08rem; margin-bottom: 1.75rem; max-width: 460px; }
.hero-actions { display: flex; gap: 0.85rem; flex-wrap: wrap; }

.ajo-ring-wrap { display: flex; align-items: center; justify-content: center; padding: 1rem; }
.ajo-ring-wrap svg { width: 100%; max-width: 380px; height: auto; }

.section-heading { text-align: center; margin: 4rem 0 2.5rem; }
.section-heading .eyebrow { display: block; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--jade); margin-bottom: 0.6rem; }
.section-heading h2 { margin-bottom: 0.5rem; }
.section-heading p { max-width: 480px; margin: 0 auto; }

.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }
.feature-card { text-align: left; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-pop); }
.feature-icon { width: 46px; height: 46px; border-radius: 13px; display: flex; align-items: center; justify-content: center; margin-bottom: 1rem; }
.feature-icon.jade { background: var(--jade-tint); color: var(--jade-deep); }
.feature-icon.indigo { background: var(--indigo-tint); color: var(--indigo-deep); }
.feature-icon.ochre { background: var(--ochre-tint); color: var(--ochre-deep); }
.feature-icon.brick { background: var(--brick-tint); color: var(--brick-deep); }
.feature-card h3 { margin-bottom: 0.45rem; }
.feature-card p { font-size: 0.87rem; margin-bottom: 0.75rem; }
.feature-card a { font-size: 0.85rem; font-weight: 700; }

.stats-bar {
  background: var(--ink); color: #fff; border-radius: var(--radius-lg);
  padding: 2.5rem 2rem; margin: 4rem 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; text-align: center;
}
.stats-bar .stat-value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; }
.stats-bar .stat-label { font-size: 0.78rem; color: #9BA491; margin-top: 0.2rem; }

@media (max-width: 900px) {
  .public-nav-links, .header-actions { display: none; }
  .mobile-nav-toggle { display: flex; }
  .hero { grid-template-columns: 1fr; padding: 2.5rem 0 2rem; text-align: center; }
  .hero p.lead { margin-left: auto; margin-right: auto; }
  .hero-actions { justify-content: center; }
  .ajo-ring-wrap { order: -1; }
  .feature-grid { grid-template-columns: 1fr 1fr; }
  .stats-bar { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .feature-grid { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: 1fr; }
}

/* ==================== Auth pages ==================== */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; background: var(--paper); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 1.55rem; margin: 0 0 0.4rem; text-align: center; }
.auth-card p.subtitle { text-align: center; color: var(--ink-soft); font-size: 0.9rem; margin-bottom: 1.6rem; }
.auth-footer-link { text-align: center; font-size: 0.85rem; margin-top: 1.1rem; color: var(--ink-soft); }
.auth-back { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 1.5rem; }

/* ==================== Dashboard (sidebar layout) ==================== */
.dashboard-shell { display: flex; min-height: 100vh; }
.dashboard-sidebar {
  width: 258px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--line); padding: 1.5rem 1.1rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 50;
}
.dashboard-sidebar .brand { margin-bottom: 2rem; padding: 0 0.4rem; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm); font-size: 0.87rem; font-weight: 500;
  color: var(--ink-soft); margin-bottom: 0.15rem;
}
.sidebar-nav a:hover { background: var(--surface-sunken); text-decoration: none; color: var(--ink); }
.sidebar-nav a.active { background: var(--jade); color: #fff; }
.sidebar-nav a.active .icon { stroke: #fff; }
.sidebar-nav .nav-badge {
  margin-left: auto; background: var(--brick); color: #fff;
  font-size: 0.68rem; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.sidebar-logout { color: var(--brick) !important; margin-top: 0.5rem; border-top: 1px solid var(--line); padding-top: 0.85rem !important; }

.dashboard-topbar-mobile {
  display: none; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 45;
}
.sidebar-scrim { display: none; position: fixed; inset: 0; background: rgba(22,36,29,0.45); z-index: 49; }
.sidebar-scrim.is-open { display: block; }

.dashboard-main { flex: 1; min-width: 0; padding: 2rem 2.25rem; }
.dashboard-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.75rem; flex-wrap: wrap; gap: 1rem; }
.dashboard-topbar h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.dashboard-topbar p { color: var(--ink-soft); font-size: 0.9rem; margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.1rem; margin-bottom: 1.5rem; }
.stat-card { padding: 1.25rem; }
.stat-card-top { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.9rem; }
.stat-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon.jade { background: var(--jade-tint); color: var(--jade-deep); }
.stat-icon.indigo { background: var(--indigo-tint); color: var(--indigo-deep); }
.stat-icon.ochre { background: var(--ochre-tint); color: var(--ochre-deep); }
.stat-icon.brick { background: var(--brick-tint); color: var(--brick-deep); }
.stat-card .stat-tag { font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); }
.stat-card .stat-value { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 500; letter-spacing: -0.01em; }
.stat-card .stat-label { font-size: 0.78rem; color: var(--ink-faint); margin-top: 0.15rem; }

.dashboard-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.25rem; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.1rem; }
.panel-heading h3 { margin: 0; }
.panel-heading a { font-size: 0.83rem; font-weight: 600; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ink-soft); }
.empty-state .icon-lg { color: var(--ink-faint); margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.88rem; }
.empty-state .btn { margin-top: 0.85rem; }

.txn-row { display: flex; align-items: center; gap: 0.85rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.txn-row:last-child { border-bottom: none; }
.txn-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.txn-icon.credit { background: var(--jade-tint); color: var(--jade-deep); }
.txn-icon.debit { background: var(--brick-tint); color: var(--brick-deep); }
.txn-body { flex: 1; min-width: 0; }
.txn-desc { font-size: 0.87rem; font-weight: 500; }
.txn-date { font-size: 0.76rem; color: var(--ink-faint); }
.txn-amount { font-family: var(--font-mono); font-size: 0.9rem; font-weight: 500; white-space: nowrap; }
.txn-amount.credit { color: var(--jade-deep); }
.txn-amount.debit { color: var(--brick-deep); }

@media (max-width: 900px) {
  .dashboard-sidebar {
    position: fixed; left: 0; top: 0; height: 100vh;
    transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: var(--shadow-pop);
  }
  .dashboard-sidebar.is-open { transform: translateX(0); }
  .dashboard-topbar-mobile { display: flex; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-main { padding: 1.5rem 1.25rem; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .dashboard-topbar { flex-direction: column; align-items: flex-start; }
  .dashboard-topbar > div:last-child { width: 100%; }
  .dashboard-topbar .btn { flex: 1; }
}

/* ==================== Reduced motion ==================== */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}