* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f0f4f7;
  color: #333;
}

header {
  background-color: #34495e;
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

#session-info {
  font-size: 0.9rem;
  color: #bdc3c7;
  flex: 1;
  text-align: center;
  min-width: 300px;
}

.header-buttons {
  display: flex;
  gap: 10px;
}

.pause-btn {
  background-color: #2ecc71;
  color: white;
  border: none;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.pause-btn:hover {
  background-color: #27ae60;
}

.pause-btn.paused {
  background-color: #e74c3c;
}

.pause-btn.paused:hover {
  background-color: #c0392b;
}

.maintenance-btn {
  background-color: #e67e22;
  color: white;
  border: none;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.maintenance-btn:hover {
  background-color: #d35400;
}

.maintenance-btn.active {
  background-color: #c0392b;
}

main {
  padding: 15px;
}

.grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto auto;
  gap: 15px;
}

.panel {
  background: white;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.panel h2 {
  background-color: #ecf0f1;
  color: #34495e;
  padding: 10px 15px;
  font-size: 1rem;
  font-weight: 600;
  border-bottom: 1px solid #ddd;
}

.tunnel-panel {
  grid-column: 1 / -1;
  grid-row: 1;
}

.devices-panel {
  grid-column: 1;
  grid-row: 2;
}

.tunnels-panel {
  grid-column: 2;
  grid-row: 2;
}

.file-panel {
  grid-column: 1;
  grid-row: 3;
}

.alerts-panel {
  grid-column: 2;
  grid-row: 3;
}

.compressed-panel {
  grid-column: 1 / -1;
  grid-row: 4;
}

.table-container {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 300px;
}

.devices-panel .table-container {
  max-height: 500px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}

th {
  background-color: #f8f9fa;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Sticky MAC address column (first column) in devices table */
.devices-panel td:first-child,
.devices-panel th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background-color: #f8f9fa;
}

.devices-panel th:first-child {
  z-index: 2;
}

.devices-panel td:first-child {
  background-color: white;
  font-weight: 600;
  font-family: 'Consolas', monospace;
}

.devices-panel tr.status-active td:first-child {
  background-color: #d4edda;
}

.devices-panel tr.status-quiet td:first-child {
  background-color: #fff3cd;
}

.devices-panel tr.status-silent td:first-child {
  background-color: #f8d7da;
}

tbody tr:hover {
  background-color: #f5f5f5;
}

/* Device status colors */
.status-active {
  background-color: #d4edda !important;
}

.status-quiet {
  background-color: #fff3cd !important;
}

.status-silent {
  background-color: #f8d7da !important;
}

/* Champion highlighting */
.champion {
  background-color: #ffd700 !important;
  color: #8b4513;
  font-weight: 600;
}

/* File info panel */
#file-info {
  padding: 15px;
}

#file-info p {
  margin-bottom: 8px;
  font-size: 0.9rem;
}

#file-info span {
  font-family: 'Consolas', monospace;
  color: #34495e;
}

.progress-bar {
  width: 100%;
  height: 20px;
  background-color: #ecf0f1;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-fill {
  height: 100%;
  background-color: #3498db;
  transition: width 0.3s ease;
  width: 0%;
}

.health-status {
  margin-top: 10px;
  font-size: 0.8rem;
  color: #7f8c8d;
}

/* Alerts panel */
#alerts-list {
  padding: 10px 15px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.85rem;
}

.alert-item {
  padding: 5px 0;
  border-bottom: 1px solid #eee;
  font-family: 'Consolas', monospace;
}

.alert-item:last-child {
  border-bottom: none;
}

/* Connection status indicator */
.connection-status {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
}

.connection-status.connected {
  background-color: #2ecc71;
}

.connection-status.disconnected {
  background-color: #e74c3c;
}

/* Tunnel info panel */
#tunnel-info {
  padding: 15px;
}

