:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-primary: #2E3A6E;
  --accent-hover: #1e2a54;
  --color-success: #10b981;
  --color-duplicate: #ef4444;
  --color-warning: #f59e0b;
  --border-color: #334155;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

/* Header & Navbar */
header.navbar {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  text-decoration: none;
  flex-shrink: 0;
}

.brand span.badge-indaba {
  background: linear-gradient(135deg, #2E3A6E, #435496);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

/* Mobile Hamburger Toggle Button (Hidden on Desktop) */
.mobile-nav-toggle {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  font-size: 1.35rem;
  cursor: pointer;
  line-height: 1;
  transition: all 0.2s ease;
}

.mobile-nav-toggle:active {
  transform: scale(0.95);
  background: var(--bg-card-hover);
}

nav.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

nav.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

nav.nav-links a:hover, nav.nav-links a.active {
  color: #fff;
  background: var(--bg-card-hover);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

main.container {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem 1.25rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  margin-bottom: 1.5rem;
}

/* Toast Banner */
.toast-banner {
  display: none;
  position: fixed;
  top: 75px;
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  max-width: 550px;
  padding: 1.15rem 1.25rem;
  border-radius: 14px;
  color: #fff;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  z-index: 1000;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from { top: 40px; opacity: 0; }
  to { top: 75px; opacity: 1; }
}

.toast-banner.success {
  background-color: var(--color-success);
  display: block;
}

.toast-banner.duplicate {
  background-color: var(--color-duplicate);
  display: block;
}

.toast-banner.warning {
  background-color: var(--color-warning);
  display: block;
}

.toast-title {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.toast-subtitle {
  font-size: 0.9rem;
  opacity: 0.95;
}

/* Form & Inputs */
.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

input[type="text"], input[type="date"], input[type="number"], select {
  width: 100%;
  padding: 0.85rem 1rem;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 48px;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="text"]:focus, input[type="date"]:focus, input[type="number"]:focus, select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(46, 58, 110, 0.4);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
  min-height: 48px;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-success {
  background: var(--color-success);
  color: #fff;
}

/* Dashboard Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.35rem 1rem;
  text-align: center;
}

.metric-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: #fff;
  margin: 0.2rem 0;
}

.metric-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.progress-bar-container {
  width: 100%;
  height: 16px;
  background: #0f172a;
  border-radius: 8px;
  overflow: hidden;
  margin: 1rem 0;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2E3A6E, #10b981);
  width: 0%;
  transition: width 0.5s ease-in-out;
}

/* Table Responsive Wrapper */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

table.table th, table.table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

table.table th {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
}

/* Scanner Video Container */
#scanner-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid var(--border-color);
  background: #000;
  min-height: 280px;
}

/* ==========================================================================
   Responsive Tablet & Smartphone Rules (Smartphones & Samsung Tabs)
   ========================================================================== */

@media (max-width: 820px) {
  header.navbar {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
  }

  .brand {
    font-size: 1rem;
  }

  .brand img {
    height: 30px !important;
  }

  .mobile-nav-toggle {
    display: flex;
  }

  nav.nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    margin-top: 0.65rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    gap: 0.5rem;
    animation: fadeInDown 0.25s ease-out;
  }

  nav.nav-links.open {
    display: flex;
  }

  nav.nav-links a {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    justify-content: flex-start;
  }

  @keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  main.container {
    padding: 1rem 0.75rem 4rem 0.75rem;
  }

  .card {
    padding: 1.15rem 1rem;
    border-radius: 14px;
    margin-bottom: 1rem;
  }

  .toast-banner {
    width: 94%;
    top: 75px;
    padding: 1rem;
  }

  .metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
  }

  .metric-value {
    font-size: 2rem;
  }

  .btn {
    width: 100%;
    min-height: 52px;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .brand span.badge-indaba {
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
  }

  .metric-value {
    font-size: 1.75rem;
  }

  #reader {
    min-height: 220px;
  }
}
