/* =========================================================
   REPORTS MODULE — PRO SAAS LAYOUT
   Mirrors the Settings module (lifted rail + workspace).
   Scoped to .reports-pro only. App navbar / main sidebar / router untouched.
   ========================================================= */
.reports-pro{
  --rp-green:#059669;--rp-green-2:#10b981;--rp-green-soft:#ecfdf5;--rp-ink:#0f172a;--rp-muted:#64748b;--rp-line:#e2e8f0;--rp-line-2:#edf2f7;--rp-bg:#f8fafc;--rp-card:#fff;
  --rp-page-pad-top:24px;--rp-page-pad-x:30px;--rp-page-pad-bottom:22px;--rp-rail-top:24px;
  min-height:calc(100dvh - var(--navbar-height));overflow:visible;background:linear-gradient(135deg,#f8fafc 0%,#ffffff 44%,#f0fdf4 100%);color:var(--rp-ink);font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}
/* Window-level scroll context (same model as Settings): keep app-content overflow
   visible so the lifted sticky rail pins to the window, and hide the global navbar
   search on this page only so the rail can rise to the app sidebar's brand line. */
body:has(.reports-pro) .app-content{overflow:visible!important;padding:0!important;}
body:has(.reports-pro) .navbar-search{display:none!important;}
.reports-pro *{box-sizing:border-box;}
.reports-pro-shell{display:grid;grid-template-columns:310px minmax(0,1fr);gap:30px;padding:var(--rp-page-pad-top) var(--rp-page-pad-x) var(--rp-page-pad-bottom);overflow:visible;align-items:start;}

/* ===================== RAIL ===================== */
.reports-rail{
  position:sticky;top:var(--rp-rail-top);
  margin-top:calc(var(--rp-rail-top) - var(--navbar-height) - var(--rp-page-pad-top));
  z-index:55;
  height:calc(100dvh - var(--rp-rail-top) - var(--rp-page-pad-bottom));
  min-height:0;align-self:start;
  border:1px solid var(--rp-line);background:rgba(255,255,255,.9);backdrop-filter:blur(16px);border-radius:22px;box-shadow:0 18px 45px rgba(15,23,42,.08);display:flex;flex-direction:column;overflow:hidden;
}
.rp-nav-title{padding:22px 22px 14px;border-bottom:1px solid var(--rp-line-2);}
.rp-nav-title h2{margin:0;font-size:21px;font-weight:900;letter-spacing:-.04em;color:#020617;}
.rp-nav-title p{margin:6px 0 0;color:var(--rp-muted);font-size:12px;font-weight:700;}
.rp-search{height:42px;margin:16px 18px 12px;border:1px solid var(--rp-line);border-radius:13px;background:#fff;display:flex;align-items:center;gap:10px;padding:0 13px;color:#94a3b8;flex:0 0 auto;}
.rp-search input{border:0;outline:0;width:100%;font-size:13px;font-weight:700;color:var(--rp-ink);background:transparent;}
.reports-rail nav{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;padding:0 12px 12px;scrollbar-width:thin;overscroll-behavior:contain;}
.reports-rail nav::-webkit-scrollbar,.rp-table-wrap::-webkit-scrollbar{width:6px;height:6px;}
.reports-rail nav::-webkit-scrollbar-thumb,.rp-table-wrap::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:999px;}
.rp-group{border-bottom:1px solid var(--rp-line-2);padding:5px 0;}
.rp-group-btn{width:100%;height:48px;border:0;background:transparent;border-radius:14px;display:grid;grid-template-columns:38px 1fr 20px;align-items:center;gap:10px;padding:0 10px;cursor:pointer;color:#334155;text-align:left;transition:.16s ease;}
.rp-group-btn:hover{background:#f8fafc;color:var(--rp-green);}
.rp-group.active-group>.rp-group-btn{color:var(--rp-green);}
.rp-group-btn>span{width:34px;height:34px;border-radius:12px;background:#f1f5f9;display:grid;place-items:center;color:inherit;}
.rp-group.active-group .rp-group-btn>span{background:var(--rp-green-soft);color:var(--rp-green);}
.rp-group-btn b{font-size:13px;font-weight:900;letter-spacing:-.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.rp-group-btn>.fa-chevron-down{font-size:11px;transition:.18s ease;color:#94a3b8;}
.rp-group.open .rp-group-btn>.fa-chevron-down{transform:rotate(180deg);color:var(--rp-green);}
.rp-subnav{display:none;padding:2px 0 8px 49px;position:relative;}
.rp-group.open .rp-subnav{display:flex;flex-direction:column;gap:3px;}
.rp-subnav:before{content:"";position:absolute;left:27px;top:4px;bottom:14px;width:1px;background:#dbe5ee;}
.rp-subitem{height:34px;border:0;background:transparent;border-radius:10px;color:#475569;font-size:12px;font-weight:800;text-align:left;padding:0 10px;cursor:pointer;transition:.15s ease;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.rp-subitem:hover{background:#f0fdf4;color:var(--rp-green);}
.rp-subitem.active{background:var(--rp-green);color:#fff;box-shadow:0 10px 22px rgba(5,150,105,.18);}

/* ===================== WORKSPACE ===================== */
.reports-workspace{min-width:0;overflow:visible;}
.rp-workspace-head{margin-bottom:18px;padding:6px 0 16px;display:flex;align-items:flex-start;justify-content:space-between;gap:22px;}
.rp-workspace-head span{display:inline-flex;margin-bottom:7px;color:var(--rp-green);font-size:12px;font-weight:900;text-transform:uppercase;letter-spacing:.06em;}
.rp-workspace-head h1{margin:0;color:#020617;font-size:26px;font-weight:900;letter-spacing:-.045em;line-height:1.1;}
.rp-workspace-head p{margin:8px 0 0;color:var(--rp-muted);font-size:13px;font-weight:700;max-width:640px;}
.rp-head-actions{display:flex;align-items:center;gap:12px;flex:0 0 auto;}
.rp-btn{height:44px;border-radius:13px;border:1px solid transparent;display:inline-flex;align-items:center;justify-content:center;gap:9px;padding:0 16px;font-size:13px;font-weight:900;cursor:pointer;transition:.16s ease;text-decoration:none;white-space:nowrap;}
.rp-btn-primary{background:linear-gradient(135deg,#059669,#10b981);color:#fff;box-shadow:0 16px 35px rgba(5,150,105,.22);}
.rp-btn-primary:hover{transform:translateY(-1px);box-shadow:0 20px 42px rgba(5,150,105,.28);}
.rp-btn-secondary{background:#fff;color:#334155;border-color:var(--rp-line);box-shadow:0 8px 20px rgba(15,23,42,.04);}
.rp-btn-secondary:hover{background:#f8fafc;color:var(--rp-green);}

.rp-kpi-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:16px;margin-bottom:18px;}
.rp-kpi{background:rgba(255,255,255,.94);border:1px solid var(--rp-line);border-radius:18px;padding:18px;box-shadow:0 12px 32px rgba(15,23,42,.06);}
.rp-kpi span{display:block;color:var(--rp-muted);font-size:11px;font-weight:900;margin-bottom:8px;text-transform:uppercase;letter-spacing:.05em;}
.rp-kpi strong{font-size:24px;font-weight:900;color:#020617;letter-spacing:-.03em;}
.rp-kpi small{display:block;margin-top:6px;color:var(--rp-green);font-size:12px;font-weight:800;}

.rp-card{background:rgba(255,255,255,.96);border:1px solid var(--rp-line);border-radius:20px;padding:20px;box-shadow:0 18px 44px rgba(15,23,42,.07);margin-bottom:18px;}
.rp-card:last-child{margin-bottom:0;}
.rp-card-head{display:flex;align-items:center;gap:13px;margin-bottom:16px;}
.rp-card-head .rp-i{width:38px;height:38px;border-radius:13px;background:var(--rp-green-soft);color:var(--rp-green);display:grid;place-items:center;flex:0 0 auto;}
.rp-card-head h3{margin:0;font-size:15px;font-weight:900;letter-spacing:-.03em;color:#020617;}
.rp-card-head p{margin:2px 0 0;font-size:12px;font-weight:700;color:var(--rp-muted);}
.rp-card-head .rp-spacer{margin-left:auto;}

.rp-filters{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:14px;}
.rp-field{display:flex;flex-direction:column;gap:7px;min-width:0;}
.rp-field span{font-size:12px;font-weight:900;color:#334155;}
.rp-field input,.rp-field select{width:100%;min-height:42px;border:1px solid #dbe3ed;border-radius:12px;background:#fff;color:#0f172a;font-size:13px;font-weight:750;outline:0;padding:0 13px;transition:.16s ease;}
.rp-field input:focus,.rp-field select:focus{border-color:#10b981;box-shadow:0 0 0 4px rgba(16,185,129,.12);}

.rp-table-wrap{overflow:auto;border:1px solid var(--rp-line);border-radius:16px;background:#fff;}
.rp-table{width:100%;border-collapse:separate;border-spacing:0;min-width:680px;}
.rp-table th{height:46px;padding:0 18px;text-align:left;background:#f8fafc;color:#475569;font-size:11px;font-weight:900;text-transform:uppercase;letter-spacing:.05em;border-bottom:1px solid var(--rp-line);white-space:nowrap;}
.rp-table td{padding:13px 18px;border-bottom:1px solid #eef2f7;font-size:13px;font-weight:700;color:#334155;}
.rp-table tbody tr:last-child td{border-bottom:0;}
.rp-table th.num,.rp-table td.num{text-align:right;}
.rp-table td.rp-empty-cell{padding:0;}

.rp-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:12px;padding:46px 24px;color:var(--rp-muted);}
.rp-empty i{width:64px;height:64px;border-radius:20px;background:var(--rp-green-soft);color:var(--rp-green);display:grid;place-items:center;font-size:26px;}
.rp-empty b{font-size:15px;font-weight:900;color:#0f172a;}
.rp-empty small{font-size:12.5px;font-weight:700;max-width:420px;line-height:1.5;}

/* Profit & Loss statement view */
.rp-pnl{display:flex;flex-direction:column;gap:3px;}
.rp-pnl-row{display:flex;align-items:center;justify-content:space-between;padding:13px 16px;border-radius:12px;font-size:13.5px;font-weight:800;color:#334155;}
.rp-pnl-row.alt{background:#f8fafc;}
.rp-pnl-row.sub{background:#f1f5f9;font-weight:900;color:#0f172a;}
.rp-pnl-row.total{background:var(--rp-green-soft);color:#047857;font-size:15.5px;font-weight:900;}
.rp-pnl-row .rp-amt{font-variant-numeric:tabular-nums;}
.rp-pnl-row .neg{color:#dc2626;}

/* ===================== RESPONSIVE ===================== */
@media(max-width:1280px){
  .reports-pro{--rp-page-pad-top:22px;--rp-page-pad-x:22px;--rp-page-pad-bottom:20px;}
  .reports-pro-shell{grid-template-columns:290px minmax(0,1fr);gap:22px;}
}
@media(max-width:920px){
  body:has(.reports-pro) .app-content{overflow:visible!important;}
  body:has(.reports-pro) .navbar-search{display:flex!important;}
  .reports-pro-shell{grid-template-columns:1fr;}
  .reports-rail{position:relative;top:auto;margin-top:0;z-index:auto;height:auto;max-height:none;}
  .reports-rail nav{max-height:430px;}
  .rp-workspace-head{flex-direction:column;align-items:stretch;}
  .rp-head-actions{justify-content:flex-end;}
}
@media(max-width:560px){
  .reports-pro-shell{padding:14px;}
  .rp-head-actions{flex-direction:column;}
  .rp-btn{width:100%;}
  .rp-card{padding:16px;border-radius:17px;}
  .rp-workspace-head h1{font-size:22px;}
}


/* =========================================================
   REPORTS — INTERNAL-SCROLL VIEWPORT (MIRRORS SETTINGS v22)
   Purpose: give Reports the exact same "contained section" feel
   as the Settings module. The module owns its own viewport below
   the navbar; the body does NOT scroll. The rail is a relatively
   positioned full-height card (no sticky / negative-margin lift),
   and the rail + workspace each scroll internally. This replaces
   the older sticky-rail + window-scroll model defined above
   (later rules win at equal specificity).
   Scope: Reports module only. Navbar, app sidebar, router untouched.
   ========================================================= */
body:has(.reports-pro){
  overflow:hidden !important;
  background:#f8fafc !important;
}
/* Pin the height chain so .app-content has a fixed height to scroll inside.
   Without these the height collapses to content and nothing scrolls. */
body:has(.reports-pro) .app-shell{
  height:100dvh !important;
  min-height:100dvh !important;
  overflow:hidden !important;
}
body:has(.reports-pro) .main-section{
  height:100dvh !important;
  min-height:0 !important;
  overflow:hidden !important;
}
body:has(.reports-pro) .app-content{
  grid-row:2 !important;
  height:auto !important;
  min-height:0 !important;
  max-height:none !important;
  overflow:hidden !important;
  padding:0 !important;
  background:linear-gradient(135deg,#f8fafc 0%,#ffffff 44%,#f0fdf4 100%) !important;
}
.reports-pro{
  height:calc(100% - 12px) !important;
  min-height:0 !important;
  max-height:100% !important;
  overflow:hidden !important;
  background:linear-gradient(135deg,#f8fafc 0%,#ffffff 44%,#f0fdf4 100%) !important;
}
.reports-pro-shell{
  height:100% !important;
  min-height:0 !important;
  max-height:100% !important;
  overflow:hidden !important;
  align-items:stretch !important;
  /* Same visual rhythm as settings-premium: 30px sides, 22px footer breathing room. */
  padding:18px 30px 22px 30px !important;
}
/* Rail becomes a self-contained full-height card (drop the sticky lift). */
.reports-rail{
  position:relative !important;
  top:auto !important;
  margin-top:0 !important;
  transform:none !important;
  z-index:2 !important;
  height:100% !important;
  min-height:0 !important;
  max-height:100% !important;
  align-self:stretch !important;
  overflow:hidden !important;
}
.reports-rail nav{
  flex:1 1 auto !important;
  min-height:0 !important;
  height:auto !important;
  max-height:none !important;
  overflow-y:auto !important;
  overflow-x:hidden !important;
  padding-bottom:12px !important;
  overscroll-behavior:contain !important;
}
.reports-workspace{
  height:100% !important;
  min-height:0 !important;
  max-height:100% !important;
  overflow-y:auto !important;
  overflow-x:hidden !important;
  padding-right:2px !important;
  padding-bottom:12px !important;
  scroll-behavior:auto !important;
  overscroll-behavior:contain !important;
}
.reports-workspace::-webkit-scrollbar{width:6px;height:6px;}
.reports-workspace::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:999px;}
.reports-workspace .rp-workspace-head{
  margin-top:0 !important;
  padding-top:0 !important;
}
.reports-workspace > :last-child{
  margin-bottom:0 !important;
}

/* Mobile: release the locked viewport and fall back to natural flow. */
@media(max-width:920px){
  body:has(.reports-pro){overflow:auto !important;}
  body:has(.reports-pro) .app-shell{
    height:auto !important;
    min-height:0 !important;
    overflow:visible !important;
  }
  body:has(.reports-pro) .main-section{
    height:auto !important;
    grid-template-rows:auto auto !important;
    overflow:visible !important;
  }
  body:has(.reports-pro) .app-content,
  .reports-pro,
  .reports-pro-shell,
  .reports-rail,
  .reports-workspace{
    height:auto !important;
    max-height:none !important;
    overflow:visible !important;
  }
  .reports-pro-shell{
    padding:16px 14px 16px 14px !important;
  }
  .reports-rail nav{
    max-height:430px !important;
    overflow-y:auto !important;
  }
}
@media(max-width:1280px){
  .reports-pro-shell{
    padding:16px 22px 12px 22px !important;
  }
}


/* =========================================================
   DIRECT TABLE PAGINATION FOOTER
   ========================================================= */
.reports-pro .rp-table-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-top: 0.5px solid #E5E7EB; background: #ffffff; }
.reports-pro .rp-page-size-control { display: inline-flex; align-items: center; gap: 8px; color: #374151; font-size: 14px; font-weight: 500; white-space: nowrap; }
.reports-pro .rp-page-size-control select { width: 56px; height: 36px; border: 0.5px solid #E5E7EB; border-radius: 8px; background: #ffffff; color: #111827; font-size: 14px; font-weight: 600; padding: 0 8px; outline: none; }
.reports-pro .rp-page-range { flex: 1; text-align: center; color: #0F6E56; font-size: 14px; font-weight: 600; }
.reports-pro .rp-pagination { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; }
.reports-pro .rp-page-btn { width: 36px; height: 36px; border: 0.5px solid #E5E7EB; border-radius: 8px; background: #ffffff; color: #374151; font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.reports-pro .rp-page-btn:hover:not(:disabled):not(.active) { background: #F9FAFB; }
.reports-pro .rp-page-btn.active { background: #0F6E56; color: #ffffff; border-color: #0F6E56; }
.reports-pro .rp-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.reports-pro .rp-page-dots { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; color: #9CA3AF; font-weight: 700; }
@media (max-width: 640px) {
  .reports-pro .rp-table-footer { flex-direction: column; align-items: stretch; }
  .reports-pro .rp-page-range { order: 1; text-align: center; }
  .reports-pro .rp-page-size-control { order: 2; justify-content: center; }
  .reports-pro .rp-pagination { order: 3; justify-content: center; }
  .reports-pro .rp-page-btn:not(.active):not(:first-child):not(:last-child), .reports-pro .rp-page-dots { display: none; }
}
