:root {
  --bg: #f3f4f6;
  --card-bg: #ffffff;
  --border-subtle: #e5e7eb;
  --text-main: #111827;
  --text-muted: #6b7280;
  --accent: #111827;
  --shadow-soft: 0 10px 25px rgba(15, 23, 42, 0.08);
  --radius-lg: 1rem;
  --radius-pill: 999px;

  --green-bg: #d1fae5;
  --green-text: #065f46;
  --yellow-bg: #fef9c3;
  --yellow-text: #854d0e;
  --red-bg: #fee2e2;
  --red-text: #991b1b;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: radial-gradient(circle at top left, #e5e7eb, #f9fafb);
  color: var(--text-main);
}

/* Layout */

.page-container {
  max-width: 1200px;
  margin: 2.5rem auto;
  padding: 0 1.5rem 3rem;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.02em;
}

.page-subtitle {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.card h2 {
  margin-top: 0;
  margin-bottom: 0.35rem;
  font-size: 1.1rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Status pills & legend */

.status-legend {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-green {
  background: var(--green-bg);
  color: var(--green-text);
}

.status-yellow {
  background: var(--yellow-bg);
  color: var(--yellow-text);
}

.status-red {
  background: var(--red-bg);
  color: var(--red-text);
}

/* Upload Card */

.upload-card .upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.75rem;
}

#rosterFileInput {
  padding: 0.4rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-subtle);
  font-size: 0.9rem;
  background-color: #f9fafb;
}

#uploadButton {
  border: none;
  border-radius: 999px;
  padding: 0.45rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: white;
  transition: transform 0.08s ease, box-shadow 0.08s ease,
    background-color 0.12s ease;
  box-shadow: 0 7px 18px rgba(15, 23, 42, 0.35);
}

#uploadButton:hover {
  transform: translateY(-1px);
  box-shadow: 0 9px 24px rgba(15, 23, 42, 0.45);
}

#uploadButton:active {
  transform: translateY(0);
  box-shadow: 0 5px 12px rgba(15, 23, 42, 0.3);
}

.upload-status {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Filters */

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 180px;
}

.filter-group label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.filter-group select,
.filter-group input {
  border-radius: 0.5rem;
  border: 1px solid var(--border-subtle);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  background-color: #f9fafb;
}

/* Table */

.table-card .table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.cadet-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.table-wrapper {
  overflow: auto;
  border-radius: 0.75rem;
  border: 1px solid var(--border-subtle);
}

.roster-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.roster-table thead {
  background: #f3f4f6;
}

.roster-table th,
.roster-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  white-space: nowrap;
}

.roster-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.roster-table tbody tr {
  cursor: pointer;
  transition: background-color 0.08s ease;
}

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

.roster-table tbody tr:hover {
  background: #e5f0ff;
}

/* Group header row for Company + Squad */
.group-row td {
  background: #e5e7eb;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #4b5563;
  padding-top: 0.6rem;
  padding-bottom: 0.35rem;
}

.group-divider {
  margin: 0 0.4rem;
  opacity: 0.7;
}

/* Edit button in table */

.edit-cadet-btn {
  white-space: nowrap;
}

/* Modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1040; /* above navbar */
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  /* IMPORTANT: override Bootstrap's display:none */
  display: block;

  background: #ffffff;
  border-radius: 1rem;
  padding: 1.75rem 2rem;
  max-width: 600px;
  width: 100%;
  position: relative;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.35);
}

.modal h2 {
  margin-top: 0;
  margin-bottom: 0.2rem;
}

.modal-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.9rem;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  color: #6b7280;
}

.modal-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.info-list {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
}

.info-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.2rem 0;
  font-size: 0.9rem;
}

.info-list li span:first-child {
  color: var(--text-muted);
}

/* Group header rows */

.group-row td {
  background: #e5e7eb;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding-top: 0.5rem;
  padding-bottom: 0.35rem;
}

.company-row td {
  font-weight: 600;
}

.squad-row td {
  background: #f3f4f6;
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: 0.04em;
  padding-left: 2.5rem;
}

.squad-label {
  font-weight: 500;
}

/* Collapse toggle buttons */

.company-toggle,
.squad-toggle {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-decoration: none;
}

.toggle-icon {
  display: inline-block;
  width: 1rem;
  text-align: center;
  font-size: 0.9rem;
}


/* Responsive */

@media (max-width: 768px) {
  .page-container {
    margin-top: 1.5rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-grid {
    grid-template-columns: 1fr;
  }
}
