:root {
  --ink: #16211f;
  --paper: #f4f2ec;
  --paper-raised: #ffffff;
  --line: #d9d4c6;
  --line-soft: #e8e5da;
  --accent: #2f5d5a;
  --accent-strong: #1f4340;
  --accent-soft: #dbe6e2;
  --warn: #a15a2a;
  --warn-soft: #f3e2d1;
  --muted: #6b7570;
  --danger: #a13a3a;
  --danger-soft: #f3dede;
  --shadow: 0 1px 2px rgba(22,33,31,0.06), 0 6px 20px rgba(22,33,31,0.06);
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
}
h1, h2, h3, .num, .brand { font-family: 'Space Grotesk', system-ui, sans-serif; }
a { color: var(--accent-strong); text-decoration: none; }

.topnav { background: var(--paper-raised); border-bottom: 1px solid var(--line-soft); }
.topnav-inner {
  max-width: 1180px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.nav-links { display: flex; gap: 18px; }
.nav-links a { color: var(--muted); font-weight: 600; font-size: 0.9rem; }
.nav-links a:hover { color: var(--accent-strong); }
.nav-user { display: flex; align-items: center; gap: 14px; font-size: 0.85rem; color: var(--muted); }
.role-pill { background: var(--accent-soft); color: var(--accent-strong); padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.logout { color: var(--danger); font-weight: 600; }

.shell { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
.narrow { max-width: 420px; margin: 60px auto; }

.card { background: var(--paper-raised); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-head { padding: 20px 24px 0; }
.card-head h2, .card-head h1 { margin: 0 0 4px; font-weight: 700; }
.card-head p { margin: 0 0 16px; color: var(--muted); font-size: 0.88rem; }
.card-body { padding: 4px 24px 24px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.field.span2 { grid-column: 1 / -1; }
label { font-size: 0.8rem; font-weight: 600; }
label .opt { font-weight: 400; color: var(--muted); font-size: 0.76rem; }
input, select, textarea {
  font-family: inherit; font-size: 0.92rem; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea { resize: vertical; min-height: 56px; }

button, .btn {
  font-family: inherit; cursor: pointer; border-radius: 8px; font-weight: 600; font-size: 0.9rem;
  padding: 11px 20px; border: 1px solid transparent; display: inline-block; text-align: center;
}
button.primary, .btn.primary { background: var(--accent-strong); color: #fdfcf8; }
button.primary:hover, .btn.primary:hover { background: var(--accent); }
button.ghost, .btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
button.danger, .btn.danger { background: var(--danger); color: #fff; }
button.small, .btn.small { padding: 6px 12px; font-size: 0.8rem; }

.alert { padding: 12px 16px; border-radius: 8px; font-size: 0.88rem; margin-bottom: 16px; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.success { background: var(--accent-soft); color: var(--accent-strong); }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--paper-raised); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.stat .l { color: var(--muted); font-size: 0.78rem; margin-top: 6px; }
.stat.warn .n { color: var(--warn); }
.stat.accent .n { color: var(--accent-strong); }
.stat.vivid { border: none; color: #fff; }
.stat.vivid .l { color: rgba(255,255,255,0.88); }
.stat.vivid.c-purple { background: #6C2BD9; }
.stat.vivid.c-orange { background: #F5A524; }
.stat.vivid.c-blue { background: #2F87EB; }
.stat.vivid.c-indigo { background: #3B0F70; }
.stat.vivid.c-red { background: #C0392B; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: none; }
tr:hover td { background: var(--paper); }

.status-badge { font-size: 0.72rem; padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.status-badge.in { background: var(--accent-soft); color: var(--accent-strong); }
.status-badge.out { background: var(--line-soft); color: var(--muted); }
.status-badge.pending { background: var(--warn-soft); color: var(--warn); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; padding: 7px 10px; font-size: 0.85rem; }

/* Badge / visitor pass */
.badge-pass {
  width: 340px; margin: 30px auto; border: 2px dashed var(--line);
  border-radius: 12px; padding: 22px; text-align: center; background: var(--paper-raised);
}
.badge-pass .org { font-weight: 700; letter-spacing: 0.02em; font-size: 1rem; }
.badge-pass .tag { color: var(--muted); font-size: 0.78rem; margin-bottom: 14px; }
.badge-photo { width: 84px; height: 84px; border-radius: 10px; object-fit: cover; margin: 0 auto 12px; background: var(--accent-soft); display: block; }
.badge-fields { text-align: left; font-size: 0.85rem; margin: 12px 0; }
.badge-fields div { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dotted var(--line-soft); gap: 10px; }
.badge-fields .k { color: var(--muted); }
.badge-fields .v { font-weight: 600; text-align: right; }
.badge-qr { margin: 16px 0 6px; }
.badge-code { font-family: 'Space Grotesk', monospace; font-weight: 700; letter-spacing: 0.03em; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .badge-pass { border: 1px solid #999; margin: 0; }
}

@media (max-width: 880px) {
  .grid2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .nav-links { order: 3; width: 100%; }
}
