/* ==========================================================================
   EPC Malta – Main Stylesheet
   Design tokens, typography, layout, utilities
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Google Fonts Import
   -------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap');

/* --------------------------------------------------------------------------
   2. CSS Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
  /* Brand colours */
  --color-primary:            #1e3a5f;
  --color-primary-light:      #2d5a8f;
  --color-primary-dark:       #152a45;
  --color-primary-fg:         #ffffff;

  --color-secondary:          #8fbc3f;
  --color-secondary-light:    #a3d44d;
  --color-secondary-dark:     #6e9430;
  --color-secondary-fg:       #0f1a04;

  --color-destructive:        #d4183d;
  --color-destructive-fg:     #ffffff;

  /* Neutrals */
  --color-bg:                 #ffffff;
  --color-fg:                 #1e293b;
  --color-muted:              #f1f5f9;
  --color-muted-fg:           #475569;
  --color-border:             rgba(30, 58, 95, 0.15);
  --color-input-bg:           #f8fafc;

  /* State colours */
  --color-success:            #166534;
  --color-warning:            #d97706;
  --color-info:               #0284c7;

  /* Typography */
  --font-family:              'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-base:           1rem;       /* 16px */
  --font-size-sm:             0.875rem;  /* 14px */
  --font-size-xs:             0.75rem;   /* 12px */
  --font-size-lg:             1.125rem;
  --font-size-xl:             1.25rem;
  --line-height-base:         1.7;
  --line-height-tight:        1.2;
  --line-height-snug:         1.4;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Border radius */
  --radius-sm:   0.375rem;
  --radius-md:   0.5rem;
  --radius-base: 0.75rem;
  --radius-lg:   1rem;
  --radius-xl:   1.25rem;
  --radius-2xl:  1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md:   0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg:   0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl:   0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-2xl:  0 25px 50px -12px rgba(0, 0, 0, 0.25);

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-base:   250ms ease;
  --transition-slow:   400ms ease;

  /* Z-index layers */
  --z-header:  1000;
  --z-overlay: 1040;
  --z-modal:   1050;
  --z-toast:   1060;

  /* Bootstrap override tokens */
  --bs-primary:        #1e3a5f;
  --bs-secondary:      #8fbc3f;
  --bs-body-font-family: var(--font-family);
  --bs-body-color:       var(--color-fg);
  --bs-body-bg:          var(--color-bg);
  --bs-border-color:     var(--color-border);
  --bs-border-radius:    var(--radius-base);
  --bs-border-radius-sm: var(--radius-sm);
  --bs-border-radius-lg: var(--radius-lg);
}

/* --------------------------------------------------------------------------
   3. Reset & Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-fg);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* --------------------------------------------------------------------------
   4. Skip Link (Accessibility)
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  z-index: var(--z-toast);
  padding: 0.75rem 1.5rem;
  background-color: var(--color-primary);
  color: var(--color-primary-fg);
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius-md) 0;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
}

/* --------------------------------------------------------------------------
   5. Focus States (WCAG AAA)
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Remove default outline when :focus-visible is supported */
:focus:not(:focus-visible) {
  outline: none;
}

/* --------------------------------------------------------------------------
   6. Typography
   -------------------------------------------------------------------------- */
h1, .h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: var(--line-height-tight);
  letter-spacing: -0.02em;
  color: var(--color-primary);
}

h2, .h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.5rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--color-primary);
}

h3, .h3 {
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  font-weight: 600;
  line-height: var(--line-height-snug);
  color: var(--color-primary);
}

h4, .h4 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--color-fg);
}

h5, .h5 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--color-fg);
}

h6, .h6 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--color-fg);
}

