@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap');

/* ===== VARIABLES & THEME ===== */

:root {
  /* Colors - Modern Dark Green Theme */
  --bg-dark: #0f172a;          /* Slate 900 */
  --bg-card: #1e293b;          /* Slate 800 */
  --bg-input: #334155;         /* Slate 700 */
  
  --primary: #10b981;          /* Emerald 500 */
  --primary-rgb: 16, 185, 129;
  --primary-hover: #059669;    /* Emerald 600 */
  --primary-transparent: rgba(16, 185, 129, 0.15);
  
  --text-main: #f8fafc;        /* Slate 50 */
  --text-muted: #94a3b8;       /* Slate 400 */
  
  --danger: #ef4444;           /* Red 500 */
  --danger-rgb: 239, 68, 68;
  --success: #22c55e;          /* Green 500 */
  --success-rgb: 34, 197, 94;
  --warning: #f59e0b;          /* Amber 500 */
  --warning-rgb: 245, 158, 11;
  --info-rgb: 59, 130, 246;

  --bg-card-rgb: 30, 41, 59;   /* Slate 800 */

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-green: 0 4px 14px 0 rgba(16, 185, 129, 0.39);
  
  /* Radii */
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  
  /* Typography */
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== LIGHT MODE OVERRIDES ===== */

.light-mode {
  --bg-dark: #f8fafc;          /* Slate 50 */
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;         /* Slate 100 */
  --text-main: #0f172a;        /* Slate 900 */
  --text-muted: #64748b;       /* Slate 500 */
  --bg-card-rgb: 255, 255, 255;
  --primary-transparent: rgba(16, 185, 129, 0.1);
}

body.light-mode .card-box {
  background-color: var(--bg-card);
  border-color: rgba(0,0,0,0.06);
  box-shadow: var(--shadow-sm);
}

body.light-mode .data-table thead th {
  background-color: #f1f5f9;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
}

body.light-mode .sidebar {
  background-color: #ffffff;
  border-right: 1px solid #e2e8f0;
}

body.light-mode .nav-item {
  color: #475569;
}

body.light-mode .nav-item:hover, body.light-mode .nav-item.active {
  background-color: #f1f5f9;
  color: var(--primary);
}

body.light-mode .topbar {
  background-color: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid #e2e8f0;
}

/* ===== RESET & GLOBAL ===== */

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  font-weight: 300; /* Ultra elegant light weight */
  letter-spacing: -0.01em;
}

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

a:hover {
  filter: brightness(1.2);
}

.text-right { text-align: right !important; }

.text-success { color: var(--success) !important; }

.text-danger { color: var(--danger) !important; }

.text-warning { color: var(--warning) !important; }

.text-muted { color: var(--text-muted) !important; }

.text-premium { color: var(--primary) !important; }

.font-bold { font-weight: 700 !important; }

/* ===== UTILITIES & COMPONENTS ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-family);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  color: var(--text-main); /* Ensure default text color is light */
  background-color: rgba(255, 255, 255, 0.05); /* Default subtle background */
}

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

.btn-primary {
  background-color: var(--primary);
  color: white;
  box-shadow: var(--shadow-green);
}

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

.btn-block {
  width: 100%;
}

/* Spinner Animation */

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s ease-in-out infinite;
  margin-left: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.btn-shimmer {
  position: relative;
  overflow: hidden;
}

.btn-shimmer::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transform: translateX(-100%);
  animation: shimmer 2s infinite;
}

/* ===== LAYOUT: LOGIN PAGE ===== */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: radial-gradient(circle at top left, var(--bg-card), var(--bg-dark) 70%);
  position: relative;
  overflow: hidden;
}

.login-body::before {
  content: "";
  position: absolute;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, var(--primary-transparent) 0%, transparent 40%);
  top: -50%;
  left: -50%;
  opacity: 0.3;
  pointer-events: none;
}

.login-container {
  width: 100%;
  max-width: 420px;
  animation: fadeUp 0.6s ease-out backwards;
}

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

