/* ============================================================
   Ryno Accounts — Enterprise UI Stylesheet
   Design system: dark navy sidebar, clean white content area
   ============================================================ */

/* ── 1. CSS Custom Properties (Design Tokens) ─────────────────────────── */
:root {
  --primary:          #1a2332;
  --primary-light:    #253448;
  --primary-hover:    #0f1824;
  --accent:           #3b82f6;
  --accent-hover:     #2563eb;
  --accent-light:     #eff6ff;
  --success:          #10b981;
  --success-light:    #ecfdf5;
  --warning:          #f59e0b;
  --warning-light:    #fffbeb;
  --danger:           #ef4444;
  --danger-light:     #fef2f2;
  --info:             #06b6d4;
  --info-light:       #ecfeff;

  --text-primary:     #1f2937;
  --text-secondary:   #6b7280;
  --text-muted:       #9ca3af;
  --text-inverse:     #ffffff;

  --bg-primary:       #ffffff;
  --bg-secondary:     #f9fafb;
  --bg-tertiary:      #f3f4f6;

  --border:           #e5e7eb;
  --border-dark:      #d1d5db;
  --border-radius:    8px;
  --border-radius-sm: 5px;
  --border-radius-lg: 12px;

  --sidebar-width:    240px;
  --topbar-height:    60px;

  --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
  --shadow:     0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl:  0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);

  --transition: 150ms ease;
  --font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
}

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

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-secondary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

img, svg { display: block; }

ul, ol { list-style: none; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ── 3. Typography ─────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }
h5 { font-size: 0.9rem; }

p { margin-bottom: 0.75rem; }
p:last-child { margin-bottom: 0; }

code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: var(--bg-tertiary);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.text-warning{ color: var(--warning); }

/* ── 4. Auth Layout ────────────────────────────────────────────────────── */
.auth-body {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-container {
  display: flex;
  width: 100%;
  max-width: 960px;
  min-height: 600px;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  margin: 2rem 1rem;
}

/* Left brand panel */
.auth-brand {
  flex: 0 0 420px;
  background: linear-gradient(160deg, #1a2332 0%, #1e3a5f 60%, #1e3a8a 100%);
  padding: 3rem;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  top: -80px; right: -80px;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: rgba(59,130,246,0.15);
}
.auth-brand::after {
  content: '';
  position: absolute;
  bottom: -60px; left: -60px;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: rgba(59,130,246,0.08);
}

.auth-brand-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 3rem;
}
.auth-logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  letter-spacing: -0.025em;
}

.auth-brand-content {
  flex: 1;
}
.auth-brand-headline {
  font-size: 1.875rem;
  font-weight: 700;
  color: white;
  line-height: 1.2;
  margin-bottom: 1rem;
}
.auth-brand-sub {
  color: rgba(255,255,255,0.65);
  font-size: 0.9375rem;
  line-height: 1.7;
}

.auth-feature-list {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}
.auth-feature-list li {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: rgba(255,255,255,0.8);
  font-size: 0.875rem;
}

.auth-plan-card {
  margin-top: 2rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--border-radius);
  padding: 1rem 1.25rem;
}
.auth-plan-name {
  font-weight: 600;
  color: white;
  margin-bottom: 0.5rem;
}
.auth-plan-features {
  list-style: disc;
  padding-left: 1.25rem;
  color: rgba(255,255,255,0.7);
  font-size: 0.875rem;
  line-height: 1.9;
}

/* Right form panel */
.auth-form-panel {
  flex: 1;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
}

.auth-form-inner {
  width: 100%;
  max-width: 380px;
}

