* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f5f7;
  color: #1a1a1a;
}

header {
  background: #c4b9a6;
  color: #5b6029;
  padding: 10px 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  height: 72px;
  width: auto;
  border-radius: 4px;
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
}

#page-title { flex: 1; text-align: center; }

@media (min-width: 641px) {
  #page-title {
    flex: none;
    text-align: left;
    margin-left: 0.75rem;
  }

  .header-right { margin-left: auto; }
}

.header-right { display: flex; align-items: center; gap: 0.75rem; flex: 0 0 auto; }

nav { display: flex; gap: 0.5rem; }

.tab-btn {
  background: transparent;
  border: 1px solid rgba(91,96,41,0.4);
  color: #5b6029;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.tab-btn.active { background: white; color: #5b6029; }

#logout-btn {
  background: transparent;
  border: none;
  color: #c0392b;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  text-decoration: underline;
  cursor: pointer;
}

#logout-btn:hover { opacity: 0.8; }

#nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: transparent;
  border: 1px solid rgba(91,96,41,0.4);
  border-radius: 6px;
  width: 42px;
  height: 38px;
  padding: 0;
}

#nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: #5b6029;
  margin: 0 auto;
}

main { padding: 1.5rem; max-width: 720px; margin: 0 auto; }

@media (max-width: 640px) {
  header { position: relative; flex-wrap: nowrap; }

  #page-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #nav-toggle { display: flex; }

  nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #c4b9a6;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 10;
  }

  nav.open { display: flex; }

  .tab-btn {
    width: 100%;
    text-align: left;
    border-radius: 4px;
    border: none;
    padding: 0.75rem 1rem;
  }

  #main-nav #logout-btn {
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
  }
}

.tab { display: none; }
.tab.active { display: block; }

#scan-instructions {
  text-align: center;
  color: #555;
  font-size: 1.1rem;
}

#scan-input {
  display: block;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
  font-size: 1.2rem;
  text-align: center;
  border: 2px solid #14213d;
  border-radius: 8px;
}

.scan-result {
  margin-top: 1rem;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 600;
  min-height: 3rem;
  padding: 1rem;
  border-radius: 8px;
}

.scan-result.ok { background: #d4edda; color: #155724; }
.scan-result.duplicate { background: #fff3cd; color: #856404; }
.scan-result.error { background: #f8d7da; color: #721c24; }

#add-member-form,
#add-trial-form,
#add-schedule-form,
#add-pricelist-form,
#add-registration-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

#add-member-form input,
#add-trial-form input,
#add-schedule-form input,
#add-schedule-form select,
#add-pricelist-form input,
#add-pricelist-form select,
#add-registration-form select {
  flex: 1;
  min-width: 140px;
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
}

#edit-member-form,
#edit-trial-form,
#edit-schedule-form,
#edit-pricelist-form,
#new-season-form,
#edit-season-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}

#new-season-form label,
#edit-season-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  text-align: left;
}

#edit-member-form input,
#edit-trial-form input,
#edit-schedule-form input,
#edit-schedule-form select,
#edit-pricelist-form input,
#edit-pricelist-form select,
#new-season-form input,
#edit-season-form input {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1rem;
}

#edit-schedule-form .checkbox-label input[type="checkbox"] {
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  accent-color: #14213d;
  cursor: pointer;
}

button {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 6px;
  background: #5b6029;
  color: white;
  cursor: pointer;
  font-size: 0.95rem;
}

button:hover { opacity: 0.9; }

.member-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.member-card.inactive { opacity: 0.5; }

.member-card.cancelled .member-name,
.member-card.cancelled .member-details {
  text-decoration: line-through;
  opacity: 0.6;
}

.member-info { display: flex; flex-direction: column; gap: 0.15rem; }
.member-name { font-weight: 600; }
.member-details { font-size: 0.8rem; color: #666; }

.member-card .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.btn-link {
  background: #e9ecef;
  color: #1a1a1a;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.95rem;
  display: inline-block;
}

.schedule-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#member-search,
#trial-search {
  width: 100%;
  padding: 0.6rem;
  margin-bottom: 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
}

#members-empty,
#trials-empty {
  color: #666;
  font-size: 0.9rem;
}

.hidden { display: none !important; }

.member-card button.secondary {
  background: #e9ecef;
  color: #1a1a1a;
}

button.danger {
  background: #c0392b;
}

button.success {
  background: #1e7e34;
}

#log-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

#schedule-season-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

#schedule-season-select {
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  max-width: 320px;
}

#log-filters input {
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
}

#log-search-name { flex: 1; min-width: 160px; }

#log-empty {
  color: #666;
  font-size: 0.9rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  margin-top: 1rem;
}

th, td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #eee;
}

.log-group-header td {
  background: #eef0f4;
  font-weight: 600;
  color: #5b6029;
}

.schedule-day-header {
  margin: 1.2rem 0 0.5rem;
  color: #5b6029;
  font-size: 1rem;
}

.schedule-day-header:first-child {
  margin-top: 0;
}

.log-group-window {
  font-weight: 400;
  color: #666;
  font-size: 0.85em;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden { display: none; }

.modal-content {
  background: white;
  padding: 1.5rem;
  border-radius: 10px;
  text-align: center;
  position: relative;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.modal-drag-handle {
  cursor: move;
  user-select: none;
}

#edit-modal .modal-content,
#edit-trial-modal .modal-content,
#edit-schedule-modal .modal-content,
#edit-pricelist-modal .modal-content,
#new-season-modal .modal-content,
#edit-season-modal .modal-content,
#registrations-modal .modal-content {
  width: 380px;
  max-width: calc(100vw - 2rem);
}

.trial-tag {
  color: #888;
  font-size: 0.85em;
}

.modal-content img { width: 260px; height: auto; margin: 1rem 0; }

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  color: #333;
  font-size: 1.5rem;
  padding: 0;
}

.modal-content a {
  display: inline-block;
  margin-top: 0.5rem;
}
