/* ============================================================
   PMS — main.css
   Modern SaaS dashboard — dark-first design system
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ── Design Tokens (Dark mode — default) ─────────────────── */
:root {
  --bg-base:       #1a1a1a;
  --bg-surface:    #222222;
  --bg-elevated:   #2a2a2a;
  --bg-hover:      #303030;
  --bg-active:     #1e2a3a;

  /* Sidebar — keep as-is */
  --bg-sidebar:         #1a1f3c;
  --bg-sidebar-hover:   #252b4a;
  --sidebar-border:     #252b4a;
  --sidebar-active-bg:  rgba(99,125,255,0.15);
  --sidebar-active-clr: #7b9fff;

  --border:        #333333;
  --border-strong: #444444;
  --border-focus:  #3b82f6;

  --text-primary:  #ececec;
  --text-secondary:#a0a0a0;
  --text-tertiary: #666666;

  --accent:        #3b82f6;
  --accent-hover:  #2563eb;
  --accent-dim:    #1e3a5f;

  --green:         #22c55e;
  --green-dim:     #14532d;
  --amber:         #f59e0b;
  --amber-dim:     #451a03;
  --red:           #ef4444;
  --red-dim:       #450a0a;
  --purple:        #a78bfa;
  --purple-dim:    #2e1065;

  /* ... rest of tokens unchanged ... */

  --font-sans:     'Inter', 'SF Pro Display', system-ui, sans-serif;
  --font-mono:     'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --text-xs:       11px;
  --text-sm:       12px;
  --text-base:     13px;
  --text-md:       14px;
  --text-lg:       16px;
  --text-xl:       20px;
  --text-2xl:      24px;
  --text-3xl:      28px;

  --radius-sm:     3px;
  --radius-md:     5px;
  --radius-lg:     8px;
  --radius-xl:     12px;

  --sidebar-width: 260px;
  --topbar-height: 56px;

  --shadow-sm:  0 1px 2px rgba(0,0,0,.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.6);
  --shadow-glow: 0 0 0 1px var(--accent), 0 0 12px rgba(59,130,246,.15);
}

/* ── Light Mode Tokens ───────────────────────────────────── */
[data-theme="light"] {
  --bg-base:       #f4f5f7;
  --bg-surface:    #ffffff;
  --bg-elevated:   #f8f9fb;
  --bg-hover:      #f0f2f5;
  --bg-active:     #e8f0fe;

  /* Sidebar stays the same dark navy in light mode */
  --bg-sidebar:         #1a1f3c;
  --bg-sidebar-hover:   #252b4a;
  --sidebar-border:     #252b4a;
  --sidebar-active-bg:  rgba(99,125,255,0.15);
  --sidebar-active-clr: #7b9fff;

  --border:        #e2e5eb;
  --border-strong: #c8cdd8;
  --border-focus:  #3b82f6;
  --text-primary:  #0f1117;
  --text-secondary:#4b5563;
  --text-tertiary: #9ca3af;
  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-dim:    #eff6ff;
  --green:         #16a34a;
  --green-dim:     #f0fdf4;
  --amber:         #d97706;
  --amber-dim:     #fffbeb;
  --red:           #dc2626;
  --red-dim:       #fef2f2;
  --purple:        #7c3aed;
  --purple-dim:    #f5f3ff;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.10);
  --shadow-glow: 0 0 0 3px rgba(37,99,235,.12);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

input,
select,
textarea,
button {
  font: inherit;
}

ul,
ol {
  list-style: none;
}

/* ── Scrollbars ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ── App Shell Layout ─────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: none;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  height: calc(100vh - var(--topbar-height));
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo { display: none; }

.sidebar-logo-img {
  height: 44px;         
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.sidebar-logo span {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.nav-section {
  padding: 0;
}

.nav-section-label {
  padding: 20px 20px 6px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.40); 
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 20px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.82); /* was 0.58 */
  border-radius: 0;
  margin: 0;
  transition: background 120ms ease, color 120ms ease;
  cursor: pointer;
  text-decoration: none;
  border-left: 3px solid transparent;
}

/* ── UPDATED: hover = full white ──────────────────────────── */
.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: rgba(255, 255, 255, 1); /* was 0.88 */
  text-decoration: none;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-clr);
  font-weight: 600;
  border-left-color: var(--sidebar-active-clr);
}