p {
  margin-bottom: 1rem;
  line-height: var(--line-height-base);
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-color: rgba(30, 58, 95, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color var(--transition-fast);
}

a:hover {
  text-decoration-color: var(--color-primary);
}

strong, b {
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   7. Layout Utilities
   -------------------------------------------------------------------------- */
.section-py {
  padding-top: var(--space-20);
  padding-bottom: var(--space-20);
}

.section-py-sm {
  padding-top: var(--space-12);
  padding-bottom: var(--space-12);
}

.section-py-lg {
  padding-top: var(--space-24);
  padding-bottom: var(--space-24);
}

.bg-gradient-page {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
}

@media (max-width: 991.98px) {
  .section-py {
    padding-top: var(--space-12);
    padding-bottom: var(--space-12);
  }

  .section-py-lg {
    padding-top: var(--space-16);
    padding-bottom: var(--space-16);
  }
}

.bg-gradient-hero {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
}

.min-h-screen {
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   8. Colour Utilities
   -------------------------------------------------------------------------- */
.text-primary    { color: var(--color-primary) !important; }
.text-secondary  { color: #4d6919 !important; } /* WCAG AA: 6.27:1 on white */
.text-muted      { color: var(--color-muted-fg) !important; }
.text-success    { color: var(--color-success) !important; }
.text-danger     { color: var(--color-destructive) !important; }

.bg-primary      { background-color: var(--color-primary) !important; }
.bg-secondary    { background-color: var(--color-secondary) !important; }
.bg-muted        { background-color: var(--color-muted) !important; }

/* --------------------------------------------------------------------------
   9. Page Banner
   -------------------------------------------------------------------------- */
.page-banner {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  padding: var(--space-12) 0;
  position: relative;
  overflow: hidden;
}

.page-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(143, 188, 63, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 40%);
  pointer-events: none;
}

.page-banner__title {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 700;
  color: #ffffff;
  margin-bottom: var(--space-3);
  line-height: 1.2;
}

.page-banner__subtitle {
  font-size: 1.0625rem;
  color: rgba(255, 255, 255, 0.85);
  max-width: 680px;
  line-height: 1.6;
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   10. Breadcrumb
   -------------------------------------------------------------------------- */
.breadcrumb-bar {
  background-color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 0;
}

.breadcrumb {
  margin-bottom: 0;
  padding: 0;
  background: transparent;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  line-height: 1.5;
}

.breadcrumb-item a {
  color: var(--color-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: var(--font-size-sm);
  font-weight: 500;
  line-height: 1.5;
  transition: color var(--transition-fast);
}

.breadcrumb-item a:hover {
  color: var(--color-secondary);
  text-decoration: underline;
}

.breadcrumb-item.active {
  color: var(--color-fg);
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

/* Override Bootstrap's float-based separator with an inline flex approach
   so it stays vertically centred regardless of how many items are present */
.breadcrumb-item + .breadcrumb-item::before {
  float: none;
  display: inline-flex;
  align-self: center;
  color: var(--color-muted-fg);
  content: '/';
  padding: 0 0.5rem;
}

/* --------------------------------------------------------------------------
   11. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.5;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-base);
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast);
  min-height: 44px; /* WCAG touch target */
  min-width: 44px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(30, 58, 95, 0.35);
}

.btn-secondary {
  background-color: var(--color-secondary);
  border-color: var(--color-secondary);
  color: #0f1a04; /* WCAG AA: 8.06:1 on #8fbc3f */
}

.btn-secondary:hover,
.btn-secondary:focus {
  background-color: var(--color-secondary-dark);
  border-color: var(--color-secondary-dark);
  color: #0f1a04; /* WCAG AA: 5.08:1 on #6e9430 */
  box-shadow: 0 4px 12px rgba(143, 188, 63, 0.35);
}

.btn-outline-primary {
  background-color: transparent;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  background-color: var(--color-primary);
  color: #ffffff;
}

.btn-outline-secondary {
  background-color: transparent;
  border-color: var(--color-secondary);
  color: #4d6919; /* WCAG AA: 6.27:1 on white */
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  background-color: var(--color-secondary);
  color: #0f1a04; /* WCAG AA: 8.06:1 on #8fbc3f */
}

.btn-ghost {
  background-color: transparent;
  border-color: transparent;
  color: var(--color-fg);
}

.btn-ghost:hover,
.btn-ghost:focus {
  background-color: var(--color-muted);
  color: var(--color-primary);
}

.btn-danger {
  background-color: var(--color-destructive);
  border-color: var(--color-destructive);
  color: #ffffff;
}

.btn-danger:hover,
.btn-danger:focus {
  background-color: #b01230;
  color: #ffffff;
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
  min-height: 52px;
}

.btn-sm {
  padding: 0.375rem 0.875rem;
  font-size: var(--font-size-sm);
  border-radius: var(--radius-md);
  min-height: 36px;
}

.btn-icon {
  padding: 0.625rem;
  border-radius: var(--radius-base);
  width: 44px;
  height: 44px;
}

/* Disabled action icon — used on table row action buttons when an action is
   not available. Apply .is-disabled alongside aria-disabled="true" and
   tabindex="-1" on the <a> element. pointer-events:none blocks mouse
   interaction; tabindex removes it from keyboard navigation. */
.btn-icon.is-disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
  color: var(--color-fg-muted);
}

.btn-icon.is-disabled:hover,
.btn-icon.is-disabled:focus {
  background-color: transparent;
  color: var(--color-fg-muted);
  box-shadow: none;
}

.btn-full {
  width: 100%;
}

/* --------------------------------------------------------------------------
   12. Cards
   -------------------------------------------------------------------------- */
.card {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

.card-hover:hover {
  box-shadow: var(--shadow-lg);
  border-color: rgba(30, 58, 95, 0.3);
}

.card-body {
  padding: var(--space-6);
}

.card-body-lg {
  padding: var(--space-8);
}

.card-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(30, 58, 95, 0.1), rgba(30, 58, 95, 0.05));
  border: 1px solid rgba(30, 58, 95, 0.2);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card:hover .card-icon {
  transform: scale(1.1);
  box-shadow: 0 8px 20px rgba(30, 58, 95, 0.15);
}

.card-icon-sm {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
}

.card-icon-secondary {
  background: linear-gradient(135deg, rgba(143, 188, 63, 0.1), rgba(143, 188, 63, 0.05));
  border-color: rgba(143, 188, 63, 0.2);
}

/* --------------------------------------------------------------------------
   13. Badge
   -------------------------------------------------------------------------- */
.badge-primary {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: var(--font-size-xs);
  font-weight: 700;
  border-radius: var(--radius-full);
  background-color: rgba(30, 58, 95, 0.1);
  color: var(--color-primary);
  border: 1px solid rgba(30, 58, 95, 0.2);
}

.badge-secondary {
  background-color: rgba(143, 188, 63, 0.1);
  color: #3d5314; /* WCAG AA: 7.55:1 on near-white bg */
  border: 1px solid rgba(143, 188, 63, 0.2);
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: var(--font-size-xs);
  font-weight: 700;
  border-radius: var(--radius-full);
}

.badge-outline {
  background-color: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-muted-fg);
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: var(--font-size-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
}

/* --------------------------------------------------------------------------
   14. Forms
   -------------------------------------------------------------------------- */
.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-fg);
  margin-bottom: 0.375rem;
}

.form-label .required {
  color: var(--color-destructive);
  margin-left: 0.25rem;
}

.form-control {
  display: block;
  width: 100%;
  padding: 0.6875rem 1rem;
  font-family: var(--font-family);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--color-fg);
  background-color: var(--color-input-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-base);
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    background-color var(--transition-fast);
  appearance: none;
  min-height: 44px;
}

.form-control:focus {
  border-color: var(--color-primary);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
  outline: none;
}

.form-control::placeholder {
  color: var(--color-muted-fg);
  opacity: 1;
}

.form-control.is-invalid {
  border-color: var(--color-destructive);
}

.form-control.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(212, 24, 61, 0.12);
}

