/* ==========================================================================
   HPU POS FINANCIAL INTELLIGENCE DASHBOARD - DESIGN SYSTEM & STYLES
   ========================================================================== */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #0f172a;
  --bg-card: rgba(18, 26, 46, 0.75);
  --bg-card-hover: rgba(26, 37, 65, 0.85);
  --bg-surface: #1e293b;
  --bg-input: #151e33;

  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(14, 165, 233, 0.6);
  --border-glow: 0 0 15px rgba(14, 165, 233, 0.25);

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-indigo: #6366f1;
  --accent-purple: #8b5cf6;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background: radial-gradient(circle at top right, #131c33 0%, #0a0e17 60%, #05070c 100%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #0b0f1a;
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-badge {
  background: linear-gradient(135deg, #0284c7, #06b6d4);
  color: white;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.35);
}

.brand-info h1 {
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-info p {
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #fff;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.8);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* Nav Tabs */
.tabs-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 28px;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: #fff;
  background: rgba(14, 165, 233, 0.15);
  border: 1px solid rgba(14, 165, 233, 0.35);
  box-shadow: 0 0 14px rgba(14, 165, 233, 0.15);
}

.tab-badge {
  background: rgba(255, 255, 255, 0.12);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

/* Container */
.main-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 28px 60px;
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.kpi-card:hover {
  transform: translateY(-3px);
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow-md);
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--card-accent, #0ea5e9), transparent);
}

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

.kpi-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  color: var(--card-accent, #0ea5e9);
  font-size: 18px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.kpi-subtext {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-subtext strong {
  color: var(--text-main);
}

/* Charts Grid */
.charts-grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.charts-grid-1-1 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-normal);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

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

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 320px;
}

/* Filter Toolbar */
.filter-bar {
  background: rgba(18, 26, 46, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.filter-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.search-input-wrapper {
  position: relative;
  min-width: 280px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
  font-size: 14px;
}

.input-text, .select-input {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  outline: none;
  transition: all var(--transition-fast);
}

.input-text {
  padding-left: 36px;
  width: 100%;
}

.input-text:focus, .select-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--border-glow);
}

.select-input option {
  background: var(--bg-secondary);
  color: var(--text-main);
}

/* Table Design */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

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

.data-table th {
  background: rgba(15, 23, 42, 0.95);
  padding: 12px 16px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  user-select: none;
}

.data-table th.sortable {
  cursor: pointer;
}

.data-table th.sortable:hover {
  color: #fff;
  background: rgba(30, 41, 59, 0.95);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.035);
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-mandiri {
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.3);
}

.badge-bri {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-bni {
  background: rgba(249, 115, 22, 0.15);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.badge-bca {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-other {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-danger {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-purple {
  background: rgba(139, 92, 246, 0.15);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Pagination */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(15, 23, 42, 0.7);
  border-top: 1px solid var(--border-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  font-size: 13px;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition-fast);
}

.page-btn:hover:not(:disabled) {
  background: #334155;
  border-color: rgba(255, 255, 255, 0.2);
}

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

/* Modal / Drawer */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.98);
  transition: transform var(--transition-normal);
}

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

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.modal-body {
  padding: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-item {
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.detail-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.detail-val {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  word-break: break-word;
}

.detail-val.highlight {
  color: var(--accent-cyan);
  font-size: 17px;
  font-weight: 800;
}

/* Audit Cards */
.audit-alert-box {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.audit-icon {
  font-size: 24px;
  color: var(--accent-amber);
}

/* Print Styles */
@media print {
  body {
    background: #fff;
    color: #000;
  }
  .app-header, .tabs-bar, .filter-bar, .pagination-bar, .btn {
    display: none !important;
  }
  .main-container {
    max-width: 100%;
    padding: 0;
  }
  .card, .kpi-card, .table-responsive {
    background: #fff;
    border: 1px solid #ccc;
    box-shadow: none;
    color: #000;
  }
  .data-table th, .data-table td {
    color: #000;
    border-bottom: 1px solid #ddd;
  }
}

/* Responsiveness */
@media (max-width: 1024px) {
  .charts-grid-2, .charts-grid-1-1 {
    grid-template-columns: 1fr;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 18px;
  }
  .tabs-bar {
    padding: 8px 14px;
  }
  .main-container {
    padding: 16px 14px 40px;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-input-wrapper {
    min-width: 100%;
  }
}

/* ============================================================
   PAYMENT STATUS TOGGLE (Terbayar / Belum Bayar)
   ============================================================ */
.payment-toggle {
  display: inline-flex;
  gap: 0;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card-bg, rgba(15,23,42,0.6));
}

.pay-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,0.07);
}

.pay-btn:last-child {
  border-right: none;
}

.pay-btn:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.pay-btn.active {
  background: var(--pay-color, rgba(56,189,248,0.18));
  color: var(--pay-color, #38bdf8);
  filter: brightness(1.1);
}

#pay-all.active {
  background: rgba(56,189,248,0.15);
  color: #38bdf8;
}

#pay-done.active {
  background: rgba(16,185,129,0.15);
  color: #10b981;
}

#pay-pending.active {
  background: rgba(244,63,94,0.15);
  color: #f43f5e;
}

/* ============================================================
   PO JATUH TEMPO — Toggle Tabs & KPI Chips
   ============================================================ */
.po-due-toggle {
  display: inline-flex;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  overflow: hidden;
}

.po-due-tab {
  background: transparent;
  border: none;
  border-right: 1px solid rgba(255,255,255,0.07);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}

.po-due-tab:last-child { border-right: none; }

.po-due-tab:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.po-due-tab.active[data-due="overdue"]  { background: rgba(244,63,94,0.18);  color: #f43f5e; }
.po-due-tab.active[data-due="upcoming"] { background: rgba(245,158,11,0.18); color: #f59e0b; }
.po-due-tab.active[data-due="nodate"]   { background: rgba(148,163,184,0.12); color: #94a3b8; }

/* Mini KPI chips */
.po-kpi-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-left: 3px solid var(--chip-color, #38bdf8);
  border-radius: 8px;
  min-width: 140px;
}

.po-kpi-num {
  font-size: 22px;
  font-weight: 800;
  color: var(--chip-color, #38bdf8);
  line-height: 1.1;
}

.po-kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Urgency row highlights */
tr.row-overdue td  { background: rgba(244,63,94,0.05); }
tr.row-upcoming td { background: rgba(245,158,11,0.05); }
