:root {
  --navy-950: #091a2b;
  --navy-900: #0f2942;
  --navy-800: #163a5c;
  --navy-700: #1e4d78;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --emerald-700: #047857;
  --emerald-600: #059669;
  --emerald-50: #ecfdf5;
  --emerald-200: #a7f3d0;
  --amber-700: #b45309;
  --amber-600: #d97706;
  --amber-50: #fffbeb;
  --amber-200: #fde68a;
  --red-700: #b91c1c;
  --red-600: #dc2626;
  --red-50: #fef2f2;
  --red-200: #fecaca;
  --slate-900: #0f172a;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.1);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--slate-900);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* Top Navigation Bar */
.topbar {
  background: var(--navy-900);
  color: #fff;
  padding: 0 20px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 500;
  box-shadow: 0 2px 10px rgba(9, 26, 43, 0.2);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.topbar-title {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-sub {
  font-size: 12px;
  color: #93c5fd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Containers */
.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.container-sm {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 14px 48px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

.card + .card {
  margin-top: 16px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--slate-900);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-desc {
  font-size: 13.5px;
  color: var(--slate-500);
  margin: 4px 0 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  line-height: 1.2;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--navy-900);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--navy-800);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-emerald {
  background: var(--emerald-600);
  color: #fff;
}
.btn-emerald:hover:not(:disabled) {
  background: var(--emerald-700);
}

.btn-danger {
  background: var(--red-600);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background: var(--red-700);
}

.btn-outline {
  background: #fff;
  color: var(--slate-700);
  border-color: var(--slate-300);
}
.btn-outline:hover:not(:disabled) {
  background: var(--slate-50);
  border-color: var(--slate-400);
}

.btn-ghost-dark {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
}
.btn-ghost-dark:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.22);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 13px 22px;
  font-size: 15.5px;
  border-radius: 10px;
}

.btn-block {
  width: 100%;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green {
  background: var(--emerald-50);
  color: var(--emerald-700);
  border: 1px solid var(--emerald-200);
}
.badge-amber {
  background: var(--amber-50);
  color: var(--amber-700);
  border: 1px solid var(--amber-200);
}
.badge-red {
  background: var(--red-50);
  color: var(--red-700);
  border: 1px solid var(--red-200);
}
.badge-slate {
  background: var(--slate-100);
  color: var(--slate-600);
  border: 1px solid var(--slate-200);
}
.badge-blue {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald-600);
  display: inline-block;
  animation: pulseDot 1.6s infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.45; }
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
}

.form-hint {
  font-size: 12px;
  color: var(--slate-500);
  margin-top: 4px;
}

.input, .select {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--slate-300);
  border-radius: var(--radius-sm);
  font-size: 16px; /* Prevents iOS auto-zoom */
  font-family: inherit;
  color: var(--slate-900);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-sm {
  padding: 8px 10px;
  font-size: 13.5px;
}

.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .topbar-sub { display: none; }
}

/* Alerts / Banners */
.alert {
  padding: 13px 15px;
  border-radius: 10px;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
  line-height: 1.45;
}

.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert-success { background: var(--emerald-50); border-color: var(--emerald-200); color: #065f46; }
.alert-warn { background: var(--amber-50); border-color: var(--amber-200); color: #92400e; }
.alert-danger { background: var(--red-50); border-color: var(--red-200); color: #991b1b; }

/* Admin Tabs */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1.5px solid var(--slate-200);
  margin-bottom: 22px;
  overflow-x: auto;
  padding-bottom: 0;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2.5px solid transparent;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--slate-500);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  margin-bottom: -1.5px;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--slate-900);
}

.tab-btn.active {
  color: var(--navy-900);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* KPI Stat Cards */
.kpi-card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--navy-900);
  margin: 6px 0 2px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 12px;
  color: var(--slate-500);
}

