/* ================================================================
   ABA UGANDA — Loan Management System
   Dark Theme Design System
   Font: 'DM Sans' (body) + 'DM Mono' (numbers/code)
   Palette: Deep navy base, teal accent, amber warnings
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Sora:wght@600;700;800&family=DM+Mono:wght@400;500&display=swap');

/* ----------------------------------------------------------------
   Animations
   ---------------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ----------------------------------------------------------------
   CSS Custom Properties
   ---------------------------------------------------------------- */
:root {
  /* Base palette */
  --bg-base:       #eff5f7;
  --bg-surface:    #ffffff;
  --bg-raised:     #f4f8fb;
  --bg-hover:      #ecf4f8;
  --bg-input:      #ffffff;

  /* Borders */
  --border:        #c9d6e0;
  --border-focus:  #1d7b72;

  /* Teal accent (primary actions, links) */
  --teal-400:      #127970;
  --teal-500:      #0f6c64;
  --teal-600:      #0f5c58;
  --teal-dim:      rgba(18, 121, 112, 0.14);

  /* Amber (warnings, pending) */
  --amber-400:     #c07a11;
  --amber-500:     #9e630f;
  --amber-dim:     rgba(192, 122, 17, 0.14);

  /* Red (danger, overdue) */
  --red-400:       #bf312d;
  --red-500:       #9d2a27;
  --red-dim:       rgba(191, 49, 45, 0.14);

  /* Green (success, paid) */
  --green-400:     #188457;
  --green-500:     #159c6b;
  --green-dim:     rgba(21, 156, 107, 0.14);

  /* Blue (info) */
  --blue-400:      #265ee8;
  --blue-dim:      rgba(38, 94, 232, 0.14);

  /* Text */
  --text-primary:   #162935;
  --text-secondary: #516a7f;
  --text-muted:     #6d7e8f;
  --text-placeholder: #96a7b9;
  --text-inverse:   #f8fafc;

  /* Typography */
  --font-body:    'Plus Jakarta Sans', system-ui, sans-serif;
  --font-heading: 'Sora', 'Plus Jakarta Sans', sans-serif;
  --font-mono:    'DM Mono', 'Courier New', monospace;

  /* Spacing */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  /* Sidebar */
  --sidebar-w:  240px;

  /* Shadow */
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.06);

  /* Transitions */
  --trans:      150ms ease;
}

/* ----------------------------------------------------------------
   Light Theme Overrides
   ---------------------------------------------------------------- */
[data-theme="light"]{
  --bg-base:       #f4f7fb;
  --bg-surface:    #ffffff;
  --bg-raised:     #f8fafc;
  --bg-hover:      #eef3f8;
  --bg-input:      #ffffff;

  --border:        #dbe4ee;
  --border-focus:  #2563eb;

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #64748b;
  --text-inverse:   #f8fafc;
  color-scheme: light;
}

/* ----------------------------------------------------------------
   Reset & Base
   ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(15, 118, 110, 0.10), transparent 24%),
    var(--bg-base);
  color:       var(--text-primary);
  line-height: 1.6;
  min-height:  100vh;
  display:     flex;
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "kern" 1;
}

a { color: var(--blue-400); text-decoration: none; }
a:hover { color: var(--teal-500); opacity: .95; }

::selection {
  background: rgba(37, 99, 235, 0.2);
  color: var(--text-primary);
}

img { max-width: 100%; display: block; }

/* ----------------------------------------------------------------
   Layout — Sidebar + Main
   ---------------------------------------------------------------- */
.layout {
  display:   flex;
  width:     100%;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width:      var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display:    flex;
  flex-direction: column;
  position:   fixed;
  top: 0; left: 0; bottom: 0;
  z-index:    100;
  transition: transform var(--trans);
}

.sidebar-brand {
  padding:     20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display:     flex;
  align-items: center;
  gap:         10px;
}

.sidebar-brand .logo-mark {
  width:           36px;
  height:          36px;
  background:      var(--teal-600);
  border-radius:   var(--radius-sm);
  display:         flex;
  align-items:     center;
  justify-content: center;
  font-weight:     600;
  font-size:       14px;
  color:           var(--text-inverse);
  letter-spacing:  -.5px;
  flex-shrink:     0;
}

.sidebar-brand .brand-name {
  font-size:   13px;
  font-weight: 600;
  color:       var(--text-primary);
  line-height: 1.3;
}
.sidebar-brand .brand-sub {
  font-size:  10px;
  color:      var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.sidebar-nav {
  flex:    1;
  padding: 12px 0;
  overflow-y: auto;
  scrollbar-gutter: stable both-edges;
}

.sidebar-footer {
  padding: 18px 20px;
  border-top: 1px solid var(--border);
}

.nav-link {
  white-space: normal;
  min-height: 44px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 400;
  transition: background var(--trans), color var(--trans);
  position: relative;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--teal-dim);
  color: var(--teal-400);
  font-weight: 500;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--teal-400);
  border-radius: 0 3px 3px 0;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .8;
  transition: opacity var(--trans);
}

