/* =====================================================================
   ISSL × Grameenphone — Credit Collection CRM (Prototype)
   Theme: ISSL orange + Grameenphone blue, corporate Roboto typography
   ===================================================================== */

:root {
  /* Brand */
  --brand-orange: #F58220;      /* ISSL logo */
  --brand-orange-600: #DB6E0F;
  --brand-orange-50: #FEF3E8;
  --brand-blue: #00ACE7;        /* Grameenphone logo */
  --brand-blue-700: #0079B8;
  --brand-blue-800: #005E8F;
  --brand-blue-50: #E6F6FD;
  --brand-navy: #0B2239;

  /* Neutrals */
  --ink: #1B2733;
  --ink-2: #3E4C5A;
  --muted: #667585;
  --line: #E2E8EF;
  --line-2: #EEF2F6;
  --bg: #F3F6F9;
  --surface: #FFFFFF;

  /* Status */
  --ok: #1E8E5A;
  --ok-50: #E7F5EE;
  --warn: #B7791F;
  --warn-50: #FDF4E3;
  --bad: #C0392B;
  --bad-50: #FBEAE8;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 34, 57, .06), 0 1px 3px rgba(16, 34, 57, .05);
  --shadow-lg: 0 10px 30px rgba(16, 34, 57, .10);
  --sidebar-w: 256px;

  /* Bootstrap overrides */
  --bs-primary: var(--brand-blue-700);
  --bs-primary-rgb: 0, 121, 184;
  --bs-body-font-family: "Roboto", "Segoe UI", Arial, sans-serif;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--bg);
  --bs-border-color: var(--line);
  --bs-link-color: var(--brand-blue-700);
  --bs-link-hover-color: var(--brand-blue-800);
}

/* ---------- Modern Sleek Scrollbars ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(147, 161, 175, 0.35) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(147, 161, 175, 0.35);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.55);
}

::-webkit-scrollbar-button {
  display: none !important;
  width: 0;
  height: 0;
}

/* Sidebar Specific Scrollbar: Ultra-clean, subtle thumb on hover */
.sidebar,
#sidebar,
aside.sidebar {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.2s ease;
}

.sidebar:hover,
#sidebar:hover,
aside.sidebar:hover {
  scrollbar-color: rgba(147, 161, 175, 0.35) transparent;
}

.sidebar::-webkit-scrollbar,
#sidebar::-webkit-scrollbar,
aside.sidebar::-webkit-scrollbar {
  width: 5px;
}

.sidebar::-webkit-scrollbar-track,
#sidebar::-webkit-scrollbar-track,
aside.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
#sidebar::-webkit-scrollbar-thumb,
aside.sidebar::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 10px;
  transition: background 0.2s ease;
}

.sidebar:hover::-webkit-scrollbar-thumb,
#sidebar:hover::-webkit-scrollbar-thumb,
aside.sidebar:hover::-webkit-scrollbar-thumb {
  background: rgba(147, 161, 175, 0.35);
}

.sidebar::-webkit-scrollbar-thumb:hover,
#sidebar::-webkit-scrollbar-thumb:hover,
aside.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.55);
}

html, body { height: 100%; overflow-x: hidden; max-width: 100%; }
.main { overflow-x: hidden; max-width: 100%; }
body {
  font-family: var(--bs-body-font-family);
  font-size: 14px;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.num, .table td.num, .kpi-value { font-variant-numeric: tabular-nums; }
h1, h2, h3, h4, h5, h6 { color: var(--ink); font-weight: 600; letter-spacing: -.005em; }

/* ---------- Buttons & form controls ---------- */
.btn { font-weight: 500; border-radius: var(--radius-sm); }
.btn-primary {
  --bs-btn-bg: var(--brand-blue-700); --bs-btn-border-color: var(--brand-blue-700);
  --bs-btn-hover-bg: var(--brand-blue-800); --bs-btn-hover-border-color: var(--brand-blue-800);
  --bs-btn-active-bg: var(--brand-blue-800); --bs-btn-active-border-color: var(--brand-blue-800);
  --bs-btn-disabled-bg: var(--brand-blue-700); --bs-btn-disabled-border-color: var(--brand-blue-700);
}
.btn-accent {
  --bs-btn-color: #fff; --bs-btn-bg: var(--brand-orange); --bs-btn-border-color: var(--brand-orange);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--brand-orange-600); --bs-btn-hover-border-color: var(--brand-orange-600);
  --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--brand-orange-600); --bs-btn-active-border-color: var(--brand-orange-600);
  --bs-btn-disabled-color: #fff; --bs-btn-disabled-bg: var(--brand-orange); --bs-btn-disabled-border-color: var(--brand-orange);
}
.btn-outline-primary {
  --bs-btn-color: var(--brand-blue-700); --bs-btn-border-color: var(--brand-blue-700);
  --bs-btn-hover-bg: var(--brand-blue-700); --bs-btn-hover-border-color: var(--brand-blue-700);
  --bs-btn-active-bg: var(--brand-blue-700); --bs-btn-active-border-color: var(--brand-blue-700);
}
.form-control, .form-select { border-radius: var(--radius-sm); border-color: #D3DBE4; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: var(--brand-blue); box-shadow: 0 0 0 .2rem rgba(0, 172, 231, .18);
}
.form-check-input:checked { background-color: var(--brand-blue-700); border-color: var(--brand-blue-700); }
.form-label { font-weight: 500; color: var(--ink-2); margin-bottom: .3rem; }
.form-text { color: var(--muted); }

