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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0d0d12;
  color: #e0e0e8;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 16px;
}

header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

header .logo .logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #00ff88;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

header .logo .logo-icon::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00ff88;
  animation: pulse 2s ease-in-out infinite;
}

header .logo h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

header .connection-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.25s ease, color 0.25s ease;
}

header .connection-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transition: background 0.25s ease;
  flex-shrink: 0;
}

header .connection-badge.status-online {
  background: rgba(0, 255, 136, 0.15);
  color: #00ff88;
}

header .connection-badge.status-online .dot {
  background: #00ff88;
}

header .connection-badge.status-offline {
  background: rgba(255, 68, 85, 0.15);
  color: #ff4455;
}

header .connection-badge.status-offline .dot {
  background: #ff4455;
}

.device-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #16161e;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  margin-bottom: 20px;
}

.device-info-bar .my-device-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.device-info-bar .my-device-tag .tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.device-info-bar .my-device-tag .tag-dot.online {
  background: #00ff88;
}

.device-info-bar .my-device-tag .tag-dot.offline {
  background: #ff4455;
}

.device-info-bar .my-device-tag .my-name {
  cursor: pointer;
  font-weight: 500;
}

.device-info-bar .my-device-tag .my-name:hover {
  color: #00ccff;
}

.device-info-bar .my-device-tag .name-editor {
  display: flex;
  align-items: center;
  gap: 4px;
}

.device-info-bar .my-device-tag .name-editor input {
  background: #0d0d12;
  border: 1px solid #00ccff;
  color: #e0e0e8;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  width: 140px;
}

.device-info-bar .stats {
  font-size: 12px;
  color: #6b6b80;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.card {
  background: #16161e;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  padding: 16px;
  transition: border-color 0.25s ease, opacity 0.25s ease;
}

.card:hover {
  border-color: #3d3d55;
}

.card.card-offline {
  opacity: 0.6;
}

.card.card-offline:hover {
  opacity: 0.8;
}

.card.card-self {
  border-color: rgba(0, 204, 255, 0.3);
}

.card.card-self:hover {
  border-color: rgba(0, 204, 255, 0.6);
}

.card .card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.card .card-header .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.card .card-header .status-dot.online {
  background: #00ff88;
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.5);
}

.card .card-header .status-dot.offline {
  background: #ff4455;
}

.card .card-header .card-name {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card .card-header .self-badge {
  font-size: 10px;
  font-weight: 600;
  color: #00ccff;
  background: rgba(0, 204, 255, 0.12);
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card .card-latency {
  margin-bottom: 12px;
}

.card .card-latency .latency-value {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.card .card-latency .latency-value small {
  font-size: 13px;
  font-weight: 400;
  opacity: 0.6;
}

.card .card-latency .latency-value.lat-good {
  color: #00ff88;
}

.card .card-latency .latency-value.lat-ok {
  color: #ffcc00;
}

.card .card-latency .latency-value.lat-bad {
  color: #ff4455;
}

.card .card-latency .latency-value.offline {
  color: #6b6b80;
  font-size: 14px;
  font-weight: 400;
}

.card .card-latency .latency-bar {
  margin-top: 6px;
  height: 3px;
  background: #2a2a3a;
  border-radius: 2px;
  overflow: hidden;
}

.card .card-latency .latency-bar .latency-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.card .card-latency .latency-bar .latency-fill.lat-good {
  background: #00ff88;
}

.card .card-latency .latency-bar .latency-fill.lat-ok {
  background: #ffcc00;
}

.card .card-latency .latency-bar .latency-fill.lat-bad {
  background: #ff4455;
}

.card .card-info {
  margin-bottom: 12px;
}

.card .card-info .info-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 12px;
}

.card .card-info .info-row .info-label {
  color: #6b6b80;
}

.card .card-info .info-row .info-value {
  color: #e0e0e8;
  font-weight: 500;
  text-align: right;
}

.card .card-footer {
  border-top: 1px solid #2a2a3a;
  padding-top: 10px;
}

.card .card-footer .footer-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  font-size: 11px;
}

.card .card-footer .footer-row .footer-label {
  color: #6b6b80;
}

.card .card-footer .footer-row .footer-value {
  color: #e0e0e8;
  font-family: monospace;
  font-size: 11px;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: #6b6b80;
}

.empty-state .empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #2a2a3a;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state .empty-icon::after {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #2a2a3a;
  border-top-color: #00ff88;
  animation: spin 1.2s linear infinite;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 4px;
}

.empty-state .empty-hint {
  font-size: 12px;
  opacity: 0.6;
}

.btn-ghost {
  background: none;
  border: none;
  color: #00ccff;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-ghost:hover {
  background: rgba(0, 204, 255, 0.1);
}

.btn-sm {
  background: #00ccff;
  border: none;
  color: #0d0d12;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
}

.btn-sm:hover {
  opacity: 0.85;
}

.btn-bw {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: rgba(0, 204, 255, 0.08);
  border: 1px solid rgba(0, 204, 255, 0.2);
  color: #00ccff;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.btn-bw:hover:not(:disabled) {
  background: rgba(0, 204, 255, 0.15);
  border-color: rgba(0, 204, 255, 0.4);
}

.btn-bw:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-bw .bw-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #00ccff;
  position: relative;
  flex-shrink: 0;
}

.btn-bw .bw-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #00ccff;
}

.card-bw {
  border-top: 1px solid #2a2a3a;
  padding-top: 10px;
  margin-top: 10px;
}

.bw-actions {
  display: flex;
}

.bw-status {
  padding: 6px 0;
  font-size: 11px;
}

.bw-status .bw-status-text {
  color: #6b6b80;
  margin-bottom: 6px;
}

.bw-status .bw-status-text strong {
  color: #00ff88;
}

.bw-status.bw-error .bw-status-text {
  color: #ff4455;
}

.bw-status.bw-error .bw-status-text strong {
  color: #ff4455;
}

.bw-status.bw-completado .bw-status-text {
  color: #e0e0e8;
}

.bw-progress {
  height: 3px;
  background: #2a2a3a;
  border-radius: 2px;
  overflow: hidden;
}

.bw-progress .bw-progress-fill {
  height: 100%;
  background: #00ccff;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.bw-status.bw-midiendo .bw-progress .bw-progress-fill {
  background: #00ff88;
}

.bw-status.bw-error .bw-progress .bw-progress-fill {
  background: #ff4455;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 600px) {
  #app { padding: 10px; }
  .device-grid { grid-template-columns: 1fr; }
  header h1 { font-size: 17px; }
  .device-info-bar {
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
  }
}
