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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #334155;
  --vlan1001: #16a34a;
  --vlanOther: #f59e0b;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Header */
header {
  background: linear-gradient(135deg, var(--bg-card) 0%, #0f172a 100%);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: space-between;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sgp-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-dark);
  border-radius: 20px;
  font-size: 0.85rem;
}

.sgp-badge {
  background: var(--primary);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.status-bar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-dark);
  border-radius: 20px;
  font-size: 0.85rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

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

/* Main */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.stat-card h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
}

.stat-card.total .stat-number { color: var(--primary); }
.stat-card.migrados .stat-number { color: var(--vlan1001); }
.stat-card.pendentes .stat-number { color: var(--vlanOther); }
.stat-card.em-andamento .stat-number { color: #f97316; }
.stat-card.online .stat-number { color: #a78bfa; }

/* Controls */
.controls {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.control-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-group label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-busca {
  flex: 1;
  min-width: 200px;
}

select, input[type="text"] {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 0.9rem;
  min-width: 150px;
}

input[type="text"] {
  flex: 1;
  min-width: 250px;
}

select:focus, input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* Buttons */
.btn {
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg-dark);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #15803d;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

/* Table */
.table-container {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.table-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.count {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: var(--bg-dark);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  white-space: nowrap;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tr:hover {
  background: var(--bg-card-hover);
}

.loading {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem !important;
}

/* VLAN Badge */
.vlan-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.vlan-1001 {
  background: rgba(22, 163, 74, 0.2);
  color: var(--vlan1001);
}

.vlan-other {
  background: rgba(245, 158, 11, 0.2);
  color: var(--vlanOther);
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.status-badge:hover {
  transform: scale(1.05);
}

.status-online {
  background: rgba(167, 139, 250, 0.2);
  color: #a78bfa;
}

.status-offline {
  background: rgba(100, 116, 139, 0.2);
  color: #64748b;
}

.status-active {
  background: rgba(22, 163, 74, 0.2);
  color: var(--success);
}

/* Migration Status */
.status-migrado {
  background: rgba(22, 163, 74, 0.2);
  color: var(--vlan1001);
}

.status-pendente {
  background: rgba(245, 158, 11, 0.2);
  color: var(--vlanOther);
}

.status-em-andamento {
  background: rgba(249, 115, 22, 0.2);
  color: #f97316;
}

.status-migrou-sem-acesso {
  background: rgba(234, 179, 8, 0.2);
  color: #eab308;
}

.status-marcar {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.status-offline-migracao {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.status-somente-presencial {
  background: rgba(168, 85, 247, 0.2);
  color: #a855f7;
}

/* Status Cell */
.status-cell {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.status-obs {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-style: italic;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 0.5rem;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.pagination button {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-dark);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
  background: var(--primary);
  border-color: var(--primary);
}

.pagination button.active {
  background: var(--primary);
  border-color: var(--primary);
}

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

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}

.modal-large {
  max-width: 900px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.1rem;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem;
  border-top: 1px solid var(--border);
}

.client-info {
  background: var(--bg-dark);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.client-info p {
  margin: 0.25rem 0;
  font-size: 0.9rem;
}

.client-info strong {
  color: var(--text-secondary);
}

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

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.form-group textarea,
.form-group input {
  width: 100%;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
}

.input-readonly {
  background: var(--bg-card-hover) !important;
  cursor: not-allowed;
}

/* History Table */
.history-table {
  width: 100%;
}

.history-table th,
.history-table td {
  padding: 0.6rem;
  font-size: 0.8rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
  header {
    padding: 1rem;
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .status-bar {
    margin-left: 0;
    width: 100%;
  }

  main {
    padding: 1rem;
  }

  .filters {
    flex-direction: column;
  }

  select, input[type="text"] {
    width: 100%;
  }

  td, th {
    padding: 0.5rem;
    font-size: 0.75rem;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* VLAN Config */
.vlan-config {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  background: var(--bg-dark);
  border-radius: 20px;
  font-size: 0.85rem;
}

.vlan-config label {
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.vlan-input {
  width: 60px !important;
  min-width: 60px !important;
  padding: 0.3rem 0.5rem !important;
  text-align: center;
  font-weight: 700;
  color: var(--vlan1001);
}

/* OLT Progress Section */
.olt-progress-section {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.olt-progress-section h2 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.olt-progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.olt-progress-item {
  background: var(--bg-dark);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid var(--border);
}

.olt-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.olt-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.olt-counts {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.olt-progress-bar {
  height: 8px;
  background: var(--bg-card-hover);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.olt-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #22c55e);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.olt-pendentes {
  font-size: 0.75rem;
  color: var(--vlanOther);
  font-weight: 500;
}

/* Modal VLAN Alvo */
.modal-vlan-alvo {
  color: var(--vlan1001);
  font-weight: 700;
}
