/* ─── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --primary:        #c8102e;
  --primary-dark:   #9e0c23;
  --primary-light:  #fdf0f2;
  --primary-mid:    #e63946;
  --dark:           #1c1f2e;
  --dark-mid:       #2d3147;
  --gray-100:       #f5f6fa;
  --gray-200:       #eef0f5;
  --gray-300:       #dee2e6;
  --gray-500:       #8a8fa8;
  --gray-700:       #4a4f68;
  --text:           #1e2130;
  --text-muted:     #6b7080;
  --white:          #ffffff;
  --shadow-xs:      0 1px 3px rgba(0,0,0,0.07);
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.09);
  --shadow:         0 4px 20px rgba(0,0,0,0.10);
  --shadow-lg:      0 8px 36px rgba(0,0,0,0.14);
  --radius:         0.625rem;
  --radius-lg:      1rem;
  --radius-xl:      1.5rem;
  --transition:     all 0.2s ease;
  --navbar-h:       62px;
}

/* ─── Base ───────────────────────────────────────────────────────────────── */
html {
  font-size: 15px;
  scroll-behavior: smooth;
}

@media (min-width: 768px) {
  html { font-size: 16px; }
}

body {
  background: var(--gray-100);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  margin-bottom: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Navbar ─────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--dark) !important;
  border-bottom: 3px solid var(--primary);
  height: var(--navbar-h);
  padding: 0 0;
  box-shadow: 0 2px 16px rgba(0,0,0,0.25);
}

.navbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white) !important;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0;
}

.navbar-brand-icon {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.navbar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.navbar-brand-text span:first-child {
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.navbar-brand-text span:last-child {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
}

.navbar-nav .nav-link {
  color: rgba(255,255,255,0.78) !important;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem !important;
  border-radius: 0.4rem;
  transition: var(--transition);
  letter-spacing: 0.01em;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus {
  color: var(--white) !important;
  background: rgba(255,255,255,0.1);
}

.navbar-nav .nav-link.active {
  color: var(--white) !important;
  background: var(--primary);
}

.navbar-nav .dropdown-menu {
  background: var(--dark-mid);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
  min-width: 230px;
}

.navbar-nav .dropdown-item {
  color: rgba(255,255,255,0.8);
  font-size: 0.85rem;
  border-radius: 0.35rem;
  padding: 0.5rem 0.75rem;
  transition: var(--transition);
}

.navbar-nav .dropdown-item:hover {
  background: rgba(255,255,255,0.12);
  color: var(--white);
}

.navbar-nav .dropdown-toggle::after {
  opacity: 0.6;
}

.navbar-user-name {
  color: var(--white) !important;
  font-weight: 600;
  font-size: 0.875rem;
  background: rgba(200,16,46,0.25);
  border: 1px solid rgba(200,16,46,0.4);
  border-radius: 2rem;
  padding: 0.3rem 0.85rem !important;
  transition: var(--transition);
}

.navbar-user-name:hover {
  background: rgba(200,16,46,0.4) !important;
}

.btn-nav-signout {
  background: none;
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.75) !important;
  font-size: 0.8rem;
  border-radius: 2rem;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}

.btn-nav-signout:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.4);
  color: var(--white) !important;
}

.navbar-toggler {
  border-color: rgba(255,255,255,0.2);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255%2c 255%2c 255%2c 0.7%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ─── Page Wrapper ───────────────────────────────────────────────────────── */
.page-wrapper {
  flex: 1;
  padding-top: calc(var(--navbar-h) + 2rem);
  padding-bottom: 3rem;
}

/* ─── Page Header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  line-height: 1.25;
}

.page-title-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--white);
  overflow: hidden;
}

.card-header {
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-300);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-700);
  padding: 0.75rem 1.25rem;
}

.card-section {
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--white);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-light);
}

/* ─── Hero (Home Page) ───────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--dark) 0%, var(--dark-mid) 60%, #3d2030 100%);
  border-radius: var(--radius-lg);
  padding: 3.5rem 3rem;
  margin-bottom: 2rem;
  color: var(--white);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(200,16,46,0.18) 0%, transparent 70%);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: 20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(200,16,46,0.10) 0%, transparent 70%);
  pointer-events: none;
}

.hero-eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--primary-mid);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hero-eyebrow::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 2px;
  background: var(--primary);
}

.hero h1 {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.hero p {
  color: rgba(255,255,255,0.75);
  font-size: 1.05rem;
  line-height: 1.7;
  max-width: 640px;
  margin-bottom: 0.75rem;
}

.hero-actions {
  margin-top: 2rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 2rem;
  padding: 0.3rem 0.85rem;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.8);
  margin-bottom: 1.5rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.feature-card {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.feature-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: rgba(200,16,46,0.25);
}

.feature-card-icon {
  width: 40px;
  height: 40px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.feature-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.feature-card p {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* ─── Auth Pages ─────────────────────────────────────────────────────────── */
.auth-wrapper {
  min-height: calc(100vh - var(--navbar-h));
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-card-header {
  background: linear-gradient(135deg, var(--dark) 0%, var(--dark-mid) 100%);
  padding: 2rem 2rem 1.5rem;
  text-align: center;
  position: relative;
}

.auth-card-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}

.auth-logo {
  width: 48px;
  height: 48px;
  background: var(--primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: white;
  margin: 0 auto 1rem;
}

.auth-card-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--white);
  margin: 0 0 0.25rem;
}

.auth-card-header p {
  color: rgba(255,255,255,0.55);
  font-size: 0.85rem;
  margin: 0;
}