/* Segmented control (duration selectors) */
.seg { display: inline-flex; background: var(--line-2); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font-weight: 500; font-size: 12.5px;
  padding: 4px 11px; border-radius: 6px; white-space: nowrap; line-height: 1.4;
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: #fff; color: var(--brand-blue-800); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- App layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; z-index: 1040;
}
.sidebar .brand { padding: 18px 20px 14px; border-bottom: 1px solid var(--line-2); }
.brand-logos { display: flex; align-items: center; gap: 12px; }
.brand-logos img.issl { height: 34px; }
.brand-logos .x { color: #B8C3CF; font-size: 13px; }
.brand-logos img.gp { height: 26px; }
.brand-caption {
  margin-top: 10px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.nav-section { padding: 16px 20px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #93A1AF; }
.side-nav { list-style: none; margin: 0; padding: 0 10px; }
.side-nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 2px 0;
  border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; position: relative;
}
.side-nav a i { font-size: 17px; color: #7D8C9B; width: 20px; text-align: center; }
.side-nav a:hover { background: var(--line-2); color: var(--ink); }
.side-nav a.active { background: var(--brand-blue-50); color: var(--brand-blue-800); }
.side-nav a.active i { color: var(--brand-blue-700); }
.side-nav a.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand-orange);
}
.side-nav a.locked { color: #A9B4BF; }
.side-nav a.locked i { color: #C3CCD5; }
.side-nav .lock { margin-left: auto; font-size: 12px; }
.sidebar .side-foot { margin-top: auto; padding: 14px 20px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--muted); }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 24px; position: sticky; top: 0; z-index: 1030;
}
.topbar .page-title { font-size: 17px; font-weight: 600; margin: 0; line-height: 1.2; }
.topbar .page-sub { font-size: 12.5px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: #fff; }
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 13px;
  background: linear-gradient(135deg, var(--brand-blue-700), var(--brand-blue));
}
.user-chip .meta { line-height: 1.15; }
.user-chip .meta .n { font-weight: 600; font-size: 13px; }
.user-chip .meta .r { font-size: 11.5px; color: var(--muted); }
.demo-switch .btn { font-size: 12.5px; }

.content { padding: 24px; flex: 1; }
.content-narrow { max-width: 1180px; }

/* Mobile */
.sidebar-toggle { display: none; }
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(11,34,57,.35); z-index: 1035; }
  .sidebar-toggle { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .user-chip .meta, .demo-switch .label { display: none; }
}

