html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
  display: flex;
  flex-direction: column;
  margin: 0;
  color: #333;
}

/* Corporate Color Scheme */
:root {
  --navy-primary: #001f3f;
  --navy-dark: #001429;
  --navy-light: #003366;
  --gray-primary: #6c757d;
  --gray-light: #e9ecef;
  --gray-dark: #495057;
  --white: #ffffff;
  --accent-blue: #0066cc;

  /* ===== Design tokens (Phase 5 foundation) ===== */
  /* Spacing scale — 4/8px rhythm. */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-8: 48px;

  /* Type scale — public base is 16px on >=768px (14px below). */
  --font-size-sm: 0.875rem; --font-size-base: 1rem; --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;  --font-size-2xl: 1.5rem; --font-size-3xl: 2rem;

  /* Radius + elevation. */
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,31,63,0.06);
  --shadow-md: 0 4px 12px rgba(0,31,63,0.10);
  --shadow-lg: 0 12px 32px rgba(0,31,63,0.16);
}

html, body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #333;
  height: 100%;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
  transition: color 0.3s ease;
}

a:hover {
  color: var(--navy-primary);
}

.btn-link {
  color: var(--accent-blue);
}

.btn-primary {
  color: var(--white);
  background-color: var(--navy-primary);
  border-color: var(--navy-primary);
  padding: 12px 30px;
  font-size: 1rem;
  border-radius: 5px;
  transition: all 0.3s ease;
}

.btn-primary:hover {
  background-color: var(--navy-light);
  border-color: var(--navy-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 31, 63, 0.2);
}

.btn-outline-primary {
  color: var(--navy-primary);
  border: 2px solid var(--navy-primary);
  background: transparent;
  padding: 12px 30px;
  font-size: 1rem;
  border-radius: 5px;
  transition: all 0.3s ease;
}

.btn-outline-primary:hover {
  background: var(--navy-primary);
  color: white;
  transform: translateY(-2px);
}

.hero-section {
  background: linear-gradient(135deg, var(--navy-primary) 0%, var(--navy-light) 100%);
  color: white;
  padding: 4rem 1.5rem;
  text-align: center;
  margin-bottom: 2.5rem;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: white;
}

.hero-subtitle {
  font-size: 1.2rem;
  opacity: 0.95;
  margin: 0 auto 1.5rem;
  max-width: 900px;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-outline-light {
  color: white;
  border: 2px solid white;
  background: transparent;
  padding: 12px 30px;
  font-size: 1rem;
  border-radius: 5px;
  transition: all 0.3s ease;
}

.btn-outline-light:hover {
  background: white;
  color: var(--navy-primary);
  transform: translateY(-2px);
}

.content-section {
  padding: 2rem 1rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
}

.section-title {
  color: var(--navy-primary);
  margin-bottom: 1.5rem;
  font-weight: 700;
}

.card.payment-card {
  border: 1px solid var(--gray-light);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  border-radius: 10px;
}

.card.payment-card .card-header {
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy-dark) 100%);
}

.card.payment-card h4 {
  margin: 0;
}

.detail-list dt {
  color: var(--gray-dark);
}

.detail-list dd {
  color: #111;
}

/* Layout bar styling */
.topbar {
  background: var(--navy-primary);
  border-bottom: 1px solid var(--navy-dark);
  margin-bottom: 1.5rem;
}

.topbar-container {
  width: 100%;
  margin: 0;
  padding: 0.75rem 1.5rem;
  display: flex;
/*  align-items: center;*/
  justify-content: space-between;
  gap: 1rem;
  color: white;
}

.topbar-left,
.topbar-center,
.topbar-right {
  flex: 1;
  display: flex;
  /*align-items: center;*/
}

.topbar-left { justify-content: flex-start; }
.topbar-center { justify-content: center; }
.topbar-right { justify-content: flex-end; }

.logo-img {
  height: 40px;
  width: auto;
  display: block;
}

.topbar-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
}

.footer-bar {
  border-top: 1px solid var(--navy-dark);
  background: var(--navy-primary);
  padding: 1rem 0;
  margin-top: auto;
  color: white;
}

.footer-container {
  width: 100%;
  margin: 0;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: white;
}

.footer-left { flex: 1; text-align: left; }
.footer-center { flex: 1; text-align: center; }
.footer-right { flex: 1; text-align: right; }

.footer-container a {
  color: white;
}

.footer-container a:hover {
  color: #dfe8f5;
}

