:root {
  --vp-sidebar: #0f172a;
  --vp-sidebar-hover: #1e293b;
  --vp-accent: #2563eb;
  --vp-bg: #f1f5f9;
  --vp-sidebar-w: 250px;
}
body { background: var(--vp-bg); font-size: .925rem; }
.btn-xs { padding: .1rem .45rem; font-size: .75rem; }

/* Layout */
/* !important: Bootstrap's .offcanvas-lg forces a transparent background at the lg breakpoint */
.sidebar { width: var(--vp-sidebar-w); background-color: var(--vp-sidebar) !important; color: #cbd5e1; }
@media (min-width: 992px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; overflow-y: auto; z-index: 1030; }
  .has-sidebar .main { margin-left: var(--vp-sidebar-w); }
}
.sidebar.offcanvas-lg { --bs-offcanvas-width: var(--vp-sidebar-w); --bs-offcanvas-bg: var(--vp-sidebar); }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1rem; border-bottom: 1px solid #1e293b; color: #fff; }
.sidebar-brand > i { font-size: 1.8rem; color: #60a5fa; }
.sidebar-brand small { color: #94a3b8; font-size: .75rem; }
.sidebar-menu { padding: .5rem; display: flex; flex-direction: column; width: 100%; }
.sidebar-menu a { display: flex; align-items: center; gap: .7rem; padding: .55rem .8rem; color: #cbd5e1; text-decoration: none; border-radius: .5rem; margin-bottom: 2px; }
.sidebar-menu a:hover { background: var(--vp-sidebar-hover); color: #fff; }
.sidebar-menu a.active { background: var(--vp-accent); color: #fff; }
.sidebar-menu a i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.sidebar-heading { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 1rem .8rem .35rem; }
.main { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; background: #fff; border-bottom: 1px solid #e2e8f0; padding: .6rem 1.25rem; display: flex; align-items: center; gap: .75rem; }
.page-title { font-size: 1.15rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { padding: 1.25rem; flex: 1; }
.app-footer { padding: .75rem 1.25rem; font-size: .75rem; color: #94a3b8; }
@media (max-width: 575px) { .content { padding: .75rem; } }

.card { border: 1px solid #e2e8f0; border-radius: .75rem; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.card-header { background: #fff; font-weight: 600; border-bottom-color: #e2e8f0; }
.card-header:first-child { border-radius: .75rem .75rem 0 0; }
.table > :not(caption) > * > * { padding: .55rem .6rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: #64748b; font-weight: 600; background: #f8fafc; }
.row-link { cursor: pointer; }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: #e2e8f0; }
.badge-type { font-weight: 500; }
.detail-table th { width: 38%; color: #64748b; font-weight: 500; }

/* KPI */
.kpi-card { transition: transform .15s; color: inherit; }
a.kpi-card:hover { transform: translateY(-2px); }
.kpi-icon { width: 48px; height: 48px; border-radius: .75rem; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.kpi-label { font-size: .8rem; color: #64748b; }

/* Login */
.main-guest { min-height: 100vh; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(135deg, #0f172a, #1e3a8a); }
.login-card { width: 100%; max-width: 420px; border: 0; }
.login-logo { width: 64px; height: 64px; margin: 0 auto .75rem; border-radius: 1rem; background: var(--vp-accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 2rem; }

/* Pass form */
.pass-type-picker .btn { border-width: 2px; }
.camera-box { width: 100%; aspect-ratio: 1; background: #f1f5f9; border: 2px dashed #cbd5e1; border-radius: .75rem; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.camera-box-sm { width: 160px; }
.camera-box video, .camera-box img { width: 100%; height: 100%; object-fit: cover; }
.camera-box img.placeholder-photo { width: 50%; height: 50%; opacity: .4; object-fit: contain; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.profile-photo { width: 160px; height: 160px; border-radius: 50%; object-fit: cover; border: 4px solid #e2e8f0; }

/* Scanner */
.scanner-box { width: 100%; min-height: 60px; border-radius: .75rem; overflow: hidden; background: #0f172a; }
.scanner-box:empty { display: none; }
.result-head { padding: 1rem 1.25rem; color: #fff; font-size: 1.5rem; font-weight: 800; border-radius: .75rem .75rem 0 0; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.result-head small { font-size: .85rem; font-weight: 500; opacity: .9; margin-left: auto; }
.result-head.ok { background: #16a34a; }
.result-head.out { background: #0891b2; }
.result-head.deny { background: #dc2626; }
.scan-photo { width: 100%; max-width: 240px; aspect-ratio: 1; object-fit: cover; border-radius: .75rem; border: 4px solid #e2e8f0; }
.form-check-lg .form-check-input { width: 1.6em; height: 1.6em; margin-top: 0; margin-right: .5rem; }
.form-check-lg { display: flex; align-items: center; padding: .75rem; background: #fef9c3; border-radius: .5rem; }
.shake { animation: shake .4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* Pass badge (screen + print) */
.pass-badge { max-width: 380px; margin: 0 auto; background: #fff; border-radius: 1rem; overflow: hidden; border: 1px solid #cbd5e1; box-shadow: 0 6px 24px rgba(15, 23, 42, .12); }
.pass-badge-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1rem; color: #fff; background: #2563eb; }
.badge-multi .pass-badge-head { background: #0891b2; }
.badge-worker .pass-badge-head { background: #d97706; }
.pass-company { font-weight: 700; }
.pass-site { font-size: .8rem; opacity: .9; }
.pass-type-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; background: rgba(255, 255, 255, .2); padding: .25rem .5rem; border-radius: .35rem; text-align: right; }
.pass-badge-body { display: flex; gap: .9rem; padding: 1rem; }
.pass-photo { width: 110px; height: 130px; object-fit: cover; border-radius: .5rem; border: 2px solid #e2e8f0; flex-shrink: 0; }
.pass-name { font-size: 1.15rem; font-weight: 700; line-height: 1.2; margin-bottom: .25rem; }
.pass-line { font-size: .8rem; color: #475569; }
.pass-badge-foot { display: flex; gap: .9rem; align-items: center; padding: .75rem 1rem 1rem; border-top: 1px dashed #cbd5e1; }
.pass-qr { width: 116px; height: 116px; flex-shrink: 0; }
.pass-qr img, .pass-qr canvas { width: 116px !important; height: 116px !important; }
.pass-no { font-family: ui-monospace, monospace; font-weight: 700; font-size: 1rem; letter-spacing: .03em; }
.pass-terms { font-size: .65rem; color: #64748b; margin-top: .25rem; }
.public-pass { max-width: 440px; margin: 0 auto; padding: 1.5rem 1rem; }

/* Reports */
.report-nav { padding: .5rem; }
.report-nav-group { font-size: .7rem; text-transform: uppercase; color: #94a3b8; padding: .6rem .6rem .25rem; letter-spacing: .06em; }
.report-nav a { display: block; padding: .4rem .6rem; border-radius: .4rem; text-decoration: none; color: #334155; font-size: .875rem; }
.report-nav a:hover { background: #f1f5f9; }
.report-nav a.active { background: #dbeafe; color: #1d4ed8; font-weight: 600; }
.report-table { max-height: 70vh; }
.report-table td { white-space: nowrap; font-size: .82rem; }
.ai-box { padding: 1rem 1.25rem; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }

/* AI chat */
.ai-chat { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 420px; }
.ai-messages { flex: 1; overflow-y: auto; background: #f8fafc; }
.ai-msg { max-width: 85%; padding: .7rem 1rem; border-radius: 1rem; margin-bottom: .75rem; }
.ai-msg-user { margin-left: auto; background: var(--vp-accent); color: #fff; border-bottom-right-radius: .25rem; }
.ai-msg-bot { background: #fff; border: 1px solid #e2e8f0; border-bottom-left-radius: .25rem; }
.ai-msg-error { background: #fee2e2; color: #991b1b; }
.ai-meta { font-size: .7rem; color: #94a3b8; margin-bottom: .25rem; }
.ai-text ul { padding-left: 1.2rem; margin: .25rem 0; }
.ai-text h5, .ai-text h6 { margin: .5rem 0 .25rem; }
.ai-code { background: #0f172a; color: #e2e8f0; padding: .6rem; border-radius: .4rem; white-space: pre-wrap; font-size: .8rem; }

/* Long API error messages (with URLs) must wrap inside the toast */
.toast-container { max-width: calc(100vw - 1rem); }
.toast-body { overflow-wrap: anywhere; }

.print-only { display: none; }

@media print {
  @page { margin: 10mm; }
  body { background: #fff !important; }
  .sidebar, .topbar, .app-footer, .no-print, .alert, .btn, .toast-container { display: none !important; }
  .has-sidebar .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  .print-only { display: block !important; }
  td.print-only, th.print-only { display: table-cell !important; }
  .card { border: 0 !important; box-shadow: none !important; }
  .pass-badge { box-shadow: none; border: 1px solid #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-area { width: 100% !important; max-width: 100% !important; flex: 0 0 100% !important; }
  .table-responsive { overflow: visible !important; max-height: none !important; }
  .print-report td, .print-report th { font-size: 9pt; padding: 2px 4px !important; }
}
