/* ========== Base ========== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: #1a1a1a; background: #f5f6f8; }
button { cursor: pointer; padding: 8px 14px; border: 1px solid #cbd2d9; background: #fff; border-radius: 6px; font-size: 14px; }
button.primary { background: #003d79; color: #fff; border-color: #003d79; }
button.primary:hover { background: #002a55; }
button.success { background: #198754; color: #fff; border-color: #198754; }
button:hover { background: #f0f3f7; }
button.primary:hover, button.success:hover { color: #fff; }
input[type=text], input[type=date], input[type=number], textarea {
  border: 1px solid #cbd2d9; border-radius: 5px; padding: 6px 9px; font-size: 14px; font-family: inherit; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid #ffd24d; border-color: #003d79; }
.hidden { display: none !important; }
.grow { flex: 1; }

/* ========== Topbar ========== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; background: #003d79; color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 600; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #ffd24d, #ffb800);
}
.topbar nav { display: flex; gap: 8px; }
.nav-btn { background: rgba(255,255,255,0.1); color: #fff; border-color: transparent; }
.nav-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.nav-btn.primary { background: #ffd24d; color: #003d79; }
.nav-btn.primary:hover { background: #ffc01f; }

/* ========== Views ========== */
.view { padding: 20px; max-width: 1200px; margin: 0 auto; }

/* ========== List ========== */
.toolbar { margin-bottom: 14px; display: flex; gap: 10px; }
.toolbar input[type=search] { max-width: 360px; }
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eef0f3; font-size: 14px; }
.data-table th { background: #f7f9fc; font-weight: 600; color: #4b5563; }
.data-table .num { text-align: right; }
.data-table tr:hover td { background: #fafbfd; }
.data-table .empty { text-align: center; color: #9aa3af; padding: 30px; }
.action-row button { padding: 4px 10px; font-size: 12px; margin-right: 4px; }

/* ========== Form (mirror slip) ========== */
.form-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.form-toolbar h2 { margin: 0; color: #003d79; }

.slip-form {
  background: #fff; border-radius: 8px; padding: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06); overflow: hidden;
}
.slip-banner {
  background: #1a1a1a; color: #fff; padding: 14px 22px;
  display: flex; justify-content: space-between; align-items: center;
}
.banner-title { font-size: 18px; font-weight: 600; }
.banner-sub { font-size: 12px; opacity: 0.7; font-style: italic; }
.banner-logo { font-size: 26px; font-weight: 700; letter-spacing: -1px; font-style: italic; }

.slip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.col { padding: 16px 18px; border-right: 1px solid #eef0f3; }
.col:last-child { border-right: none; }

.box { border: 1px solid #d8dde3; border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; }
.box legend { font-size: 12px; font-weight: 700; color: #003d79; text-transform: uppercase; padding: 0 6px; }
.box legend i { font-weight: 400; font-style: italic; color: #6b7280; text-transform: none; font-size: 11px; }

.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.row label { font-size: 12px; color: #4b5563; min-width: 110px; }
.row label i { color: #9aa3af; font-style: italic; font-size: 11px; }
.row input, .row textarea { flex: 1; min-width: 100px; }
.row .static { flex: 1; padding: 6px 9px; color: #1a1a1a; font-weight: 500; }

/* ===== Pill radio/checkbox group =====
   Pakai specificity tinggi untuk override .row input dan .row label */

.checks {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  flex: 1 1 auto;
  margin: 0;
  padding: 0;
  list-style: none;
}
.checks.row   { flex-direction: row; flex-wrap: wrap; align-items: center; }
.checks.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.checks.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.checks.grid4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }

/* Pill (override .row label) */
.row .checks label,
.checks > label {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: #1a1a1a;
  cursor: pointer;
  padding: 5px 12px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.2;
  min-width: 0;
  width: auto;
  flex: 0 0 auto;
}
.checks.grid2 > label,
.checks.grid3 > label,
.checks.grid4 > label,
.row .checks.grid2 label,
.row .checks.grid3 label,
.row .checks.grid4 label { width: 100%; }

.checks > label:hover,
.row .checks label:hover { border-color: #003d79; background: #eef4ff; }

.checks > label:has(input:checked),
.row .checks label:has(input:checked) {
  border-color: #003d79;
  background: #e8f0fb;
  font-weight: 600;
  color: #003d79;
}

/* Radio/Checkbox itself (override .row input flex:1 min-width:100px) */
.row .checks input,
.checks input[type=radio],
.checks input[type=checkbox] {
  flex: none !important;
  width: 14px !important;
  height: 14px !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0;
  accent-color: #003d79;
  cursor: pointer;
}

@media (max-width: 900px) {
  .slip-grid { grid-template-columns: 1fr; }
  .col { border-right: none; border-bottom: 1px solid #eef0f3; }
}

/* ========== Print preview stage ========== */
.print-toolbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
  background: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.print-toolbar label { font-size: 13px; color: #4b5563; display: flex; align-items: center; gap: 6px; }

.print-stage { display: flex; justify-content: center; }
.page-a4 {
  position: relative;
  width: 210mm; height: 175mm;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  overflow: hidden;
}
.form-bg {
  position: absolute; top: 0; left: 0; width: 210mm; height: 175mm;
  opacity: 0.35; pointer-events: none;
}
.overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

/* Cetak field — semua absolut, satuan mm */
.f {
  position: absolute;
  font-family: "Courier New", monospace;
  font-size: 8pt;
  font-weight: 600;
  color: #000;
  white-space: nowrap;
}
.f.wrap { white-space: normal; line-height: 1.25; }
.f.x { font-family: Arial, sans-serif; font-weight: 900; font-size: 7pt; line-height: 1; }

/* Label kalibrasi — hanya di layar, tidak tercetak */
.f-label {
  position: absolute;
  font-size: 5.5pt;
  font-family: Arial, sans-serif;
  color: #e53e3e;
  background: rgba(255,255,240,0.85);
  padding: 0 2px;
  white-space: nowrap;
  line-height: 1;
  pointer-events: none;
  z-index: 10;
}
.f-dot {
  position: absolute;
  width: 3px; height: 3px;
  background: #e53e3e;
  border-radius: 50%;
  transform: translate(-1px,-1px);
  pointer-events: none;
  z-index: 11;
}

/* ========== Print rules ========== */
@page { size: 210mm 175mm; margin: 0; }
@media print {
  body { background: #fff; margin: 0; }
  .no-print, .topbar, .print-toolbar { display: none !important; }
  .print-stage { display: block; }
  .page-a4 { box-shadow: none; width: 210mm; height: 175mm; page-break-after: avoid; }
  .form-bg { opacity: 0 !important; }
  .f-label, .f-dot { display: none !important; }
}
