/* =====================================================================
   Financial Transaction Recorder - Application Stylesheet
   Modern SaaS look: soft shadows, glassmorphism accents, dark/light mode
   ===================================================================== */

:root {
  --ftr-primary: #4f46e5;
  --ftr-primary-dark: #4338ca;
  --ftr-accent: #06b6d4;
  --ftr-success: #16a34a;
  --ftr-danger: #dc2626;
  --ftr-warning: #d97706;
  --ftr-bg: #f4f6fb;
  --ftr-surface: #ffffff;
  --ftr-surface-glass: rgba(255, 255, 255, 0.65);
  --ftr-border: #e6e9f2;
  --ftr-text: #1f2430;
  --ftr-text-muted: #6b7280;
  --ftr-sidebar-bg: #12142a;
  --ftr-sidebar-text: #c9cbe0;
  --sidebar-width: 260px;
  --sidebar-width-collapsed: 78px;
  --topbar-height: 68px;
}

[data-bs-theme="dark"] {
  --ftr-bg: #0f1120;
  --ftr-surface: #171a2e;
  --ftr-surface-glass: rgba(23, 26, 46, 0.65);
  --ftr-border: #262a45;
  --ftr-text: #e7e9f5;
  --ftr-text-muted: #9295b3;
  --ftr-sidebar-bg: #0b0c1a;
  --ftr-sidebar-text: #aeb1cf;
}

* { box-sizing: border-box; }

body {
  background: var(--ftr-bg);
  color: var(--ftr-text);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  transition: background-color .25s ease, color .25s ease;
}

a { text-decoration: none; }

/* ---------------- Layout ---------------- */
.ftr-app {
  display: flex;
  min-height: 100vh;
}

.ftr-sidebar {
  width: var(--sidebar-width);
  background: var(--ftr-sidebar-bg);
  color: var(--ftr-sidebar-text);
  flex-shrink: 0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 1030;
  display: flex;
  flex-direction: column;
  transition: width .2s ease, transform .2s ease;
  overflow-x: hidden;
}
.ftr-sidebar.collapsed { width: var(--sidebar-width-collapsed); }

.ftr-sidebar .brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.1rem 1.2rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.ftr-sidebar .brand .logo-badge {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--ftr-primary), var(--ftr-accent));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.ftr-nav { padding: .75rem .6rem; flex: 1; overflow-y: auto; }
.ftr-nav .nav-section-title {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: #6d7096; padding: .9rem .8rem .3rem;
  white-space: nowrap;
}
.ftr-nav .nav-link {
  color: var(--ftr-sidebar-text);
  border-radius: 10px;
  padding: .62rem .8rem;
  display: flex; align-items: center; gap: .75rem;
  font-size: .89rem;
  margin-bottom: 2px;
  white-space: nowrap;
}
.ftr-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.ftr-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.ftr-nav .nav-link.active {
  background: linear-gradient(135deg, var(--ftr-primary), var(--ftr-primary-dark));
  color: #fff;
  box-shadow: 0 4px 14px rgba(79,70,229,.35);
}
.ftr-sidebar.collapsed .nav-link span,
.ftr-sidebar.collapsed .brand span,
.ftr-sidebar.collapsed .nav-section-title { display: none; }

.ftr-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  transition: margin-left .2s ease;
}
.ftr-main.expanded { margin-left: var(--sidebar-width-collapsed); }

.ftr-topbar {
  height: var(--topbar-height);
  background: var(--ftr-surface-glass);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ftr-border);
  display: flex; align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  position: sticky; top: 0; z-index: 1020;
}

.ftr-content { padding: 1.5rem; }

/* ---------------- Cards ---------------- */
.card {
  border: 1px solid var(--ftr-border);
  background: var(--ftr-surface);
  border-radius: 16px;
  color: var(--ftr-text);
}
.card-glass {
  background: var(--ftr-surface-glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--ftr-border);
}

.stat-card {
  border-radius: 18px;
  padding: 1.25rem 1.4rem;
  border: 1px solid var(--ftr-border);
  background: var(--ftr-surface);
  position: relative;
  overflow: hidden;
  height: 100%;
}
.stat-card .stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: #fff;
  margin-bottom: .75rem;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-card .stat-label { color: var(--ftr-text-muted); font-size: .82rem; }
