:root{
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --sidebar-w: 250px;
  --bg: #f4f5f9;
  --card-border: #edeef2;
  --text-muted: #6b7280;
}
*{ box-sizing: border-box; }
body{
  font-family: 'Inter', -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: #1f2430;
  margin: 0;
}

/* ---- App shell ---- */
.app-shell{ display: flex; min-height: 100vh; }
.sidebar{
  width: var(--sidebar-w);
  background: #17182b;
  color: #cbd0e0;
  position: fixed; top:0; left:0; bottom:0;
  display:flex; flex-direction:column;
  z-index: 1030;
  transition: transform .2s ease;
}
.sidebar-brand{
  display:flex; align-items:center; gap:.65rem;
  padding: 1.15rem 1.2rem; font-weight:700; color:#fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: 1rem;
}
.sidebar-brand .brand-icon{
  height: 34px; width:34px; border-radius:9px; display:flex; align-items:center; justify-content:center;
  background: var(--accent); flex-shrink:0; overflow:hidden;
}
.sidebar-brand .brand-icon img{ height:100%; width:100%; object-fit:contain; }
.sidebar-brand .brand-icon i{ font-size:1.05rem; color:#fff; }
.sidebar-brand span{ line-height:1.2; }
.sidebar-scroll{ overflow-y:auto; padding: .75rem .6rem; flex:1; }
.nav-group{ margin-bottom: .4rem; }
.nav-group-label{
  display:flex; align-items:center; gap:.5rem;
  font-size:.72rem; text-transform:uppercase; letter-spacing:.06em;
  color:#6b7290; padding: .8rem .6rem .3rem;
}
.sidebar .nav-link{
  display:flex; align-items:center; gap:.65rem;
  color:#cbd0e0; padding:.55rem .8rem; border-radius:8px;
  font-size:.89rem; font-weight:500; margin: 1px 0;
}
.sidebar .nav-link i{ font-size:1rem; width:1.1rem; text-align:center; opacity:.85; }
.sidebar .nav-link:hover{ background: rgba(255,255,255,.06); color:#fff; }
.sidebar .nav-link.active{ background: var(--accent); color: var(--accent-ink); }

.app-main{ margin-left: var(--sidebar-w); flex:1; display:flex; flex-direction:column; min-width:0; }
.topbar{
  height: 62px; background:#fff; border-bottom:1px solid var(--card-border);
  display:flex; align-items:center; justify-content:space-between;
  padding: 0 1.25rem; position: sticky; top:0; z-index:1020;
}
.topbar-title{ font-weight:600; font-size:1.05rem; }
.avatar{
  width:34px; height:34px; border-radius:50%; background: var(--accent); color:#fff;
  display:flex; align-items:center; justify-content:center; font-weight:600; font-size:.9rem;
}
.btn-icon{ border:none; background:transparent; font-size:1.3rem; }
.app-content{ padding: 1.5rem; flex:1; }
.app-content [id]{ scroll-margin-top: 80px; } /* keeps in-page anchor jumps (e.g. pagination) clear of the sticky topbar */
.app-footer{
  padding: .9rem 1.5rem; font-size:.8rem; color: var(--text-muted);
  border-top:1px solid var(--card-border); background:#fff;
  display:flex; justify-content:space-between; flex-wrap:wrap; gap:.3rem;
}
.app-footer .powered-by strong{ color:#1f2430; }

@media (max-width: 991.98px){
  .sidebar{ transform: translateX(-100%); }
  .sidebar.show{ transform: translateX(0); }
  .app-main{ margin-left:0; }
}

/* ---- Cards / widgets ---- */
.card{ border: 1px solid var(--card-border); border-radius:12px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.stat-card{ padding:1.25rem; }
.stat-card .stat-value{ font-size:1.6rem; font-weight:700; }
.stat-card .stat-label{ color: var(--text-muted); font-size:.82rem; }
.stat-card .stat-icon{
  width:44px; height:44px; border-radius:10px; display:flex; align-items:center; justify-content:center;
  background: #eef0fb;
  background: color-mix(in srgb, var(--accent) 12%, white);
  color: var(--accent); font-size:1.2rem;
}

.btn-accent{ background: var(--accent); border-color: var(--accent); color:#fff; }
.btn-accent:hover{ filter: brightness(.92); color:#fff; }
.text-accent{ color: var(--accent); }

.item-tile{ cursor: pointer; transition: transform .1s, box-shadow .1s; }
.item-tile:hover{ transform: translateY(-2px); box-shadow: 0 4px 10px rgba(16,24,40,.08); }

/* theme color swatches on settings page */
.swatch{
  width:34px; height:34px; border-radius:8px; cursor:pointer; border:2px solid transparent;
  display:inline-block;
}
.swatch.selected{ border-color:#1f2430; }

.select2-container .select2-selection--single{ height: 38px !important; padding-top: 4px; }

/* ---- Billing: change-due / short-amount readout ---- */
.change-due-box{
  margin-top:.5rem; padding:.6rem .75rem; border-radius:9px; font-weight:700; font-size:1.05rem;
  text-align:center; display:none;
}
.change-due-box.show{ display:block; }
.change-due-box.due-positive{ background:#e7f7ee; color:#0f9d58; }
.change-due-box.due-negative{ background:#fdecec; color:#d93025; }

.disc-type-btn.active{ background: var(--accent); color:#fff; }

/* ---- Pagination ---- */
.pagination .page-link{ color:#4b5563; border-color: var(--card-border); }
.pagination .page-item.active .page-link{ background: var(--accent); border-color: var(--accent); color:#fff; }
.pagination .page-item.disabled .page-link{ color:#c3c7d1; }
.pagination .page-link:focus{ box-shadow:none; }
/* Only elevate a select2 widget's stacking while its dropdown is actually open —
   giving every container a permanent high z-index made closed dropdowns on the
   base page float above open modals. */
.select2-container--open{ z-index: 2060; }
.select2-dropdown{ z-index: 2060 !important; }
.modal-backdrop{ z-index: 1050; }
.modal{ z-index: 1055; }

/* ---- Kill Bootstrap's default blue focus glow, use a subtle accent ring instead ---- */
.form-control:focus,
.form-select:focus,
.form-check-input:focus,
textarea:focus,
input:focus,
select:focus,
.btn:focus,
.btn:focus-visible,
.select2-container--default.select2-container--focus .select2-selection,
.select2-container--default .select2-selection:focus,
.select2-selection:focus{
  box-shadow: none !important;
  outline: none !important;
  border: 1.5px solid var(--accent) !important;
}
.form-check-input:checked{ background-color: var(--accent) !important; border-color: var(--accent) !important; }

/* ---- Page header (used at the top of every module) ---- */
.page-header{
  display:flex; align-items:flex-start; justify-content:space-between; flex-wrap:wrap; gap:1rem;
  margin-bottom: 1.5rem;
}
.page-header h4{ font-weight:700; margin:0 0 .2rem; font-size:1.3rem; }
.page-header .page-subtitle{ color: var(--text-muted); font-size:.88rem; margin:0; }

/* ---- Buttons ---- */
.btn{ border-radius:9px; font-weight:500; font-size:.89rem; transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s; }
.btn-sm{ border-radius:7px; }

.btn-accent{ background: var(--accent); border-color: var(--accent); color:#fff; }
.btn-accent:hover, .btn-accent:active{ background: color-mix(in srgb, var(--accent) 82%, black); border-color: color-mix(in srgb, var(--accent) 82%, black); color:#fff; }

.btn-outline-accent{ border-color: var(--accent); color: var(--accent); background:#fff; }
.btn-outline-accent:hover, .btn-outline-accent:active{ background: var(--accent); border-color: var(--accent); color:#fff; }

.btn-outline-secondary{ border-color:#d7dae0; color:#4b5563; background:#fff; }
.btn-outline-secondary:hover, .btn-outline-secondary:active{ background:#4b5563; border-color:#4b5563; color:#fff; }

.btn-danger{ background:#dc2626; border-color:#dc2626; }
.btn-danger:hover{ background:#b91c1c; border-color:#b91c1c; }

.btn-outline-danger{ border-color:#dc2626; color:#dc2626; background:#fff; }
.btn-outline-danger:hover{ background:#dc2626; border-color:#dc2626; color:#fff; }

.text-accent{ color: var(--accent); }

/* ---- Confirm dialog ---- */
.confirm-icon{
  width:56px; height:56px; border-radius:50%; margin:0 auto; display:flex; align-items:center; justify-content:center;
  background: #fff6e5; color:#b7791f; font-size:1.6rem;
}

/* ---- Tables ---- */
.table-clean{ background:#fff; border-radius:12px; overflow:hidden; border:1px solid var(--card-border); }
.table-clean thead th{
  background:#fafbfd; font-size:.72rem; text-transform:uppercase; letter-spacing:.04em;
  color: var(--text-muted); font-weight:600; border-bottom:1px solid var(--card-border); padding:.8rem 1rem;
}
.table-clean tbody td{ padding:.8rem 1rem; vertical-align:middle; font-size:.88rem; border-bottom:1px solid var(--card-border); }
.table-clean tbody tr:last-child td{ border-bottom:none; }
.table-clean tbody tr:hover{ background:#fafbfd; }

/* ---- Badges / status pills ---- */
.pill{ display:inline-flex; align-items:center; gap:.3rem; padding:.25rem .65rem; border-radius:999px; font-size:.75rem; font-weight:600; }
.pill-success{ background:#e7f7ee; color:#0f9d58; }
.pill-danger{ background:#fdecec; color:#d93025; }
.pill-warning{ background:#fff6e5; color:#b7791f; }

.bg-accent{ background: var(--accent) !important; }
.pill-muted{ background:#f1f2f6; color:#6b7280; }

/* ---- Empty state ---- */
.empty-state{ text-align:center; padding:3rem 1rem; color: var(--text-muted); }
.empty-state i{ font-size:2.4rem; opacity:.35; margin-bottom:.75rem; display:block; }

