:root {
  color-scheme: light;
  --navy: #0e2a47;
  --blue: #1264a3;
  --blue-dark: #0b4d7d;
  --gold: #d7a928;
  --green: #178449;
  --red: #b42318;
  --surface: #ffffff;
  --muted: #65758b;
  --line: #dfe7ef;
  --shadow: 0 18px 55px rgba(18, 45, 72, .12);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--navy);
  background: linear-gradient(145deg, #f4f8fc 0%, #e9f1f8 100%);
}

button, input { font: inherit; }

button { cursor: pointer; }
button:disabled, input:disabled { cursor: not-allowed; opacity: .65; }

a { color: var(--blue); }

.screen-shell {
  width: min(100% - 32px, 680px);
  margin: 0 auto;
  padding: 28px 0 52px;
}

.card {
  background: var(--surface);
  border: 1px solid rgba(19, 72, 112, .08);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 5vw, 42px);
}

.brand {
  text-align: center;
  margin-bottom: 24px;
}

.brand img {
  width: 116px;
  height: 64px;
  object-fit: contain;
  display: block;
  margin: 0 auto 12px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.55rem, 5vw, 2.3rem);
  line-height: 1.12;
  letter-spacing: -.02em;
}

.brand p, .event-window, .muted {
  color: var(--muted);
}

.brand p { margin: 8px 0 0; }

.event-window {
  background: #f4f8fc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  text-align: center;
  margin: 20px 0 26px;
  font-size: .92rem;
}

.form-area { position: relative; }

label {
  display: block;
  font-weight: 700;
  margin: 18px 0 8px;
}

input[type="text"], input[type="password"], input[type="datetime-local"] {
  width: 100%;
  border: 1px solid #cbd8e5;
  border-radius: 12px;
  background: #fff;
  padding: 13px 14px;
  color: var(--navy);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(18, 100, 163, .12);
}

.search-wrapper { position: relative; }

.helper {
  color: var(--muted);
  font-size: .86rem;
  margin-top: 7px;
}

.suggestions {
  display: none;
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 35px rgba(14, 42, 71, .14);
  overflow: hidden;
  max-height: 310px;
  overflow-y: auto;
}

.suggestion-item {
  display: block;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #eef3f7;
  background: #fff;
  color: var(--navy);
}

.suggestion-item:last-child { border-bottom: 0; }
.suggestion-item:hover, .suggestion-item:focus { background: #f2f8fd; }
.suggestion-name { font-weight: 700; }
.suggestion-division { color: var(--muted); font-size: .84rem; margin-top: 3px; }

.primary-btn, .secondary-btn, .danger-btn, .link-btn {
  border: 0;
  border-radius: 12px;
  padding: 13px 16px;
  font-weight: 800;
  transition: transform .15s, filter .15s;
}

.primary-btn:hover, .secondary-btn:hover, .danger-btn:hover, .link-btn:hover { filter: brightness(.97); transform: translateY(-1px); }

.primary-btn {
  width: 100%;
  margin-top: 24px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: #fff;
}

.secondary-btn { background: #edf5fb; color: var(--blue-dark); }
.danger-btn { background: #fff0ee; color: var(--red); }
.link-btn { background: transparent; color: var(--blue); padding-inline: 0; }

.message { min-height: 25px; margin-top: 16px; text-align: center; font-weight: 650; }
.success-text { color: var(--green); }
.error-text { color: var(--red); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 20, 35, .62);
}

.modal-backdrop[hidden] { display: none; }

.modal {
  width: min(100%, 430px);
  background: #fff;
  border-radius: 20px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 25px 70px rgba(0, 0, 0, .28);
}

.modal h2 { margin: 0 0 10px; }
.modal p { color: var(--muted); line-height: 1.5; }
.countdown { color: var(--blue-dark); font-weight: 800; }

.status-panel {
  border-radius: 14px;
  padding: 14px 16px;
  margin: 18px 0;
  line-height: 1.5;
}

.status-panel.info { background: #eef7ff; border: 1px solid #bfdef5; color: #164d72; }
.status-panel.warning { background: #fff8e8; border: 1px solid #f2dc9d; color: #6a4b00; }
.status-panel.error { background: #fff1ef; border: 1px solid #f1c4bf; color: #7c2119; }

.hidden { display: none !important; }

.admin-shell {
  width: min(100% - 32px, 1180px);
  margin: 0 auto;
  padding: 28px 0 54px;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.admin-header h1 { margin: 0; font-size: clamp(1.45rem, 3vw, 2.2rem); }
.admin-header p { margin: 7px 0 0; color: var(--muted); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.login-card { width: min(100%, 440px); margin: 10vh auto 0; }
.login-card h1 { margin-top: 0; }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, .9fr) minmax(0, 1.6fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: #fff;
  border: 1px solid rgba(19, 72, 112, .08);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel h2 { margin: 0 0 15px; font-size: 1.08rem; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 17px; }
.stat-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 12px 0; }
.stat-row:first-child { padding-top: 0; }
.stat-row:last-child { border-bottom: 0; padding-bottom: 0; }
.stat-value { font-size: 1.35rem; font-weight: 850; color: var(--blue-dark); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid #e8eef3; vertical-align: top; }
th { background: #f4f8fb; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: #50657a; }
tbody tr:hover { background: #fbfdff; }
.empty-row { text-align: center; color: var(--muted); padding: 26px; }

.qr-shell {
  width: min(100% - 32px, 790px);
  margin: 0 auto;
  padding: 28px 0 50px;
  text-align: center;
}

.qr-card { background: #fff; padding: clamp(22px, 5vw, 44px); border-radius: 22px; box-shadow: var(--shadow); }
.qr-card h1 { margin-top: 0; }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 24px; margin-top: 20px; }
.qr-code-card { min-width: 0; padding: 18px; border: 1px solid #d9e3ee; border-radius: 16px; background: #f8fbff; }
.qr-code-card h2 { margin: 0 0 12px; font-size: 1.15rem; }
.qr-image { display: block; width: min(100%, 560px); margin: 0 auto 14px; border-radius: 14px; }
.qr-url { overflow-wrap: anywhere; color: var(--muted); font-size: .9rem; }
.qr-meta { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px 20px; color: var(--muted); font-size: .9rem; }
.qr-code-card .qr-meta { justify-content: flex-start; gap: 6px 12px; }

.invalid-card { width: min(100% - 32px, 560px); margin: 12vh auto 0; text-align: center; }
.invalid-card h1 { margin-top: 0; }

@media (max-width: 820px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .admin-header { flex-direction: column; }
  .admin-actions { justify-content: flex-start; }
}

@media print {
  body { background: #fff; }
  .no-print, .settings-panel, .admin-actions, .admin-header .muted { display: none !important; }
  .admin-shell { width: 100%; padding: 0; }
  .panel { box-shadow: none; border: 0; padding: 0; }
  .dashboard-grid { display: block; }
  .attendance-panel { margin-top: 0; }
  table { min-width: 0; }
}