.login-card {
  background-color: rgba(var(--bg-card-rgb), 0.7); /* Themed with transparency */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(var(--text-main), 0.1);
}

.light-mode .login-card {
  border-color: rgba(0,0,0,0.05);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header .logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 0.5rem;
}

.login-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.login-header h1 span {
  font-weight: 300;
  color: var(--primary);
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.login-form .input-group {
  margin-bottom: 1.25rem;
}

.login-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.login-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--bg-input);
  border: 1px solid transparent;
  color: var(--text-main);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition);
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-transparent);
}

.login-form input::placeholder {
  color: #64748b;
}

.error-message {
  color: var(--danger);
  font-size: 0.825rem;
  margin-bottom: 1rem;
  text-align: center;
  min-height: 1.2rem;
}

.login-footer {
  margin-top: 2rem;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.05);
  padding-top: 1.5rem;
}

.login-footer p {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.login-footer strong {
  color: var(--text-main);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ===== APP LAYOUT (DASHBOARD & INTERNAL PAGES) ===== */

html { background-color: var(--bg-dark); }

.app-layout {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-dark);
  animation: appFadeIn 0.3s ease-out;
}

@media (min-width: 769px) {
  /* Reverted: Let the whole page scroll normally */
  .app-layout {
    height: auto;
    overflow: visible;
  }
}

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

.sidebar {
  width: 280px;
  background-color: var(--bg-card);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 100vh;
  contain: layout;
  will-change: transform;
}

.sidebar-header {
  padding: 1.5rem;
  min-height: 74px; /* Fix height to avoid jump during JS title injection */
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-card);
}

.sidebar-header h2 {
  font-size: 1.25rem;
  font-weight: 300;
}

.sidebar-header h2 span {
  font-weight: 300;
  color: var(--primary);
}

/* --- SIDEBAR LOGO STYLING --- */

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    overflow: hidden;
}

.sidebar-logo img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 8px;
    background: white; /* Contrast for logos with transparent backgrounds */
    padding: 2px;
    flex-shrink: 0;
}

.sidebar-logo span {
    font-size: 1.1rem;
    font-weight: 300;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}