/* ── UPDATED: icons more visible ──────────────────────────── */
.nav-item .nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.80; /* was 0.65 */
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
  opacity: 1;
}

/* Sidebar bottom user area */
.sidebar-user {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user #topbar-user-name {
  color: rgba(255, 255, 255, 0.85) !important;
  font-size: var(--text-sm);
  font-weight: 500;
}

.sidebar-user .text-muted,
.sidebar-user #topbar-user-role {
  color: rgba(255, 255, 255, 0.38) !important;
}

.sidebar-user .btn-ghost {
  color: rgba(255, 255, 255, 0.45);
}

.sidebar-user .btn-ghost:hover {
  background: var(--bg-sidebar-hover);
  color: rgba(255, 255, 255, 0.85);
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px 0 0;
  gap: 12px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 110;
}
.topbar-logo {
  width: var(--sidebar-width);
  height: var(--topbar-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-right: 1px solid var(--border);
  border-bottom: none;
  padding: 4px 10px;
  box-sizing: border-box;
  overflow: hidden;
}

.topbar-logo-img {
  display: block;
  width: 100%;
  height: calc(var(--topbar-height) - 8px);
  max-width: none;
  object-fit: contain;
  object-position: center center;
  transform: scale(1.12);
  transform-origin: center center;
}

.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

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

/* ── Theme toggle icon visibility ─────────────────────────── */
[data-theme="dark"] #icon-moon  { display: block; }
[data-theme="dark"] #icon-sun   { display: none; }
[data-theme="light"] #icon-moon { display: none; }
[data-theme="light"] #icon-sun  { display: block; }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  flex: 1;
  min-width: 0; 
  padding: 24px 28px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.page-header p {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: 3px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
}

.card-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 14px 16px;
}

.card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--accent);
  position: relative;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.stat-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.grid-4 .stat-card:nth-child(1) {
  border-left-color: var(--green);
  background: linear-gradient(135deg, var(--bg-surface) 60%, rgba(34,197,94,0.04));
}
.grid-4 .stat-card:nth-child(2) {
  border-left-color: var(--accent);
  background: linear-gradient(135deg, var(--bg-surface) 60%, rgba(59,130,246,0.04));
}
.grid-4 .stat-card:nth-child(3) {
  border-left-color: var(--red);
  background: linear-gradient(135deg, var(--bg-surface) 60%, rgba(239,68,68,0.04));
}
.grid-4 .stat-card:nth-child(4) {
  border-left-color: var(--purple);
  background: linear-gradient(135deg, var(--bg-surface) 60%, rgba(167,139,250,0.04));
}

[data-theme="light"] .grid-4 .stat-card:nth-child(1) {
  background: linear-gradient(135deg, var(--bg-surface) 60%, rgba(22,163,74,0.03));
}
[data-theme="light"] .grid-4 .stat-card:nth-child(2) {
  background: linear-gradient(135deg, var(--bg-surface) 60%, rgba(37,99,235,0.03));
}
[data-theme="light"] .grid-4 .stat-card:nth-child(3) {
  background: linear-gradient(135deg, var(--bg-surface) 60%, rgba(220,38,38,0.03));
}
[data-theme="light"] .grid-4 .stat-card:nth-child(4) {
  background: linear-gradient(135deg, var(--bg-surface) 60%, rgba(124,58,237,0.03));
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-top: 6px;
  line-height: 1.1;
}

.stat-change {
  font-size: var(--text-xs);
  margin-top: 4px;
  color: var(--text-tertiary);
}
.stat-change.up   { color: var(--green); }
.stat-change.down { color: var(--red); }

.stat-bar {
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 8px;
}
.stat-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 600ms ease;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 120ms ease;
  line-height: 1;
  font-family: var(--font-sans);
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: var(--red);
}
.btn-danger:hover:not(:disabled) {
  background: var(--red);
  color: #fff;
}

.btn-sm {
  height: 26px;
  padding: 0 10px;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn-lg {
  height: 36px;
  padding: 0 18px;
  font-size: var(--text-md);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-full {
  width: 100%;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 12px;
  position: relative; 
}

.form-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: block;
}

.form-label .required {
  color: var(--red);
  margin-left: 2px;
}

.form-control {
  display: block;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-glow);
}

.form-control::placeholder {
  color: var(--text-tertiary);
}