/* ---------- Cards ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: #fff; border-bottom: 1px solid var(--line-2); padding: 14px 18px; border-radius: var(--radius) var(--radius) 0 0 !important; }
.card-body { padding: 18px; }
.card-title { font-size: 15px; font-weight: 600; margin: 0; }
.card-sub { font-size: 12.5px; color: var(--muted); margin: 2px 0 0; }
.graph-tag {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--brand-orange-600); background: var(--brand-orange-50); border-radius: 4px; padding: 2px 6px; margin-right: 6px; vertical-align: 1px;
}

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 28px 0 12px; flex-wrap: wrap; }
.section-head h2 { font-size: 16px; margin: 0; }
.section-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.section-head:first-child { margin-top: 0; }

/* ---------- KPI tiles ---------- */
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px 10px; height: 100%; position: relative; overflow: hidden;
}
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand-blue); }
.kpi.accent::after { background: var(--brand-orange); }
.kpi .kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .kpi-value { font-size: 22px; font-weight: 600; margin-top: 4px; letter-spacing: -.01em; white-space: nowrap; }
.kpi .kpi-foot { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kpi .spark { height: 36px; margin-top: 6px; }
.delta { font-weight: 600; font-size: 12px; white-space: nowrap; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }

/* Stat boxes (Highest / Lowest / Average) */
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #FBFCFD; min-width: 0;
}
.stat .l { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.stat .v { font-size: 16px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .d { font-size: 11.5px; color: var(--muted); }
.stat.hi .l i { color: var(--ok); }
.stat.lo .l i { color: var(--bad); }
.stat.avg .l i { color: var(--brand-blue-700); }
@media (max-width: 575.98px) { .stat-row { grid-template-columns: 1fr; } }

.chart-box { position: relative; width: 100%; height: 290px; }
.chart-box.sm { height: 220px; }
.chart-box.lg { height: 330px; }
@media (min-width: 1200px) {
  .chart-box { height: 340px; }
  .chart-box.sm { height: 260px; }
  .chart-box.lg { height: 420px; }
}
@media (max-width: 575.98px) {
  .chart-box, .chart-box.sm, .chart-box.lg { height: 240px; }
}
.chart-box canvas { width: 100% !important; max-width: 100% !important; }

/* Full-screen chart toggle */
body.has-chart-fullscreen {
  overflow: hidden !important;
}
.card.chart-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  z-index: 999999 !important;
  background: #ffffff !important;
  border: 0 !important;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  box-shadow: none !important;
}
.card.chart-fullscreen .card-header {
  border-radius: 0 !important;
  padding: 16px 24px !important;
  background: #ffffff !important;
  border-bottom: 1px solid var(--line-2) !important;
}
.card.chart-fullscreen .card-body {
  flex: 1 1 auto !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 24px !important;
  overflow-y: auto !important;
}
.card.chart-fullscreen .chart-box {
  flex: 1 1 auto !important;
  height: calc(100vh - 220px) !important;
  min-height: 400px !important;
  width: 100% !important;
}

.year-chips { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12.5px; color: var(--ink-2); }
.year-chips .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.year-chips b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
.table { --bs-table-color: var(--ink); margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .6rem .75rem; border-bottom-color: var(--line-2); }
.table thead th {
  font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  background: #F7F9FB; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table-brand thead th { background: var(--brand-navy); color: #fff; border-bottom: 0; }
.table tfoot td { font-weight: 600; background: #F7F9FB; border-top: 1px solid var(--line); }
.table-hover tbody tr:hover > * { background: #F6FAFD; }
.table td.num, .table th.num { text-align: right; }

/* ---------- Badges ---------- */
.badge-soft { font-weight: 600; font-size: 11.5px; padding: .35em .6em; border-radius: 6px; }
.badge-ok { background: var(--ok-50); color: var(--ok); }
.badge-warn { background: var(--warn-50); color: var(--warn); }
.badge-bad { background: var(--bad-50); color: var(--bad); }
.badge-info { background: var(--brand-blue-50); color: var(--brand-blue-800); }
.badge-muted { background: var(--line-2); color: var(--muted); }
.badge-orange { background: var(--brand-orange-50); color: var(--brand-orange-600); }
.role-badge { font-size: 11px; font-weight: 600; padding: .3em .55em; border-radius: 5px; }
.role-admin { background: #1B2733; color: #fff; }
.role-process_owner { background: var(--brand-blue-50); color: var(--brand-blue-800); }
.role-client { background: #EEF0F3; color: #45505C; }
.role-team_leader { background: var(--brand-orange-50); color: var(--brand-orange-600); }

/* ---------- Upload ---------- */
.dropzone {
  border: 2px dashed #C9D4DF; border-radius: var(--radius); background: #FAFCFD; padding: 28px 18px; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand-blue); background: var(--brand-blue-50); }
.dropzone i { font-size: 32px; color: var(--brand-blue-700); }
.dropzone .fname { font-weight: 600; margin-top: 6px; word-break: break-all; }
.progress { height: 8px; border-radius: 99px; background: var(--line-2); }
.progress-bar { background: linear-gradient(90deg, var(--brand-blue-700), var(--brand-blue)); }

.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.result-grid .cell { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.result-grid .cell .l { font-size: 11.5px; color: var(--muted); }
.result-grid .cell .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 767.98px) { .result-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Data entry ---------- */
.entry-tabs .nav-link { color: var(--ink-2); font-weight: 500; border-radius: 8px; padding: 8px 16px; }
.entry-tabs .nav-link.active { background: var(--brand-navy); color: #fff; }
.entry-tabs .nav-link.disabled { color: #B3BDC7; }
.calc-list { list-style: none; padding: 0; margin: 0; }
.calc-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.calc-list li:last-child { border-bottom: 0; }
.calc-list b { font-variant-numeric: tabular-nums; }

/* ---------- Permission matrix ---------- */
.perm-matrix td, .perm-matrix th { text-align: center; }
.perm-matrix td:first-child, .perm-matrix th:first-child { text-align: left; }
.perm-yes { color: var(--ok); font-size: 16px; }
.perm-no { color: #C3CCD5; font-size: 16px; }
.perm-cond { color: var(--warn); font-size: 12px; font-weight: 600; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-hero {
  background: radial-gradient(1200px 500px at -10% 110%, rgba(245,130,32,.30), transparent 60%),
              linear-gradient(150deg, #0B2239 0%, #0D3656 55%, #005E8F 100%);
  color: #fff; padding: 48px 56px; display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.login-hero h1 { color: #fff; font-size: 34px; font-weight: 700; line-height: 1.15; margin: auto 0 14px; max-width: 460px; }
.login-hero p { color: rgba(255,255,255,.78); font-size: 15px; max-width: 460px; }
.login-hero .logos { display: flex; align-items: center; gap: 16px; background: #fff; padding: 12px 18px; border-radius: 10px; align-self: flex-start; }
.login-hero .logos img.issl { height: 36px; }
.login-hero .logos img.gp { height: 28px; }
.login-hero .facts { display: flex; gap: 28px; margin-top: 28px; flex-wrap: wrap; }
.login-hero .facts .n { font-size: 22px; font-weight: 700; }
.login-hero .facts .t { font-size: 12px; color: rgba(255,255,255,.7); }
.login-hero .bars { position: absolute; right: -40px; bottom: -20px; opacity: .10; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: #fff; }
.login-card { width: 100%; max-width: 420px; }
.demo-users { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.demo-user {
  text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 10px 12px; transition: border-color .15s, background .15s;
}
.demo-user:hover { border-color: var(--brand-blue); background: var(--brand-blue-50); }
.demo-user .n { font-weight: 600; font-size: 13px; }
.demo-user .u { font-size: 11.5px; color: var(--muted); }
@media (max-width: 991.98px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { padding: 32px 24px; }
  .login-hero h1 { font-size: 26px; margin-top: 28px; }
}

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.small-muted { font-size: 12px; color: var(--muted); }
.divider-v { width: 1px; align-self: stretch; background: var(--line); }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.empty i { font-size: 28px; display: block; margin-bottom: 6px; color: #B8C3CF; }
.data-flag { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 5px; }
.data-flag.csv { background: var(--ok-50); color: var(--ok); }
.data-flag.upload { background: var(--brand-blue-50); color: var(--brand-blue-800); }
.data-flag.manual { background: var(--brand-orange-50); color: var(--brand-orange-800); }
.toast-container { z-index: 1090; }
.access-denied { max-width: 520px; margin: 60px auto; text-align: center; }
.access-denied i { font-size: 44px; color: var(--brand-orange); }
.legend-inline { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend-inline .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.pager .page-link { color: var(--brand-blue-700); }
.pager .active > .page-link { background: var(--brand-blue-700); border-color: var(--brand-blue-700); }
.text-orange { color: var(--brand-orange-600) !important; }
.text-gp { color: var(--brand-blue-700) !important; }
.asof { font-size: 12.5px; color: var(--muted); }
.asof b { color: var(--ink); }

/* ---------- Refinements ---------- */
.role-badge, .badge-soft, .data-flag, .table td.num { white-space: nowrap; }
.form-check-input { border-color: #A9B6C3; }
@media (max-width: 991.98px) {
  .topbar .page-sub { display: none; }
  .topbar .page-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
}
.partial-note { font-size: 11.5px; color: var(--muted); }
