/* ════════════════════════════════════════════════════════════════
   CloudLedgerAI — Direct Expenses, Receipts & Payments Module CSS
   ════════════════════════════════════════════════════════════════ */

.nav-group.exp-pay-group.open .nav-sub {
  max-height: 220px;
}

/* ── Container & Header ────────────────────────────────────────── */
.ep-workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.15s ease-in-out;
}

.ep-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: #ffffff;
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.ep-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ep-title-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
}
.ep-icon-expenses { background: linear-gradient(135deg, #ef4444, #f87171); }
.ep-icon-receipts { background: linear-gradient(135deg, #10b981, #34d399); }
.ep-icon-payments { background: linear-gradient(135deg, #6366f1, #818cf8); }

.ep-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ep-subtitle {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

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

.ep-search-box {
  position: relative;
  min-width: 240px;
}
.ep-search-box input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  background: #f8fafc;
  transition: all 0.15s ease;
}
.ep-search-box input:focus {
  background: #fff;
  border-color: #6366f1;
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.ep-search-box svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: #94a3b8;
}

/* ── KPI Grid ──────────────────────────────────────────────────── */
.ep-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.ep-kpi-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.ep-kpi-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.ep-kpi-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.ep-kpi-badge {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

/* ── Tables & Badges ───────────────────────────────────────────── */
.ep-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  overflow: hidden;
}

.ep-table-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color);
  background: #fafbff;
  font-size: 13px;
  color: #64748b;
}

.ep-table-wrap {
  overflow-x: auto;
}

.ep-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.ep-table th {
  padding: 11px 16px;
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

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

.ep-table tr:hover td {
  background: #f8faff;
}

.ep-table .payment-link {
  color: #2563eb;
  font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ep-table .payment-link:hover {
  text-decoration: underline;
}

.ep-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
}
.ep-mode-cash { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.ep-mode-bank { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.ep-mode-card { background: #faf5ff; color: #7e22ce; border-color: #e9d5ff; }

.ep-branch-badge {
  background: #f1f5f9;
  color: #475569;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.ep-status-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.ep-status-paid { background: #dcfce7; color: #15803d; }
.ep-status-open { background: #e0e7ff; color: #3730a3; }

/* ── Drawers (Slide-in Panels) ─────────────────────────────────── */
.ep-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.ep-drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.ep-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 680px;
  background: #ffffff;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
  z-index: 1051;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.ep-drawer.open {
  transform: translateX(0);
}

.ep-drawer-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.ep-drawer-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ep-drawer-close {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #64748b;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}
.ep-drawer-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.ep-drawer-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ep-form-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  align-items: start;
  gap: 16px;
}

.ep-form-label {
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  padding-top: 8px;
}
.ep-form-label.required::after {
  content: " *";
  color: #ef4444;
  font-weight: bold;
}

.ep-input-group {
  display: flex;
  gap: 8px;
}

.ep-receipt-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.ep-receipt-dropzone:hover, .ep-receipt-dropzone.dragover {
  border-color: #6366f1;
  background: #eef2ff;
}
.ep-receipt-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  background: #e0e7ff;
  color: #4f46e5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ep-receipt-title {
  font-weight: 600;
  font-size: 13.5px;
  color: #1e293b;
}
.ep-receipt-sub {
  font-size: 12px;
  color: #64748b;
  margin-top: 3px;
}

.ep-drawer-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.ep-btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.ep-btn-primary {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #ffffff;
  border: none;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}
.ep-btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.ep-btn-secondary {
  background: #ffffff;
  color: #334155;
  border: 1px solid var(--border-color);
}
.ep-btn-secondary:hover {
  background: #f1f5f9;
}

.ep-btn-danger {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}
.ep-btn-danger:hover {
  background: #fecaca;
}

/* ══════════════════════════════════════════════════════════════════
   DARK MODE OVERRIDES (Payments & Expenses)
   ══════════════════════════════════════════════════════════════════ */
[data-theme="dark"] .ep-tab-nav {
  background: #0f172a !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .ep-tab-btn {
  color: #94a3b8 !important;
}
[data-theme="dark"] .ep-tab-btn.active {
  background: #2563eb !important;
  color: #ffffff !important;
}
[data-theme="dark"] .ep-card,
[data-theme="dark"] .ep-modal-content,
[data-theme="dark"] .ep-drawer {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}
[data-theme="dark"] .ep-drawer-header,
[data-theme="dark"] .ep-drawer-footer {
  background: #0f172a !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .ep-btn-secondary {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}
[data-theme="dark"] .ep-btn-secondary:hover {
  background: #334155 !important;
}


/* ══════════════════════════════════════════════════════════════════
   ENHANCED EXPENSES MODULE (Direct vs Operating Split & Analytics)
   ══════════════════════════════════════════════════════════════════ */
.ep-icon-expenses-pro {
  background: linear-gradient(135deg, #0f172a, #334155);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}

.ep-kpis-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 1100px) {
  .ep-kpis-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 600px) {
  .ep-kpis-4 {
    grid-template-columns: 1fr;
  }
}

.ep-kpi-card-pro {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ep-kpi-card-pro:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.ep-kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ep-kpi-icon-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ep-kpi-icon-total { background: #f1f5f9; color: #0f172a; }
.ep-kpi-icon-direct { background: #fff7ed; color: #c2410c; }
.ep-kpi-icon-opex { background: #eff6ff; color: #1d4ed8; }
.ep-kpi-icon-month { background: #ecfdf5; color: #047857; }

.ep-kpi-sub {
  font-size: 11.5px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ── Analytics Split Row ───────────────────────────────────────── */
.ep-analytics-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 14px;
}
@media (max-width: 960px) {
  .ep-analytics-grid {
    grid-template-columns: 1fr;
  }
}

.ep-panel {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.02);
}

.ep-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.ep-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 7px;
}

.ep-split-bar {
  height: 10px;
  border-radius: 999px;
  background: #f1f5f9;
  overflow: hidden;
  display: flex;
  margin-bottom: 12px;
}
.ep-split-seg-direct {
  background: #ea580c;
  height: 100%;
  transition: width 0.3s ease;
}
.ep-split-seg-opex {
  background: #2563eb;
  height: 100%;
  transition: width 0.3s ease;
}

.ep-split-legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #475569;
  margin-bottom: 14px;
}
.ep-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
}

.ep-cat-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.ep-cat-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ep-cat-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #334155;
}
.ep-cat-track {
  height: 5px;
  border-radius: 999px;
  background: #f1f5f9;
  overflow: hidden;
}
.ep-cat-fill {
  height: 100%;
  border-radius: 999px;
}

.ep-channel-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ep-channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  font-size: 12.5px;
}
.ep-channel-left {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-weight: 600;
}

/* ── Segmented Filter Toolbar ──────────────────────────────────── */
.ep-filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color);
  background: #fafbff;
}

.ep-seg {
  display: inline-flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
  flex-wrap: wrap;
}
.ep-seg-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.ep-seg-btn:hover {
  color: #0f172a;
}
.ep-seg-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.ep-seg-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-family: var(--font-mono);
}
.ep-seg-btn.active .ep-seg-count {
  background: #eff6ff;
  color: #1d4ed8;
}

.ep-type-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.ep-type-direct {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}
.ep-type-operating {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

/* Dark mode extensions */
[data-theme="dark"] .ep-kpi-card-pro,
[data-theme="dark"] .ep-panel {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}
[data-theme="dark"] .ep-panel-title,
[data-theme="dark"] .ep-cat-meta {
  color: #f8fafc !important;
}
[data-theme="dark"] .ep-channel-row,
[data-theme="dark"] .ep-filter-toolbar,
[data-theme="dark"] .ep-seg {
  background: #0f172a !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .ep-seg-btn.active {
  background: #1e293b !important;
  color: #f8fafc !important;
}