.sidebar-nav {
  padding: 1.5rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-header {
  padding: 1.25rem 1rem 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 300;
  letter-spacing: 0.15em;
  opacity: 0.7;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  font-weight: 300;
  transition: var(--transition);
  text-decoration: none;
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover, .nav-item.active {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.nav-item.active {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-left-color: var(--primary);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: contentFadeIn 0.4s ease-out;
}

@keyframes contentFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.topbar {
  height: 70px;
  background-color: var(--bg-card);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem; /* Slightly reduced padding */
  flex-shrink: 0;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.5rem;
}

/* Page action buttons grouping */

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.1rem;
  position: relative;
}

.logout-icon {
  color: #ffffff; /* Putih di Dark Mode */
}

.light-mode .logout-icon {
  color: #ef4444 !important; /* Merah di Light Mode */
}

.action-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background-color: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

.content-area {
  padding: 1.5rem;
  flex: 1;
  overflow: visible;
}

/* ===== CARDS & TABLES ===== */

.card-box {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th, .data-table td {
  padding: 0.875rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

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

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

/* === OPTIMASI TABEL (GLOBAL) === */

/* Spasi Baris Rapat */

.data-table th, .data-table td {
  padding: 0.75rem 0.625rem !important;
  font-size: 0.875rem;
}

/* Tombol Aksi Sejajar */

.action-btns {
  display: flex !important;
  flex-direction: row !important;
  gap: 0.5rem !important;
  flex-wrap: nowrap !important;
}

/* Sticky Column System (Hanya untuk Tabel Stok / Kambing) */

.data-table.sticky-enabled {
  position: relative !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

/* Target kolom identity yang diaktifkan fiturnya */

.data-table .sticky-col {
  position: sticky !important;
  left: 0 !important;
  z-index: 20 !important;
  background-color: var(--bg-card) !important;
  border-right: 1px solid rgba(255,255,255,0.1) !important;
}

/* Header tetap di atas */

th.sticky-col {
  z-index: 22 !important;
}

/* PERBAIKAN: Mode Terang (Light Mode) */

body.light-mode .sticky-col {
  background-color: #ffffff !important;
  border-right: 1px solid #e2e8f0 !important;
}

body.light-mode .data-table tbody tr:nth-child(even) td.sticky-col {
  background-color: #f1f5f9 !important;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success { background-color: rgba(34, 197, 94, 0.15); color: var(--success); }

.badge-warning { background-color: rgba(245, 158, 11, 0.15); color: var(--warning); }

.badge-danger { background-color: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* --- STICKY HEADER (DESKTOP) --- */

@media (min-width: 769px) {
  .sidebar {
    height: auto;
    overflow-y: visible;
  }

  /* --- CONDITIONAL SCROLLING FOR TABLE --- */
  .table-responsive {
    max-height: calc(100vh - 280px); /* Default offset for Master Data, Sakit, Mati */
    overflow-y: auto !important;
    overscroll-behavior: contain;
    padding-right: 5px; 
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
  }

  /* Specific offset for pages with stats cards / summary grids */
  .tall-header .table-responsive {
    max-height: calc(100vh - 400px); 
  }

  .data-table thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 30 !important;
    background-color: var(--bg-card) !important;
    background-clip: padding-box;
    border-bottom: 2px solid rgba(255,255,255,0.1) !important;
  }

  /* Priority z-index for sticky-col headers */
  th.sticky-col {
    z-index: 35 !important;
  }
}

/* --- PERBAIKAN VISIBILITAS TOMBOL AKSI --- */

.btn-edit-action, .btn-view-photo, .btn-verify-single {
  background-color: rgba(16, 185, 129, 0.2) !important;
  color: #34d399 !important; /* Emerald 400 */
  border: 1px solid rgba(16, 185, 129, 0.4) !important;
}

/* Row highlight for selections */

.row-selected {
  background-color: rgba(16, 185, 129, 0.1) !important;
}

.row-selected td {
  border-top: 1px solid var(--success) !important;
  border-bottom: 1px solid var(--success) !important;
}

/* Specific densities for split tables in Pelunasan page */

.card-box.tall-header .data-table td {
  padding: 0.75rem 0.5rem;
  font-size: 0.8rem;
}

/* Pelunasan Page Grid */

.pay-layout-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (min-width: 1024px) {
  .pay-layout-grid {
    grid-template-columns: 380px 1fr;
  }
}

/* Tabs System */

.tab-container {
  display: flex;
  flex-direction: column;
}

.tab-header {
  display: flex;
  gap: 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 1.5rem;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.75rem 0.25rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

@media (max-width: 768px) {
    .topbar {
        padding: 0 0.75rem !important;
        height: 60px !important;
        justify-content: space-between !important;
        gap: 0.5rem !important;
    }

    .page-title {
        font-size: 0.9rem !important;
        max-width: 130px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        flex: 1 !important;
    }

    .topbar-actions {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 0.4rem !important;
        margin-left: auto !important;
    }

    .topbar-actions .action-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 1.1rem !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
  
  /* Form actions stacking */
  .header-actions {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }
  .header-actions .btn {
    width: 100%;
  }

  /* Improved table density for mobile */
  .data-table th, .data-table td {
    padding: 0.6rem 0.5rem;
    font-size: 0.75rem;
  }
}

/* Scroll Hint for horizontal elements */

.scroll-hint-wrapper {
  position: relative;
  overflow: hidden;
}

.scroll-hint-wrapper::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 30px;
  background: linear-gradient(to left, var(--bg-card), transparent);
  pointer-events: none;
  opacity: 0.8;
}

.tab-content {
  display: none;
}

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

/* Logout button specifically for better visibility */

#logoutBtn {
  color: var(--text-main) !important;
  font-weight: 600;
  display: flex !important;
  align-items: center;
  gap: 8px;
}

#logoutBtn:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.1) !important;
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.2) !important;
}

.btn-edit-action:hover, .btn-view-photo:hover {
  background-color: rgba(16, 185, 129, 0.3) !important;
  transform: translateY(-2px);
}

.btn-delete-action {
  background-color: rgba(239, 68, 68, 0.2) !important;
  color: #f87171 !important; /* Red 400 */
  border: 1px solid rgba(239, 68, 68, 0.4) !important;
}

.btn-delete-action:hover {
  background-color: rgba(239, 68, 68, 0.3) !important;
  transform: translateY(-2px);
}

/* Form Controls in App */

.form-label {
  display: block;
  font-size: 0.825rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.form-control {
  width: 100%;
  height: 46px; /* Optimized height for mobile/desktop */
  padding: 0.75rem 1rem;
  background-color: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-main) !important;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition);
}

.form-section {
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-top: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

body.light-mode .form-section {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.05);
}

/* Responsive Form Grids */

.responsive-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.responsive-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

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

@media (max-width: 768px) {
  .responsive-grid-2, .responsive-grid-4 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* Fix dark mode for select dropdown options */

select.form-control {
  cursor: pointer;
}

select.form-control option {
  background-color: var(--bg-card);
  color: var(--text-main);
  padding: 10px;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-transparent);
}

/* ===== MODAL ===== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

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

.modal, .modal-content {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px; /* Increased from 500px */
  box-shadow: var(--shadow-lg), 0 20px 25px -5px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transform: translateY(20px);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  color: var(--text-main);
}

.modal-lg {
  max-width: 900px !important;
}

.modal-xl {
  max-width: 1200px !important;
}

.modal-overlay.active .modal,
.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* Dipertegas */
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main); /* Pastikan warna putih/terang */
}

