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

:root {
  --cps-primary: #D71920;
  --cps-secondary: #0B2D4D;
  --cps-accent: #B8BDC3;
  --cps-light: #f5f5f5;
  --cps-dark: #333;
  --success-color: #28a745;
  --error-color: #dc3545;
  --warning-color: #ffc107;
  --present-color: #28a745;
  --absent-color: #dc3545;
  --border-radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, var(--cps-primary) 0%, var(--cps-secondary) 100%);
  color: var(--cps-dark);
  min-height: 100vh;
}

.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Navbar */
.navbar {
  background: var(--cps-primary);
  color: white;
  padding: 20px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 20px;
}

.navbar-logo {
  height: 60px;
  width: auto;
  display: inline-block;
}

.navbar-text h1 {
  font-size: 28px;
  font-weight: bold;
  margin: 0;
  letter-spacing: 0;
}

.navbar-text p {
  font-size: 14px;
  opacity: 0.9;
  margin: 5px 0 0 0;
}

.navbar-menu {
  display: flex;
  gap: 15px;
}

.nav-btn {
  background: var(--cps-secondary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.nav-btn:hover {
  background: var(--cps-accent);
  color: var(--cps-primary);
  transform: translateY(-2px);
}

.nav-btn.logout-btn {
  background: var(--error-color);
}

.nav-btn.logout-btn:hover {
  background: #c82333;
}

/* Screens */
.screen {
  flex: 1;
  padding: 40px 20px;
  animation: fadeIn 0.3s ease;
}

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

/* Login */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.login-card {
  background: white;
  padding: 40px;
  border-radius: var(--border-radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 25px;
  padding-top: 10px;
}

.logo-img {
  width: min(100%, 300px);
  max-width: 300px;
  height: auto;
  display: inline-block;
}

.login-card h2 {
  margin-bottom: 30px;
  color: var(--cps-primary);
  text-align: center;
  font-size: 24px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.login-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #ddd;
  color: #666;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.app-footer {
  margin-top: auto;
  padding: 18px 24px;
  background: rgba(255, 255, 255, 0.96);
  border-top: 3px solid var(--cps-accent);
  color: var(--cps-primary);
  font-size: 13px;
  text-align: center;
}

.login-card input {
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: var(--border-radius);
  font-size: 14px;
  transition: border-color 0.3s ease;
}

.login-card input:focus {
  outline: none;
  border-color: var(--cps-secondary);
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.btn-primary {
  background: var(--cps-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--cps-secondary);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 51, 102, 0.3);
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
}

/* Admin Container */
.admin-container {
  max-width: 1200px;
  margin: 0 auto;
}

.super-admin-header {
  color: white;
  margin-bottom: 30px;
}

.super-admin-header h2 {
  font-size: 28px;
  margin-bottom: 8px;
}

.super-admin-header p {
  opacity: 0.92;
  line-height: 1.45;
}

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

.branding-grid label {
  display: grid;
  gap: 8px;
  color: #555;
  font-size: 13px;
  font-weight: 700;
}

.branding-grid input[type="color"] {
  width: 100%;
  height: 44px;
  padding: 4px;
}

.districts-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.district-card {
  border: 2px solid #ddd;
  border-radius: var(--border-radius);
  padding: 18px;
  background: #fafafa;
}

.district-card.inactive {
  opacity: 0.72;
  border-style: dashed;
}

.district-card h4 {
  color: var(--cps-primary);
  font-size: 18px;
  margin-bottom: 4px;
}

.district-card p {
  color: #666;
  font-size: 13px;
  line-height: 1.4;
  margin-top: 8px;
}

.district-brand-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.district-brand-line img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 4px;
}

.district-swatches {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.district-swatches span {
  width: 34px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.workspace-status {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.workspace-status.active {
  background: rgba(40, 167, 69, 0.12);
  color: #1f7a35;
}

.workspace-status.inactive {
  background: rgba(108, 117, 125, 0.16);
  color: #495057;
}

.district-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.profile-details {
  display: grid;
  gap: 10px;
}

.profile-details p {
  color: #555;
  font-size: 14px;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.guide-card {
  margin-bottom: 0;
}

.guide-card p,
.guide-card li {
  color: #555;
  font-size: 14px;
  line-height: 1.5;
}

.guide-card ol {
  padding-left: 20px;
}

.guide-card li + li,
.guide-card p + p {
  margin-top: 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.48);
}

.modal-card {
  width: min(100%, 460px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-header h3 {
  color: var(--cps-primary);
  margin: 0;
}

.modal-close {
  width: 34px;
  height: 34px;
  border: 1px solid #ddd;
  border-radius: 999px;
  background: white;
  color: #555;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.modal-close:hover {
  border-color: var(--cps-primary);
  color: var(--cps-primary);
}

.modal-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-card input {
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: var(--border-radius);
  font-size: 14px;
}

.workspace-action {
  border: 1px solid var(--cps-primary);
  border-radius: 999px;
  background: white;
  color: var(--cps-primary);
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.workspace-action:hover {
  background: var(--cps-primary);
  color: white;
}

.workspace-action.danger {
  border-color: var(--error-color);
  color: var(--error-color);
}

.workspace-action.danger:hover {
  background: var(--error-color);
  color: white;
}

.admin-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.tab-btn {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.tab-btn.active {
  background: white;
  color: var(--cps-primary);
}

.tab-content {
  animation: fadeIn 0.3s ease;
}

.tab-content h2 {
  color: white;
  margin-bottom: 30px;
  font-size: 28px;
}

/* Cards */
.card {
  background: white;
  padding: 30px;
  border-radius: var(--border-radius);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.card h3 {
  color: var(--cps-primary);
  margin-bottom: 20px;
  font-size: 20px;
}

.card form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.card input,
.card select {
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: var(--border-radius);
  font-size: 14px;
}

.card input:focus,
.card select:focus {
  outline: none;
  border-color: var(--cps-secondary);
}

/* Messages */
.error-message {
  color: var(--error-color);
  font-size: 14px;
  margin-top: 10px;
}

.success-message {
  color: var(--success-color);
  font-size: 14px;
  margin-top: 10px;
}

.info-text {
  color: #666;
  font-size: 14px;
  margin-top: 15px;
}

/* Events List */
.events-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.event-card {
  background: #f9f9f9;
  border: 2px solid #ddd;
  border-radius: var(--border-radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.event-card:hover {
  border-color: var(--cps-secondary);
  box-shadow: 0 5px 15px rgba(0, 51, 102, 0.2);
  transform: translateY(-2px);
}

.event-card h4 {
  color: var(--cps-primary);
  margin-bottom: 10px;
  font-size: 18px;
}

.event-card p {
  font-size: 14px;
  color: #666;
  margin: 8px 0;
}

.event-card .badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 10px;
}

.event-card .badge.active {
  background: var(--success-color);
  color: white;
}

.event-card .badge.closed {
  background: #6c757d;
  color: white;
}

/* Scanner Container */
.scanner-container {
  max-width: 600px;
  margin: 0 auto;
}

.phase {
  animation: fadeIn 0.3s ease;
}

.scanner-card {
  background: white;
  padding: 40px;
  border-radius: var(--border-radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  margin-bottom: 20px;
}

.scanner-card h2 {
  color: var(--cps-primary);
  margin-bottom: 30px;
  text-align: center;
  font-size: 28px;
}

.scanner-card h3 {
  color: var(--cps-primary);
  margin-bottom: 20px;
  text-align: center;
  font-size: 22px;
}

.scanner-card input {
  width: 100%;
  padding: 16px;
  border: 2px solid #ddd;
  border-radius: var(--border-radius);
  font-size: 18px;
  text-align: center;
  transition: all 0.3s ease;
}

.scanner-card input:focus {
  outline: none;
  border-color: var(--cps-secondary);
  box-shadow: 0 0 0 3px rgba(0, 102, 153, 0.1);
}

.event-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  padding: 20px 30px;
  border-radius: var(--border-radius);
  margin-bottom: 30px;
}

.event-header h2 {
  color: var(--cps-primary);
  margin: 0;
  font-size: 24px;
}

/* Results */
.result-container {
  margin-top: 30px;
  min-height: 200px;
}

.result {
  background: white;
  border-radius: var(--border-radius);
  padding: 40px;
  text-align: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  animation: slideIn 0.3s ease;
}

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

.result-status {
  font-size: 60px;
  font-weight: bold;
  margin-bottom: 20px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-status.success {
  color: var(--success-color);
}

.result-status.error {
  color: var(--error-color);
}

.result-message {
  font-size: 16px;
  color: #666;
  margin-bottom: 15px;
}

.result-name {
  font-size: 28px;
  font-weight: bold;
  color: var(--cps-primary);
  margin: 20px 0;
}

.scan-stats {
  background: white;
  padding: 20px;
  border-radius: var(--border-radius);
  text-align: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.scan-stats p {
  font-size: 18px;
  color: var(--cps-primary);
  font-weight: 600;
}

.scan-stats span {
  font-size: 28px;
  color: var(--cps-accent);
  font-weight: bold;
}

/* Attendance Table */
.attendance-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
}

.attendance-table thead {
  background: var(--cps-primary);
  color: white;
}

.attendance-table th,
.attendance-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #ddd;
  font-size: 14px;
}

.attendance-table tbody tr:hover {
  background: #f9f9f9;
}

.attendance-table tbody tr:nth-child(even) {
  background: #f5f5f5;
}

/* Report Table */
.report-table-wrapper {
  overflow-x: auto;
  margin: 20px 0;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
}

.report-table thead {
  background: var(--cps-primary);
  color: white;
}

.report-table th,
.report-table td {
  padding: 12px;
  text-align: center;
  border-bottom: 1px solid #ddd;
  font-size: 14px;
}

.report-table th:first-child,
.report-table td:first-child {
  text-align: left;
  padding-left: 16px;
}

.report-table th.status-column {
  width: 120px;
  font-weight: 600;
}

.report-table tbody tr:hover {
  background: #f9f9f9;
}

.report-table tbody tr:nth-child(even) {
  background: #f5f5f5;
}

.status-present {
  color: var(--present-color);
  font-size: 20px;
  font-weight: bold;
}

.status-absent {
  color: var(--absent-color);
  font-size: 20px;
  font-weight: bold;
}

.status-empty {
  color: #ccc;
  font-size: 18px;
}

/* Print Report Styles */
.print-page {
  padding: 20px 25px;
  background: white;
  color: var(--cps-dark);
  font-family: 'Times New Roman', Times, serif;
  line-height: 1.3;
}

.print-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--cps-primary);
  text-align: center;
}

.print-logo {
  height: 50px;
  width: auto;
  margin-right: 15px;
}

.print-title h1 {
  font-size: 24px;
  color: var(--cps-primary);
  margin: 0;
  font-weight: bold;
}

.print-title p {
  font-size: 14px;
  color: var(--cps-secondary);
  margin: 2px 0 0 0;
}

.print-info {
  background: #f5f5f5;
  padding: 10px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 11px;
  border-bottom: 0.5px solid #ddd;
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-weight: bold;
  color: var(--cps-primary);
  width: 80px;
}

.info-value {
  flex: 1;
  text-align: right;
  color: var(--cps-dark);
}

.print-stats {
  margin-bottom: 12px;
}

.print-stats h2 {
  color: var(--cps-primary);
  font-size: 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--cps-accent);
  padding-bottom: 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat-box {
  background: #f9f9f9;
  padding: 8px;
  border-left: 2px solid var(--cps-primary);
  text-align: center;
  page-break-inside: avoid;
}

.stat-label {
  font-size: 9px;
  color: #666;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 18px;
  font-weight: bold;
  color: var(--cps-primary);
}

.stat-value.present {
  color: var(--present-color);
}

.stat-value.absent {
  color: var(--absent-color);
}

.print-table-section {
  margin-top: 12px;
}

.print-table-section h2 {
  color: var(--cps-primary);
  font-size: 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--cps-accent);
  padding-bottom: 4px;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}

.print-table thead {
  background: var(--cps-primary);
  color: white;
}

.print-table th,
.print-table td {
  padding: 4px 6px;
  text-align: left;
  border-bottom: 0.5px solid #ddd;
}

.print-table th {
  font-weight: bold;
  text-transform: uppercase;
  font-size: 9px;
}

.print-table tbody tr:nth-child(even) {
  background: #f9f9f9;
}

.print-table tbody tr {
  page-break-inside: avoid;
}

.print-footer {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 0.5px solid #ddd;
  text-align: center;
  font-size: 9px;
  color: #999;
}

/* Accounts Table */
.accounts-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
}

.accounts-table thead {
  background: var(--cps-primary);
  color: white;
}

.accounts-table th,
.accounts-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #ddd;
  font-size: 14px;
}

.accounts-table th {
  font-weight: bold;
  text-transform: uppercase;
  font-size: 12px;
}

.accounts-table tbody tr:hover {
  background: #f9f9f9;
}

.accounts-table tbody tr:nth-child(even) {
  background: #f5f5f5;
}

/* Database Table */
.database-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
}

.upload-mode-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.upload-mode-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border: 2px solid #ddd;
  border-radius: var(--border-radius);
  background: #fafafa;
  cursor: pointer;
}

.upload-mode-option:has(input:checked) {
  border-color: var(--cps-primary);
  background: rgba(107, 44, 44, 0.06);
}

.upload-mode-option input {
  width: auto;
  margin-top: 3px;
}

.upload-mode-option span,
.upload-mode-option small {
  display: block;
}

.upload-mode-option small {
  margin-top: 4px;
  color: #666;
  line-height: 1.35;
}

.database-table thead {
  background: var(--cps-primary);
  color: white;
}

.database-table th,
.database-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #ddd;
  font-size: 13px;
}

.database-table th {
  font-weight: bold;
  text-transform: uppercase;
  font-size: 11px;
}

.database-table tbody tr:hover {
  background: #f9f9f9;
}

.database-table tbody tr:nth-child(even) {
  background: #f5f5f5;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.action-buttons button {
  padding: 6px 12px;
  font-size: 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: white;
  font-weight: 500;
}

.edit-btn {
  background: var(--cps-primary);
}

.edit-btn:hover {
  background: var(--cps-secondary);
}

.delete-btn {
  background: #dc3545;
}

.delete-btn:hover {
  background: #c82333;
}

/* Print Media Query */
@media print {
  body {
    background: white;
    margin: 0;
    padding: 0;
  }

  .container,
  .navbar,
  .screen {
    display: none !important;
  }

  #printReportTemplate {
    display: block !important;
  }

  .print-page {
    padding: 20px;
    page-break-after: always;
  }

  .print-page:last-child {
    page-break-after: auto;
  }

  .stat-box,
  .print-table,
  .print-stats {
    page-break-inside: avoid;
  }

  a {
    text-decoration: none;
  }

  button,
  input,
  select {
    display: none !important;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    gap: 15px;
    text-align: center;
    padding: 15px;
  }

  .navbar-menu {
    width: 100%;
    flex-direction: column;
  }

  .nav-btn {
    width: 100%;
  }

  .screen {
    padding: 20px 15px;
  }

  .scanner-card {
    padding: 20px;
  }

  .login-card {
    padding: 25px;
  }

  .admin-tabs {
    flex-direction: column;
  }

  .events-list {
    grid-template-columns: 1fr;
  }

  .branding-grid,
  .districts-list {
    grid-template-columns: 1fr;
  }

  .attendance-table {
    font-size: 12px;
  }

  .attendance-table th,
  .attendance-table td {
    padding: 8px;
  }
}

@media (max-width: 480px) {
  .navbar-brand h1 {
    font-size: 20px;
  }

  .result-status {
    font-size: 48px;
    min-height: 60px;
  }

  .result-name {
    font-size: 22px;
  }

  .scanner-card input {
    font-size: 16px;
  }
}
