/* ══════════════════════════════════════════
   BASE
══════════════════════════════════════════ */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f0f4f8;
  color: #333;
  min-height: 100vh;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.hidden { display: none !important; }

/* ══════════════════════════════════════════
   HEADER
══════════════════════════════════════════ */
header {
  text-align: center;
  margin-bottom: 28px;
}

header h1 { font-size: 2rem; color: #1a73e8; }
header p  { color: #666; margin-top: 4px; }

.header-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
  width: 100%;
}

#header-logo {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: contain;
  border: none;
  background: none;
  padding: 0;
}

.header-kontak { font-size: 0.82rem; color: #888; margin-top: 4px; }

.header-user-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 600;
}
.user-admin    { background: #fff3cd; color: #856404; }
.user-karyawan { background: #e8f0fe; color: #1a73e8; }
.user-role     { font-size: 0.75rem; font-weight: 400; opacity: 0.75; }

.btn-logout {
  background: #f1f3f4;
  color: #444;
  border: 1px solid #ddd;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-logout:hover { background: #fce8e6; color: #c5221f; border-color: #f5c6c6; }

/* ══════════════════════════════════════════
   TAB NAV (desktop)
══════════════════════════════════════════ */
.tab-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
  background: none;
  border: none;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  border-radius: 6px 6px 0 0;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.tab-btn:hover  { color: #1a73e8; }
.tab-btn.active { color: #1a73e8; border-bottom-color: #1a73e8; }

.tab-content         { display: none; }
.tab-content.active  { display: block; }

/* ══════════════════════════════════════════
   SUMMARY CARDS
══════════════════════════════════════════ */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  border-left: 5px solid #ccc;
}
.card-icon  { font-size: 2rem; }
.card-info  { display: flex; flex-direction: column; }
.card-label { font-size: 0.78rem; color: #888; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.card-count { font-size: 1.6rem; font-weight: 700; color: #222; line-height: 1.2; }
.card-sub   { font-size: 0.75rem; color: #aaa; }

/* ══════════════════════════════════════════
   FORM SECTION
══════════════════════════════════════════ */
.form-section {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.form-section h2 { font-size: 1.1rem; margin-bottom: 16px; color: #444; }

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 160px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus { border-color: #1a73e8; }
.form-group input[readonly] { background: #f8f9fa; color: #555; cursor: default; }

.form-group-btn { justify-content: flex-end; }

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn-primary {
  background: #1a73e8; color: #fff; border: none;
  padding: 10px 20px; border-radius: 8px;
  font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: background 0.2s; white-space: nowrap;
}
.btn-primary:hover { background: #1558b0; }

.btn-secondary {
  background: #f1f3f4; color: #444; border: 1px solid #ddd;
  padding: 8px 14px; border-radius: 8px;
  font-size: 0.88rem; cursor: pointer; transition: background 0.2s;
}
.btn-secondary:hover { background: #e2e5e9; }

.btn-danger {
  background: #ea4335; color: #fff; border: none;
  padding: 8px 14px; border-radius: 8px;
  font-size: 0.88rem; cursor: pointer; transition: background 0.2s;
}
.btn-danger:hover { background: #c5221f; }

.btn-icon {
  background: none; border: none; cursor: pointer;
  font-size: 1rem; padding: 4px 6px; border-radius: 6px;
  transition: background 0.15s;
}
.btn-icon:hover { background: #f1f3f4; }

/* ══════════════════════════════════════════
   TABLE SECTION
══════════════════════════════════════════ */
.table-section {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.table-section h2 { font-size: 1.1rem; margin-bottom: 16px; color: #444; }

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-group input[type="date"],
.filter-group select {
  padding: 7px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.88rem;
  outline: none;
}
.filter-group input[type="date"]:focus,
.filter-group select:focus { border-color: #1a73e8; }

.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead tr { background: #f8f9fa; }
th {
  padding: 10px 12px; text-align: left;
  font-size: 0.8rem; font-weight: 700; color: #666;
  text-transform: uppercase; letter-spacing: 0.4px;
  border-bottom: 2px solid #eee;
}
td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
tbody tr:hover { background: #fafbfc; }

.empty-msg { text-align: center; color: #aaa; padding: 32px; font-style: italic; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-produk { background: #e8f0fe; color: #1a73e8; }

.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  font-size: 0.88rem;
  color: #666;
}
#footer-total { font-weight: 700; color: #222; font-size: 1rem; }

/* ══════════════════════════════════════════
   MODAL
══════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: #fff; border-radius: 12px;
  padding: 28px 32px; max-width: 360px; width: 90%;
  text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal p { margin-bottom: 20px; font-size: 1rem; color: #333; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }

/* ══════════════════════════════════════════
   LOADING
══════════════════════════════════════════ */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.loading-box {
  background: #fff; border-radius: 14px;
  padding: 28px 36px; text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.loading-spinner {
  width: 36px; height: 36px;
  border: 4px solid #e0e0e0; border-top-color: #1a73e8;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box p { font-size: 0.95rem; color: #555; margin: 0; }

/* ══════════════════════════════════════════
   PROFIL
══════════════════════════════════════════ */
.logo-preview-wrap {
  display: flex; align-items: center; gap: 20px;
  margin-bottom: 24px; padding: 16px;
  background: #f8f9fa; border-radius: 12px; border: 1px dashed #ddd;
}
.logo-preview {
  width: 90px; height: 90px; border-radius: 14px;
  border: 2px solid #ddd; background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; overflow: hidden; flex-shrink: 0;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-actions { display: flex; flex-direction: column; gap: 8px; }

.profil-card { padding: 8px 0; }
.profil-empty { text-align: center; color: #aaa; padding: 32px; font-style: italic; }
.profil-preview-inner { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.profil-logo-big {
  width: 100px; height: 100px; object-fit: contain;
  border-radius: 16px; border: 2px solid #eee;
  background: #f8f9fa; padding: 6px; flex-shrink: 0;
}
.profil-logo-placeholder {
  width: 100px; height: 100px; border-radius: 16px;
  border: 2px solid #eee; background: #f8f9fa;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; flex-shrink: 0;
}
.profil-info { flex: 1; min-width: 200px; }
.profil-info h3 { font-size: 1.3rem; font-weight: 700; color: #222; margin-bottom: 4px; }
.profil-tagline { color: #888; font-size: 0.9rem; margin-bottom: 12px; }
.profil-detail-grid {
  display: grid; grid-template-columns: auto 1fr;
  gap: 6px 12px; font-size: 0.9rem; color: #444; align-items: center;
}

/* ══════════════════════════════════════════
   REKAP
══════════════════════════════════════════ */
.rekap-filter-bar { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }

.rekap-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 16px;
}
.rekap-card { background: #f8f9fa; border-radius: 10px; padding: 16px; border: 1px solid #eee; }
.rekap-card-title {
  font-weight: 700; font-size: 0.95rem; color: #333;
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid #e0e0e0;
}
.rekap-card-row {
  display: flex; justify-content: space-between;
  align-items: center; font-size: 0.88rem; color: #555; padding: 4px 0;
}

.rekap-total-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: #1a73e8; color: #fff;
  border-radius: 10px 10px 0 0;
  padding: 14px 20px; font-size: 1rem; font-weight: 600; margin-top: 4px;
}
.rekap-total-bar strong { font-size: 1.15rem; }

.rekap-uang-detail {
  background: #fff; border: 1px solid #d0e3ff;
  border-top: none; border-radius: 0 0 10px 10px; overflow: hidden;
}
.rekap-uang-row {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: 12px; align-items: center;
  padding: 9px 20px; font-size: 0.9rem;
  border-bottom: 1px solid #f0f0f0; color: #444;
}
.rekap-uang-row:last-child { border-bottom: none; }
.rekap-uang-row strong { min-width: 110px; text-align: right; font-size: 0.92rem; }
.rekap-uang-sub { font-size: 0.78rem; color: #aaa; text-align: right; }

.rekap-kurir-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.rekap-kurir-card { background: #f8f9fa; border-radius: 10px; border: 1px solid #eee; overflow: hidden; }
.rekap-kurir-header { background: #7c3aed; color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 10px; }
.rekap-kurir-nama { font-weight: 700; font-size: 0.95rem; }
.rekap-kurir-jabatan { font-size: 0.78rem; background: rgba(255,255,255,0.2); padding: 2px 8px; border-radius: 20px; }
.rekap-kurir-subhead {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px;
  padding: 8px 16px; font-size: 0.75rem; font-weight: 700; color: #888;
  text-transform: uppercase; background: #f0eeff; border-bottom: 1px solid #e0e0e0;
}
.rekap-kurir-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px;
  padding: 8px 16px; font-size: 0.88rem; color: #444;
  border-bottom: 1px solid #f0f0f0; align-items: center;
}
.rekap-kurir-row span:nth-child(2),
.rekap-kurir-subhead span:nth-child(2) { min-width: 80px; text-align: right; }
.rekap-kurir-row span:nth-child(3),
.rekap-kurir-subhead span:nth-child(3) { min-width: 100px; text-align: right; }
.rekap-kurir-footer {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px;
  padding: 10px 16px; font-size: 0.88rem;
  background: #fef7e0; font-weight: 600; color: #555;
}
.rekap-kurir-footer strong { min-width: 100px; text-align: right; }

.text-green  { color: #34a853; }
.text-orange { color: #e37400; }
.text-red    { color: #ea4335; }

/* ══════════════════════════════════════════
   KREDIT
══════════════════════════════════════════ */
.kredit-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.kredit-sum-card {
  background: #fff; border-radius: 12px; padding: 18px 20px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07); border-left: 5px solid #ccc;
}

/* ══════════════════════════════════════════
   BOTTOM NAV SPACER
══════════════════════════════════════════ */
.bottom-nav-spacer { display: none; }

/* ══════════════════════════════════════════
   BOTTOM NAV (mobile only)
══════════════════════════════════════════ */
.bottom-nav { display: none; }

/* ══════════════════════════════════════════
   RESPONSIVE MOBILE ≤ 768px
══════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Container — padding kiri kanan cukup, bawah untuk spacer */
  .container { padding: 16px 12px 16px; }

  /* Header */
  header h1 { font-size: 1.4rem; }
  header p  { font-size: 0.85rem; }

  /* Sembunyikan tab nav desktop */
  .tab-nav { display: none; }

  /* Summary cards 2 kolom */
  .summary { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { padding: 12px 14px; gap: 10px; }
  .card-icon  { font-size: 1.5rem; }
  .card-count { font-size: 1.3rem; }
  .card-label { font-size: 0.72rem; }

  /* Form */
  .form-section { padding: 16px 14px; margin-bottom: 16px; }
  .form-row { flex-direction: column; gap: 10px; margin-bottom: 8px; }
  .form-group { min-width: 100%; }
  .form-group-btn { flex-direction: column !important; }
  .form-group-btn button { width: 100%; }

  /* Tabel */
  .table-section { padding: 16px 14px; margin-bottom: 16px; }
  .table-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .filter-group { flex-wrap: wrap; gap: 6px; width: 100%; }
  .filter-group input,
  .filter-group select { flex: 1; min-width: 120px; font-size: 0.82rem; }
  .filter-group button { font-size: 0.82rem; padding: 7px 10px; }
  table { font-size: 0.8rem; }
  th, td { padding: 8px 8px; }

  /* Tombol */
  .btn-primary  { font-size: 0.88rem; padding: 9px 14px; }
  .btn-secondary, .btn-danger { font-size: 0.82rem; padding: 7px 10px; }

  /* Profil */
  .logo-preview-wrap { flex-direction: column; align-items: flex-start; }
  .profil-preview-inner { flex-direction: column; }

  /* Rekap */
  .rekap-filter-bar { flex-direction: column; }
  .rekap-cards { grid-template-columns: 1fr; }
  .rekap-kurir-grid { grid-template-columns: 1fr; }
  .rekap-total-bar { flex-direction: column; gap: 4px; text-align: center; }

  /* Kredit */
  .kredit-summary { grid-template-columns: repeat(2, 1fr); }

  /* Modal */
  .modal { padding: 20px 16px; width: 95%; }

  /* Bottom nav spacer — mendorong konten agar tidak tertutup */
  .bottom-nav-spacer {
    display: block;
    height: 72px;
    width: 100%;
  }

  /* Bottom nav */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    z-index: 1000;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .bottom-nav::-webkit-scrollbar { display: none; }

  .bnav-btn {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    flex: 0 0 auto; min-width: 64px;
    padding: 8px 6px 10px;
    background: none; border: none;
    cursor: pointer; color: #999;
    transition: color 0.2s; gap: 3px;
  }
  .bnav-btn.active { color: #1a73e8; }
  .bnav-icon  { font-size: 1.3rem; line-height: 1; }
  .bnav-label { font-size: 0.65rem; font-weight: 600; white-space: nowrap; }
}

@media (max-width: 400px) {
  .summary { grid-template-columns: 1fr; }
  .kredit-summary { grid-template-columns: 1fr; }
  header h1 { font-size: 1.2rem; }
}
