:root {
  --bg: #f3f5f7;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #0f766e;
  --primary-dark: #0a5a54;
  --danger: #dc2626;
  --warning-bg: #fff4f4;
  --warning-border: #fecaca;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, #f8fafc 0%, var(--bg) 220px, var(--bg) 100%);
  color: var(--text);
}

body.modal-open {
  overflow: hidden;
}

.app-shell {
  width: 100%;
  margin: 0;
  padding: 16px;
}

.card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.event-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.event-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.event-title {
  text-align: center;
  flex: 1;
}

.event-logo {
  width: 88px;
  height: 88px;
  border-radius: 0;
  object-fit: contain;
  border: 0;
  background: transparent;
  flex-shrink: 0;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 1.45rem;
}

h2 {
  font-size: 1.08rem;
  margin-bottom: 10px;
}

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

.event-meta > div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.meta-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 2px;
}

.event-meta p {
  margin: 0;
  font-weight: 600;
}

.grid {
  display: grid;
  gap: 10px;
}

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

.full {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.2);
  border-color: var(--primary);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--primary-dark);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.add-row-wrap {
  margin-top: 10px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
}

#coachesTable {
  min-width: 0;
}

th,
td {
  border: 1px solid var(--line);
  padding: 8px;
  font-size: 0.86rem;
  vertical-align: middle;
}

th {
  background: #f9fafb;
  text-align: left;
}

td input,
td select {
  width: 100%;
  padding: 7px;
  font-size: 0.84rem;
}

#athletesTable th:nth-child(2),
#athletesTable td:nth-child(2) {
  min-width: 280px;
}

#athletesTable th:nth-child(4),
#athletesTable td:nth-child(4) {
  min-width: 90px;
  width: 90px;
}

#athletesTable th:nth-child(3),
#athletesTable td:nth-child(3) {
  min-width: 230px;
}

#athletesTable th:nth-child(7),
#athletesTable td:nth-child(7) {
  min-width: 80px;
  width: 80px;
}

#athletesTable th:nth-child(10),
#athletesTable td:nth-child(10) {
  min-width: 120px;
  width: 120px;
  white-space: nowrap;
}

#athletesTable th:nth-child(11),
#athletesTable td:nth-child(11) {
  min-width: 56px;
  width: 56px;
  text-align: center;
}

#coachesTable th:nth-child(1),
#coachesTable td:nth-child(1) {
  width: 60px;
  min-width: 60px;
}

#coachesTable th:nth-child(2),
#coachesTable td:nth-child(2) {
  min-width: 320px;
}

#coachesTable th:nth-child(3),
#coachesTable td:nth-child(3) {
  width: 180px;
  min-width: 180px;
}

#coachesTable th:nth-child(4),
#coachesTable td:nth-child(4) {
  width: 56px;
  min-width: 56px;
  text-align: center;
}

.actions-btn {
  background: var(--danger);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.actions-btn:hover {
  background: #b91c1c;
}

.actions-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.totals-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.warning {
  margin-top: 10px;
  border: 1px solid var(--warning-border);
  background: var(--warning-bg);
  color: #7f1d1d;
  border-radius: 10px;
  padding: 10px;
  font-size: 0.86rem;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 260px));
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafafa;
  padding: 12px;
}

.summary-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-value {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.warning-card {
  border-color: #fca5a5;
  background: #fff5f5;
}

.total-card {
  border-color: rgba(15, 118, 110, 0.35);
  background: #f0fdfa;
}

.grand-total {
  font-size: 1.25rem;
}

#exportBtn {
  display: block;
  margin: 0 auto;
}

.export-copy {
  margin: 0 0 10px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.entry-modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.entry-modal[hidden] {
  display: none;
}

.entry-modal-card {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.2);
}

.entry-modal-card h3 {
  margin: 0 0 10px;
}

.entry-modal-card p {
  margin: 0 0 14px;
  color: #374151;
  line-height: 1.45;
}

@media (max-width: 900px) {
  .grid.two,
  .event-meta {
    grid-template-columns: 1fr;
  }

  .summary-cards {
    grid-template-columns: 1fr;
  }

  .event-logo {
    width: 64px;
    height: 64px;
  }

  .app-shell {
    padding: 10px;
  }
}