/* Session Cards */
.session-card {
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 16px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.session-card.is-active {
  border-color: var(--emerald-600);
  background: linear-gradient(180deg, #f0fdf9 0%, #ffffff 42%);
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.12);
}

.session-pin-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--navy-900);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.session-pin-code {
  font-family: ui-monospace, monospace;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #fde047;
}

/* Map Area */
.map-layout {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 18px;
  align-items: start;
}

@media (max-width: 980px) {
  .map-layout { grid-template-columns: 1fr; }
}

#hallMap {
  width: 100%;
  height: 470px;
  border-radius: var(--radius);
  border: 1.5px solid var(--slate-300);
  z-index: 1;
  background: #e2e8f0;
}

.my-loc-wrap {
  position: relative;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.my-loc-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.35);
  animation: myLocPulse 1.8s ease-out infinite;
}

.my-loc-core {
  position: relative;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2563eb;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.55);
}

@keyframes myLocPulse {
  0% { transform: scale(0.75); opacity: 0.9; }
  100% { transform: scale(2.1); opacity: 0; }
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}

.corner-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  margin-bottom: 8px;
}

.corner-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--navy-900);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Signature Canvas */
.sig-wrapper {
  border: 2px dashed var(--slate-300);
  border-radius: var(--radius);
  background: #fff;
  position: relative;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.sig-wrapper.has-ink {
  border-style: solid;
  border-color: var(--navy-700);
}

.sig-canvas {
  display: block;
  width: 100%;
  height: 195px;
  cursor: crosshair;
  touch-action: none;
}

.sig-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: var(--slate-400);
  font-size: 14px;
  gap: 4px;
}

.sig-guide-line {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 42px;
  border-bottom: 1px dashed var(--slate-300);
  pointer-events: none;
}

/* PIN Digit Inputs */
.pin-input-large {
  font-family: ui-monospace, monospace;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.4em;
  text-align: center;
  padding: 12px;
  color: var(--navy-900);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th {
  text-align: left;
  padding: 11px 12px;
  background: var(--slate-50);
  color: var(--slate-600);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1.5px solid var(--slate-200);
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--slate-100);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #f8fafc;
}

.sig-thumb {
  height: 40px;
  max-width: 120px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  padding: 2px 4px;
}

/* Toggle Switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  margin-bottom: 10px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: var(--slate-300);
  border-radius: 999px;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.switch input:checked + .slider {
  background: var(--emerald-600);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.toast {
  background: var(--navy-900);
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease;
}

.toast.success { background: var(--emerald-700); }
.toast.error { background: var(--red-700); }
.toast.warn { background: var(--amber-700); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}

/* Landing Hero */
.hero-banner {
  background: linear-gradient(135deg, var(--navy-950) 0%, var(--navy-800) 60%, #1d4ed8 100%);
  color: #fff;
  border-radius: 20px;
  padding: 36px 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.hero-banner h1 {
  margin: 10px 0 8px;
  font-size: 28px;
  line-height: 1.2;
}

.hero-banner p {
  margin: 0;
  color: #cbd5e1;
  font-size: 15px;
  max-width: 660px;
}

/* Mobile Signing Header */
.sign-hero {
  background: linear-gradient(135deg, var(--navy-950), var(--navy-800));
  color: #fff;
  padding: 20px 18px 22px;
  border-radius: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--navy-900);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  flex-shrink: 0;
}

.step-badge.done {
  background: var(--emerald-600);
}

/* QR Display Card */
.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1.5px solid var(--slate-200);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
}

.qr-box img {
  max-width: 230px;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

/* Leaflet custom numbered marker */
.corner-map-pin {
  background: #0f2942;
  color: #fff;
  border: 2.5px solid #fff;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}

/* Projector Screen Mode */
.projector-body {
  background: radial-gradient(circle at top left, #173a5e 0%, #071422 65%);
  color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px 36px;
}

/* Print Styles */
@media print {
  .no-print { display: none !important; }
  body { background: #fff !important; }
}