.nav-link:hover svg {
  opacity: 1;
}

.nav-section {
  padding: 12px 0;
}

.nav-section:first-child {
  padding-top: 8px;
}

.nav-group {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.nav-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--trans);
  text-align: left;
}

.nav-group-toggle:hover {
  background: rgba(45, 212, 191, .04);
}

.nav-group-toggle:focus {
  outline: none;
}

.nav-group-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.nav-group-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 200ms ease;
  flex-shrink: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.nav-group.collapsed .nav-group-arrow {
  transform: rotate(-90deg);
}

.nav-group-items {
  display: block;
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 200ms ease;
}

.nav-group.collapsed .nav-group-items {
  max-height: 0;
  overflow: hidden;
}

.sidebar-footer {
  padding: 12px 20px 20px;
  border-top: 1px solid var(--border);
}

.user-card {
  display:     flex;
  align-items: center;
  gap:         10px;
  padding:     10px;
  border-radius: var(--radius-md);
  background:  var(--bg-raised);
}

.user-avatar {
  width:           34px;
  height:          34px;
  border-radius:   50%;
  background:      var(--teal-600);
  display:         flex;
  align-items:     center;
  justify-content: center;
  font-size:       12px;
  font-weight:     600;
  color:           #fff;
  flex-shrink:     0;
}

.user-name  { font-size: 12.5px; font-weight: 500; color: var(--text-primary); }
.user-role  { font-size: 11px;   color: var(--text-muted); }
.user-logout {
  margin-left: auto;
  color:       var(--text-muted);
  font-size:   11px;
  flex-shrink: 0;
}
.user-logout:hover { color: var(--red-400); opacity: 1; }



.page-body {
  padding:      28px;
  flex:         1;
  min-width:    0;
  width:        100%;
  box-sizing:   border-box;
  max-width:    calc(100vw - var(--sidebar-w));
}

/* Top bar */
.topbar {
  height:      56px;
  padding:     0 28px;
  background:  var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display:     flex;
  align-items: center;
  gap:         16px;
  position:    sticky;
  top:         0;
  z-index:     50;
}

.topbar-title {
  font-size:   16px;
  font-weight: 700;
  font-family: var(--font-heading);
  color:       var(--text-primary);
  flex:        1;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

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

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
  align-items: stretch;
}

.dashboard-grid--stacked {
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
}

.dashboard-grid .card {
  height: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.dashboard-grid .card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ----------------------------------------------------------------
   Cards
   ---------------------------------------------------------------- */
.card {
  background:    linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.96) 100%);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow:      hidden;
  transform-style: preserve-3d;
  box-shadow:    var(--shadow-soft);
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease, background 220ms ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.10);
  border-color: rgba(37, 99, 235, 0.18);
}

.card-header {
  padding:       16px 20px;
  border-bottom: 1px solid var(--border);
  display:       flex;
  align-items:   center;
  justify-content: space-between;
  gap:           12px;
}

.card-title {
  font-size:   14px;
  font-weight: 700;
  font-family: var(--font-heading);
  color:       var(--text-primary);
}

.card-body { padding: 20px; }

/* ----------------------------------------------------------------
   Metric cards (dashboard numbers)
   ---------------------------------------------------------------- */
.metrics-grid {
  display:               grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap:                   16px;
  margin-bottom:         24px;
}

.metric-card {
  background:    var(--bg-surface);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       18px;
  position:      relative;
  overflow:      hidden;
  transform-style: preserve-3d;
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
}

.metric-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 72px rgba(5, 18, 44, 0.14);
  border-color: rgba(56, 139, 253, 0.22);
}

.metric-card::before {
  content:    '';
  position:   absolute;
  top: 0; left: 0; right: 0;
  height:     2px;
}

.metric-card.teal::before  { background: var(--teal-500); }
.metric-card.amber::before { background: var(--amber-500); }
.metric-card.red::before   { background: var(--red-500); }
.metric-card.green::before { background: var(--green-500); }
.metric-card.blue::before  { background: var(--blue-400); }

.metric-label {
  font-size:   11.5px;
  color:       var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 10px;
}

.metric-value {
  font-size:      24px;
  font-weight:    700;
  color:          var(--text-primary);
  font-family:    var(--font-mono);
  letter-spacing: -.5px;
  line-height:    1.2;
}

.metric-value.teal  { color: var(--teal-400); }
.metric-value.amber { color: var(--amber-400); }
.metric-value.red   { color: var(--red-400); }
.metric-value.green { color: var(--green-400); }

.metric-sub {
  font-size:    11.5px;
  color:        var(--text-muted);
  margin-top:   6px;
}