.auth-card-body {
  padding: 2rem;
}

.auth-footer-links {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.auth-footer-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.auth-footer-links a:hover {
  text-decoration: underline;
}

.auth-divider {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 0.75rem 0;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 0.5rem 1.1rem;
  transition: var(--transition);
  letter-spacing: 0.01em;
  border-width: 1.5px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: white;
  box-shadow: 0 4px 14px rgba(200,16,46,0.35);
}

.btn-secondary {
  background: var(--white);
  border-color: var(--gray-300);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-100);
  border-color: var(--gray-500);
  color: var(--text);
}

.btn-outline-primary {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 4px 14px rgba(200,16,46,0.25);
}

.btn-outline-secondary {
  border-color: var(--gray-300);
  color: var(--gray-700);
}

.btn-outline-secondary:hover {
  background: var(--gray-100);
  border-color: var(--gray-500);
  color: var(--text);
}

.btn-outline-danger:hover {
  box-shadow: 0 4px 12px rgba(220,53,69,0.25);
}

.btn-lg {
  padding: 0.7rem 1.6rem;
  font-size: 1rem;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
  border-width: 1.5px;
}

.btn:focus, .btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus,
.form-select:focus {
  box-shadow: 0 0 0 3px rgba(200,16,46,0.18);
  outline: none;
}

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-control, .form-select {
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.9rem;
  padding: 0.5rem 0.85rem;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  background: var(--white);
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.35rem;
}

.form-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-control-plaintext {
  color: var(--text);
  font-size: 0.9rem;
  padding-left: 0;
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table {
  font-size: 0.875rem;
  color: var(--text);
  border-color: var(--gray-200);
}

.table thead th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-700);
  background: var(--gray-100);
  border-bottom: 2px solid var(--gray-300);
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.table tbody td {
  padding: 0.7rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--gray-200);
}

.table-hover tbody tr:hover {
  background: rgba(200,16,46,0.04);
}

.table-wrapper {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input {
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
}

.dataTables_wrapper .dataTables_length select {
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: white !important;
  border-radius: 0.375rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--gray-100) !important;
  border-color: var(--gray-300) !important;
  color: var(--text) !important;
  border-radius: 0.375rem;
}

/* ─── Accordion ──────────────────────────────────────────────────────────── */
.accordion-item {
  border: 1px solid var(--gray-300);
  margin-bottom: 0.5rem;
  border-radius: var(--radius) !important;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.accordion-button {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  background: var(--white);
  padding: 1rem 1.25rem;
  border-radius: var(--radius) !important;
  transition: var(--transition);
}

.accordion-button::after {
  filter: none;
  opacity: 0.5;
}

.accordion-button:not(.collapsed) {
  background: var(--primary-light);
  color: var(--primary-dark);
  box-shadow: none;
  border-bottom: 1px solid rgba(200,16,46,0.15);
}

.accordion-button:not(.collapsed)::after {
  opacity: 1;
  filter: none;
}

.accordion-button:focus {
  box-shadow: 0 0 0 3px rgba(200,16,46,0.15);
}

.accordion-body {
  padding: 1.25rem;
  background: var(--white);
}

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  padding: 0.3em 0.65em;
  border-radius: 0.35rem;
}

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius);
  border-width: 0;
  border-left: 4px solid transparent;
  font-size: 0.9rem;
}

.alert-success {
  background: #e8f5e9;
  border-left-color: #4caf50;
  color: #2e7d32;
}

.alert-danger {
  background: #fdecea;
  border-left-color: #f44336;
  color: #c62828;
}

.alert-warning {
  background: #fff8e1;
  border-left-color: #ffc107;
  color: #7a5c00;
}

.alert-info {
  background: #e3f2fd;
  border-left-color: #2196f3;
  color: #1565c0;
}

/* ─── Modals ─────────────────────────────────────────────────────────────── */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-300);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1rem 1.5rem;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.5rem;
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--dark);
  color: rgba(255,255,255,0.45);
  padding: 1.25rem 0;
  font-size: 0.8rem;
  margin-top: auto;
}

.site-footer a {
  color: rgba(255,255,255,0.6);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--white);
}

/* ─── Back to Top ────────────────────────────────────────────────────────── */
#return-to-top {
  background: var(--dark);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.8);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex !important;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: var(--transition);
  z-index: 1050;
}

#return-to-top.d-none { display: none !important; }

#return-to-top:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 4px 16px rgba(200,16,46,0.4);
}

/* ─── Info Row (key/value pairs) ─────────────────────────────────────────── */
.info-row {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-bottom: 1.25rem;
}

.info-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
}

.info-value {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 500;
}

/* ─── Section divider line ───────────────────────────────────────────────── */
.section-hr {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 1.5rem 0;
}

/* ─── Misc utilities ─────────────────────────────────────────────────────── */
.text-primary { color: var(--primary) !important; }

.fw-700 { font-weight: 700; }

a {
  color: var(--primary);
}

a:hover {
  color: var(--primary-dark);
}

dt {
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.85rem;
}

dd {
  color: var(--text);
}

code {
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 0.3rem;
  padding: 0.15em 0.4em;
  font-size: 0.85em;
  color: var(--primary-dark);
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .hero {
    padding: 2rem 1.5rem;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .auth-wrapper {
    padding: 1.5rem 1rem;
  }

  .auth-card-body {
    padding: 1.5rem;
  }

  .page-wrapper {
    padding-top: calc(var(--navbar-h) + 1.25rem);
  }
}
