/* ── Base ────────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
:root {
  --sidebar-w: 240px;
  --navy:      #0F172A;
  --navy2:     #1E293B;
  --blue:      #2563EB;
  --blue-lt:   #EFF6FF;
  --border:    #E2E8F0;
  --bg:        #F8FAFC;
  --text:      #0F172A;
  --text-2:    #64748B;
  --text-3:    #94A3B8;
  --white:     #FFFFFF;
  --radius:    10px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
}
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-size: 14px;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .25s ease;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
}
.logo-icon {
  width: 36px; height: 36px;
  background: var(--blue);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: rgba(255,255,255,.6);
  text-decoration: none; font-size: 13.5px; font-weight: 500;
  margin-bottom: 2px; transition: all .15s; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(37,99,235,.25); color: #fff; }
.nav-icon { width: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-dot { width: 6px; height: 6px; background: var(--blue); border-radius: 50%; margin-left: auto; }

.sidebar-footer { padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.08); }
.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  background: rgba(255,255,255,.05);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-name { color: #fff; font-size: 12.5px; font-weight: 600; }
.user-role { color: rgba(255,255,255,.45); font-size: 11px; }
.logout-btn { margin-left: auto; color: rgba(255,255,255,.4); transition: color .15s; }
.logout-btn:hover { color: #fff; }

/* ── Overlay (mobile) ───────────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 199;
}
.sidebar-overlay.show { display: block; }

/* ── Main wrap ──────────────────────────────────────────────────────────────── */
.main-wrap { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

/* ── Topbar ─────────────────────────────────────────────────────────────────── */
.topbar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 56px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-weight: 600; font-size: 15px; color: var(--text); }
.topbar-right { margin-left: auto; }
.topbar-badge {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px;
  font-size: 12px; color: var(--text-2); font-weight: 500;
}
.mobile-toggle {
  display: none; background: none; border: none;
  color: var(--text-2); cursor: pointer; padding: 4px;
}

/* ── Page content ───────────────────────────────────────────────────────────── */
.page-content { flex: 1; padding: 28px; }

/* ── Page header ────────────────────────────────────────────────────────────── */
.page-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-hdr-left h1 { font-size: 20px; font-weight: 700; margin: 0; color: var(--text); }
.page-hdr-left p  { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.ct-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 20px;
}
.ct-card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.ct-card-title { font-weight: 600; font-size: 14px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.ct-card-body { padding: 20px; }

/* ── Stat cards ─────────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #EFF6FF; color: var(--blue); }
.stat-icon.green  { background: #F0FDF4; color: #16A34A; }
.stat-icon.red    { background: #FEF2F2; color: #DC2626; }
.stat-icon.purple { background: #FAF5FF; color: #9333EA; }
.stat-icon.orange { background: #FFF7ED; color: #EA580C; }
.stat-val   { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-2); margin-top: 3px; }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.ct-table { width: 100%; border-collapse: collapse; }
.ct-table thead th {
  background: #F8FAFC; color: var(--text-2);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ct-table tbody td {
  padding: 13px 16px; border-bottom: 1px solid #F1F5F9;
  font-size: 13.5px; vertical-align: middle;
}
.ct-table tbody tr:last-child td { border-bottom: none; }
.ct-table tbody tr:hover td { background: #F8FAFC; }
.ct-table tfoot td { padding: 13px 16px; background: #F8FAFC; font-weight: 600; border-top: 2px solid var(--border); }

/* ── DataTables overrides ───────────────────────────────────────────────────── */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border); border-radius: 7px;
  padding: 6px 10px; font-size: 13px; outline: none;
}
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--blue); }
.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: 6px !important; font-size: 13px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--blue) !important; border-color: var(--blue) !important; color: #fff !important;
}
.dataTables_wrapper .dataTables_info { font-size: 12px; color: var(--text-2); }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge-ct {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.bg-green  { background: #DCFCE7; color: #15803D; }
.bg-red    { background: #FEE2E2; color: #B91C1C; }
.bg-yellow { background: #FEF9C3; color: #A16207; }
.bg-blue   { background: #DBEAFE; color: #1D4ED8; }
.bg-gray   { background: #F1F5F9; color: #475569; }
.bg-purple { background: #F3E8FF; color: #7E22CE; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn-ct {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 7px; font-size: 13.5px;
  font-weight: 500; cursor: pointer; border: none; transition: all .15s;
  font-family: inherit;
}
.btn-primary-ct  { background: var(--blue); color: #fff; }
.btn-primary-ct:hover { background: #1D4ED8; }
.btn-secondary-ct { background: var(--white); color: var(--text); border: 1px solid var(--border); }
.btn-secondary-ct:hover { background: var(--bg); }
.btn-danger-ct   { background: #FEE2E2; color: #B91C1C; border: 1px solid #FECACA; }
.btn-danger-ct:hover { background: #FECACA; }
.btn-icon {
  width: 30px; height: 30px; border-radius: 6px; border: none;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s; background: transparent;
}
.btn-icon.edit  { color: var(--blue); }
.btn-icon.edit:hover  { background: var(--blue-lt); }
.btn-icon.del   { color: #DC2626; }
.btn-icon.del:hover   { background: #FEE2E2; }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-content { border: none; border-radius: 12px; box-shadow: var(--shadow-md); }
.modal-header {
  background: var(--navy); border-radius: 12px 12px 0 0;
  padding: 18px 24px; border-bottom: none;
}
.modal-title { color: #fff; font-size: 15px; font-weight: 600; }
.modal-body  { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); gap: 10px; }
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.form-control, .form-select {
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 13.5px; font-family: inherit; transition: border .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-section {
  background: #F8FAFC; border-radius: 8px; padding: 16px;
  margin-bottom: 4px; border: 1px solid var(--border);
}
.form-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); margin-bottom: 14px; }

/* ── Rate display box ───────────────────────────────────────────────────────── */
.rate-box {
  background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
  border: 1px solid #BFDBFE; border-radius: 8px;
  padding: 14px 16px; text-align: center;
}
.rate-box .rate-val { font-size: 24px; font-weight: 700; color: var(--blue); }
.rate-box .rate-sub { font-size: 11px; color: #64748B; margin-top: 2px; }

/* ── Login ──────────────────────────────────────────────────────────────────── */
.login-bg {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0F172A 0%, #1E3A5F 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 44px 40px;
  width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  width: 52px; height: 52px; background: var(--blue); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; margin: 0 auto 20px;
}
.login-card h1 { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.login-card .sub { font-size: 13px; color: var(--text-2); text-align: center; margin-bottom: 28px; }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast-stack { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 10px; min-width: 260px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15); animation: slideIn .2s ease;
  font-size: 13.5px; font-weight: 500;
}
.toast-item.success { background: #F0FDF4; border: 1px solid #BBF7D0; color: #15803D; }
.toast-item.danger  { background: #FEF2F2; border: 1px solid #FECACA; color: #B91C1C; }
.toast-item.warning { background: #FFFBEB; border: 1px solid #FDE68A; color: #B45309; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Reconciliation rows ────────────────────────────────────────────────────── */
.recon-matched  td { background: #F0FDF4; }
.recon-under    td { background: #FEF2F2; }
.recon-over     td { background: #EFF6FF; }
.recon-none     td { background: #FFFBEB; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .mobile-toggle { display: flex; }
  .page-content { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 16px; }
}