/* ----------------------------------------------------------------
   Tables
   ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }

table.aba-table {
  width:           100%;
  border-collapse: collapse;
  font-size:       13.5px;
  background:      transparent;
}

.aba-table thead tr {
  border-bottom: 1px solid var(--border);
}

.aba-table th {
  padding:        10px 16px;
  text-align:     left;
  font-size:      11px;
  font-weight:    700;
  color:          var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .07em;
  white-space:    nowrap;
  background:     rgba(248, 250, 252, 0.8);
}

.aba-table td {
  padding:       12px 16px;
  color:         var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.aba-table tbody tr:last-child td { border-bottom: none; }

.aba-table tbody tr:hover td { background: var(--bg-hover); }
.aba-table tbody tr:nth-child(even) td { background: rgba(248, 250, 252, 0.45); }

.mono { font-family: var(--font-mono); font-size: 13px; }

/* ----------------------------------------------------------------
   Badges / Status pills
   ---------------------------------------------------------------- */
.badge {
  display:        inline-flex;
  align-items:    center;
  gap:            5px;
  padding:        3px 10px;
  border-radius:  20px;
  font-size:      11.5px;
  font-weight:    500;
  letter-spacing: .02em;
  white-space:    nowrap;
}

.badge-teal   { background: var(--teal-dim);  color: var(--teal-400); }
.badge-amber  { background: var(--amber-dim); color: var(--amber-400); }
.badge-red    { background: var(--red-dim);   color: var(--red-400); }
.badge-green  { background: var(--green-dim); color: var(--green-400); }
.badge-blue   { background: var(--blue-dim);  color: var(--blue-400); }
.badge-muted  { background: var(--bg-raised); color: var(--text-secondary); }

/* ----------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------- */
.btn {
  display:       inline-flex;
  align-items:   center;
  gap:           7px;
  padding:       8px 16px;
  border-radius: var(--radius-md);
  font-size:     13.5px;
  font-weight:   600;
  font-family:   var(--font-body);
  border:        1px solid transparent;
  cursor:        pointer;
  transition:    background var(--trans), border-color var(--trans), transform var(--trans), box-shadow var(--trans);
  text-decoration: none;
  white-space:   nowrap;
  line-height:   1;
  box-shadow:    0 6px 16px rgba(15, 23, 42, 0.04);
}

.btn:active { transform: scale(.98); }