.form-control.is-valid {
  border-color: var(--color-success);
}

.form-select {
  display: block;
  width: 100%;
  padding: 0.6875rem 2.5rem 0.6875rem 1rem;
  font-family: var(--font-family);
  font-size: 0.9375rem;
  color: var(--color-fg);
  background-color: var(--color-input-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-base);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%231e3a5f' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  background-size: 16px 12px;
  appearance: none;
  min-height: 44px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--color-primary);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
  outline: none;
}

.form-check-input {
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  vertical-align: middle;
  cursor: pointer;
  accent-color: var(--color-primary);
  transition: border-color var(--transition-fast);
}

.form-check-input:focus {
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}

.form-check-input:checked {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.form-check-label {
  cursor: pointer;
  font-size: var(--font-size-sm);
  padding-left: 0.375rem;
}

.form-text {
  font-size: var(--font-size-xs);
  color: var(--color-muted-fg);
  margin-top: 0.375rem;
}

.invalid-feedback {
  display: none;
  font-size: var(--font-size-xs);
  color: var(--color-destructive);
  margin-top: 0.375rem;
}

.form-control.is-invalid ~ .invalid-feedback,
.form-select.is-invalid ~ .invalid-feedback,
.was-validated .form-control:invalid ~ .invalid-feedback,
.was-validated .form-select:invalid ~ .invalid-feedback {
  display: block;
}

textarea.form-control {
  resize: vertical;
  min-height: 120px;
}

.input-group-icon {
  position: relative;
}

.input-group-icon .form-control {
  padding-left: 2.75rem;
}

.input-group-icon .input-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted-fg);
  pointer-events: none;
  transition: color var(--transition-fast);
}

