:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #17233b;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --baby: #7c3aed;
  --kids: #2563eb;
  --jr: #0d9488;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { margin: 0 0 .5em; }
a { color: var(--brand); text-decoration: none; }

/* ---- navigation: fixed left sidebar on desktop, top bar + drawer on mobile ---- */
.topnav { background: #0f1b33; color: #fff; z-index: 50; }
.topnav .brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.topnav .brand span { color: #7eb0ff; }
.topnav a { color: #c7d4ec; text-decoration: none; display: flex; align-items: center; white-space: nowrap; }
.topnav a:hover { color: #fff; }
.ni { display: inline-block; width: 26px; margin-right: 8px; text-align: center; flex: 0 0 auto; }
.nav-user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: 0 0 auto;
}
.u-info { flex: 1; min-width: 0; }
.u-name { font-size: 13.5px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-role { font-size: 12px; color: #94a3c0; text-transform: capitalize; }
#logout-link { font-size: 18px; padding: 6px 8px !important; border-radius: 8px; }
#logout-link:hover { background: rgba(255, 255, 255, .1); }
.nav-toggle {
  display: none; background: none; border: 0; color: #fff; font-size: 24px;
  padding: 8px 10px; cursor: pointer; line-height: 1;
}
.nav-toggle:hover { background: rgba(255, 255, 255, .08); }

/* desktop: vertical sidebar */
@media (min-width: 1081px) {
  .topnav { position: fixed; left: 0; top: 0; bottom: 0; width: 230px; display: flex; flex-direction: column; }
  body.with-nav { padding-left: 230px; }
  .nav-top { padding: 20px 18px 12px; }
  .nav-links { display: flex; flex-direction: column; flex: 1; overflow-y: auto; padding: 4px 12px 16px; min-height: 0; }
  .nav-main { display: flex; flex-direction: column; gap: 2px; }
  .nav-bottom {
    display: flex; flex-direction: column; gap: 2px; margin-top: auto;
    padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .12);
  }
  .topnav a { padding: 10px 12px; border-radius: 8px; font-size: 14.5px; }
  .topnav a:hover { background: rgba(255, 255, 255, .07); }
  .topnav a.active { background: var(--brand); color: #fff; font-weight: 600; }
  .nav-user { padding: 12px 6px 0; }
}

/* mobile / tablet: top bar with hamburger drawer */
@media (max-width: 1080px) {
  .topnav { position: sticky; top: 0; }
  .nav-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px; }
  .topnav .brand { padding: 10px 4px; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: #0f1b33; flex-direction: column; align-items: stretch;
    padding: 6px 0 10px; box-shadow: 0 12px 24px rgba(0, 0, 0, .35);
    border-top: 1px solid rgba(255, 255, 255, .1);
    max-height: calc(100vh - 60px); overflow-y: auto;
  }
  .nav-links.open { display: flex; }
  .nav-main, .nav-bottom { display: flex; flex-direction: column; }
  .topnav a { padding: 13px 20px; border-left: 3px solid transparent; }
  .topnav a.active { border-left-color: var(--brand); background: rgba(255, 255, 255, .06); }
  .nav-bottom { margin-top: 6px; border-top: 1px solid rgba(255, 255, 255, .15); padding-top: 6px; }
  .nav-user { padding: 12px 20px; }
}

@media print {
  body.with-nav { padding-left: 0; }
}

.wrap { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
.wrap.narrow { max-width: 640px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(15, 27, 51, .04);
}
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* ---- forms ---- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

button, .btn {
  display: inline-block; border: 0; border-radius: 8px; padding: 10px 18px;
  font: inherit; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff;
}
button:hover, .btn:hover { background: var(--brand-dark); }
button.secondary, .btn.secondary { background: #e2e8f0; color: var(--ink); }
button.secondary:hover { background: #cbd5e1; }
button.danger { background: var(--danger); }
button.ok, .btn.ok { background: var(--ok); }
button.big { padding: 14px 24px; font-size: 17px; width: 100%; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ---- badges / alerts ---- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.baby { background: #ede9fe; color: var(--baby); }
.badge.kids { background: #dbeafe; color: var(--kids); }
.badge.jr { background: #ccfbf1; color: var(--jr); }
.badge.other { background: #fee2e2; color: var(--danger); }
.badge.in { background: #dcfce7; color: var(--ok); }
.badge.out { background: #f1f5f9; color: var(--muted); }
.badge.visitor { background: #fef3c7; color: var(--warn); }

.alert {
  border-radius: 8px; padding: 12px 14px; margin: 10px 0; font-size: 14px;
}
.alert.medical { background: #fef2f2; border: 2px solid #fca5a5; color: #7f1d1d; }
.alert.medical strong { color: var(--danger); }
.alert.info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; }
.alert.success { background: #f0fdf4; border: 1px solid #86efac; color: #14532d; }
.alert.error { background: #fef2f2; border: 1px solid #fca5a5; color: #7f1d1d; }

/* ---- stats ---- */
.stat { text-align: center; padding: 18px 8px; }
.stat .num { font-size: 40px; font-weight: 800; line-height: 1.1; }
.stat .lbl { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:hover td { background: #f8fafc; }
.table-scroll { overflow-x: auto; }

/* ---- kid selection cards (check-in) ---- */
.kid-card {
  border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  margin-bottom: 10px; cursor: pointer; display: flex; gap: 12px; align-items: flex-start;
  background: #fff; transition: border-color .1s, background .1s;
}
.kid-card.selected { border-color: var(--brand); background: #eff6ff; }
.kid-card.disabled { opacity: .55; cursor: default; }
.kid-card .check { font-size: 22px; width: 28px; text-align: center; color: #cbd5e1; }
.kid-card.selected .check { color: var(--brand); }
.kid-card h3 { margin: 0; font-size: 17px; }
.kid-card .meta { font-size: 13px; color: var(--muted); }

.svc-btn {
  border: 2px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px;
  padding: 12px 18px; font-weight: 700;
}
.svc-btn.selected { border-color: var(--brand); background: var(--brand); color: #fff; }

/* ---- simple bar charts ---- */
.bar-row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 10px; margin: 6px 0; font-size: 14px; }
.bar-row .track { background: #eef2f7; border-radius: 6px; height: 22px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 6px; background: var(--brand); min-width: 2px; }
.bar-row .val { font-weight: 700; text-align: right; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt0 { margin-top: 0; }
.center { text-align: center; }
.security-code { font-size: 34px; font-weight: 800; letter-spacing: .2em; }

/* ---- print sticker ---- */
/* On screen the sticker area is parked off-viewport: it exists only for the printer,
   so receipts/labels are never visible to the next family at the station or kiosk. */
#sticker-area { position: absolute; left: -10000px; top: 0; width: 100mm; }
@media print {
  body * { visibility: hidden; }
  #sticker-area, #sticker-area * { visibility: visible; }
  #sticker-area { position: absolute; left: 0; top: 0; width: 100%; }
  .sticker { page-break-after: always; }
}
.sticker {
  width: 89mm; height: 59mm; border: 1px dashed #cbd5e1; border-radius: 6px;
  padding: 5mm; margin: 8px auto; background: #fff; display: flex; flex-direction: column; justify-content: space-between;
  font-family: -apple-system, sans-serif;
}
.sticker .s-name { font-size: 26px; font-weight: 800; }
.sticker .s-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.sticker .s-code { font-size: 22px; font-weight: 800; letter-spacing: .15em; }
.sticker .s-alert { color: #dc2626; font-weight: 700; font-size: 13px; }

@media (max-width: 640px) {
  .row { flex-direction: column; gap: 0; }
  .stat .num { font-size: 30px; }
}