.modal-close, .close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
}

.modal-close:hover, .close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  color: var(--text-main); /* Pastikan isi modal terbaca */
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  background-color: var(--bg-card);
}

/* Specific fix for cancel/neutral buttons in dark mode footer */

.modal-footer .btn:not(.btn-primary):not(.btn-danger):not(.btn-edit) {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-footer .btn:not(.btn-primary):not(.btn-danger):not(.btn-edit):hover {
  background-color: rgba(255, 255, 255, 0.15);
}

/* Action Buttons Grid */

.action-btns {
  display: flex;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  border-radius: 4px;
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.1);
  color: #f87171; /* Red 400 */
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover { background-color: rgba(239, 68, 68, 0.2); transform: translateY(-1px); }

.btn-edit {
  background-color: rgba(245, 158, 11, 0.1);
  color: #fbbf24; /* Amber 400 */
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.btn-edit:hover { background-color: rgba(245, 158, 11, 0.2); transform: translateY(-1px); }

/* ===== LIGHT MODE OVERRIDES ===== */

.light-mode {
  --bg-dark: #f1f5f9;          /* Slate 100 */
  --bg-card: #ffffff;          /* White */
  --bg-input: #f8fafc;         /* Slate 50 */
  --bg-card-rgb: 255, 255, 255;
  
  --primary: #059669;          /* Emerald 600 - darker for contrast */
  --primary-hover: #047857;
  --primary-transparent: rgba(16, 185, 129, 0.1);
  
  --text-main: #0f172a;        /* Slate 900 */
  --text-muted: #475569;       /* Slate 600 */
  
  /* Soften the green shadow in light mode */
  --shadow-green: 0 4px 14px 0 rgba(5, 150, 105, 0.2);
}

body.light-mode .sidebar { border-right-color: #e2e8f0; }

body.light-mode .topbar,
body.light-mode .sidebar-header,
body.light-mode .modal-header,
body.light-mode .modal-footer,
body.light-mode .tabs-header { border-bottom-color: #e2e8f0; border-top-color: #e2e8f0; }

body.light-mode .card-box, 
body.light-mode .modal-content,
body.light-mode .form-control { border-color: #e2e8f0; }

body.light-mode .form-control { border: 1px solid #cbd5e1; }

body.light-mode .data-table th, body.light-mode .data-table td { border-bottom-color: #e2e8f0; text-shadow: none;}

body.light-mode .data-table tbody tr:hover { background-color: #f8fafc; }

body.light-mode .btn[style*="border: 1px solid rgba"] { border-color: #cbd5e1 !important; color: var(--text-muted) !important;}

body.light-mode .profile-upload { border-color: #cbd5e1; }

body.light-mode .type-tab { border-color: #cbd5e1; }

body.light-mode .type-tab:hover { background: #f8fafc; }

/* ==========================================================================
   CUSTOM NOTIFICATION SYSTEM (TOASTS & MODALS)
   ========================================================================== */

:root {
    --toast-success: #10b981;
    --toast-danger: #ef4444;
    --toast-info: #3b82f6;
    --toast-warning: #f59e0b;
}

/* Toast System - Removed duplicate block/* Transaction Table Elegance */

.item-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.item-badge:hover {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
}

.status-pill {
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.status-review {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.diff-box {
    padding: 1rem;
    border-radius: 12px;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 1rem;
}

.diff-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 5px;
}

.diff-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.diff-old { color: #ef4444; text-decoration: line-through; opacity: 0.7; }

.diff-new { color: #10b981; font-weight: 500; }

.toast-info { border-left: 4px solid var(--toast-info); }

.toast-warning { border-left: 4px solid var(--toast-warning); }

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

@keyframes toast-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@keyframes custom-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes spring-up {
    0% { transform: scale(0.9) translateY(20px); opacity: 0; }
    70% { transform: scale(1.02) translateY(-2px); opacity: 1; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Modal Overlay & Custom Modal */

.modal-overlay-custom {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4); 
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    opacity: 0;
    animation: custom-fade-in 0.3s ease-out forwards;
}

.modal-custom {
    width: 95%;
    max-width: 440px;
    background: rgba(var(--bg-card-rgb), 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 
        0 0 0 1px rgba(255,255,255,0.05),
        0 20px 50px -12px rgba(0, 0, 0, 0.5),
        0 10px 20px -5px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    animation: spring-up 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    color: var(--text-main);
    text-align: center;
}

.light-mode .modal-custom {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 
        0 20px 50px -12px rgba(0, 0, 0, 0.15),
        0 10px 20px -5px rgba(0, 0, 0, 0.1);
    --bg-card-rgb: 255, 255, 255;
    color: #1e293b;
}

.modal-custom-header {
    margin-bottom: 2rem;
}

.modal-custom-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.modal-custom-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-top: 0.5rem;
}

.modal-custom-body {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
}

.light-mode .modal-custom-body {
    color: #475569;
}

.modal-custom-footer {
    display: flex;
    gap: 1rem;
    justify-content: stretch;
}

.modal-custom-footer .btn {
    flex: 1;
    height: 48px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.01em;
}

/* Toast System - Elegant Glass (Consolidated) */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    background: rgba(var(--bg-card-rgb, 30, 41, 59), 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 14px 20px;
    min-width: 300px;
    max-width: 450px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text-main);
    pointer-events: auto;
    transform: translateX(110%);
    animation: toast-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transition: all 0.3s ease;
}

.toast-icon {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.25rem;
}

.toast-content {
    flex-grow: 1;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-main) !important;
}

.toast.hiding {
    animation: toast-out 0.3s forwards;
}

@keyframes toast-in {
    to { transform: translateX(0); }
}

@keyframes toast-out {
    to { transform: translateX(110%); opacity: 0; }
}

/* ===== MOBILE RESPONSIVE & NAVIGATION (CONSOLIDATED) ===== */

@media (max-width: 768px) {
    .topbar {
        padding: 0 0.5rem !important;
        gap: 0.25rem;
    }

    .user-menu {
        gap: 0.25rem;
        flex: 1;
        justify-content: flex-end;
    }

    #userEmailDisplay {
        font-size: 0.65rem !important;
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-right: 8px;
    }
    .topbar {
        padding: 0 0.75rem !important;
        gap: 0.75rem;
    }
    .user-menu {
        gap: 0.75rem;
        flex: 1;
        justify-content: flex-end;
    }

    .header-actions {
        margin-right: 0;
        gap: 0.25rem;
    }
    :root {
        --sidebar-width: 0px;
    }

    .app-layout {
        display: block;
    }

    /* FIX: SIDEBAR MENU POSITION ON MOBILE */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px; /* Hide off-screen by default */
        bottom: 0;
        z-index: 10001; /* Stay above everything else */
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        height: 100vh;
        overflow-y: auto;
    }

    .sidebar.active {
        transform: translateX(280px); /* Slide in when active */
    }

    .menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 10px;
        color: var(--text-main);
        font-size: 1.25rem;
        cursor: pointer;
        padding: 0;
        margin-right: 0.5rem;
        flex-shrink: 0;
    }


    /* Typography Refinement for Mobile */
    body {
        font-size: 14px;
    }

    h1 { font-size: 1.4rem !important; }
    h2 { font-size: 1.2rem !important; }
    h3 { font-size: 1.1rem !important; letter-spacing: -0.01em; }
    h4 { font-size: 1rem !important; }

    .page-title {
        font-size: 0.95rem !important;
        font-weight: 800;
        max-width: 180px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        letter-spacing: -0.01em;
    }

    .topbar {
        position: fixed;
        top: 0; left: 0; right: 0;
        z-index: 10000;
        height: 60px;
        padding: 0 0.75rem;
        background: var(--bg-card);
        backdrop-filter: blur(10px);
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .topbar-actions {
        gap: 0.35rem !important;
    }

    .action-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    /* Content Area Buttons - Stacking on mobile */
    .content-area .header-actions {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
        width: 100%;
    }
    .content-area .header-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Grid Stacking Fix */
    .dashboard-grid, .stats-grid, .form-row, .komisi-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Premium Grid → auto-fit 2-column on mobile, stacks safely */
    .premium-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
        gap: 0.75rem !important;
        margin-bottom: 1.25rem !important;
    }

    /* Compact premium cards on mobile */
    .premium-card {
        min-height: auto !important;
        padding: 0.75rem 0.75rem 0.75rem 1rem !important;
        border-radius: 12px !important;
        gap: 0.5rem !important;
    }
    .premium-value { 
        font-size: 0.9rem !important; 
        line-height: 1.2;
        word-break: break-all !important;
    }
    .premium-label { 
        font-size: 0.6rem !important; 
        margin-bottom: 0.15rem !important;
        white-space: normal !important;
        line-height: 1.3;
    }
    .premium-icon-box {
        display: none !important;
    }

    /* grid-cards → 2 column slim on mobile */
    .grid-cards {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
        gap: 0.5rem !important;
    }

    /* Modal Adjustments */
    .modal-overlay {
        align-items: flex-start !important;
        padding: 0 !important;
    }

    .modal-content, .modal-xl, .modal-lg {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    /* Force forms to take up full available height and handle their own layout */
    .modal-content form {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 !important;
        height: 100% !important;
        overflow: hidden !important;
    }

    .modal-body {
        flex: 1 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: 5rem !important; /* Safe area for bottom navigation */
    }

    /* Padding & Table Density - Compensate for fixed topbar height (60px) */
    .content-area { 
        padding: calc(60px + 1rem) 1rem 1rem 1rem !important; 
    }
    .data-table th, .data-table td {
        padding: 0.6rem 0.4rem !important;
        font-size: 0.8rem !important;
    }
}

/* --- PREMIUM UI: TOPBAR ACTIONS (HORIZONTAL) --- */

.topbar-actions {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    flex-direction: row !important;
}

/* --- PREMIUM UI: CARD SYSTEM --- */

.premium-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    min-height: 130px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

body.light-mode .premium-card {
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
}

.premium-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 5px;
    background: var(--primary);
    opacity: 0.8;
}

/* Color Variants */

.premium-card.emerald::before { background: #10b981; }

.premium-card.amber::before { background: #f59e0b; }

.premium-card.rose::before { background: #f43f5e; }

.premium-card.indigo::before { background: #6366f1; }

.premium-card.violet::before { background: #8b5cf6; }

.premium-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

.premium-value {
    font-size: 1.6rem;
    font-weight: 300; /* Ultra-elegant light weight */
    color: var(--text-main);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.premium-icon-box {
    position: absolute;
    top: 50%;
    right: 1.5rem;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    transition: all 0.3s ease;
}

body.light-mode .premium-icon-box {
    background: #f8fafc;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

/* Icon Box Color Themes (Light Mode) */

body.light-mode .emerald .premium-icon-box { background: rgba(16, 185, 129, 0.08); color: #10b981; }

body.light-mode .amber .premium-icon-box { background: rgba(245, 158, 11, 0.08); color: #f59e0b; }

body.light-mode .rose .premium-icon-box { background: rgba(244, 63, 94, 0.08); color: #f43f5e; }

body.light-mode .indigo .premium-icon-box { background: rgba(99, 102, 241, 0.08); color: #6366f1; }

body.light-mode .violet .premium-icon-box { background: rgba(139, 92, 246, 0.08); color: #8b5cf6; }

.premium-card:hover .premium-icon-box {
    transform: translateY(-50%) scale(1.1) rotate(-5deg);
    background: var(--primary-transparent);
    color: var(--primary);
}

/* --- PREMIUM GLASS UTILITIES --- */

.glass-panel {
    background: rgba(var(--bg-card-rgb), 0.6) !important;
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2) !important;
}

body.light-mode .glass-panel {
    background: rgba(255, 255, 255, 0.7) !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    box-shadow: 0 8px 32px 0 rgba(16, 185, 129, 0.05) !important;
}

.text-premium {
    font-weight: 300 !important;
    letter-spacing: -0.02em !important;
}

/* --- PREMIUM GRID SYSTEM --- */

.premium-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

/* --- PREMIUM BREAKDOWN PILLS --- */

.kambing-breakdown {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap; /* Allow wrapping on narrow screens */
    margin-top: 1.25rem;
    border-top: none !important;
    padding-top: 0 !important;
}

.breakdown-pill {
    flex: 1;
    min-width: 80px; /* Ensure pills are readable */
    padding: 0.75rem 0.4rem;
    border-radius: 14px;
    background: rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 1px solid rgba(0,0,0,0.02);
    transition: all 0.2s ease;
}

body.light-mode .breakdown-pill {
    background: #f8fafc;
}

.breakdown-pill .pill-label {
    font-size: 0.55rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.breakdown-pill .pill-value {
    font-size: 1.1rem;
    font-weight: 300;
}

/* Pill Themes */

.breakdown-pill.emerald { background: rgba(16, 185, 129, 0.06) !important; color: #059669; }

.breakdown-pill.amber { background: rgba(245, 158, 11, 0.06) !important; color: #d97706; }

.breakdown-pill.rose { background: rgba(244, 63, 94, 0.06) !important; color: #e11d48; }

@media (max-width: 768px) {
    .section-icon { display: none !important; }
}

/* Sidebar Overlay */

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

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

/* Hide toggle on Desktop */

.menu-toggle {
    display: none;
}

/* --- WHATSAPP & PROFILE PREMIUM UI REFINEMENT --- */

.wa-grid-settings {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
}

@media (max-width: 768px) {
    .wa-grid-settings {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    .wa-config-left {
        border-right: none !important;
        padding-right: 0 !important;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        padding-bottom: 2rem;
    }

    /* Hilangkan teks instruksi yang bikin berantakan di HP */
    #tabWA h4 + p {
        display: none !important;
    }
    
    #tabWA .card-box {
        padding: 1.25rem !important;
    }

    #waTemplateEditor {
        min-height: 450px !important;
        font-size: 0.8rem !important;
    }
}

/* --- WHATSAPP STATUS INDICATOR DOT --- */

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.8rem;
    font-weight: 600;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 10px currentColor;
}

.status-dot::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0.4;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.8); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

.status-dot.active { background-color: var(--success); color: var(--success); }

.status-dot.inactive { background-color: var(--danger); color: var(--danger); }

/* --- PREMIUM PHOTO LIGHTBOX --- */

#photoLightbox {
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    background: rgba(15, 23, 42, 0.85); /* Slate 900 semi-transparent */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#photoLightbox img {
    border: 4px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.8), 0 18px 36px -18px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease;
    background: #000;
}

#btnDownloadLightbox {
    position: fixed !important;
    bottom: 30px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: var(--primary) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px var(--primary-transparent) !important;
    padding: 14px 28px !important;
    border-radius: 50px !important; /* Pill shape for premium feel */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    letter-spacing: 0.05em;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    z-index: 100001 !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

#btnDownloadLightbox:hover {
    transform: translateX(-50%) translateY(-5px) scale(1.05) !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6), 0 0 20px var(--primary) !important;
    background: var(--primary-hover) !important;
}

#lightboxLoading {
    font-size: 1.1rem;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    letter-spacing: 0.05em;
}

/* --- LIGHT MODE ADJUSTMENTS FOR LIGHTBOX --- */

body.light-mode #photoLightbox {
    background: rgba(255, 255, 255, 0.85);
}

body.light-mode #lightboxLoading {
    color: var(--text-main) !important;
}

/* Money Input Standardization */

.money-input {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Finance Page Enhancements */

#containerRealtimeBalance {
    min-height: 120px; /* Mencegah layar goyang saat filter kosong */
    transition: all 0.3s ease;
}

.balance-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease, transform 0.2s ease;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    animation: fadeInSlide 0.4s ease-out forwards;
}

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

body.light-mode .balance-card {
    background: #ffffff;
    border-color: rgba(0,0,0,0.05);
    box-shadow: var(--shadow-sm);
}

.balance-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 4px;
    background: var(--primary);
    opacity: 0.5;
}

.balance-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
}

.balance-value {
    font-size: 1.35rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.balance-subinfo {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    margin-top: 4px;
    font-weight: 400;
    flex-wrap: wrap;
}

.balance-subinfo span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.active-filter {
    border-color: var(--primary) !important;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.3) !important;
}

/* Filter Bar Styling */

.filter-bar-keu {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    align-items: flex-end;
}

.filter-bar-keu > div {
    flex: 1;
}

.filter-bar-keu > div:first-child {
    flex: 2; /* Search input gets more space */
}

/* Mobile Responsiveness for Finance Grid */

@media (max-width: 850px) {
    /* Ringkasan Utama (Total) dibuat besar & penuh */
    .premium-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Rincian Channel tetap 2 kolom agar hemat tempat */
    #containerRealtimeBalance {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    .balance-card {
        padding: 0.85rem 1rem !important;
        min-height: 100px !important;
        align-items: flex-start !important; /* Paksa Rata Kiri */
    }

    .balance-info {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: flex-start; /* Pastikan konten di dalamnya rata kiri */
    }
    
    .balance-label {
        font-size: 0.65rem !important;
        margin-bottom: 0.25rem !important;
        text-align: left !important;
    }

    .balance-value {
        font-size: 1.15rem !important;
        margin-bottom: 0.5rem !important;
        text-align: left !important;
        width: 100%;
    }

    .balance-subinfo {
        flex-direction: column !important;
        gap: 4px !important;
        font-size: 0.75rem !important;
        width: 100%;
    }

    .balance-subinfo span {
        width: 100%;
        display: flex !important;
        justify-content: flex-start !important;
        align-items: center;
        gap: 8px !important;
    }

    /* Fixed width for icons to align consecutive numbers */
    .balance-subinfo span i, 
    .balance-subinfo span .icon-emoji {
        display: inline-block;
        width: 18px;
        text-align: center;
    }

    .filter-bar-keu {
        padding: 0.85rem !important;
        gap: 0.75rem !important;
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .filter-bar-keu > div {
        min-width: 0 !important; /* Prevent grid breakout */
    }

    /* Kotak Pencarian tetap lebar penuh */
    .filter-bar-keu > div:first-child {
        grid-column: span 2 !important;
    }

    .form-label {
        font-size: 0.7rem !important;
        margin-bottom: 4px !important;
        display: block !important;
    }
}

