:root {
  --blue: #0753A1;
  --blue-dark: #053b73;
  --blue-soft: #eef5fc;
  --red: #ED1C24;
  --green: #15803d;
  --green-soft: #ecfdf3;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --text: #1c2430;
  --muted: #64748b;
  --border: #dde5ef;
  --bg: #f4f7fb;
  --white: #ffffff;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-accent { display: flex; height: 5px; width: 100%; }
.topbar-accent .r { width: 22%; background: var(--red); }
.topbar-accent .b { flex: 1; background: var(--blue); }
.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { height: 44px; width: auto; }
.brand-text h1 { font-size: 16px; font-weight: 800; color: var(--blue); }
.brand-text p { font-size: 12px; color: var(--muted); }
.nav-links { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.container { max-width: 1120px; margin: 28px auto; padding: 0 20px 56px; }
.container-sm { max-width: 720px; margin: 28px auto; padding: 0 20px 56px; }
.container-wide { max-width: 1360px; margin: 24px auto; padding: 0 20px 56px; }

.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 4px 16px rgba(7, 83, 161, 0.04);
}
.panel + .panel { margin-top: 20px; }

.panel-title {
  font-size: 13.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--blue);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 5px;
}
.field input[type="text"],
.field input[type="tel"],
.field input[type="password"],
.field input[type="date"],
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(7, 83, 161, 0.12);
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 700px) {
  .row-2, .row-3 { grid-template-columns: 1fr; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 15px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s, background 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 7px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover:not(:disabled) { opacity: 0.92; }
.btn-green { background: #16a34a; color: #fff; }
.btn-green:hover:not(:disabled) { background: #15803d; }
.btn-outline { background: #fff; color: var(--blue); border: 1.5px solid var(--blue); }
.btn-outline:hover:not(:disabled) { background: var(--blue-soft); }
.btn-ghost { background: #f1f5f9; color: #334155; }
.btn-ghost:hover:not(:disabled) { background: #e2e8f0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}
.badge-pending { background: var(--amber-soft); color: var(--amber); border: 1px solid #fde68a; }
.badge-approved { background: var(--green-soft); color: var(--green); border: 1px solid #bbf7d0; }
.badge-rejected { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-blue { background: var(--blue-soft); color: var(--blue); border: 1px solid #cfe0f5; }

.alert {
  padding: 12px 15px;
  border-radius: 10px;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.alert-info { background: var(--blue-soft); color: var(--blue-dark); border: 1px solid #cfe0f5; }
.alert-success { background: var(--green-soft); color: var(--green); border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

.upload-box {
  display: block;
  border: 1.5px dashed #94a3b8;
  border-radius: 10px;
  padding: 13px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  transition: border-color 0.15s, background 0.15s;
}
.upload-box:hover { border-color: var(--blue); background: var(--blue-soft); }
.upload-box span { display: block; font-size: 13px; font-weight: 700; color: var(--blue); }
.upload-box small { font-size: 11.5px; color: var(--muted); }
.upload-box.has-file { border-color: #16a34a; background: #f0fdf4; }
.upload-box.has-file span { color: #15803d; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 9px;
}
.segmented button {
  border: none;
  background: transparent;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.segmented button.active {
  background: var(--white);
  color: var(--blue);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Stat cards */
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.stat-card small {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.5px;
}
.stat-card strong {
  display: block;
  font-size: 26px;
  font-weight: 800;
  color: var(--blue);
  margin-top: 4px;
}

/* PVC Card & Receipt Preview */
.pvc-card {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(7, 83, 161, 0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.pvc-card.horizontal { width: 480px; height: 303px; max-width: 100%; }
.pvc-card.vertical { width: 303px; height: 480px; max-width: 100%; }

.pvc-bar { display: flex; height: 11px; width: 100%; flex-shrink: 0; }
.pvc-bar .seg-red { width: 28%; background: var(--red); }
.pvc-bar .seg-blue { flex: 1; background: var(--blue); }
.pvc-bar-bottom { display: flex; height: 7px; width: 100%; flex-shrink: 0; }
.pvc-bar-bottom .seg-blue { flex: 1; background: var(--blue); }
.pvc-bar-bottom .seg-red { width: 22%; background: var(--red); }

.pvc-card.horizontal .pvc-body { flex: 1; padding: 14px 22px 10px; display: flex; flex-direction: column; justify-content: space-between; }
.pvc-card.horizontal .pvc-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #edf2f7; padding-bottom: 8px; }
.pvc-card.horizontal .pvc-logo { height: 50px; width: auto; }
.pvc-badge { font-size: 9.5px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--blue); background: var(--blue-soft); border: 1px solid #cfe0f5; padding: 4px 10px; border-radius: 999px; }
.pvc-card.horizontal .pvc-main { display: flex; align-items: center; gap: 16px; margin: 10px 0 6px; }
.pvc-photo { width: 102px; height: 102px; object-fit: cover; border: 3px solid var(--blue); background: #f1f5f9; flex-shrink: 0; }
.pvc-photo.circle { border-radius: 50%; }
.pvc-photo.square { border-radius: 10px; }
.pvc-info { min-width: 0; flex: 1; }
.pvc-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); }
.pvc-name { font-size: 18px; font-weight: 800; color: var(--text); line-height: 1.18; margin: 2px 0 8px; word-wrap: break-word; }
.pvc-course { font-size: 13px; font-weight: 700; color: var(--blue); line-height: 1.25; }
.pvc-qr-wrap { flex-shrink: 0; text-align: center; }
.pvc-qr-wrap img { width: 58px; height: 58px; display: block; border: 1px solid #e2e8f0; border-radius: 6px; padding: 2px; background: #fff; }
.pvc-footer { display: flex; justify-content: space-between; align-items: center; font-size: 10px; color: var(--muted); padding-top: 6px; border-top: 1px solid #f1f5f9; }
.pvc-footer strong { color: var(--red); font-weight: 700; }

.pvc-card.vertical .pvc-body { flex: 1; padding: 16px 20px 12px; display: flex; flex-direction: column; align-items: center; text-align: center; justify-content: space-between; }
.pvc-card.vertical .pvc-header { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pvc-card.vertical .pvc-logo { height: 70px; width: auto; }
.pvc-card.vertical .pvc-main { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.pvc-card.vertical .pvc-photo { width: 112px; height: 112px; }
.pvc-card.vertical .pvc-name { font-size: 17px; margin: 2px 0 6px; }
.pvc-card.vertical .pvc-footer { width: 100%; }

/* Receipt */
.receipt {
  width: 100%;
  max-width: 760px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.10), 0 0 0 1px rgba(7, 83, 161, 0.12);
  overflow: hidden;
}
.receipt-body { padding: 24px 28px 20px; }
.receipt-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 14px; border-bottom: 2px solid var(--blue-soft); margin-bottom: 18px; }
.receipt-brand img { height: 64px; width: auto; }
.receipt-meta { text-align: right; }
.receipt-title { font-size: 18px; font-weight: 800; color: var(--blue); }
.receipt-number { font-size: 13px; font-weight: 700; color: var(--red); margin-top: 2px; }
.receipt-date { font-size: 12px; color: var(--muted); }
.receipt-statement { background: #f8fbff; border-left: 4px solid var(--blue); border-radius: 0 8px 8px 0; padding: 14px 16px; font-size: 14.5px; color: #1e293b; line-height: 1.65; margin-bottom: 16px; }
.receipt-statement strong { color: var(--blue-dark); }
.receipt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
@media (max-width: 600px) { .receipt-grid { grid-template-columns: 1fr; } }
.receipt-box { border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; }
.receipt-box small { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.receipt-box div { font-size: 13.5px; font-weight: 700; }
.receipt-box.highlight div { color: var(--blue); font-size: 15.5px; }
.receipt-sign-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; min-height: 112px; }
.sign-line { width: 230px; text-align: center; }
.sign-line .line { border-top: 1.5px solid #94a3b8; margin-bottom: 6px; }
.sign-line span { font-size: 11px; color: var(--muted); font-weight: 600; }
.stamp-img { max-width: 158px; max-height: 124px; width: auto; height: auto; object-fit: contain; transform: rotate(-8deg); opacity: 0.94; mix-blend-mode: multiply; }
.stamp-img.hidden { display: none; }
.rec-qr-box { text-align: center; }
.rec-qr-box img { width: 78px; height: 78px; border: 1px solid var(--border); border-radius: 6px; padding: 3px; background: #fff; display: block; margin: 0 auto 3px; }
.rec-qr-box small { font-size: 9.5px; color: var(--muted); display: block; }
.receipt-foot { background: #f8fafc; border-top: 1px solid var(--border); padding: 10px 28px; display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); flex-wrap: wrap; gap: 8px; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.5px; background: #f8fafc; }
.table-wrap { overflow-x: auto; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.58);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 14px; max-width: 820px; width: 100%; max-height: 90vh;
  overflow: auto; padding: 20px; box-shadow: 0 24px 60px rgba(0,0,0,0.25);
}

@media print {
  body { background: #fff; }
  .topbar, .no-print { display: none !important; }
  .pvc-card, .receipt { box-shadow: none; border: 1px solid #cbd5e1; break-inside: avoid; margin-bottom: 24px; }
}