.input-group-icon:focus-within .input-icon {
  color: var(--color-primary);
}

/* Right-side icon group – used for password show/hide toggles */
.input-icon-group {
  position: relative;
}

.input-icon-group .form-control {
  padding-right: 3rem;
}

.input-icon-group__btn {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--color-muted-fg);
  cursor: pointer;
  padding: 0;
  transition: color var(--transition-fast);
}

.input-icon-group__btn:hover,
.input-icon-group__btn:focus-visible {
  color: var(--color-primary);
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   15. Alerts / Info Boxes
   -------------------------------------------------------------------------- */
.alert {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-base);
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--font-size-sm);
}

.alert-icon {
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.alert-primary {
  background-color: rgba(30, 58, 95, 0.06);
  border-color: rgba(30, 58, 95, 0.2);
  color: var(--color-primary);
}

.alert-secondary {
  background-color: rgba(143, 188, 63, 0.08);
  border-color: rgba(143, 188, 63, 0.25);
  color: #4d6919; /* WCAG AA: 5.83:1 on near-white bg */
}

.alert-success {
  background-color: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}

.alert-warning {
  background-color: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.alert-danger {
  background-color: #fff1f2;
  border-color: #fecdd3;
  color: #be123c;
}

/* --------------------------------------------------------------------------
   16. Tables
   -------------------------------------------------------------------------- */
.table-epc {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.table-epc thead th {
  background-color: var(--color-primary);
  color: #ffffff;
  padding: 0.75rem 1rem;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.table-epc tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  color: var(--color-fg);
}

.table-epc tbody tr:last-child td {
  border-bottom: none;
}

.table-epc tbody tr:hover td {
  background-color: rgba(30, 58, 95, 0.03);
}

.table-epc tbody tr:nth-child(even) td {
  background-color: rgba(241, 245, 249, 0.5);
}

.table-responsive-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
}

/* ── Mobile card layout for .table-epc ─────────────────────────────────────
   Below 768 px every <tr> becomes a 2-column grid card.
   Certificate ID spans the full width as a card header.
   Actions are anchored to the top-right of that header.
   Middle columns arrange as: Issue Date | Building Type
                               Rating Type | Paid
   Certificate Type is hidden on mobile.
   Each cell shows its column label (via data-label / ::before) above the
   value — populated automatically by initTableLabels() in main.js.
   -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {

  /* Let cards fill the container naturally */
  .table-responsive {
    overflow: visible;
  }

  /* Hide column headers — labels are injected via ::before */
  .table-epc thead {
    display: none;
  }

  /* Reset outer table elements to block */
  .table-epc,
  .table-epc tbody {
    display: block;
    width: 100%;
  }

  /* Each row → 2-column grid card */
  .table-epc tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    position: relative;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }

  /* ── Certificate ID: full-width card header ── */
  .table-epc tbody td:first-child {
    grid-column: 1 / -1;
    order: -1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.875rem 8.75rem 0.875rem 1rem;
    border-bottom: 1px solid var(--color-border);
    font-weight: 700;
    color: var(--color-primary);
    font-family: monospace;
    font-size: var(--font-size-sm);
    background: transparent;
  }

  .table-epc tbody td:first-child::before {
    content: attr(data-label);
    font-family: var(--font-family);
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--color-muted-fg);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
  }

  /* ── Actions: anchored top-right of the card header ── */
  .table-epc tbody td:last-child {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 0.125rem;
    padding: 0.5rem 0.375rem;
    border: none;
    background: transparent;
    z-index: 1;
  }

  /* Compact icon buttons in the action column on mobile.
     32×32px keeps them visually tight while still exceeding the
     WCAG 2.5.8 AA minimum of 24×24px. Gap is removed — WCAG 2.5.8
     does not require space between adjacent targets, only a minimum
     target size. */
  .table-epc tbody td:last-child > div {
    gap: 0;
  }

  .table-epc tbody td:last-child .btn-icon {
    width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
  }

  .table-epc tbody td:last-child::before {
    display: none;
  }

  /* ── Certificate Type: hidden on mobile ── */
  .table-epc tbody td:nth-child(3) {
    display: none;
  }

  /* ── Middle cells: label stacked above value ── */
  .table-epc tbody td:not(:first-child):not(:last-child):not(:nth-child(3)) {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.75rem 0.875rem;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-fg);
    border-bottom: 1px solid rgba(30, 58, 95, 0.07);
  }

  .table-epc tbody td:not(:first-child):not(:last-child):not(:nth-child(3))::before {
    content: attr(data-label);
    font-family: var(--font-family);
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--color-muted-fg);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
    white-space: nowrap;
  }

  /* ── Column order: Issue Date | Building Type / Rating Type | Paid ── */
  .table-epc tbody td:nth-child(2) { order: 1; } /* Issue Date     → top-left  */
  .table-epc tbody td:nth-child(5) { order: 2; } /* Building Type  → top-right */
  .table-epc tbody td:nth-child(4) { order: 3; } /* Rating Type    → btm-left  */
  .table-epc tbody td:nth-child(6) { order: 4; } /* Paid           → btm-right */

  /* No bottom border on the bottom row of grid cells */
  .table-epc tbody td:nth-child(4),
  .table-epc tbody td:nth-child(6) {
    border-bottom: none;
  }

  /* Suppress desktop alternating-row and hover tints */
  .table-epc tbody tr:nth-child(even) td,
  .table-epc tbody tr:hover td {
    background-color: transparent;
  }
}

