:root {
  --bg: #fff5f5;
  --maroon: #800000;
  --lightred: #ff4d4d;
  --black: #000;
  --gap: 12px;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, "Poppins", sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--black);
  line-height: 1.35;
}

.wrap {
  max-width: 980px;
  margin: 18px auto;
  padding: 0 12px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  left: 8px;
  top: 8px;
  background: #fff;
  padding: 6px;
  border-radius: 6px;
  z-index: 1000;
}

/* ========= Header & Navigation ========= */
header {
  background: var(--maroon);
  color: #fff;
  padding: 10px 0;
}

header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap; /* Makes it responsive */
  gap: 10px;
}

.nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  width: 100%;
}

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #fff;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 0.95rem;
  border-radius: 6px;
}

.nav-btn:hover,
.nav-btn.active {
  background: var(--lightred);
  color: #fff;
}

/* ========= Panels ========= */
.panel {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
  display: none; /* Hide all by default */
}

.panel.active {
  display: block; /* Show only active panel */
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.card {
  background: #fff;
  border: 1px solid #f0dede;
  padding: 10px;
  border-radius: 8px;
  text-align: center;
}

.card strong {
  display: block;
  font-size: 1.15rem;
}

.chart .bars {
  display: flex;
  gap: 6px;
  align-items: end;
  height: 80px;
  overflow-x: auto;
  padding-bottom: 4px;
}

/* ========= Controls & Records ========= */
.controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.search input {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #ddd;
}

.cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.record {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #eee;
}

.record .meta {
  flex: 1;
  margin-left: 10px;
}

.record .actions button {
  margin-left: 6px;
}

/* ========= Forms ========= */
label {
  display: block;
  margin-top: 8px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #ddd;
  margin-top: 6px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

button {
  background: var(--maroon);
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  border: 0;
  cursor: pointer;
}

button[aria-pressed="true"],
button:focus {
  outline: 3px solid rgba(128, 0, 0, .2);
}

.error {
  color: var(--lightred);
  font-size: .9rem;
  margin-top: 6px;
}

/* ========= File Upload ========= */
.btn-file {
  display: inline-block;
  position: relative;
  overflow: hidden;
}

.btn-file input[type=file] {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
}

/* ========= Larger Screens ========= */
@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .controls {
    grid-template-columns: 1fr 1fr auto;
  }

  .cards {
    flex-direction: column;
  }
}

@media (min-width: 1024px) {
  header .wrap {
    gap: 20px;
  }

  .wrap {
    padding: 0 20px;
  }

  .cards {
    gap: 10px;
  }
}

/* ========= Mobile-first Responsiveness ========= */
@media (max-width: 768px) {
  body {
    font-size: 15px;
    line-height: 1.4;
  }

  header .wrap {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  h1 {
    font-size: 1.4rem;
    margin-bottom: 8px;
  }

  .nav {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .nav-btn {
    width: 100%;
    text-align: center;
    padding: 10px;
    font-size: 1rem;
  }

  .panel {
    padding: 14px;
    margin: 8px 0;
  }

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

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

  .form-actions {
    flex-direction: column;
  }

  input,
  select,
  button {
    font-size: 1rem;
  }

  footer p {
    font-size: 0.85rem;
    text-align: center;
  }
}

/* ========= Very Small Phones ========= */
@media (max-width: 480px) {
  h2 {
    font-size: 1.1rem;
  }

  p,
  label {
    font-size: 0.9rem;
  }

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

  .card {
    padding: 8px;
  }

  .nav-btn {
    padding: 8px;
    font-size: 0.9rem;
  }
}

/* ========= Accessibility ========= */
:focus {
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

.empty {
  text-align: center;
  color: #777;
  padding: 12px;
}