.btn-primary {
  background:   linear-gradient(135deg, var(--blue-400) 0%, var(--teal-500) 100%);
  border-color: var(--blue-400);
  color:        #fff;
}
.btn-primary:hover { background: linear-gradient(135deg, #1d4ed8 0%, var(--teal-600) 100%); border-color: #1d4ed8; color: #fff; opacity: 1; box-shadow: 0 10px 24px rgba(37, 99, 235, 0.18); }

.btn-secondary {
  background:   var(--bg-raised);
  border-color: var(--border);
  color:        var(--text-primary);
  box-shadow:    none;
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); opacity: 1; }

.btn-danger {
  background:   transparent;
  border-color: var(--red-500);
  color:        var(--red-400);
}
.btn-danger:hover { background: var(--red-dim); color: var(--red-400); opacity: 1; }

.btn-success {
  background:   var(--green-500);
  border-color: var(--green-500);
  color:        #fff;
}
.btn-success:hover { background: var(--green-400); border-color: var(--green-400); color: #fff; opacity: 1; }

.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-lg { padding: 11px 22px; font-size: 14.5px; }

/* ----------------------------------------------------------------
   Forms
   ---------------------------------------------------------------- */
.form-group { margin-bottom: 18px; }

label {
  display:       block;
  font-size:     12.5px;
  font-weight:   500;
  color:         var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: .02em;
}

.form-control,
input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="password"],
input[type="tel"],
select,
textarea {
  width:         100%;
  background:    var(--bg-input);
  border:        1px solid var(--border);
  border-radius: var(--radius-md);
  color:         var(--text-primary);
  font-family:   var(--font-body);
  font-size:     14px;
  padding:       9px 13px;
  outline:       none;
  transition:    border-color var(--trans), box-shadow var(--trans), background var(--trans);
  appearance:    none;
  box-shadow:    inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow:   0 0 0 3px rgba(37, 99, 235, .14), inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

::placeholder {
  color: var(--text-placeholder);
  opacity: 1;
}

input[type="date"],
input[type="datetime-local"],
input[type="time"] {
  color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: brightness(.9);
  opacity: .85;
}

select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b949e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

textarea { resize: vertical; min-height: 90px; }

.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 11.5px; color: var(--red-400); margin-top: 4px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ----------------------------------------------------------------
   Alerts / Messages
   ---------------------------------------------------------------- */
.alert {
  display:       flex;
  align-items:   flex-start;
  gap:           10px;
  padding:       12px 16px;
  border-radius: var(--radius-md);
  font-size:     13.5px;
  margin-bottom: 16px;
  border:        1px solid transparent;
  box-shadow:    0 8px 20px rgba(15, 23, 42, 0.04);
}

.alert-success { background: var(--green-dim);  border-color: rgba(22, 163, 74, 0.24); color: var(--green-500); }
.alert-danger  { background: var(--red-dim);    border-color: rgba(185, 28, 28, 0.24);   color: var(--red-500); }
.alert-warning { background: var(--amber-dim);  border-color: rgba(180, 83, 9, 0.24); color: var(--amber-500); }
.alert-info    { background: var(--blue-dim);   border-color: rgba(37, 99, 235, 0.24);  color: var(--blue-400); }

/* ----------------------------------------------------------------
   Loan status colours helper
   ---------------------------------------------------------------- */
.status-DRAFT     { color: var(--text-muted); }
.status-PENDING   { color: var(--amber-400); }
.status-APPROVED  { color: var(--blue-400); }
.status-ACTIVE    { color: var(--green-400); }
.status-COMPLETED { color: var(--teal-400); }
.status-REJECTED  { color: var(--red-400); }
.status-DEFAULTED { color: var(--red-500); }

/* ----------------------------------------------------------------
   Amortization schedule table
   ---------------------------------------------------------------- */
.schedule-table th  { background: var(--bg-raised); }
.schedule-table .paid-row td { color: var(--text-muted); }
.schedule-table .paid-row td:first-child { text-decoration: line-through; }
.schedule-table .overdue-row td { color: var(--red-400); }

/* ----------------------------------------------------------------
   Receipt (print-optimised)
   ---------------------------------------------------------------- */
.receipt-wrap {
  max-width:     520px;
  margin:        0 auto;
  background:    var(--bg-surface);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       32px;
}

.receipt-header { text-align: center; margin-bottom: 24px; }
.receipt-number { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }
.receipt-row {
  display:        flex;
  justify-content: space-between;
  padding:        9px 0;
  border-bottom:  1px solid var(--border);
  font-size:      13.5px;
}
.receipt-row:last-child { border-bottom: none; }
.receipt-label  { color: var(--text-secondary); }
.receipt-total  { font-size: 18px; font-weight: 600; font-family: var(--font-mono); color: var(--teal-400); }

@media print {
  body { background: #fff; color: #000; }
  .sidebar, .topbar, .btn, .topbar-actions { display: none !important; }
  .main  { margin-left: 0; }
  .receipt-wrap { border: none; background: #fff; color: #000; }
  .receipt-label { color: #555; }
  .receipt-total { color: #000; }
  .card { box-shadow: none !important; border: none !important; }
  .card-header, .card-body, .table-wrap { background: transparent !important; }
  .table-wrap { overflow: visible !important; max-height: none !important; }
  .aba-table { width: 100%; border-collapse: collapse; font-size: 12px; }
  .aba-table th, .aba-table td { border: 1px solid #ccc !important; }
  .schedule-table th { background: #f5f5f5 !important; }
  .schedule-table .paid-row td { color: #777 !important; }
  .schedule-table .overdue-row td { color: #a00 !important; }
  .empty-state, .nav-link, .sidebar-brand, .footer, .htmx-indicator { display: none !important; }
}

/* ----------------------------------------------------------------
   Chart container
   ---------------------------------------------------------------- */
.chart-wrap { position: relative; height: 240px; }

/* ----------------------------------------------------------------
   Summary totals
   ---------------------------------------------------------------- */
.summary-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-total {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-raised);
}

.summary-total strong {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.summary-total .summary-total-value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

/* ----------------------------------------------------------------
   Empty state
   ---------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding:    48px 24px;
  color:      var(--text-muted);
}
.empty-state .empty-icon { font-size: 36px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ----------------------------------------------------------------
   HTMX loading indicator
   ---------------------------------------------------------------- */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.htmx-request.htmx-indicator  { display: inline-flex; }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width:  14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--teal-400);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

/* ----------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------- */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid--stacked {
    grid-template-columns: 1fr;
  }
}



@media (max-width: 640px) {
  :root { --sidebar-w: 240px; }
  .summary-totals {
    grid-template-columns: 1fr;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .sidebar { 
    width: 100%; 
    max-width: 280px;
    transition: transform .25s ease;
  }
  .sidebar-nav { 
    padding: 12px 8px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
  }
  .topbar { 
    padding: 0 12px;
    height: 52px;
  }
  .topbar-title {
    font-size: 14px;
    font-weight: 600;
  }
  .page-body { padding: 12px; }
  html { font-size: 14px; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 10px; }
  .metric-card { padding: 14px !important; }
  .metric-value { font-size: 20px; }
  .metric-label, .metric-sub { font-size: 10px; }
  .card { margin-bottom: 12px; }
  .form-row { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .table-wrap { 
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .aba-table { font-size: 12px; }
  .btn { padding: 8px 12px; font-size: 12px; }
  .btn-sm { padding: 6px 10px; font-size: 11px; }
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }
  .nav-link { 
    padding: 8px 8px; 
    font-size: 12.5px;
    gap: 8px;
  }
  .nav-link svg { width: 14px; height: 14px; }
  .sidebar-brand { padding: 16px 12px 12px; }
  .sidebar-brand .logo-mark { width: 32px; height: 32px; font-size: 12px; }
  .sidebar-brand .brand-name { font-size: 12px; }
  .sidebar-brand .brand-sub { font-size: 9px; }
  #sidebar-toggle {
    padding: 6px 8px;
    border-radius: 6px;
  }
}

@media (max-width: 520px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .metric-value { font-size: 18px; }
  .metric-card { padding: 12px !important; }
}

/* ----------------------------------------------------------------
   Search & Filter Bars — Responsive Layout
   ---------------------------------------------------------------- */
.search-filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.search-filter-bar input,
.search-filter-bar select {
  flex-shrink: 0;
}

.card-header-split {
  flex-wrap: wrap;
  align-items: flex-start;
}

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}

.card-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.client-table th,
.client-table td {
  padding: 14px 18px;
}

.client-table th:first-child,
.client-table td:first-child {
  padding-left: 20px;
}

.actions-col {
  text-align: right;
  white-space: nowrap;
}

.empty-state-wide {
  padding: 40px 0;
}

.search-filter-bar input,
.search-filter-bar select {
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .search-filter-bar {
    gap: 6px;
    padding: 0 2px 2px 2px;
  }
  .search-filter-bar input {
    width: 200px;
    max-width: 200px;
  }
  .search-filter-bar select {
    width: 140px;
    max-width: 140px;
  }
  .search-filter-bar .btn {
    flex-shrink: 0;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  .search-filter-bar {
    gap: 4px;
    padding: 0 2px 2px 2px;
  }
  .search-filter-bar input {
    width: 160px;
    max-width: 160px;
    font-size: 12px;
  }
  .search-filter-bar select {
    width: 120px;
    max-width: 120px;
    font-size: 12px;
  }
  .search-filter-bar .btn {
    padding: 6px 10px;
    font-size: 11px;
    flex-shrink: 0;
  }
}

/* ----------------------------------------------------------------
   Utility classes
   ---------------------------------------------------------------- */
.mt-1 { margin-top:    8px; }  .mt-2 { margin-top:  16px; }
.mt-3 { margin-top:   24px; }  .mt-4 { margin-top:  32px; }
.mb-1 { margin-bottom: 8px; }  .mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; } .mb-4 { margin-bottom: 32px; }
.gap-2 { gap: 8px; }  .gap-3 { gap: 16px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-sm    { font-size: 12.5px; }
.fw-500     { font-weight: 500; }
.w-100      { width: 100%; }
.d-none     { display: none; }

/* ================================================================
   Clickable Cards (Dashboard, Tables)
   ================================================================ */
.clickable-card, .clickable-row {
  cursor: pointer;
  transition: all var(--trans);
}

.clickable-card:hover {
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.clickable-row:hover {
  background: var(--bg-hover);
}

.metric-card, .card-clickable {
  cursor: pointer;
  transition: all var(--trans);
}

.metric-card:hover, .card-clickable:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(45, 212, 191, 0.1);
}

/* ================================================================
   Select2 Dark Theme Styling
   ================================================================ */
.select2-container--default .select2-selection--single {
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 36px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  color: var(--text-primary);
  font-family: var(--font-body);
  transition: all var(--trans);
}

.select2-container--default .select2-selection--single:hover {
  border-color: var(--border-focus);
}

.select2-container--default.select2-container--focus .select2-selection--single {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 139, 253, 0.1);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--text-primary);
  padding: 0;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 28px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: var(--text-secondary) transparent transparent transparent;
}

/* ----------------------------------------------------------------
   Compact, responsive filter bar styles
   Applies to forms often used in card headers for list pages.
   Overrides inline width styles to allow flexible, full-width layout.
---------------------------------------------------------------- */
.card-header form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}
.card-header form input,
.card-header form select,
.card-header form .form-control {
  /* allow fields to grow and share available space */
  flex: 1 1 200px !important;
  min-width: 120px !important;
  width: auto !important;
  margin-bottom: 0 !important;
}
.card-header form button,
.card-header form .btn {
  flex: 0 0 auto !important;
}
.card-header .filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

@media (max-width: 768px) {
  .card-header form input,
  .card-header form select,
  .card-header form .form-control {
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }
  .card-header { align-items: flex-start; }
}

.select2-container--default .select2-dropdown {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.select2-container--default .select2-search--dropdown .select2-search__field {
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
}

.select2-container--default .select2-results__option {
  color: var(--text-primary);
  padding: 12px;
}

.select2-container--default .select2-results__option:hover, 
.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.select2-container--default .select2-results__option[aria-selected=true] {
  background-color: var(--teal-dim);
  color: var(--teal-400);
}

/* Multiple select styling */
.select2-container--default .select2-selection--multiple {
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-height: 36px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
  background-color: var(--teal-600);
  border: 1px solid var(--teal-500);
  color: var(--text-inverse);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin: 2px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  color: var(--text-inverse);
  margin-right: 4px;
}

/* ----------------------------------------------------------------
   Payment battery indicator — improved visibility & theme-aware
   ---------------------------------------------------------------- */
.payment-warning-shell { box-shadow: none; }

/* Dark theme adjustments */
[data-theme="dark"] .payment-warning-shell {
  background: rgba(255,255,255,0.02);
  border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .payment-battery {
  border-color: rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
}

[data-theme="dark"] .payment-battery-fill {
  box-shadow: inset 0 -6px 10px rgba(0,0,0,0.08);
}

/* Light theme adjustments */
.payment-battery {
  border-color: rgba(15, 23, 42, 0.06);
  background: rgba(255,255,255,0.02);
}
.payment-battery-fill { box-shadow: inset 0 -6px 8px rgba(255,255,255,0.02); }

/* Professional color scale for coverage */
.payment-battery-fill[data-level="low"] { background: var(--red-400); }
.payment-battery-fill[data-level="mid"] { background: var(--amber-400); }
.payment-battery-fill[data-level="high"] { background: var(--teal-400); }
.payment-battery-fill[data-level="full"] { background: var(--green-400); }

/* Force more prominent battery visuals to avoid theme overrides */
.payment-warning-shell { z-index: 5; }
.payment-battery {
  width: 72px !important;
  height: 36px !important;
  border-radius: 8px !important;
  padding: 3px !important;
  box-shadow: 0 6px 18px rgba(2,6,23,0.45) inset, 0 8px 20px rgba(2,6,23,0.3);
  border: 2px solid rgba(255,255,255,0.06) !important;
}
.payment-battery::after { right: -7px !important; top: 10px !important; width: 6px !important; height: 10px !important; }
.payment-battery-fill {
  height: 100% !important;
  border-radius: 6px !important;
  transition: width 0.18s ease !important;
  box-shadow: inset 0 -6px 12px rgba(0,0,0,0.15) !important;
  min-width: 6px !important;
}
.payment-battery-fill[data-level="low"] { background: linear-gradient(90deg, #ff6b6b, #ff3b3b) !important; }
.payment-battery-fill[data-level="mid"] { background: linear-gradient(90deg, #f59e0b, #d97706) !important; }
.payment-battery-fill[data-level="high"] { background: linear-gradient(90deg, #14b8a6, #0d9488) !important; }
.payment-battery-fill[data-level="full"] { background: linear-gradient(90deg, #34d399, #10b981) !important; }

/* ================================================================
   MODAL / POPUP SYSTEM
   ================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(2, 6, 23, 0.45);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--trans);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* Dark theme modal adjustments */
[data-theme="dark"] .modal-overlay {
  background: rgba(2, 6, 23, 0.75);
}

[data-theme="dark"] .modal {
  background: var(--surface);
  border-color: var(--surface-3);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

/* ================================================================
   IMPROVED CLICKABLE ROWS
   ================================================================ */
.clickable-row {
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.clickable-row:hover {
  background: var(--bg-hover) !important;
  box-shadow: inset 3px 0 0 var(--accent);
}

.clickable-row:active {
  background: var(--bg-raised) !important;
}

.clickable-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Clickable row with arrow indicator */
.clickable-row[data-href] td:last-child {
  position: relative;
}

.clickable-row[data-href]:hover td:last-child::after {
  content: '→';
  position: absolute;
  right: 8px;
  color: var(--accent);
  font-weight: 600;
  animation: slideRight 0.2s ease;
}

@keyframes slideRight {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ================================================================
   IMPROVED FILTER BAR - Single Row Alignment
   ================================================================ */
.filter-bar-single-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.filter-bar-single-row::-webkit-scrollbar {
  height: 4px;
}

.filter-bar-single-row::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.filter-bar-single-row .filter-field {
  flex: 0 1 auto;
  min-width: 0;
}

.filter-bar-single-row .filter-field input,
.filter-bar-single-row .filter-field select {
  width: 100%;
  min-width: 140px;
  margin: 0;
}

.filter-bar-single-row .filter-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  display: block;
  white-space: nowrap;
}

.filter-bar-single-row .filter-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: flex-end;
  padding-bottom: 0;
}

/* ================================================================
   DARK THEME COLOR BALANCING
   ================================================================ */

/* Softer surface transitions */
[data-theme="dark"] .card {
  background: linear-gradient(135deg, rgba(31, 41, 55, 0.95) 0%, rgba(17, 24, 39, 0.98) 100%);
  border-color: rgba(51, 65, 85, 0.6);
}

[data-theme="dark"] .card:hover {
  border-color: rgba(96, 165, 250, 0.25);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Better table row contrast */
[data-theme="dark"] .aba-table tbody tr:nth-child(even) td {
  background: rgba(31, 41, 55, 0.3);
}

[data-theme="dark"] .aba-table tbody tr:hover td {
  background: rgba(51, 65, 85, 0.4) !important;
}

/* Improved header contrast */
[data-theme="dark"] .aba-table thead th {
  background: rgba(31, 41, 55, 0.8);
  border-color: rgba(51, 65, 85, 0.8);
}

/* Softer card header */
[data-theme="dark"] .card-header {
  background: rgba(31, 41, 55, 0.6);
  border-color: rgba(51, 65, 85, 0.5);
}

/* Better input contrast */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--surface-2);
  border-color: var(--surface-3);
  color: var(--text-primary);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

/* Improved badge contrast */
[data-theme="dark"] .badge-muted {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
}

[data-theme="dark"] .badge-neutral {
  background: rgba(148, 163, 184, 0.2);
  color: #CBD5E1;
}

/* Better button contrast */
[data-theme="dark"] .btn-secondary {
  background: var(--surface-3);
  border-color: var(--surface-2);
  color: var(--text-secondary);
}

[data-theme="dark"] .btn-secondary:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border);
}

/* Improved pagination */
[data-theme="dark"] .pagination .page-link {
  background: var(--surface-2);
  border-color: var(--surface-3);
  color: var(--text-secondary);
}

[data-theme="dark"] .pagination .page-item.active .page-link {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

[data-theme="dark"] .pagination .page-item:hover .page-link {
  background: var(--surface-3);
  color: var(--text-primary);
}

/* Softer stat card backgrounds */
[data-theme="dark"] .stat-card {
  background: linear-gradient(135deg, rgba(31, 41, 55, 0.95) 0%, rgba(17, 24, 39, 0.98) 100%);
  border-color: rgba(51, 65, 85, 0.5);
}

[data-theme="dark"] .stat-card:hover {
  border-color: rgba(96, 165, 250, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

/* Better empty state contrast */
[data-theme="dark"] .empty-state {
  background: rgba(31, 41, 55, 0.3);
  border: 1px dashed var(--surface-3);
  border-radius: var(--radius-lg);
}

/* Improved alert contrast */
[data-theme="dark"] .alert {
  border-color: rgba(255, 255, 255, 0.08);
}

/* ================================================================
   SMOOTH SCROLL INDICATOR FOR FILTERS
   ================================================================ */
.filter-scroll-indicator {
  position: relative;
}

.filter-scroll-indicator::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(to right, transparent, var(--surface));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.filter-scroll-indicator.can-scroll-right::after {
  opacity: 1;
}

/* ================================================================
   QUICK ACTION TOOLTIPS
   ================================================================ */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  padding: 6px 10px;
  background: var(--text-primary);
  color: var(--bg-surface);
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.15s ease;
  pointer-events: none;
  z-index: 100;
}

[data-tooltip]:hover::before {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-8px);
}

/* ================================================================
   ENHANCED ROW ACTIONS - Inline action buttons
   ================================================================ */
.row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.clickable-row:hover .row-actions {
  opacity: 1;
}

.row-actions .btn-icon {
  padding: 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--trans);
  display: flex;
  align-items: center;
  justify-content: center;
}

.row-actions .btn-icon:hover {
  background: var(--bg-hover);
  border-color: var(--border);
  color: var(--text-primary);
}

.row-actions .btn-icon.btn-icon-danger:hover {
  background: var(--red-dim);
  border-color: var(--red-500);
  color: var(--red-400);
}

.row-actions .btn-icon.btn-icon-success:hover {
  background: var(--green-dim);
  border-color: var(--green-500);
  color: var(--green-400);
}

/* ================================================================
   ENHANCED RESPONSIVENESS
   ================================================================ */

/* Large screens - ensure proper spacing */
@media (min-width: 1400px) {
  .page-body {
    max-width: 1400px;
    margin: 0 auto;
  }
}

/* Medium-large screens */
@media (max-width: 1200px) {
  .aba-table th,
  .aba-table td {
    padding: 10px 12px;
    font-size: 13px;
  }
  
  .filter-field input {
    min-width: 160px !important;
  }
}

/* Medium screens */
@media (max-width: 992px) {
  :root {
    --sidebar-w: 240px;
  }
  
  .page-body {
    padding: 20px;
  }
  
  .aba-table {
    font-size: 12.5px;
  }
  
  .aba-table th,
  .aba-table td {
    padding: 8px 10px;
  }
  
  .card-header {
    padding: 14px 16px;
  }
  
  .card-body {
    padding: 16px;
  }
  
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Tablet screens */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 100%;
  }
  
  .page-body {
    padding: 16px;
  }
  
  /* Stack tables horizontally scrollable */
  .table-wrap {
    margin: 0 -16px;
    padding: 0 16px;
  }
  
  /* Ensure filter bars are fully scrollable */
  .filter-bar-single-row {
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }
  
  .filter-bar-single-row input,
  .filter-bar-single-row select {
    flex-shrink: 0;
    max-width: 200px;
  }
  
  /* Stack stat cards */
  .stat-grid,
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  
  /* Adjust card layouts */
  .card-header-content {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  
  .card-header-title {
    margin-bottom: 8px;
  }
  
  /* Smaller table text */
  .aba-table {
    font-size: 12px;
  }
  
  .aba-table th {
    font-size: 10px;
    padding: 8px 8px;
  }
  
  .aba-table td {
    padding: 8px 8px;
  }
  
  /* Adjust buttons */
  .btn {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .btn-sm {
    padding: 6px 10px;
    font-size: 12px;
  }
  
  /* Modal adjustments */
  .modal {
    width: 95% !important;
    max-height: 80vh;
  }
  
  .modal-header {
    padding: 14px 16px;
  }
  
  .modal-body {
    padding: 16px;
  }
  
  .modal-footer {
    padding: 12px 16px;
  }
}

/* Small mobile screens */
@media (max-width: 576px) {
  .page-body {
    padding: 12px;
  }
  
  /* Single column stats */
  .stat-grid,
  .metrics-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* Full-width filter inputs */
  .filter-bar-single-row {
    gap: 6px;
  }
  
  .filter-bar-single-row input {
    min-width: 120px !important;
    flex: 1 1 100% !important;
  }
  
  .filter-bar-single-row select {
    flex: 1 1 100% !important;
  }
  
  .filter-actions {
    flex: 1 1 100% !important;
    justify-content: flex-end;
  }
  
  .filter-actions .btn {
    flex: 0 0 auto;
  }
  
  /* Compact table */
  .aba-table th,
  .aba-table td {
    padding: 6px 8px;
    font-size: 11px;
  }
  
  .aba-table th {
    font-size: 9px;
    letter-spacing: 0.04em;
  }
  
  /* Smaller badges */
  .badge {
    padding: 3px 8px;
    font-size: 10px;
  }
  
  /* Modal full screen */
  .modal {
    width: 98% !important;
    max-height: 90vh;
    border-radius: var(--radius-md);
  }
  
  .modal-header {
    padding: 12px 14px;
  }
  
  .modal-title {
    font-size: 15px;
  }
  
  .modal-body {
    padding: 14px;
  }
  
  .modal-footer {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .modal-footer .btn {
    flex: 1 1 auto;
    min-width: 100px;
  }
  
  /* Topbar adjustments */
  .topbar {
    padding: 0 12px;
    height: 52px;
  }
  
  .topbar-title {
    font-size: 14px;
    font-weight: 600;
  }
  
  .topbar-actions {
    gap: 6px;
  }
  
  .topbar-actions .btn {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* Extra small screens */
@media (max-width: 380px) {
  .page-body {
    padding: 8px;
  }
  
  .card {
    border-radius: var(--radius-md);
  }
  
  .card-header {
    padding: 12px 14px;
  }
  
  .card-body {
    padding: 12px;
  }
  
  .aba-table th,
  .aba-table td {
    padding: 5px 6px;
    font-size: 10px;
  }
  
  .btn {
    padding: 7px 10px;
    font-size: 11px;
  }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .modal {
    max-height: 90vh;
  }
  
  .modal-body {
    max-height: 60vh;
  }
  
  .page-body {
    padding: 12px;
  }
}

/* High density displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .aba-table,
  .card,
  .btn {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Print styles */
@media print {
  .filter-bar-single-row,
  .filter-actions,
  .btn,
  .modal-overlay {
    display: none !important;
  }
  
  .aba-table {
    font-size: 10px;
  }
  
  .aba-table th,
  .aba-table td {
    padding: 4px 6px;
    border: 1px solid #ddd !important;
  }
}

/* Accessibility - reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .clickable-row:hover {
    box-shadow: none !important;
  }
  
  .clickable-row[data-href]:hover td:last-child::after {
    animation: none !important;
    opacity: 1;
  }
}

/* Dark theme specific responsiveness */
@media (max-width: 768px) {
  [data-theme="dark"] .filter-bar-single-row::-webkit-scrollbar-thumb {
    background: var(--surface-3);
  }
  
  [data-theme="dark"] .modal-overlay {
    background: rgba(2, 6, 23, 0.85);
  }
}
