:root {
  --brand-primary: #003FA3;
  --brand-secondary: #FF8600;
  --brand-accent: #00D4FF;
  --brand-bg: #FFFFFF;
  --brand-text: #111827;
  --brand-text-muted: #4B5563;
  --brand-border: #D1D5DB;
  --brand-success: #059669;
  --brand-warning: #B45309;
  --brand-error: #B91C1C;
  --brand-light: #F9FAFB;
  --brand-dark: #1A2A3A;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 2.5rem;
  
  /* Border radius */
  --radius-none: 0;
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-3xl: 2rem;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 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);
  
  /* Typography - Consistent Scale */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  
  /* Font sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  
  /* Line heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;
  
  /* Font weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--brand-text);
  background-color: white;
  line-height: var(--leading-relaxed);
  font-size: var(--text-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography Scale */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: var(--brand-text);
  margin: 0 0 var(--space-md) 0;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); font-weight: var(--font-semibold); }
h4 { font-size: var(--text-xl); font-weight: var(--font-semibold); }
h5 { font-size: var(--text-lg); font-weight: var(--font-medium); }
h6 { font-size: var(--text-base); font-weight: var(--font-medium); }

p {
  margin: 0 0 var(--space-md) 0;
  line-height: var(--leading-relaxed);
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

a:hover {
  color: #003FA3;
}

a:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Buttons - Enhanced with consistent states */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background-color: #003FA3;
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
  color: white;
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-primary:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 82, 206, 0.3);
}

/* Secondary - use sparingly for accent actions only */
.btn-secondary {
  background-color: var(--brand-secondary);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-secondary:hover {
  background-color: #E67300;
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
  color: white;
}

.btn-secondary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 134, 0, 0.3);
}

.btn-outline {
  background-color: transparent;
  color: var(--brand-primary);
  border: 2px solid var(--brand-primary);
}

.btn-outline:hover {
  background-color: var(--brand-primary);
  color: white;
  transform: translateY(-1px);
}

.btn-outline:active {
  transform: translateY(0);
}

.btn-outline:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 82, 206, 0.2);
}

.btn-ghost {
  background-color: transparent;
  color: var(--brand-primary);
  border: none;
}

.btn-ghost:hover {
  background-color: var(--brand-bg);
  color: var(--brand-primary);
}

.btn-ghost:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 82, 206, 0.15);
}

.btn-sm {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
}

.btn-lg {
  padding: var(--space-lg) var(--space-xl);
  font-size: var(--text-lg);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn:disabled:hover {
  transform: none;
}

/* Forms - Enhanced Accessibility */
.form-group {
  margin-bottom: var(--space-lg);
}

label {
  display: block;
  margin-bottom: var(--space-sm);
  font-weight: var(--font-medium);
  color: var(--brand-text);
  cursor: pointer;
}

input,
textarea,
select {
  width: 100%;
  padding: var(--space-md);
  border: 2px solid var(--brand-border);
  border-radius: var(--radius-lg);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background-color: white;
}

/* Modern date input styling with inline SVG icon */
input[type="date"] {
  appearance: none;
  background-color: white;
  border-radius: var(--radius-lg);
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%230052CE" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>');
  background-repeat: no-repeat;
  background-position: right var(--space-md) center;
  background-size: 20px 20px;
  padding-right: 48px;
  min-height: 46px;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0;
  display: block;
  width: 24px;
  height: 24px;
  cursor: pointer;
}

/* Consistent control heights */
input[type="date"],
select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
textarea {
  min-height: 44px;
}

/* Modern radio/checkbox styling while keeping native accessibility */
input[type="radio"],
input[type="checkbox"] {
  accent-color: var(--brand-primary);
  -webkit-appearance: auto;
  appearance: auto;
  background-color: #fff;
  border: 1px solid var(--brand-border);
  margin-right: var(--space-md);
  cursor: pointer;
}

input[type="radio"] {
  width: 20px;
  height: 20px;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

@media (max-width: 768px) {
  input[type="radio"],
  input[type="checkbox"] {
    width: 22px;
    height: 22px;
  }

  input[type="date"] {
  padding-right: 44px;
  border: 2px solid var(--brand-border);
  border-radius: var(--radius-lg);
}

input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.85;
  cursor: pointer;
}

input[type="date"]:hover {
  border-color: rgba(0, 82, 206, 0.45);
}
}

/* Enhanced focus states for accessibility */
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(0, 82, 206, 0.1);
}

/* Keyboard focus visibility */
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

/* Checkbox label styling - flex layout for proper alignment */
.form-group > label[style*="display: flex"],
.form-group label:has(input[type="checkbox"]),
.form-group label:has(input[type="radio"]) {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  font-weight: 400;
  padding: var(--space-md) 0;
}

/* Ensure checkbox input stays fixed size */
.form-group label input[type="checkbox"],
.form-group label input[type="radio"] {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  margin-top: 2px;
  cursor: pointer;
}

/* Label text should wrap naturally */
.form-group label span {
  flex: 1;
  line-height: 1.5;
}

/* Mobile optimization for checkboxes */
@media (max-width: 768px) {
  .form-group label input[type="checkbox"],
  .form-group label input[type="radio"] {
    width: 24px;
    height: 24px;
    margin-top: 0;
  }
}

/* Cards */
.card {
  background-color: white;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-md);
  padding: var(--space-xl);
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--space-lg);
  color: var(--brand-text);
}

/* Badges */
.badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-primary {
  background-color: rgba(0, 82, 206, 0.1);
  color: var(--brand-primary);
}

.badge-secondary {
  background-color: rgba(255, 134, 0, 0.1);
  color: var(--brand-secondary);
}

.badge-success {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--brand-success);
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--brand-warning);
}

.badge-error {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--brand-error);
}

/* Alerts */
.alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
}

.alert-success {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--brand-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.alert-error {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--brand-error);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert-warning {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--brand-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.alert-info {
  background-color: rgba(0, 82, 206, 0.1);
  color: var(--brand-primary);
  border: 1px solid rgba(0, 82, 206, 0.3);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-lg);
}

thead {
  background-color: var(--brand-light);
  border-bottom: 2px solid var(--brand-border);
}

th {
  padding: var(--space-md);
  text-align: left;
  font-weight: 600;
  color: var(--brand-text);
}

td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--brand-border);
}

tbody tr:hover {
  background-color: var(--brand-light);
}

/* Grid */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

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

/* Responsive */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* Utilities */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-left {
  text-align: left;
}

.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mt-4 { margin-top: var(--space-xl); }

.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-4 { margin-bottom: var(--space-xl); }

.p-1 { padding: var(--space-sm); }
.p-2 { padding: var(--space-md); }
.p-3 { padding: var(--space-lg); }
.p-4 { padding: var(--space-xl); }

.hidden {
  display: none;
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gap-2 { gap: var(--space-md); }
.gap-3 { gap: var(--space-lg); }
.gap-4 { gap: var(--space-xl); }