.form-control.is-invalid {
  border-color: var(--red);
}

.form-control.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .15);
}

textarea.form-control {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239399a6' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: 3px;
}

.form-error {
  font-size: var(--text-xs);
  color: var(--red);
  margin-top: 3px;
}

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

/* ── Tables ───────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card .table-wrapper {
  border: none;
  border-radius: 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th {
  padding: 0 12px;
  height: 30px;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.table td {
  padding: 0 12px;
  height: 34px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
  white-space: nowrap;
  font-size: var(--text-sm);
}

.table tbody tr:hover td {
  background: var(--bg-hover);
}

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

.table td.num {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-align: right;
}

.table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.03);   /* was rgba(30,32,36,0.4) */
}
[data-theme="light"] .table tbody tr:nth-child(even) td {
  background: rgba(248, 249, 251, 0.4);
}
.table tbody tr:hover td {
  background: var(--bg-hover);
}

/* ── Badges / Status pills ────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.badge-success  { background: var(--green-dim);  color: var(--green); }
.badge-warning  { background: var(--amber-dim);  color: var(--amber); }
.badge-danger   { background: var(--red-dim);    color: var(--red); }
.badge-info     { background: var(--accent-dim); color: var(--accent); }
.badge-neutral  { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border-left: 3px solid;
}

.alert-success { background: var(--green-dim);  border-color: var(--green);  color: var(--green); }
.alert-warning { background: var(--amber-dim);  border-color: var(--amber);  color: var(--amber); }
.alert-danger  { background: var(--red-dim);    border-color: var(--red);    color: var(--red); }
.alert-info    { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ── Modals ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: visible;
  transform: translateY(8px) scale(0.99);
  transition: transform 150ms ease;
}

.modal-backdrop.open .modal {
  transform: translateY(0) scale(1);
}

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

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

.modal-body {
  padding: 18px;
  overflow-y: auto;           
  max-height: calc(88vh - 120px);
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-backdrop[style*="display: flex"],
.modal-backdrop[style*="display:flex"] {
  opacity: 1;
  pointer-events: all;
}

/* ── Toast ────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 320px;
  animation: toast-in 150ms ease forwards;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.warning { border-left: 3px solid var(--amber); }
.toast.info    { border-left: 3px solid var(--accent); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Grid helpers ─────────────────────────────────────────── */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* ── Utilities ────────────────────────────────────────────── */
.text-muted  { color: var(--text-secondary); }
.text-sm     { font-size: var(--text-sm); }
.text-xs     { font-size: var(--text-xs); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.font-bold   { font-weight: 700; }
.font-medium { font-weight: 600; }
.mt-1  { margin-top: 4px; }
.mt-2  { margin-top: 8px; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 16px; }
.w-full { width: 100%; }

.currency {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: -0.01em;
}

.section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Typeahead dropdown ───────────────────────────────────── */
.typeahead-dropdown {
  position: absolute;
  z-index: 9999;
  background: var(--bg-surface); 
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  margin-top: 2px;
  width: 100%;
  max-height: 220px;
  overflow-y: auto;
}

.typeahead-option {
  padding: 8px 10px;
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.typeahead-option:last-child {
  border-bottom: none;
}

.typeahead-option:hover,
.typeahead-option.active {
  background: var(--bg-hover);
  color: var(--accent);
}
.utility-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 20px;
  border: 1px solid var(--border); font-size: .82rem;
  cursor: pointer; transition: all .15s;
  background: var(--bg-surface); user-select: none;
}
.utility-chip:hover { border-color: var(--primary); }
.utility-chip input[type=checkbox] { accent-color: var(--primary); }
.utility-chip:has(input:checked) {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border-color: var(--primary); color: var(--primary);
}

.filter-chip {
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  color: var(--text-muted);
  line-height: 1.6;
}
.filter-chip:hover  { border-color: var(--primary); color: var(--primary); }
.filter-chip.active {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border-color: var(--primary);
  color: var(--primary);
}
/* colour helpers used in the summary table */
.ts-success { color: var(--green,  #1a7f5a); }
.ts-danger  { color: var(--red,    #c0392b); }
.ts-warning { color: var(--amber,  #b45309); }
.ts-bold    { font-weight: 600; }

/* ── Statement charge group styles ─────────────────────────────────────── */
.stmt-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.stmt-group-label {
  font-size: 13px;
  font-weight: 700;
  color: #0f1f3d;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stmt-group-label::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 14px;
  background: #2d6be4;
  border-radius: 2px;
}
.stmt-group-total { font-size: 13px; font-weight: 700; color: #0f1f3d; }
.stmt-line-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
.stmt-line-table thead tr {
  background: #0f1f3d;
  color: #fff;
}
.stmt-line-table thead th {
  padding: 7px 14px;
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: .04em;
  text-align: left;
}
.stmt-line-table thead th:last-child { text-align: right; }
.stmt-line-table tbody tr { border-bottom: 1px solid #f1f5f9; }
.stmt-line-table tbody tr:last-child { border-bottom: none; }
.stmt-line-table tbody td {
  padding: 9px 14px;
  color: #374151;
}
.stmt-line-table tbody td:last-child { text-align: right; font-weight: 700; color: #0f1f3d; }
 
/* Edit btn active state */
#stmt-edit-btn.editing {
  background: var(--text-primary);
  color: var(--bg-base);
  border-color: var(--text-primary);
}
.utility-deposit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.utility-deposit-row .utility-chip {
  display: flex; align-items: center; gap: 6px;
  min-width: 130px;
  font-size: .85rem;
  cursor: pointer;
  user-select: none;
}
.utility-deposit-row .utility-deposit-amount {
  max-width: 160px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #E24B4A;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  border-radius: 8px;
  text-align: center;
  pointer-events: none;
  border: 2px solid var(--bg-base, #fff); 
  display: none;
}
.notif-badge:not(:empty) { display: flex; align-items: center; justify-content: center; }
/* ── Reports nav group / submenu ── */
.nav-group { display: flex; flex-direction: column; }

.nav-group-toggle {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  /* Explicitly repeat nav-item layout since <button> ignores inherited height */
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 20px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.82);
  transition: background 120ms ease, color 120ms ease;
  border-left: 3px solid transparent;
  font-family: var(--font-sans);
}

.nav-group-toggle:hover {
  background: var(--bg-sidebar-hover);
  color: rgba(255, 255, 255, 1);
}

.nav-group.open .nav-group-toggle {
  color: rgba(255, 255, 255, 1);
}

.nav-group-chevron {
  margin-left: auto;
  transition: transform 0.2s ease;
  flex-shrink: 0;
  opacity: 0.5;
}

.nav-group.open .nav-group-chevron { transform: rotate(180deg); }

.nav-group-children {
  display: none;
  flex-direction: column;
  padding-left: 10px;
  border-left: 2px solid rgba(255,255,255,0.08);
  margin-left: 30px;   /* aligns with text, not icon */
  margin-top: 2px;
  margin-bottom: 4px;
}

.nav-group.open .nav-group-children { display: flex; }

.nav-sub-item {
  font-size: 12.5px;
  height: 34px;        /* slightly shorter than top-level */
  padding-left: 8px;
  color: rgba(255, 255, 255, 0.65);
}

.nav-sub-item:hover {
  color: rgba(255, 255, 255, 1);
}

.nav-sub-item.active {
  color: var(--sidebar-active-clr);
  background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-active-clr);
}

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .topbar {
    left: 0;
  }
  #sidebar-toggle {
    display: flex !important;
  }
  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .form-row.cols-2,
  .form-row.cols-3 {
    grid-template-columns: 1fr;
  }
}
/* ── Additional responsive behavior for narrow screens ─────── */
@media (max-width: 640px) {
  .main-content {
    padding: 16px 14px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .page-header h1 {
    font-size: 18px;
  }

  .topbar {
    padding-right: 12px;
  }

  .topbar-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar-actions .btn span,
  .topbar-actions .btn-secondary span {
    display: none; /* keep icons, drop label text if you wrap labels in <span> */
  }

  /* Filter bars — force each control to full width and stack */
  .flex[style*="flex-wrap"] {
    flex-direction: column;
    align-items: stretch !important;
  }

  .form-group {
    min-width: 0 !important;
    width: 100%;
  }

  .form-control {
    width: 100% !important;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-height: auto;
    padding: 10px 12px;
  }

  .card-body {
    padding: 12px;
  }

  .stat-value {
    font-size: 18px;
  }

  .modal {
    max-width: 100%;
    margin: 0 8px;
  }

  .modal-body {
    padding: 14px;
  }
}

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}