/* --------------------------------------------------------------------------
   16b. table-epc--delegate modifier
   Overrides the absolute-positioned last column so the Toggle Status button
   sits in the grid flow with its label, rather than floating unlabelled.
   Column order on mobile: Name | Email / Status | Toggle Status
   -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {

  .table-epc.table-epc--delegate tbody td:last-child {
    position: static;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.75rem 0.875rem;
    border-bottom: none;
    background: transparent;
    z-index: auto;
    order: 4;
  }

  .table-epc.table-epc--delegate tbody td:last-child::before {
    display: block;
    content: attr(data-label);
    font-family: var(--font-family);
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--color-muted-fg);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
    white-space: nowrap;
  }

  /* Reorder: Name | Email on row 1, Status | Toggle Status on row 2 */
  .table-epc.table-epc--delegate tbody td:nth-child(2) { order: 1; }
  .table-epc.table-epc--delegate tbody td:nth-child(4) { order: 2; border-bottom: 1px solid rgba(30,58,95,0.07); }
  .table-epc.table-epc--delegate tbody td:nth-child(5) { order: 3; border-bottom: none; }
  .table-epc.table-epc--delegate tbody td:last-child    { order: 4; }

}

/* --------------------------------------------------------------------------
   17. Pagination
   -------------------------------------------------------------------------- */
.pagination .page-link {
  color: var(--color-primary);
  border-color: var(--color-border);
  font-weight: 500;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-base) !important;
  margin: 0 0.25rem;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.pagination .page-link:hover {
  background-color: var(--color-muted);
  color: var(--color-primary);
  border-color: var(--color-border);
}

.pagination .page-item.active .page-link {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
}

.pagination .page-item.disabled .page-link {
  color: var(--color-muted-fg);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   18. Animations
   -------------------------------------------------------------------------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

@keyframes ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-12px); }
}

.animate-fade-in-up {
  animation: fadeInUp 0.5s ease both;
}

.animate-fade-in {
  animation: fadeIn 0.4s ease both;
}

.animate-scale-in {
  animation: scaleIn 0.4s ease both;
}

.animate-float {
  animation: floatY 4s ease-in-out infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* Scroll-triggered animation base state */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }
.reveal-delay-5 { transition-delay: 0.5s; }

/* --------------------------------------------------------------------------
   19. Utility Helpers
   -------------------------------------------------------------------------- */
.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;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.rounded-xl  { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }

.shadow-card { box-shadow: var(--shadow-md); }
.shadow-card-hover { box-shadow: var(--shadow-xl); }

/* --------------------------------------------------------------------------
   20. Print Styles
   -------------------------------------------------------------------------- */
@media print {
  .site-header,
  .site-footer,
  .breadcrumb-bar,
  .btn,
  .cookie-banner {
    display: none !important;
  }

  body {
    font-size: 12pt;
    color: #000;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  h1, h2, h3, h4, h5, h6 {
    color: #000;
  }
}
