/* =========================================
   DASAR & VARIABEL
   ========================================= */
:root {
  --text: #111;
  --muted: #666;
  --line: #000;
  --border-weight: 1.875px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f5f6f7;
  color: var(--text);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* =========================================
   TOOLBAR & INTERAKSI
   ========================================= */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  padding: 10px 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  border: 1px solid #ccc;
  background: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}

.btn:hover { background: #fafafa; }
.btn.primary { background: #111; color: #fff; border-color: #111; }
.btn.good { background: #1f7a1f; color: #fff; border-color: #1f7a1f; }
.btn.warn { background: #b94a00; color: #fff; border-color: #b94a00; }

/* =========================================
   STRUKTUR HALAMAN
   ========================================= */
.page {
  max-width: 900px;
  margin: 20px auto;
  background: #fff;
  border: var(--border-weight) solid #000 !important;
  padding: 30px;
  position: relative;
  overflow: hidden; /* Menjaga watermark tidak keluar */
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.watermark {
  position: absolute; /* Ubah ke absolute agar relatif terhadap .page */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-18deg);
  pointer-events: none;
  user-select: none;
  font-size: 80px;
  font-weight: 900;
  color: rgba(0,0,0,0.06);
  text-transform: uppercase;
  z-index: 0;
  white-space: nowrap;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-bottom: var(--border-weight) solid #000 !important;
  padding-bottom: 20px;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}

/* Fix Logo side-by-side */
.logosLeft {
  display: flex;
  align-items: center;
  gap: 5px;
}

.logo-aigen-front { height: 70px; width: auto; object-fit: contain; }
.logo-konsen-back { height: 80px; width: auto; object-fit: contain; margin-left: -10px; }

/* =========================================
   TABEL (Fix Kepotong)
   ========================================= */
/* Tambahkan div pembungkus di HTML: <div class="table-responsive"><table>...</table></div> */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin: 20px 0;
  border: var(--border-weight) solid #000;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px; /* Memastikan tabel punya ruang minimum */
}

thead th {
  background: #f8f8f8;
  border: 1px solid #000; /* Garis antar kolom lebih halus di dalam */
  border-bottom: var(--border-weight) solid #000 !important;
  padding: 12px 10px;
  font-size: 12px;
}

tbody td {
  border: 1px solid #000;
  padding: 10px;
  font-size: 14px;
}

/* =========================================
   BAGIAN BAWAH & SIGNATURE
   ========================================= */
.bottom {
  display: flex;
  flex-wrap: wrap; /* Agar otomatis turun di layar kecil */
  gap: 20px;
  margin-top: 20px;
}

.keterangan-box {
  border: var(--border-weight) solid #000 !important;
  padding: 12px;
  flex: 1;
  min-width: 300px;
}

.totals {
  border: var(--border-weight) solid #000 !important;
  border-radius: 8px;
  padding: 15px;
  min-width: 280px;
}

/* Posisi Signature yang Aman */
.signature-wrapper {
  display: flex;
  justify-content: flex-end;
  margin-top: 30px;
}

.box-sign {
  text-align: center;
  width: 220px;
}

.sign-wrapper {
  position: relative;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
}

.img-signature { height: 80px; z-index: 2; position: relative; }
.img-stamp {
  height: 100px;
  position: absolute;
  opacity: 0.5;
  z-index: 1;
  mix-blend-mode: multiply;
}

/* =========================================
   RESPONSIF HP (Sempurna)
   ========================================= */
@media screen and (max-width: 768px) {
  .page {
    margin: 0;
    padding: 15px;
    border: none !important;
    width: 100%;
  }

  .top {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .right { text-align: center; width: 100%; }
  
  .meta {
    grid-template-columns: 1fr; /* List vertikal di HP */
    text-align: center;
    gap: 10px;
  }
  
  .meta input.meta-date { width: 100%; text-align: center; }

  .grid { grid-template-columns: 1fr; }

  .bottom { flex-direction: column; }
  
  .keterangan-box, .totals { width: 100%; }

  .signature-wrapper {
    justify-content: center;
    margin-top: 40px;
  }
  
  .watermark { font-size: 40px; opacity: 0.03; }
}

/* =========================================
   PRINT PREVIEW
   ========================================= */
@media print {
  .toolbar, .no-print, .actions-col { display: none !important; }
  .page { margin: 0; border: none !important; box-shadow: none; width: 100%; }
  body { background: #fff; }
}