@media (max-width: 768px) {
  .hero-title {
    font-size: 2rem;
  }
  .hero-subtitle {
    font-size: 1rem;
  }
  .btn-primary, .btn-outline-primary {
    width: 100%;
  }
  .topbar-container,
  .footer-container {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .topbar-title {
    font-size: 1.1rem;
  }
}

/* Match card headers to the primary/navy color */
.card-header.bg-primary {
  background-color: var(--navy-primary) !important;
  border-color: var(--navy-primary) !important;
}

/* ===== Pagination Styles ===== */
.pagination {
  margin-bottom: 0;
}

.pagination .page-link {
  color: var(--navy-primary);
  border-color: #e2e8f0;
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
}

.pagination .page-item.active .page-link {
  background-color: var(--navy-primary);
  border-color: var(--navy-primary);
}

.pagination .page-item.disabled .page-link {
  color: #adb5bd;
  background-color: #f8f9fa;
}

.pagination .page-link:hover {
  background-color: #e2e8f0;
  color: var(--navy-primary);
}

/* ===== Badge Styles ===== */
/* Custom badge colors compatible with Bootstrap 5 .badge class */
.badge-success, .badge.bg-success { background-color: #48bb78 !important; color: #fff !important; }
.badge-warning, .badge.bg-warning { background-color: #ed8936 !important; color: #fff !important; }
.badge-danger, .badge.bg-danger { background-color: #f56565 !important; color: #fff !important; }
.badge-info, .badge.bg-info { background-color: #4299e1 !important; color: #fff !important; }
.badge-primary, .badge.bg-primary { background-color: var(--navy-primary) !important; color: #fff !important; }
.badge-secondary, .badge.bg-secondary { background-color: #718096 !important; color: #fff !important; }
.badge-light, .badge.bg-light { background-color: #e2e8f0 !important; color: #4a5568 !important; }

/* ===== Copyable Elements ===== */
.copyable {
  cursor: pointer;
  transition: background-color 0.2s;
  padding: 2px 4px;
  border-radius: 3px;
}

.copyable:hover {
  background-color: #e2e8f0;
}

.copyable.copied {
  background-color: #c6f6d5;
}

.copyable .copy-icon {
  opacity: 0.3;
  margin-left: 4px;
  font-size: 0.75rem;
}

.copyable:hover .copy-icon {
  opacity: 1;
}

/* ===== Card Footer ===== */
.card-footer {
  background-color: #f8f9fa;
  border-top: 1px solid #e2e8f0;
  padding: 0.75rem 1rem;
}

/* ===== Filter Card ===== */
.filter-card {
  border: 1px solid #e2e8f0;
}

.filter-header {
  background-color: #f8f9fa;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1rem;
}

.filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 0.25rem;
  display: block;
}

.filter-input {
  font-size: 0.875rem;
}

.filter-btn {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}

/* ===== Accessibility & UI/UX Enhancements ===== */

/* Skip Navigation Link for keyboard users */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--navy-primary);
  color: var(--white);
  padding: 8px 16px;
  z-index: 9999;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 4px 0;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--accent-blue);
  outline-offset: 2px;
}

/* Enhanced Focus States - WCAG 2.1 Level AA compliant */
*:focus-visible {
  outline: 3px solid var(--accent-blue);
  outline-offset: 2px;
}

.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--accent-blue);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.25);
}

/* Screen Reader Only - Visually hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Improved Form Accessibility */
.form-group label,
.form-label {
  font-weight: 600;
  color: var(--gray-dark);
  margin-bottom: 0.375rem;
}

.form-control:invalid:not(:placeholder-shown),
.form-control.is-invalid {
  border-color: #dc3545;
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25);
}

.form-control:valid:not(:placeholder-shown),
.form-control.is-valid {
  border-color: #28a745;
}

.form-text,
.help-text {
  font-size: 0.875rem;
  color: var(--gray-primary);
  margin-top: 0.25rem;
}

/* Required Field Indicator 
   Note: Visual asterisks should be paired with aria-required="true" on form fields
   for screen reader accessibility. The CSS provides visual cues only.
*/
.required-indicator::after {
  content: " *";
  color: #dc3545;
  font-weight: bold;
  /* Visual indicator only - aria-required="true" handles screen reader announcement */
}

/* Improved Button States */
.btn {
  font-weight: 600;
  min-height: 44px; /* WCAG touch target minimum */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn:disabled,
.btn.disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

/* Loading State for Buttons */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spinner 0.75s linear infinite;
}

@keyframes btn-spinner {
  to { transform: rotate(360deg); }
}

/* Status Badge Accessibility */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-paid,
.status-badge.badge-success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.badge-pending,
.status-badge.badge-warning {
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeeba;
}

.badge-failed,
.status-badge.badge-danger {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* Alert Enhancements with Icons */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
}

.alert-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
}

.alert-content {
  flex: 1;
}

/* Improved Table Accessibility */
.table {
  --table-stripe-bg: rgba(0, 0, 0, 0.02);
}

.table th {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--gray-dark);
  background-color: var(--gray-light);
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.table td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
}

.table tbody tr:hover {
  background-color: rgba(0, 102, 204, 0.05);
}

/* Responsive Table Wrapper */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Stack table on mobile */
@media (max-width: 576px) {
  .table-mobile-stack thead {
    display: none;
  }
  
  .table-mobile-stack tbody tr {
    display: block;
    border: 1px solid var(--gray-light);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    padding: 1rem;
  }
  
  .table-mobile-stack td {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border: none;
  }
  
  .table-mobile-stack td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--gray-dark);
  }
}