#tunnel-info p {
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.tunnel-status {
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.tunnel-status.running {
  background-color: #d4edda;
  color: #155724;
}

.tunnel-status.stopped {
  background-color: #f8d7da;
  color: #721c24;
}

.tunnel-url {
  display: block;
  font-family: 'Consolas', monospace;
  font-size: 1.1rem;
  padding: 12px 15px;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  margin: 10px 0;
  word-break: break-all;
  user-select: all;
}

.tunnel-url.active {
  background-color: #d4edda;
  border-color: #c3e6cb;
  color: #155724;
}

.tunnel-url.inactive {
  background-color: #f8d7da;
  border-color: #f5c6cb;
  color: #721c24;
}

.tunnel-hint {
  font-size: 0.85rem;
  color: #6c757d;
  font-style: italic;
}

/* Login overlay */
#login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #34495e;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-container {
  background: white;
  padding: 40px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  min-width: 320px;
}

.login-container h1 {
  margin-bottom: 10px;
  color: #34495e;
  font-size: 1.5rem;
}

.login-container p {
  margin-bottom: 20px;
  color: #7f8c8d;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-form input {
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  outline: none;
}

#login-form input:focus {
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

#login-form button {
  padding: 12px;
  background-color: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

#login-form button:hover {
  background-color: #2980b9;
}

.login-error {
  color: #e74c3c;
  margin-top: 10px;
  font-size: 0.9rem;
}

.logout-btn {
  background-color: #95a5a6;
  color: white;
  border: none;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.logout-btn:hover {
  background-color: #7f8c8d;
}

/* Panel header with button */
.panel-header-row {
  background-color: #ecf0f1;
  border-bottom: 1px solid #ddd;
  padding: 6px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header-row h2 {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
}

/* GCS badges */
.gcs-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
}

.gcs-badge.uploaded {
  background-color: #d4edda;
  color: #155724;
}

.gcs-badge.pending {
  background-color: #fff3cd;
  color: #856404;
}

.gcs-badge.uploading {
  background-color: #cce5ff;
  color: #004085;
}

.gcs-badge.failed {
  background-color: #f8d7da;
  color: #721c24;
  cursor: help;
}

/* Delete buttons */
.delete-file-btn {
  background-color: #e74c3c;
  color: white;
  border: none;
  padding: 3px 10px;
  font-size: 0.75rem;
  border-radius: 3px;
  cursor: pointer;
}

.delete-file-btn:hover {
  background-color: #c0392b;
}

.retry-file-btn {
  background-color: #3498db;
  color: white;
  border: none;
  padding: 3px 10px;
  font-size: 0.75rem;
  border-radius: 3px;
  cursor: pointer;
}

.retry-file-btn:hover {
  background-color: #2980b9;
}

/* Error popup overlay */
.error-overlay {
  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;
}

.error-popup {
  background: white;
  border-radius: 8px;
  padding: 24px;
  max-width: 600px;
  width: 90%;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.error-popup h3 {
  color: #e74c3c;
  margin-bottom: 12px;
}

.error-popup p {
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.error-popup pre {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 12px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.error-popup button {
  background-color: #34495e;
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}

.error-popup button:hover {
  background-color: #2c3e50;
}

.delete-all-btn {
  background-color: #e74c3c;
  color: white;
  border: none;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
}

.delete-all-btn:hover {
  background-color: #c0392b;
}

/* Disk usage */
.disk-usage {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #eee;
}

.disk-fill {
  background-color: #2ecc71;
}

.disk-fill.warning {
  background-color: #f39c12;
}

.disk-fill.critical {
  background-color: #e74c3c;
}

/* Filter buttons */
.filter-buttons {
  display: flex;
  gap: 4px;
}

.filter-btn {
  background-color: #bdc3c7;
  color: #2c3e50;
  border: none;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.filter-btn:hover {
  background-color: #95a5a6;
  color: white;
}

.filter-btn.active {
  background-color: #3498db;
  color: white;
}

/* Responsive */
@media (max-width: 1200px) {
  .grid-container {
    grid-template-columns: 1fr;
  }

  .devices-panel,
  .tunnels-panel,
  .file-panel,
  .alerts-panel,
  .compressed-panel {
    grid-column: 1;
    grid-row: auto;
  }
}
