* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  min-height: 100vh;
}

/* Utility */
.hidden { display: none !important; }
.error { color: #e53e3e; margin-top: 0.5rem; font-size: 0.875rem; }

/* Screens */
.screen { display: none; }
.screen.active { display: block; }

/* Login */
.login-card {
  max-width: 400px;
  margin: 10vh auto;
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  text-align: center;
}
.login-card h1 { font-size: 1.75rem; margin-bottom: 0.25rem; }
.login-card > p { color: #666; margin-bottom: 1.5rem; }

/* Forms */
.form-group { margin-bottom: 1rem; text-align: left; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.25rem; font-size: 0.875rem; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.875rem;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: #4a90d9;
  box-shadow: 0 0 0 2px rgba(74,144,217,0.2);
}
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.15s;
}
.btn:hover { background: #f0f0f0; }
.btn-primary { background: #4a90d9; color: white; border-color: #4a90d9; }
.btn-primary:hover { background: #3a7bc8; }
.btn-danger { background: #e53e3e; color: white; border-color: #e53e3e; }
.btn-danger:hover { background: #c53030; }
.btn-success { background: #38a169; color: white; border-color: #38a169; }
.btn-success:hover { background: #2f855a; }
.btn-small { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-warning { background: #d69e2e; color: white; border-color: #d69e2e; }
.btn-warning:hover { background: #b7791f; }

/* Header */
header {
  background: white;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e2e2e2;
}
header h1 { font-size: 1.25rem; }
.header-right { display: flex; align-items: center; gap: 1rem; }

/* Badge */
.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-setup { background: #edf2f7; color: #4a5568; }
.badge-active { background: #c6f6d5; color: #22543d; }
.badge-complete { background: #bee3f8; color: #2a4365; }

/* Tabs */
.tabs {
  display: flex;
  background: white;
  border-bottom: 1px solid #e2e2e2;
  padding: 0 2rem;
}
.tab {
  padding: 0.75rem 1.5rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: #666;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab:hover { color: #333; }
.tab.active { color: #4a90d9; border-bottom-color: #4a90d9; font-weight: 600; }

/* Tab Content */
.tab-content { display: none; padding: 1.5rem 2rem; }
.tab-content.tab-active { display: block; }

/* Section Header */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.section-header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Card */
.card {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 1rem;
}

/* Submissions Grid */
.submissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.submission-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  overflow: hidden;
}
.submission-card .card-images {
  height: 180px;
  background: #e2e2e2;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.submission-card .card-images img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.submission-card .card-images .no-images {
  color: #999;
  font-size: 0.875rem;
}
.submission-card .image-count {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.6);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
}
.submission-card .card-body { padding: 1rem; }
.submission-card .card-body h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.submission-card .card-body .builder { color: #666; font-size: 0.875rem; margin-bottom: 0.5rem; }
.submission-card .card-body .description { font-size: 0.8rem; color: #888; margin-bottom: 0.75rem; }
.submission-card .card-actions { display: flex; gap: 0.5rem; }

/* Empty State */
.empty-state { text-align: center; padding: 3rem; color: #999; }

/* Competition */
.comp-actions { display: flex; gap: 1rem; margin-top: 1rem; }
.comp-stat { margin-bottom: 0.5rem; }
.comp-stat strong { display: inline-block; width: 160px; }

/* Results */
.round-section {
  margin-bottom: 0.75rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  overflow: hidden;
}
.round-section summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  user-select: none;
  border-bottom: 1px solid transparent;
  list-style: none;
}
.round-section summary::-webkit-details-marker { display: none; }
.round-section summary::before {
  content: '▶';
  font-size: 0.65rem;
  margin-right: 0.6rem;
  transition: transform 0.15s;
  display: inline-block;
  color: #888;
}
.round-section[open] summary::before { transform: rotate(90deg); }
.round-section[open] summary { border-bottom-color: #e2e2e2; }
.round-matchup-count { font-size: 0.78rem; color: #888; font-weight: 400; }
.round-badge-current {
  display: inline-block;
  margin-left: 0.5rem;
  background: #c6f6d5;
  color: #22543d;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
  vertical-align: middle;
}
.round-section-body { padding: 0.75rem 1.25rem; }
.matchup-result {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background: white;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.matchup-result .sub-name { flex: 1; font-size: 0.875rem; }
.matchup-result .vote-count {
  min-width: 40px;
  text-align: center;
  font-weight: 600;
  padding: 0 0.5rem;
}
.matchup-result .vs { color: #999; padding: 0 0.5rem; font-size: 0.75rem; }
.matchup-result .winner { color: #38a169; }

/* Voter Details Table */
.voter-table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.voter-table th, .voter-table td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid #eee; font-size: 0.875rem; }
.voter-table th { background: #f7f7f7; font-weight: 600; }

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal.hidden { display: none; }
.modal-content {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e2e2e2;
}
.modal-header h3 { font-size: 1.125rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
}
.modal-body { padding: 1.5rem; }

/* Drop Zone */
.drop-zone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
  margin-bottom: 1rem;
}
.drop-zone:hover, .drop-zone.dragover { border-color: #4a90d9; background: #f0f7ff; }

/* Upload Progress */
.upload-progress { margin-bottom: 1rem; }
.upload-item { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; font-size: 0.875rem; }
.upload-item .progress-bar { flex: 1; height: 4px; background: #e2e2e2; border-radius: 2px; overflow: hidden; }
.upload-item .progress-bar .fill { height: 100%; background: #4a90d9; transition: width 0.3s; }

/* Current Images */
.current-images { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.current-images img { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; border: 1px solid #ddd; }

@media (max-width: 768px) {
  .form-row { flex-direction: column; }
  .tabs { overflow-x: auto; }
  .tab-content { padding: 1rem; }
  header { padding: 0.75rem 1rem; }
  .submissions-grid { grid-template-columns: 1fr; }
}