.bg-grad-indigo { background: linear-gradient(135deg,#4f46e5,#6366f1); }
.bg-grad-cyan { background: linear-gradient(135deg,#06b6d4,#0891b2); }
.bg-grad-green { background: linear-gradient(135deg,#16a34a,#22c55e); }
.bg-grad-red { background: linear-gradient(135deg,#dc2626,#ef4444); }
.bg-grad-amber { background: linear-gradient(135deg,#d97706,#f59e0b); }
.bg-grad-purple { background: linear-gradient(135deg,#7c3aed,#a855f7); }

/* ---------------- Auth pages ---------------- */
.ftr-auth-wrapper {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at top left, #4f46e5 0%, #1e1b4b 45%, #0f1120 100%);
  padding: 1.5rem;
}
.ftr-auth-card {
  width: 100%; max-width: 420px;
  background: rgba(255,255,255,.92);
  border-radius: 20px;
  padding: 2.2rem 2rem;
  box-shadow: 0 25px 60px rgba(0,0,0,.35);
  backdrop-filter: blur(12px);
}
[data-bs-theme="dark"] .ftr-auth-card { background: rgba(23,26,46,.9); color: var(--ftr-text); }
.ftr-auth-logo {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, var(--ftr-primary), var(--ftr-accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.6rem; margin: 0 auto 1rem;
}

/* ---------------- Tables ---------------- */
.table-modern thead th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ftr-text-muted); border-bottom-width: 1px;
  cursor: pointer; user-select: none; white-space: nowrap;
}
.table-modern thead th.sortable:hover { color: var(--ftr-primary); }
.table-modern thead th i { font-size: .7rem; opacity: .5; }
.table-modern td, .table-modern th { vertical-align: middle; }
.badge-credit { background: rgba(22,163,74,.12); color: #16a34a; }
.badge-debit { background: rgba(220,38,38,.12); color: #dc2626; }

/* ---------------- Misc ---------------- */
.doc-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  background: rgba(79,70,229,.08); color: var(--ftr-primary);
  padding: .3rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  border: none; cursor: pointer;
}
[data-bs-theme="dark"] .doc-chip { background: rgba(99,102,241,.18); }

.dropzone {
  border: 2px dashed var(--ftr-border);
  border-radius: 14px;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ftr-text-muted);
  transition: border-color .15s ease, background-color .15s ease;
  cursor: pointer;
}
.dropzone.dragover { border-color: var(--ftr-primary); background: rgba(79,70,229,.06); }

.skeleton {
  background: linear-gradient(90deg, var(--ftr-border) 25%, #f0f1f7 37%, var(--ftr-border) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: 8px;
}
[data-bs-theme="dark"] .skeleton { background: linear-gradient(90deg, #262a45 25%, #33375a 37%, #262a45 63%); background-size: 400% 100%; }
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.toast-stack { position: fixed; top: 1rem; right: 1rem; z-index: 2000; }

.file-preview-thumb {
  width: 100%; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--ftr-border);
}
.upload-item {
  border: 1px solid var(--ftr-border); border-radius: 10px; padding: .5rem .7rem;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem;
  background: var(--ftr-surface);
}

.avatar-circle {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--ftr-primary), var(--ftr-accent));
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem;
}

.sidebar-toggle-btn, .theme-toggle-btn, .icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--ftr-border);
  background: var(--ftr-surface);
  color: var(--ftr-text);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover, .sidebar-toggle-btn:hover, .theme-toggle-btn:hover { background: var(--ftr-bg); }

@media (max-width: 991.98px) {
  .ftr-sidebar { transform: translateX(-100%); }
  .ftr-sidebar.mobile-open { transform: translateX(0); }
  .ftr-main, .ftr-main.expanded { margin-left: 0; }
}

@media (max-width: 767.98px) {
  .ftr-content { padding: 1rem; }
  .ftr-topbar { padding: 0 .85rem; gap: .5rem; }
  .stat-card { padding: 1rem 1.1rem; }
  .stat-card .stat-value { font-size: 1.35rem; }
  .ftr-auth-card { padding: 1.6rem 1.3rem; }
}

@media (max-width: 575.98px) {
  .avatar-circle { width: 32px; height: 32px; font-size: .78rem; }
  .ftr-topbar .fw-semibold.small { font-size: .78rem; }
}