/* Card Improvements */
.card {
  border-radius: 0.5rem;
  border: 1px solid var(--gray-light);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card-header {
  background-color: var(--gray-light);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding: 1rem 1.25rem;
  font-weight: 600;
}

.card-header.bg-primary {
  background-color: var(--navy-primary) !important;
  color: var(--white);
}

.card-body {
  padding: 1.25rem;
}

/* Dashboard Cards with better visual hierarchy */
.dashboard-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dashboard-card .card-title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.dashboard-card .card-subtitle {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

/* Navigation Tabs Accessibility */
.nav-tabs .nav-link {
  color: var(--gray-dark);
  border: none;
  border-bottom: 3px solid transparent;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.nav-tabs .nav-link:hover {
  color: var(--navy-primary);
  border-bottom-color: var(--gray-light);
}

.nav-tabs .nav-link.active {
  color: var(--navy-primary);
  border-bottom-color: var(--navy-primary);
  background: transparent;
}

.nav-tabs .nav-link:focus-visible {
  outline: 3px solid var(--accent-blue);
  outline-offset: -3px;
}

/* Improved Modal Accessibility */
.modal-dialog {
  max-height: 90vh;
}

.modal-content {
  border-radius: 0.5rem;
}

.modal-header {
  border-bottom: 1px solid var(--gray-light);
  padding: 1rem 1.25rem;
}

.modal-body {
  padding: 1.25rem;
  max-height: 60vh;
  overflow-y: auto;
}

/* Progress Indicators */
.progress-wrapper {
  margin: 1rem 0;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.progress {
  height: 0.5rem;
  border-radius: 9999px;
  background-color: var(--gray-light);
}

.progress-bar {
  background-color: var(--navy-primary);
  border-radius: 9999px;
  transition: width 0.3s ease;
}

/* Toast/Notification Styles */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--white);
  border-radius: 0.375rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: toast-in 0.3s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast-success { border-left: 4px solid #28a745; }
.toast-error { border-left: 4px solid #dc3545; }
.toast-warning { border-left: 4px solid #ffc107; }
.toast-info { border-left: 4px solid var(--accent-blue); }

/* Keyboard Shortcut Indicators */
.kbd {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  font-family: monospace;
  font-size: 0.75rem;
  background-color: var(--gray-light);
  border: 1px solid var(--gray-primary);
  border-radius: 0.25rem;
  box-shadow: 0 1px 0 var(--gray-primary);
}

/* Print Styles */
@media print {
  .topbar,
  .footer-bar,
  .skip-link,
  .btn,
  .filter-card,
  .pagination,
  .no-print {
    display: none !important;
  }
  
  .card {
    border: 1px solid #000;
    box-shadow: none;
  }
  
  body {
    font-size: 12pt;
    color: #000;
  }
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --navy-primary: #000;
    --accent-blue: #0000ff;
  }
  
  .btn {
    border: 2px solid currentColor;
  }
  
  .card {
    border: 2px solid #000;
  }
}

/* Dark Mode Support (future-ready) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
  }
}

/* Responsive Typography */
@media (max-width: 576px) {
  h1, .h1 { font-size: 1.75rem; }
  h2, .h2 { font-size: 1.5rem; }
  h3, .h3 { font-size: 1.25rem; }
  h4, .h4 { font-size: 1.1rem; }
  
  .card-body {
    padding: 1rem;
  }
  
  .btn {
    width: 100%;
  }
  
  .form-row {
    flex-direction: column;
  }
  
  .form-row > .form-group,
  .form-row > [class*="col-"] {
    padding: 0;
    margin-bottom: 1rem;
  }
}

/* ===== Receipt Styles ===== */
.receipt-card {
  max-width: 800px;
  margin: 0 auto;
}

.receipt-header {
  background: linear-gradient(135deg, var(--navy-primary, #001f3f), #003366);
}

.receipt-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6c757d;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 0.35rem;
  margin-bottom: 0.5rem;
}

.receipt-table {
  margin-bottom: 0;
}

.receipt-table td {
  padding: 0.3rem 0;
  border: none;
  font-size: 0.875rem;
}

.receipt-total td {
  border-top: 2px solid #333;
  padding-top: 0.5rem;
  font-size: 0.95rem;
}

.receipt-footer p {
  font-size: 0.75rem;
}

/* ===== Print Styles ===== */
@media print {
  body * {
    visibility: hidden !important;
  }

  header, header *,
  footer, footer * {
    visibility: visible !important;
  }

  #receipt-section, #receipt-section *,
  .receipt-card, .receipt-card * {
    visibility: visible !important;
  }

  #receipt-section, .receipt-card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
  }

  .d-print-none {
    display: none !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #ccc;
  }

  .receipt-header, .card-header {
    background: #f8f9fa !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .badge-success, .bg-success {
    background: #28a745 !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}