.auth-form-header {
  margin-bottom: 2rem;
}
.auth-form-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
}
.auth-form-subtitle {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.auth-form-footer {
  margin-top: 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ── 5. App Layout (sidebar + topbar + main) ──────────────────────────── */
.app-body {
  background: var(--bg-secondary);
  min-height: 100vh;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── 6. Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: width var(--transition), transform var(--transition);
}

/* Scrollbar styling for sidebar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}
.sidebar-logo-text {
  font-size: 1rem;
  font-weight: 700;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.sidebar-section {
  padding: 0 0 0.5rem;
}
.sidebar-section-label {
  display: block;
  padding: 0.625rem 1rem 0.375rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
}

.sidebar-menu { padding: 0; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5625rem 1rem;
  color: rgba(255,255,255,0.65);
  font-size: 0.875rem;
  font-weight: 450;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  border-radius: 0;
  white-space: nowrap;
  position: relative;
}
.sidebar-link:hover {
  background: rgba(255,255,255,0.07);
  color: white;
}
.sidebar-link.active {
  background: rgba(59,130,246,0.18);
  color: white;
  font-weight: 500;
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.sidebar-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  opacity: 0.75;
}
.sidebar-link:hover .sidebar-icon,
.sidebar-link.active .sidebar-icon { opacity: 1; }

.sidebar-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 0.125rem 0.4rem;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 0.875rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.sidebar-company {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.sidebar-company-avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.sidebar-company-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-company-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-company-plan {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.4);
  text-transform: capitalize;
}

/* Collapsed sidebar */
.app-layout.sidebar-collapsed .sidebar {
  width: 60px;
}
.app-layout.sidebar-collapsed .sidebar-logo-text,
.app-layout.sidebar-collapsed .sidebar-section-label,
.app-layout.sidebar-collapsed .sidebar-link span:not(.sidebar-icon),
.app-layout.sidebar-collapsed .sidebar-badge,
.app-layout.sidebar-collapsed .sidebar-company-info {
  display: none;
}
.app-layout.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 0.5625rem;
}
.app-layout.sidebar-collapsed .sidebar-icon {
  width: 20px; height: 20px;
  opacity: 1;
}
.app-layout.sidebar-collapsed .app-main {
  margin-left: 60px;
}

/* ── 7. Main area ──────────────────────────────────────────────────────── */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* ── 8. Topbar ─────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.375rem;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  transition: color var(--transition), background var(--transition);
}
.sidebar-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.topbar-date {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* User menu */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.375rem 0.625rem;
  border-radius: var(--border-radius);
  transition: background var(--transition);
  position: relative;
  user-select: none;
}
.topbar-user:hover { background: var(--bg-tertiary); }

.user-avatar {
  width: 34px; height: 34px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.user-avatar-sm {
  width: 28px; height: 28px;
  font-size: 0.6875rem;
  border-radius: 6px;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}
.user-role {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: capitalize;
}
.user-chevron {
  color: var(--text-muted);
  transition: transform var(--transition);
}
.topbar-user[aria-expanded="true"] .user-chevron {
  transform: rotate(180deg);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 200px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  display: none;
}
.user-dropdown.open { display: block; }

.user-dropdown-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.user-dropdown-header strong {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-dropdown-header span {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--bg-secondary); }
.dropdown-item-danger { color: var(--danger); }
.dropdown-item-danger:hover { background: var(--danger-light); }

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

/* ── 9. Page Content Area ──────────────────────────────────────────────── */
.page-content {
  padding: 1.5rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.page-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.125rem;
}
.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ── 10. Cards ─────────────────────────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.card-action {
  font-size: 0.8125rem;
  color: var(--accent);
  font-weight: 500;
}
.card-action:hover { color: var(--accent-hover); }

.card-body {
  padding: 1.25rem;
}
.card-body.p-0 { padding: 0; }

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); }

.kpi-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-icon svg { width: 20px; height: 20px; }

