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

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

.navbar {
  background: #1a1a2e;
  color: white;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.nav-brand {
  font-size: 1.2rem;
  font-weight: bold;
  color: #4fc3f7;
}

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

.nav-links a {
  color: #ccc;
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.nav-links a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-links a.active {
  background: rgba(79, 195, 247, 0.2);
  color: #4fc3f7;
}

.logout-btn {
  color: #ff6b6b !important;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1 {
  margin-bottom: 1.5rem;
  color: #1a1a2e;
}

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.login-box {
  background: white;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.login-box h1 {
  color: #1a1a2e;
  margin-bottom: 0.5rem;
}

.login-box p {
  color: #666;
  margin-bottom: 1.5rem;
}

.login-box input {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.5rem;
  padding: 0.75rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: #444;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #4fc3f7;
  box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.2);
}

.form-group textarea {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  resize: vertical;
}

.basic-info-preview {
  margin-top: 0.5rem;
  padding: 0.6rem 1rem;
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #2e7d32;
}

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

.form-row .form-group {
  flex: 1;
  min-width: 150px;
}

.team-select-wrapper {
  display: flex;
  gap: 0.5rem;
}

.team-select-wrapper select {
  flex: 1;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: normal !important;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-primary {
  background: #4fc3f7;
  color: #1a1a2e;
}

.btn-primary:hover {
  background: #29b6f6;
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover {
  background: #bdbdbd;
}

.btn-danger {
  background: #ef5350;
  color: white;
}

.btn-danger:hover {
  background: #e53935;
}

.btn-small {
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
}

.btn-full {
  width: 100%;
}

.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.alert-error {
  background: #ffebee;
  border: 1px solid #ef9a9a;
  color: #c62828;
}

.alert-success {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  color: #2e7d32;
}

.alert h3 {
  margin-bottom: 0.5rem;
}

.alert ul {
  margin-left: 1.5rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  border-bottom: 2px solid #e0e0e0;
  padding-bottom: 0;
}

.tab {
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: #666;
  border-radius: 6px 6px 0 0;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.tab:hover {
  color: #333;
  background: #f0f0f0;
}

.tab.active {
  color: #1a1a2e;
  border-bottom-color: #4fc3f7;
  font-weight: 700;
}

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

.filters form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filters select,
.filters input {
  padding: 0.4rem 0.6rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.85rem;
  min-width: 120px;
}

.autocomplete-wrap {
  position: relative;
  display: inline-block;
}

.autocomplete-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.autocomplete-item {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.autocomplete-item:hover {
  background: #e8f0fe;
}

.export-bar {
  margin-bottom: 0.75rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.table-wrapper {
  overflow-x: auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: #1a1a2e;
  color: white;
}

th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
}

tr:hover {
  background: #f8f9fa;
}

.team-group-header td {
  background: #e8eaf6;
  font-weight: 700;
  color: #1a1a2e;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid #c5cae9;
  font-size: 0.9rem;
}

.team-group-header:hover {
  background: none;
}

.team-group-header:hover td {
  background: #e8eaf6;
}

.game-separator td {
  padding: 0;
  height: 8px;
  background: #ddd;
  border-bottom: none;
}

.game-separator:hover {
  background: none;
}

.game-separator:hover td {
  background: #ddd;
}

.winner {
  font-weight: 700;
  color: #1a1a2e;
}

.trophy {
  font-size: 0.85em;
  margin-left: 2px;
}

.empty {
  text-align: center;
  color: #999;
  padding: 2rem !important;
}

.pagination-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.page-info {
  font-size: 0.85rem;
  color: #666;
  margin-right: 0.5rem;
}

.page-num {
  font-size: 0.85rem;
  color: #333;
  font-weight: 500;
  padding: 0 0.25rem;
}

.page-size-select {
  padding: 0.3rem 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.8rem;
  margin-right: 0.5rem;
}

.pagination-bar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.alias-tag {
  display: inline-block;
  background: #e3f2fd;
  color: #1565c0;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  margin: 2px;
  white-space: nowrap;
}

.alias-remove {
  background: none;
  border: none;
  color: #e53935;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 2px;
  margin-left: 2px;
  line-height: 1;
}

.alias-remove:hover {
  color: #b71c1c;
}

.alias-add-btn {
  font-size: 0.75rem !important;
  padding: 1px 6px !important;
}

.aliases-cell {
  max-width: 400px;
}

.add-team-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem;
  background: #f0f4f8;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.add-team-form .input-field {
  padding: 0.4rem 0.6rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
}
.add-team-form .input-small {
  width: 120px;
}


.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.modal-box h3 {
  color: #e74c3c;
  margin-bottom: 1rem;
  font-size: 1.3rem;
}
.modal-box p {
  margin-bottom: 0.75rem;
  color: #555;
  font-size: 0.95rem;
}
.modal-box .pin-input {
  width: 100%;
  padding: 0.75rem;
  font-size: 1.2rem;
  text-align: center;
  letter-spacing: 0.3em;
  border: 2px solid #ddd;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}
.modal-box .pin-input:focus {
  border-color: #e74c3c;
  outline: none;
}
.modal-error {
  color: #e74c3c;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}
.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}
.btn-cancel {
  flex: 1;
  padding: 0.65rem;
  border: 1px solid #ddd;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}
.btn-cancel:hover {
  background: #f0f0f0;
}
.btn-danger {
  flex: 1;
  padding: 0.65rem;
  border: none;
  background: #e74c3c;
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
}
.btn-danger:hover {
  background: #c0392b;
}
.btn-danger:disabled {
  background: #999;
  cursor: not-allowed;
}

.multi-select-wrap {
  position: relative;
  display: inline-block;
}

.multi-select-btn {
  padding: 0.4rem 0.6rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.85rem;
  background: white;
  cursor: pointer;
  min-width: 120px;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: #666;
  transition: border-color 0.2s;
}

.multi-select-btn:hover {
  border-color: #4fc3f7;
}

.multi-select-btn.has-selection {
  color: #1a1a2e;
  border-color: #4fc3f7;
  background: #f0f9ff;
}

.multi-arrow {
  font-size: 0.7rem;
  color: #999;
}

.multi-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 200;
  min-width: 180px;
  max-height: 260px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.multi-select-dropdown.open {
  display: block;
}

.multi-select-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #333;
  transition: background 0.15s;
  user-select: none;
}

.multi-select-item:hover {
  background: #f0f4f8;
}

.multi-select-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #4fc3f7;
  cursor: pointer;
  flex-shrink: 0;
}

.multi-select-item span {
  flex: 1;
  white-space: nowrap;
}

.multi-select-action {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  color: #4fc3f7;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  text-align: right;
}

.multi-select-action:hover {
  color: #1a1a2e;
  background: #f8f8f8;
}

@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .form-row {
    flex-direction: column;
  }
  .filters form {
    flex-direction: column;
  }
  .filters select,
  .filters input {
    width: 100%;
  }
  .multi-select-wrap {
    width: 100%;
  }
  .multi-select-btn {
    width: 100%;
  }
  .multi-select-dropdown {
    width: 100%;
  }
  .plotter-dual {
    grid-template-columns: 1fr;
  }
}

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

.plotter-session-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #e3f2fd;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-weight: 600;
  color: #1565c0;
}

.plotter-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.plotter-panel {
  background: white;
  padding: 1.25rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.plotter-panel-header {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: white;
  background: #1a1a2e;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.plotter-display-row {
  text-align: center;
  margin-bottom: 1rem;
}

.plotter-display-row label {
  font-size: 0.85rem;
  color: #666;
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
}

.plotter-display {
  font-size: 2.5rem;
  font-weight: 700;
  color: #1a1a2e;
  background: #f5f5f5;
  border: 2px solid #ddd;
  border-radius: 8px;
  padding: 0.5rem;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.plotter-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.keypad-btn {
  padding: 0.75rem;
  font-size: 1.3rem;
  font-weight: 600;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #f8f9fa;
  cursor: pointer;
  transition: all 0.15s;
  color: #1a1a2e;
}

.keypad-btn:hover {
  background: #e8eaf6;
  border-color: #4fc3f7;
}

.keypad-btn:active {
  background: #c5cae9;
}

.keypad-special {
  background: #fff3e0;
  border-color: #ffcc80;
  color: #e65100;
}

.keypad-special:hover {
  background: #ffe0b2;
}

.keypad-cancel {
  background: #ffebee;
  border-color: #ef9a9a;
  color: #c62828;
}

.keypad-cancel:hover {
  background: #ffcdd2;
}

.plotter-location,
.plotter-source {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.loc-btn,
.src-btn {
  flex: 1;
  padding: 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: #f8f9fa;
  cursor: pointer;
  transition: all 0.15s;
  color: #555;
}

.loc-btn:hover,
.src-btn:hover {
  border-color: #4fc3f7;
  background: #f0f9ff;
}

.loc-btn.active,
.src-btn.active {
  border-color: #4fc3f7;
  background: #e1f5fe;
  color: #0277bd;
}

.plotter-add-btn {
  margin-top: 0.5rem;
  font-size: 1.1rem;
  padding: 0.75rem;
}

#entriesTable {
  margin-top: 1rem;
}

#entriesTable h2 {
  margin-bottom: 0.75rem;
  color: #1a1a2e;
  font-size: 1.1rem;
}

.plot-for {
  background: #f1f8e9;
}

.plot-for:hover {
  background: #e8f5e9 !important;
}

.plot-against {
  background: #fff3e0;
}

.plot-against:hover {
  background: #fff8e1 !important;
}

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

.edgeai-section {
  margin-bottom: 1.5rem;
}

.edgeai-section h2 {
  color: #1a1a2e;
  font-size: 1.15rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #4fc3f7;
}

.edgeai-card {
  background: white;
  padding: 1.25rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 0.75rem;
}

.edgeai-card h3 {
  color: #1a1a2e;
  font-size: 1rem;
  margin-bottom: 0.75rem;
  text-align: center;
  background: #f0f4f8;
  padding: 0.5rem;
  border-radius: 6px;
}

.edgeai-card h4 {
  color: #555;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 1rem 0 0.5rem 0;
  padding-top: 0.75rem;
  border-top: 1px solid #eee;
}

.edgeai-card h4:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.edgeai-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.edgeai-table th {
  background: #1a1a2e;
  color: white;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
}

.edgeai-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
}

.edgeai-table tr:last-child td {
  border-bottom: none;
}

.edgeai-label {
  font-weight: 600;
  color: #1a1a2e;
  white-space: nowrap;
}

.edgeai-empty {
  color: #999;
  font-style: italic;
  text-align: center;
  padding: 0.75rem;
  font-size: 0.85rem;
}

.edgeai-dual-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.edgeai-record-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.edgeai-record-card {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  text-align: center;
  font-size: 1.1rem;
  letter-spacing: 1px;
}

.edgeai-record-card strong {
  display: block;
  margin-bottom: 0.5rem;
  color: #1a1a2e;
  font-size: 0.9rem;
  letter-spacing: 0;
}

.field-container {
  margin-top: 0.5rem;
  flex: 1;
  min-width: 0;
}

.field-legend {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.5rem;
  justify-content: center;
}

.legend-kick,
.legend-play {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  margin-right: 2px;
}

.legend-kick {
  background: #ff9800;
}

.legend-play {
  background: #2196f3;
}

.field {
  background: #2e7d32;
  border-radius: 8px;
  overflow: hidden;
  border: 3px solid #1b5e20;
}

.field-half {
  padding: 0.75rem 0.5rem;
}

.field-for {
  background: rgba(255,255,255,0.08);
}

.field-against {
  background: rgba(0,0,0,0.08);
}

.field-half-label {
  text-align: center;
  color: rgba(255,255,255,0.7);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.field-midline {
  height: 2px;
  background: rgba(255,255,255,0.4);
  margin: 0 0.5rem;
}

.field-zones {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.25rem;
}

.field-zone {
  text-align: center;
  padding: 0.5rem 0.25rem;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.zone-label {
  color: rgba(255,255,255,0.6);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.zone-markers-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  align-items: center;
}

.zone-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 700;
  color: white;
  min-width: 28px;
  min-height: 24px;
}

.zone-kick {
  background: #ff9800;
}

.zone-play {
  background: #2196f3;
}

.zone-none {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.5);
}

.zone-total {
  color: rgba(255,255,255,0.9);
  font-size: 0.75rem;
  font-weight: 600;
}

.edgeai-btn-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.edgeai-prompt-editor {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
}

.edgeai-prompt-editor label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.edgeai-prompt-editor textarea {
  width: 100%;
  margin-bottom: 0.5rem;
}

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

.ai-stream-content {
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
}

@media (max-width: 768px) {
  .edgeai-dual-tables {
    grid-template-columns: 1fr;
  }
  .edgeai-record-row {
    grid-template-columns: 1fr;
  }
  .edgeai-btn-row {
    flex-direction: column;
    align-items: stretch;
  }
}
