:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --sidebar-w: 240px;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #2563eb;
}

* { box-sizing: border-box; }
body { font-family: 'Segoe UI', sans-serif; background: #f1f5f9; }

/* Sidebar */
#sidebar {
  position: fixed; top: 0; left: 0; height: 100vh;
  width: var(--sidebar-w); background: var(--sidebar-bg);
  z-index: 1000; overflow-y: auto; transition: width .3s;
  display: flex; flex-direction: column;
}
#sidebar.collapsed { width: 60px; }
#sidebar .brand {
  padding: 16px 20px; border-bottom: 1px solid #334155;
  display: flex; align-items: center; gap: 10px;
  color: #fff; font-weight: 700; font-size: 15px; text-decoration: none;
}
#sidebar .brand img { width: 32px; height: 32px; border-radius: 6px; object-fit: contain; }
#sidebar .brand span { white-space: nowrap; overflow: hidden; }
#sidebar .nav-section { padding: 8px 12px 4px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; color: #64748b; letter-spacing: 0.8px; }
#sidebar.collapsed .nav-section { display: none; }
#sidebar .nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; color: var(--sidebar-text);
  text-decoration: none; border-radius: 6px; margin: 1px 8px;
  font-size: 14px; transition: all .2s; white-space: nowrap; overflow: hidden;
}
#sidebar .nav-link:hover { background: #334155; color: #fff; }
#sidebar .nav-link.active { background: var(--sidebar-active); color: #fff; }
#sidebar .nav-link i { width: 18px; font-size: 15px; flex-shrink: 0; }
#sidebar.collapsed .nav-link span { display: none; }

/* Main content */
#main {
  margin-left: var(--sidebar-w); min-height: 100vh;
  transition: margin-left .3s;
}
#main.expanded { margin-left: 60px; }

/* Topbar */
#topbar {
  background: #fff; padding: 12px 24px; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100; gap: 12px;
}
#topbar .page-title { font-weight: 600; font-size: 16px; color: #1e293b; }
#topbar .topbar-right { display: flex; align-items: center; gap: 12px; }
#page-content { padding: 24px; }

/* Cards */
.stat-card {
  background: #fff; border-radius: 12px; padding: 20px;
  border: 1px solid #e2e8f0; display: flex; align-items: center; gap: 16px;
}
.stat-card .icon {
  width: 52px; height: 52px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.stat-card .label { font-size: 12px; color: #64748b; font-weight: 500; }
.stat-card .value { font-size: 22px; font-weight: 700; color: #1e293b; line-height: 1.2; }

/* Tables */
.card { background: #fff; border-radius: 12px; border: 1px solid #e2e8f0; }
.card-header { padding: 16px 20px; border-bottom: 1px solid #e2e8f0; font-weight: 600; }
.card-body { padding: 16px 20px; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
  color: #64748b; font-weight: 600; background: #f8fafc; border-bottom: 2px solid #e2e8f0; }
.table td { vertical-align: middle; font-size: 14px; }
.table-hover tbody tr:hover { background: #f8fafc; }

/* Status badges */
.badge-diterima { background: #dbeafe; color: #1d4ed8; }
.badge-dicuci { background: #fef3c7; color: #d97706; }
.badge-dikeringkan { background: #fde8d8; color: #c2410c; }
.badge-disetrika { background: #e9d5ff; color: #7c3aed; }
.badge-packing { background: #d1fae5; color: #059669; }
.badge-selesai { background: #6ee7b7; color: #064e3b; }
.badge-diambil { background: #94a3b8; color: #1e293b; }
.badge-paid { background: #d1fae5; color: #059669; }
.badge-partial { background: #fef3c7; color: #d97706; }
.badge-unpaid { background: #fee2e2; color: #dc2626; }
.badge-open { background: #dbeafe; color: #1d4ed8; }
.badge-overdue { background: #fee2e2; color: #dc2626; }

/* Forms */
.form-label { font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 4px; }
.form-control, .form-select { font-size: 14px; border-color: #d1d5db; border-radius: 8px; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.btn { border-radius: 8px; font-size: 14px; font-weight: 500; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* Modal */
.modal-content { border-radius: 12px; border: none; box-shadow: 0 25px 50px rgba(0,0,0,.15); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid #e2e8f0; }
.modal-footer { padding: 12px 20px; border-top: 1px solid #e2e8f0; }

/* Login page */
#login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%);
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px;
  width: 100%; max-width: 420px; box-shadow: 0 25px 50px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo h4 { color: #1e293b; font-weight: 700; margin-top: 8px; }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; }

/* Loader */
.page-loader {
  display: flex; align-items: center; justify-content: center;
  padding: 60px; color: #64748b;
}
.table-responsive { overflow-x: auto; }

/* Search bar */
.search-bar { position: relative; }
.search-bar i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #9ca3af; }
.search-bar input { padding-left: 32px; }

/* Print */
@media print {
  #sidebar, #topbar, .btn, .no-print { display: none !important; }
  #main { margin-left: 0; }
}

/* Sidebar overlay backdrop (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1049;
  cursor: pointer;
}
.sidebar-overlay.active { display: block; }

/* Mobile (≤ 768px): sidebar slides in as overlay */
@media (max-width: 768px) {
  #sidebar {
    left: -260px;
    width: 240px !important;
    transition: left .25s ease;
    z-index: 1050;
    box-shadow: none;
  }
  #sidebar.mobile-open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
  }
  /* Undo desktop icon-only collapse on mobile */
  #sidebar.collapsed { width: 240px !important; }
  #sidebar.collapsed .nav-link span,
  #sidebar.collapsed .brand span,
  #sidebar.collapsed .nav-section { display: inherit !important; }
  #main, #main.expanded { margin-left: 0 !important; }
  #page-content { padding: 12px; }
  #topbar { padding: 10px 14px; }
  #topbar .page-title { font-size: 14px; }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-card .value { font-size: 17px; }
  .stat-card .icon { width: 42px; height: 42px; font-size: 17px; }
  .table td, .table th { white-space: nowrap; }
  .card-body { padding: 12px 14px; }
  .card-header { padding: 12px 14px; }
  .modal-dialog { margin: 4px; }
  .modal-dialog-centered { min-height: calc(100% - 8px); }
  .nav-tabs .nav-item { flex: 1 1 auto; text-align: center; }
}

.cursor-pointer { cursor: pointer; }
.text-primary { color: var(--primary) !important; }
.membership-silver { color: #94a3b8; }
.membership-gold { color: #f59e0b; }
.membership-platinum { color: #8b5cf6; }