.kpi-cash     .kpi-icon { background: #eff6ff; color: var(--accent); }
.kpi-receivable .kpi-icon { background: #ecfdf5; color: var(--success); }
.kpi-payable  .kpi-icon { background: #fffbeb; color: var(--warning); }
.kpi-profit   .kpi-icon { background: #ecfdf5; color: var(--success); }
.kpi-loss     .kpi-icon { background: var(--danger-light); color: var(--danger); }

.kpi-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.kpi-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}
.kpi-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin: 0.125rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.kpi-sub.kpi-warning { color: var(--warning); font-weight: 500; }

/* Quick Actions */
.quick-actions-body {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.quick-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.quick-action-btn svg { width: 16px; height: 16px; color: var(--accent); }
.quick-action-btn:hover {
  background: white;
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
}

/* ── 11. Tables ────────────────────────────────────────────────────────── */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  padding: 0.625rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }

.table-hover tbody tr:hover td { background: var(--bg-secondary); }
.table-sm th, .table-sm td { padding: 0.5rem 1rem; }

.table-link {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}
.table-link:hover { text-decoration: underline; }

.th-actions, .td-actions { text-align: right; white-space: nowrap; }
.td-actions { display: flex; gap: 0.375rem; justify-content: flex-end; align-items: center; }

.table tfoot td { border-top: 2px solid var(--border-dark); }
.table-total td { background: var(--bg-tertiary); font-weight: 600; }
.table-subtotal td { background: var(--bg-secondary); font-weight: 500; border-top: 1px solid var(--border-dark); }
.table-group-header th, .table-group-header td {
  background: var(--primary);
  color: rgba(255,255,255,0.9);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.5rem 1rem;
}
.table-balanced td { background: var(--success-light); }
.table-imbalanced td { background: var(--danger-light); }
.table-profit td { background: var(--success-light); color: var(--success); }
.table-loss td { background: var(--danger-light); color: var(--danger); }

.row-inactive td { opacity: 0.55; }
.row-voided td { opacity: 0.55; text-decoration: line-through; }
.row-voided .badge, .row-voided .btn { text-decoration: none; opacity: 1; }

.td-narration { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Report table */
.table-report { font-size: 0.875rem; }
.table-report td:last-child, .table-report th:last-child { text-align: right; }

/* ── 12. Forms ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.125rem; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
}
.form-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.375rem;
}
.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}
.form-label.required::after {
  content: ' *';
  color: var(--danger);
  font-weight: 600;
}
.required { color: var(--danger); }

.form-input,
.form-control,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  padding: 0.5625rem 0.75rem;
  background: white;
  border: 1px solid var(--border-dark);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.form-input::placeholder,
.form-control::placeholder { color: var(--text-muted); }
.form-input:focus,
.form-control:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* Input group (prefix/suffix) */
.input-group {
  display: flex;
  position: relative;
}
.input-group .form-input {
  flex: 1;
}
.input-prefix {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-dark);
  border-right: none;
  border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  white-space: nowrap;
}
.input-group .form-input {
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}
.input-suffix-btn {
  position: absolute;
  right: 0;
  top: 0; bottom: 0;
  padding: 0 0.75rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: color var(--transition);
}
.input-suffix-btn:hover { color: var(--text-primary); }

/* Checkbox */
.form-check-group { margin-top: 0.25rem; }
.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.form-check-input {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}
.form-check-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.form-link {
  font-size: 0.8125rem;
  color: var(--accent);
  font-weight: 500;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  padding-top: 0.5rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border);
}

/* Password strength */
.password-strength {
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 0.25rem;
  height: 1rem;
  transition: color var(--transition);
}
.strength-weak     { color: var(--danger); }
.strength-fair     { color: var(--warning); }
.strength-good     { color: var(--info); }
.strength-strong   { color: var(--success); }
.strength-very-strong { color: var(--success); }

/* ── 13. Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--border-radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:disabled, .btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-secondary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
}

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

.btn-sm  { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-xs  { padding: 0.25rem  0.5rem;  font-size: 0.75rem;   }
.btn-lg  { padding: 0.75rem  1.5rem;  font-size: 1rem;       }
.btn-full{ width: 100%; justify-content: center; }

.btn-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ── 14. Badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.55em;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1;
}
.badge-success   { background: var(--success-light); color: #065f46; }
.badge-warning   { background: var(--warning-light); color: #92400e; }
.badge-danger    { background: var(--danger-light);  color: #991b1b; }
.badge-info      { background: var(--info-light);    color: #155e75; }
.badge-secondary { background: var(--bg-tertiary);   color: var(--text-secondary); }

/* Account type badges */
.badge-type-asset     { background: #eff6ff; color: #1e40af; }
.badge-type-liability { background: #fef3c7; color: #92400e; }
.badge-type-equity    { background: #f0fdf4; color: #166534; }
.badge-type-revenue   { background: #ecfeff; color: #155e75; }
.badge-type-expense   { background: #fff1f2; color: #9f1239; }

/* Role badges */
.badge-owner      { background: #f5f3ff; color: #4c1d95; }
.badge-accountant { background: #eff6ff; color: #1e3a8a; }
.badge-auditor    { background: #ecfeff; color: #155e75; }
.badge-viewer     { background: var(--bg-tertiary); color: var(--text-secondary); }

/* ── 15. Alerts ────────────────────────────────────────────────────────── */
.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  position: relative;
}
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: var(--danger-light);  color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: var(--info-light);    color: #155e75; border: 1px solid #a5f3fc; }

.alert-list {
  list-style: disc;
  padding-left: 1.25rem;
  margin-top: 0.25rem;
}
.alert-list li { margin-bottom: 0.125rem; }

.alert-dismissible { padding-right: 2.5rem; }
.alert-close {
  position: absolute;
  top: 0.625rem; right: 0.75rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.125rem;
  opacity: 0.6;
  transition: opacity var(--transition);
  line-height: 1;
  color: inherit;
}
.alert-close:hover { opacity: 1; }

/* ── 16. Filter bar ────────────────────────────────────────────────────── */
.filter-bar {
  margin-bottom: 1rem;
}
.filter-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.filter-input  { max-width: 260px; }
.filter-select { max-width: 160px; }
.filter-date   { max-width: 150px; }

/* ── 17. Empty state ───────────────────────────────────────────────────── */
.empty-state {
  padding: 3.5rem 2rem;
  text-align: center;
  color: var(--text-muted);
}
.empty-state svg {
  width: 48px; height: 48px;
  margin: 0 auto 1rem;
  opacity: 0.3;
}
.empty-state p {
  font-size: 0.9375rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

/* ── 18. Transaction entry lines ──────────────────────────────────────── */
.entry-lines-wrapper {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.entry-lines-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}
.entry-balance-indicator {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}
.entry-balance-indicator.balanced   { background: var(--success-light); color: #065f46; }
.entry-balance-indicator.imbalanced { background: var(--danger-light);  color: #991b1b; }

.entry-table .form-input,
.entry-table .form-select {
  padding: 0.4375rem 0.625rem;
  font-size: 0.8125rem;
}

/* ── 19. Detail grid ───────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}
.detail-item-full { grid-column: 1 / -1; }
.detail-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.detail-value {
  font-size: 0.9375rem;
  color: var(--text-primary);
}

/* ── 20. Reports ───────────────────────────────────────────────────────── */
.report-card {
  overflow: hidden;
}
.report-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
  background: var(--bg-secondary);
}
.report-company {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
}
.report-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0.25rem 0;
}
.report-period {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.bs-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* ── 21. Pagination ────────────────────────────────────────────────────── */
.pagination-nav {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}
.page-item .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 0.625rem;
  border: 1px solid var(--border-dark);
  border-radius: var(--border-radius-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  background: white;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.page-item .page-link:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.page-item.active .page-link { background: var(--accent); color: white; border-color: var(--accent); }
.page-item.disabled .page-link { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ── 22. Toast notifications ───────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
}
.toast {
  min-width: 260px;
  max-width: 360px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  animation: toast-in 0.25s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(2rem); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger);  }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info    { border-left: 3px solid var(--accent);  }

.toast-message { font-size: 0.875rem; color: var(--text-primary); flex: 1; }
.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.toast-close:hover { color: var(--text-primary); }

/* ── 23. Modal ─────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--text-muted);
  padding: 0.25rem;
  line-height: 1;
  border-radius: 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }
.modal-body   { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ── 24. User cell ─────────────────────────────────────────────────────── */
.user-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── 25. Error pages ───────────────────────────────────────────────────── */
.error-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
}
.error-box {
  text-align: center;
  padding: 3rem 2rem;
}
.error-code {
  font-size: 6rem;
  font-weight: 800;
  color: var(--border-dark);
  line-height: 1;
  margin-bottom: 0.5rem;
}
.error-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.error-message {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* ── 26. Account code ──────────────────────────────────────────────────── */
.account-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  color: var(--primary);
  font-weight: 600;
}

/* ── 27. Utility classes ───────────────────────────────────────────────── */
.mb-0 { margin-bottom: 0; }
.mt-0 { margin-top: 0; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none !important; }

/* ── 28. Print styles ──────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .filter-bar, .btn, .alert-close, .toast-container { display: none !important; }
  .app-main { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc; }
  .report-card { break-inside: avoid; }
  body { background: white; }
  .table td, .table th { padding: 0.375rem 0.5rem; }
}

/* ── 29. Responsive ────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .bs-layout { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile sidebar overlay backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}

@media (max-width: 768px) {
  /* On mobile, sidebar is hidden off-screen by default */
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important; /* full width drawer */
    --sidebar-width: 240px;
  }

  /* Show full sidebar text on mobile drawer (override icon-only) */
  .sidebar-logo-text,
  .sidebar-section-label,
  .sidebar-link span:not(.sidebar-icon),
  .sidebar-badge,
  .sidebar-company-info { display: revert; }

  .sidebar-link { justify-content: flex-start; padding: 0.65rem 1rem; }
  .sidebar-icon { width: 18px; height: 18px; }

  /* No margin offset on mobile — sidebar is overlay */
  .app-main { margin-left: 0 !important; }

  /* When sidebar is open on mobile */
  .app-layout.sidebar-open .sidebar { transform: translateX(0); }
  .app-layout.sidebar-open .sidebar-backdrop { display: block; }

  /* Desktop collapse class has no effect on mobile */
  .app-layout.sidebar-collapsed .sidebar { transform: translateX(-100%); }
  .app-layout.sidebar-collapsed .app-main { margin-left: 0 !important; }

  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .auth-container { flex-direction: column; margin: 1rem; }
  .auth-brand { flex: none; padding: 2rem; }
  .auth-brand-headline { font-size: 1.375rem; }
  .auth-form-panel { padding: 2rem 1.5rem; }
  .topbar-date { display: none; }
  .user-info { display: none; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .filter-form { flex-direction: column; align-items: stretch; }
  .filter-input, .filter-select, .filter-date { max-width: none; }
  .page-content { padding: 1rem; }
  .topbar { padding: 0 1rem; }
}

/* ============================================================
   Payables & Receivables — Aging, Detail, Progress
   ============================================================ */

/* Aging grid */
.aging-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--border);
}
.aging-bucket {
  padding: 1.25rem 1.5rem;
  border-right: 1px solid var(--border);
  text-align: center;
}
.aging-bucket:last-child { border-right: none; }
.aging-days  { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.375rem; font-weight: 500; }
.aging-amount { font-size: 1.1rem; font-weight: 700; }
.aging-bucket--ok       .aging-amount { color: var(--text-primary); }
.aging-bucket--warn     .aging-amount { color: var(--warning); }
.aging-bucket--alert    .aging-amount { color: #f97316; }
.aging-bucket--critical .aging-amount { color: var(--danger); }

/* Detail layout (2 cards side-by-side) */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0;
}
.detail-list { padding: 0 1.5rem 1.5rem; }
.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--bg-tertiary);
  gap: 1rem;
}
.detail-item:last-child { border-bottom: none; }
.detail-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
  min-width: 120px;
}
.detail-value { font-size: 0.875rem; color: var(--text-primary); text-align: right; }

/* Payment summary inside card body */
.payment-summary { padding: 1.5rem; }
.payment-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  font-size: 0.9375rem;
}
.payment-summary-divider {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 0;
}

/* Progress bar */
.progress-wrap {}
.progress-bar-track {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.bg-success { background: var(--success); }
.bg-accent  { background: var(--accent); }
.progress-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
  text-align: right;
}

/* Table row highlight for overdue */
tr.row-danger { background-color: #fff5f5; }
tr.row-danger:hover { background-color: #ffe4e4; }

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1rem 1.25rem;
  flex-wrap: wrap;
}
.filter-bar .form-control { flex: 1; min-width: 150px; max-width: 220px; }
.filter-bar .form-control--sm { flex: 0 0 auto; min-width: 120px; }

/* KPI card variants */
.kpi-card--danger  { border-top: 3px solid var(--danger); }
.kpi-card--warning { border-top: 3px solid var(--warning); }
.kpi-card--success { border-top: 3px solid var(--success); }

/* btn-action icon buttons */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.btn-action:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-action svg { width: 15px; height: 15px; }

/* Misc utility */
.text-xs   { font-size: 0.7rem; }
.text-sm   { font-size: 0.8125rem; }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.ml-1 { margin-left: 0.25rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.link-primary { color: var(--accent); text-decoration: none; }
.link-primary:hover { text-decoration: underline; }
.text-danger  { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-muted   { color: var(--text-muted); }
.text-warning { color: var(--warning); }

/* Modal overlay */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.is-open { display: flex; }
.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.375rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 0.25rem;
}
.modal-body   { padding: 1.25rem 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
}

/* card-footer */
.card-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

/* table-empty */
.table-empty {
  text-align: center;
  padding: 2.5rem 1rem !important;
  color: var(--text-muted);
}

/* form-hint */
.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 0.5rem;
}

@media (max-width: 900px) {
  .aging-grid  { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .aging-grid  { grid-template-columns: 1fr 1fr; }
  .filter-bar  { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control,
  .filter-bar .form-control--sm { max-width: none; }
}

/* ============================================================
   AI Phase 1 — Suggestion Panel & Duplicate Review UI
   ============================================================ */

/* Inline suggestion panel (below narration textarea) */
.ai-suggest-panel {
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
  margin-top: 0.5rem;
  padding: 0.625rem 0.875rem;
}
.ai-suggest-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #1d4ed8;
  margin-bottom: 0.5rem;
}
.ai-suggest-icon { width: 13px; height: 13px; }
.ai-suggest-dismiss {
  margin-left: auto;
  cursor: pointer;
  font-size: 1rem;
  color: #93c5fd;
  line-height: 1;
  padding: 0 0.125rem;
}
.ai-suggest-dismiss:hover { color: #1d4ed8; }
.ai-suggest-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* Suggestion chip */
.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #bfdbfe;
  background: #fff;
  cursor: pointer;
  font-size: 0.78rem;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.ai-chip:hover { background: #dbeafe; border-color: #93c5fd; transform: translateY(-1px); }
.ai-chip--applied { background: #dcfce7; border-color: #86efac; }
.ai-chip-type  { color: #6b7280; font-size: 0.7rem; }
.ai-chip-label { color: #1e40af; font-weight: 600; }
.ai-chip-conf  { color: #3b82f6; font-size: 0.7rem; }
.ai-chip-check { color: #16a34a; font-weight: 700; }

/* Highlighted ledger select (when AI suggests but no exact match) */
.ai-highlighted {
  outline: 2px solid #3b82f6;
  outline-offset: 1px;
  animation: aiPulse 0.6s ease 3;
}
@keyframes aiPulse {
  0%, 100% { outline-color: #3b82f6; }
  50%       { outline-color: #93c5fd; }
}

/* AI dashboard — How it works list */
.ai-how-list { display: flex; flex-direction: column; gap: 1rem; padding: 0.5rem 0; }
.ai-how-item { display: flex; gap: 0.875rem; align-items: flex-start; }
.ai-how-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ai-how-icon svg { width: 18px; height: 18px; }
.ai-how-icon--blue   { background: #dbeafe; color: #1d4ed8; }
.ai-how-icon--orange { background: #ffedd5; color: #c2410c; }
.ai-how-icon--green  { background: #dcfce7; color: #15803d; }
.ai-how-title { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); margin-bottom: 0.2rem; }
.ai-how-desc  { font-size: 0.8125rem; color: var(--text-muted); line-height: 1.5; }

/* AI empty state */
.ai-empty-state {
  text-align: center; padding: 2.5rem 1rem; color: var(--text-muted);
}
.ai-empty-state svg { width: 40px; height: 40px; margin: 0 auto 0.75rem; display: block; color: var(--success); }

/* Duplicate flag cards */
.dup-card {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
}
.dup-card:last-child { border-bottom: none; }
.dup-card--resolved { opacity: 0.7; }
.dup-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.875rem;
}
.dup-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.dup-compare {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem;
  align-items: center; margin-bottom: 0.875rem;
}
.dup-vs { font-weight: 700; color: var(--text-muted); font-size: 0.875rem; text-align: center; }
.dup-txn {
  background: var(--bg-secondary); border-radius: 8px;
  padding: 0.875rem 1rem;
}
.dup-txn-ref    { font-weight: 600; margin-bottom: 0.2rem; }
.dup-txn-date   { margin-bottom: 0.25rem; }
.dup-txn-narration { font-size: 0.8125rem; color: var(--text-secondary); margin-bottom: 0.375rem; }
.dup-txn-amount { font-size: 1rem; }
.dup-actions    { display: flex; gap: 0.625rem; }
.dup-resolved-label { display: flex; align-items: center; gap: 0.5rem; }

/* Tab bar (for filter tabs) */
.tab-bar {
  display: flex; gap: 0; border-bottom: 2px solid var(--border);
}
.tab-link {
  padding: 0.625rem 1.125rem;
  font-size: 0.875rem; font-weight: 500;
  color: var(--text-muted); text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-link:hover { color: var(--text-primary); }
.tab-link--active { color: var(--accent); border-bottom-color: var(--accent); }

/* Rules info grid */
.rules-info-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem;
}
.rules-info-item {
  background: var(--bg-secondary); border-radius: 8px; padding: 0.875rem;
}
.rules-info-label {
  font-family: monospace; font-size: 0.8125rem; font-weight: 700;
  color: var(--accent); margin-bottom: 0.375rem;
}
.rules-info-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }

/* Range input */
.form-range { width: 100%; accent-color: var(--accent); }

@media (max-width: 768px) {
  .dup-compare   { grid-template-columns: 1fr; }
  .dup-vs        { display: none; }
  .rules-info-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .rules-info-grid { grid-template-columns: 1fr; }
  .tab-link { padding: 0.5rem 0.75rem; font-size: 0.8rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Cash Flow Statement
   ═══════════════════════════════════════════════════════════════════════════ */
.cf-table { border-collapse: collapse; }
.cf-section-header th { background: var(--bg-secondary); font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary);
  padding: 0.6rem 1.25rem; }
.cf-primary td { font-weight: 500; padding: 0.6rem 1.25rem; }
.cf-indent td   { padding: 0.45rem 1.25rem 0.45rem 2.5rem; color: var(--text-secondary); font-size: 0.9rem; }
.cf-subtotal    { border-top: 1px solid var(--border); background: var(--bg-secondary); }
.cf-subtotal td { padding: 0.65rem 1.25rem; font-size: 0.9rem; }
.cf-net         { border-top: 2px solid var(--border-dark, #cbd5e1); }
.cf-net td      { padding: 0.75rem 1.25rem; font-size: 0.95rem; }
.cf-positive td { color: var(--success); }
.cf-negative td { color: var(--danger); }
.cf-cash-line td { padding: 0.55rem 1.25rem; color: var(--text-secondary); }
.cf-closing      { border-top: 2px solid var(--accent); border-bottom: 3px double var(--accent); background: rgba(59,130,246,.04); }
.cf-closing td   { padding: 0.85rem 1.25rem; font-size: 1rem; color: var(--accent); }
.cf-amount       { width: 160px; font-variant-numeric: tabular-nums; }
.cf-empty        { padding: 0.75rem 2.5rem !important; font-style: italic; }
.cf-note         { margin-top: 1rem; padding: 0.75rem 1rem; background: var(--bg-secondary);
  border-left: 3px solid var(--accent); border-radius: var(--radius); font-size: 0.82rem;
  color: var(--text-secondary); line-height: 1.6; }
.report-method   { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ═══════════════════════════════════════════════════════════════════════════
   Print / PDF — hides chrome, keeps report content clean
   ═══════════════════════════════════════════════════════════════════════════ */
@media print {
  .sidebar,
  .topbar,
  .filter-bar,
  .btn-group,
  .cf-note,
  .alert { display: none !important; }

  .app-main  { margin-left: 0 !important; }
  .app-layout { display: block !important; }
  .page-content { padding: 0 !important; }
  .page-header { margin-bottom: 0.5rem !important; }
  .page-header h1 { font-size: 1.1rem !important; }
  .page-header p  { font-size: 0.8rem !important; }

  .card, .report-card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; }
  .bs-layout { display: block !important; }
  .bs-layout .card { margin-bottom: 1rem; }

  .table th, .table td { padding: 4px 8px !important; font-size: 10pt !important; }
  .table-group-header td, .table-group-header th { font-size: 9pt !important; }
  .cf-indent td { padding-left: 24px !important; }

  .report-header { padding: 0.75rem 1rem !important; }
  .report-company { font-size: 11pt !important; }
  .report-title   { font-size: 13pt !important; }
  .report-period  { font-size: 9pt !important; }

  body { font-size: 10pt; color: #000; background: #fff; }
  a    { color: inherit !important; text-decoration: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Inventory module
   ═══════════════════════════════════════════════════════════════════════════ */
.row-warning { background: rgba(245,158,11,.06); }
.row-warning:hover { background: rgba(245,158,11,.12) !important; }
.fw-500  { font-weight: 500; }
.ms-1    { margin-left: 0.25rem; }
.ms-auto { margin-left: auto; }
.d-inline { display: inline; }
.gap-2   { gap: 0.5rem; }
.radio-group { display: flex; gap: 1rem; align-items: center; }
.radio-group label { display: flex; align-items: center; gap: 0.35rem; cursor: pointer; font-size:0.9rem; }
.filter-toggle { display: flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; cursor: pointer; }
.input-prefix  { display: flex; align-items: center; }
.input-prefix span { background: var(--bg-secondary); border: 1px solid var(--border); border-right: none;
  padding: 0 0.6rem; height: 36px; line-height: 36px; border-radius: var(--radius) 0 0 var(--radius);
  font-size: 0.9rem; color: var(--text-secondary); white-space: nowrap; }
.input-prefix .form-input { border-radius: 0 var(--radius) var(--radius) 0; }

/* ═══════════════════════════════════════════════════════════════════════════
   Settings module — company, subscription, features
   ═══════════════════════════════════════════════════════════════════════════ */
.settings-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .settings-layout { grid-template-columns: 1fr; } }

/* Plan current badge */
.plan-current-badge { display: flex; align-items: baseline; gap: 0.75rem; }
.plan-current-badge .plan-name  { font-size: 1.4rem; font-weight: 700; color: var(--accent); text-transform: capitalize; }
.plan-current-badge .plan-price { font-size: 0.9rem; color: var(--text-muted); }

/* Subscription banner */
.sub-current-banner { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.9rem 1.25rem; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.sub-label    { display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing:.06em; color: var(--text-muted); }
.sub-plan-name { font-size: 1.2rem; font-weight: 700; color: var(--accent); text-transform: capitalize; }
.sub-usage    { font-size: 0.88rem; color: var(--text-secondary); }

/* Plan comparison grid */
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 800px) { .plan-grid { grid-template-columns: 1fr; } }

.plan-card          { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem;
  position: relative; background: var(--bg-card); display: flex; flex-direction: column; }
.plan-card-current  { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,.15); }
.plan-card-featured { background: linear-gradient(135deg, rgba(59,130,246,.04) 0%, rgba(59,130,246,.01) 100%); }
.plan-popular-badge { position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; font-size: 0.7rem; font-weight: 600; padding: 2px 10px;
  border-radius: 20px; letter-spacing: .05em; white-space: nowrap; }

.plan-card-header   { margin-bottom: 1.25rem; }
.plan-card-name     { font-weight: 700; font-size: 1rem; text-transform: capitalize; margin-bottom: 0.4rem; }
.plan-card-price    { margin-bottom: 0.2rem; }
.price-amount       { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); }
.price-period       { font-size: 0.85rem; color: var(--text-muted); }
.plan-card-users    { font-size: 0.82rem; color: var(--text-muted); }

.plan-features-list { list-style: none; padding: 0; margin: 0 0 1.25rem; flex: 1; }
.plan-features-list li { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0;
  font-size: 0.88rem; }
.feat-yes svg  { color: var(--success); flex-shrink: 0; }
.feat-no  svg  { color: var(--text-muted); flex-shrink: 0; }
.feat-no       { color: var(--text-muted); }
.feat-addon    { font-size: 0.75rem; color: var(--text-muted); margin-left: 0.25rem; }
.plan-card-action .btn-block { width: 100%; text-align: center; }

/* Feature toggles */
.feature-toggle-list { list-style: none; padding: 0; margin: 0; }
.feature-toggle-item { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.feature-toggle-item:last-child { border-bottom: none; }
.feature-locked .feature-info  { opacity: .6; }

.feature-label      { font-weight: 500; font-size: 0.95rem; margin-bottom: 0.2rem; }
.feature-desc       { font-size: 0.83rem; color: var(--text-muted); line-height: 1.5; }
.feature-upgrade-note { font-size: 0.8rem; margin-top: 0.3rem; color: var(--warning, #d97706); }
.feature-upgrade-note a { color: var(--accent); }

.feature-toggle-ctrl { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; flex-shrink: 0; min-width: 64px; }
.toggle-status { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

/* Toggle switch */
.toggle-switch        { position: relative; display: inline-block; width: 42px; height: 24px; cursor: pointer; }
.toggle-switch input  { opacity: 0; width: 0; height: 0; }
.toggle-slider        { position: absolute; inset: 0; background: var(--border-dark, #cbd5e1);
  border-radius: 24px; transition: background 0.2s; }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Notification Bell ────────────────────────────────────────────────────── */
.notif-bell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.notif-bell:hover { background: var(--bg-hover); color: var(--text); }

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

.notif-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}
.notif-dropdown.open { display: block; }

.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .875rem;
}

.notif-dropdown-footer {
  padding: .65rem 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: .82rem;
}

/* Notification list page */
.notif-item { transition: background 0.1s; }
.notif-item:hover { background: var(--bg-hover); }
.notif-item--unread { background: var(--primary-50, #eff6ff); }
.notif-item--unread:hover { background: #dbeafe; }
.notif-item:last-child { border-bottom: none !important; }
