:root {
  --navy: #13215f;
  --navy-dark: #0c1640;
  --navy-soft: #e8ebf5;
  --gray: #9e9e9e;
  --gray-light: #e4e4e4;
  --text: #1b1f2e;
  --muted: #6b6f7b;
  --bg: #f5f6f9;
  --white: #ffffff;
  --green: #138a3e;
  --red: #c81e1e;
  --amber: #b26b00;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, select { font: inherit; }

/* header */
.top {
  display: flex; align-items: center; gap: 24px;
  background: var(--white); padding: 10px 28px;
  border-bottom: 4px solid var(--navy);
}
.top img { height: 84px; margin: -6px 0; }
.top .app-name {
  color: var(--gray); font-weight: 600; letter-spacing: .18em; text-transform: uppercase;
  font-size: 14px; border-left: 2px solid var(--gray-light); padding-left: 20px;
}
.top nav { margin-left: auto; display: flex; gap: 6px; }
.top nav a {
  color: var(--navy); text-decoration: none; font-weight: 600; padding: 10px 16px;
  border-radius: 8px;
}
.top nav a:hover { background: var(--navy-soft); }
.top nav a.on { background: var(--navy); color: var(--white); }

main { max-width: 1100px; margin: 0 auto; padding: 28px; }
h1 { color: var(--navy); margin: 0 0 18px; font-size: 26px; }
h2 { color: var(--navy); font-size: 19px; margin: 0 0 12px; }
.muted { color: var(--muted); }

.card {
  background: var(--white); border: 1px solid var(--gray-light); border-radius: var(--radius);
  padding: 22px; margin-bottom: 20px;
}

/* buttons & inputs */
.btn {
  background: var(--navy); color: var(--white); border: 0; border-radius: 8px;
  padding: 10px 18px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--navy-dark); }
.btn.ghost { background: var(--white); color: var(--navy); border: 1.5px solid var(--navy); }
.btn.ghost:hover { background: var(--navy-soft); }
.btn.danger { background: var(--white); color: var(--red); border: 1.5px solid var(--red); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
label { display: block; font-weight: 600; margin: 14px 0 6px; color: var(--navy); }
input[type=text], input[type=password], select {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--gray-light); border-radius: 8px;
  background: var(--white);
}
input:focus { outline: none; border-color: var(--navy); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.error { color: var(--red); font-weight: 600; margin-top: 10px; min-height: 1.2em; }
.banner {
  background: #fff4dc; border: 1px solid #f0c66a; color: #6b4600; border-radius: 10px;
  padding: 12px 16px; margin-bottom: 20px;
}

/* avatar */
.avatar {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex: none;
  background: var(--navy-soft); color: var(--navy); display: grid; place-items: center;
  font-weight: 700; font-size: 20px; border: 2px solid var(--gray-light);
}

/* badges */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px;
  font-weight: 700; letter-spacing: .03em;
}
.b-ENTRY { background: #e1f4e8; color: var(--green); }
.b-EXIT { background: var(--navy-soft); color: var(--navy); }
.b-DENIED { background: #fde4e4; color: var(--red); }
.b-MISSED_EXIT, .b-MANUAL_EXIT { background: #fff1d6; color: var(--amber); }
.b-PHONE_CHANGE { background: #eee; color: #444; }
.b-in { background: #e1f4e8; color: var(--green); }
.b-out { background: #eee; color: var(--muted); }
.b-off { background: #fde4e4; color: var(--red); }

/* modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(12, 22, 64, .55); display: none;
  align-items: center; justify-content: center; z-index: 50;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius); padding: 26px; width: min(460px, 92vw);
  border-top: 6px solid var(--navy); max-height: 92vh; overflow: auto;
}

table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 13px; text-transform: uppercase;
     letter-spacing: .06em; padding: 8px 10px; border-bottom: 2px solid var(--gray-light); }
td { padding: 10px; border-bottom: 1px solid var(--gray-light); vertical-align: middle; }
tr.denied td { background: #fff6f6; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 14px; }

@media print {
  .top nav, .no-print { display: none !important; }
  body { background: white; }
  .card { border: 1px solid #bbb; break-inside: avoid; }
}

/* logged-in person in the header */
.who-am-i { color: var(--navy); font-weight: 600; padding: 10px 6px 10px 16px; border-left: 2px solid var(--gray-light); margin-left: 6px; white-space: nowrap; }
.who-am-i span { color: var(--muted); font-weight: 500; font-size: 13px; }
.table-wrap { overflow-x: auto; }

/* phones and small screens */
@media (max-width: 800px) {
  .top { flex-wrap: wrap; gap: 10px 16px; padding: 10px 14px; }
  .top img { height: 56px; margin: 0; }
  .top .app-name { padding-left: 14px; }
  .top nav { margin-left: 0; width: 100%; flex-wrap: wrap; gap: 4px; }
  .top nav a { padding: 6px 10px; font-size: 15px; }
  .who-am-i { padding: 6px 10px; font-size: 15px; }
  .who-am-i { border-left: 0; padding-left: 10px; margin-left: auto; }
  main { padding: 16px 14px; }
  .card { padding: 16px; }
}
