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

:root {
  --color-primary: #1E293B;
  --color-secondary: #334155;
  --color-accent: #2563EB;
  --color-background: #000000;
  --color-foreground: #F8FAFC;
  --color-muted: #1E293B;
  --color-border: #334155;
  --color-danger: #EF4444;
  --color-warning: #F59E0B;
  --color-info: #3B82F6;
  --font-heading: 'Space Grotesk', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --sidebar-width: 224px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-background);
  color: var(--color-foreground);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Dashboard Layout */
.dashboard {
  display: flex;
  min-height: 100vh;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-muted);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-accent);
  min-width: 0;
}

.logo svg {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
}

.logo span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.highlight {
  color: var(--color-foreground);
}

.subtitle {
  margin-top: 6px;
  color: #94A3B8;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav,
.nav-menu {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  list-style: none;
}

.nav-menu li {
  min-width: 0;
}

.nav-item,
.nav-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 10px 12px;
  color: var(--color-foreground);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 150ms ease;
  min-width: 0;
}

.nav-menu a svg,
.nav-item svg {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
}

.nav-item:hover,
.nav-menu a:hover {
  background: var(--color-secondary);
}

.nav-item.active,
.nav-menu li.active a {
  background: var(--color-accent);
  color: var(--color-background);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--color-border);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  max-width: 1440px;
  padding: 20px;
  min-height: 100vh;
}

/* Header */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--color-border);
}

.header-left,
.header-right {
  min-width: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  line-height: 1.2;
  margin-bottom: 4px;
}

.page-subtitle {
  color: #94A3B8;
  font-size: 0.9rem;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.user-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.user-role {
  color: #94A3B8;
  font-size: 0.78rem;
}

.header-info h1 {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.header-date {
  color: var(--color-border);
  font-size: 0.875rem;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  background: var(--color-accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--color-background);
}

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

.stat-card {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.3s ease;
}

.stat-item {
  min-height: 84px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  background: rgba(30, 41, 59, 0.35);
}

.stat-card:nth-child(1) { background: rgba(59, 130, 246, 0.1); border-color: rgba(59, 130, 246, 0.3); }
.stat-card:nth-child(1) .stat-value { color: #3B82F6; }
.stat-card:nth-child(1) .stat-label { color: #3B82F6; }

.stat-card:nth-child(2) { background: rgba(34, 197, 94, 0.1); border-color: rgba(34, 197, 94, 0.3); }
.stat-card:nth-child(2) .stat-value { color: #22C55E; }
.stat-card:nth-child(2) .stat-label { color: #22C55E; }

.stat-card:nth-child(3) { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.3); }
.stat-card:nth-child(3) .stat-value { color: #EF4444; }
.stat-card:nth-child(3) .stat-label { color: #EF4444; }

.stat-card:nth-child(4) { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.3); }
.stat-card:nth-child(4) .stat-value { color: #F59E0B; }
.stat-card:nth-child(4) .stat-label { color: #F59E0B; }

.stat-card:nth-child(5) { background: rgba(139, 92, 246, 0.1); border-color: rgba(139, 92, 246, 0.3); }
.stat-card:nth-child(5) .stat-value { color: #2563EB; }
.stat-card:nth-child(5) .stat-label { color: #2563EB; }

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.total {
  background: rgba(59, 130, 246, 0.15);
  color: var(--color-info);
}

.stat-icon.active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--color-accent);
}

.stat-icon.blocked {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
}

.stat-icon.expired {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
}

.stat-icon.services {
  background: rgba(139, 92, 246, 0.15);
  color: #2563EB;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 0.875rem;
  opacity: 0.8;
}

/* Cards */
.card {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 18px;
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--color-border);
}

.card-header h2,
.card-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
}

.card-actions {
  display: flex;
  gap: 12px;
}

.card-body {
  padding: 18px;
}

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-foreground);
}

.form-group input,
.form-group select {
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--color-foreground);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  transition: border-color 150ms ease;
  width: 100%;
  min-width: 0;
}

.form-group small {
  line-height: 1.35;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-accent);
}

.form-group input::placeholder {
  color: var(--color-border);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 16px;
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 150ms ease;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.btn-outline {
  background: transparent;
  color: var(--color-foreground);
  border: 1px solid var(--color-border);
}

.btn-outline:hover {
  border-color: var(--color-accent);
}

.alert {
  border-radius: 8px;
  border: 1px solid var(--color-border);
  margin-bottom: 16px;
  padding: 12px 14px;
}

.alert-sucesso {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
  color: #86EFAC;
}

.maintenance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.maintenance-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 14px;
  background: rgba(30, 41, 59, 0.32);
}

.maintenance-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(34, 197, 94, 0.12);
  color: var(--color-accent);
}

.maintenance-icon svg {
  width: 20px;
  height: 20px;
}

.maintenance-info {
  min-width: 0;
}

.maintenance-info h4 {
  font-size: 0.95rem;
  line-height: 1.25;
}

.maintenance-info p {
  color: #94A3B8;
  font-size: 0.82rem;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.7);
  padding: 10px 0;
}

.info-label {
  color: #94A3B8;
  font-size: 0.88rem;
}

.info-value {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
  font-weight: 600;
  font-size: 0.88rem;
}

.card-body img[alt="QR Code 2FA"] {
  width: min(220px, 100%);
  height: auto;
}

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

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--color-secondary);
  color: var(--color-foreground);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  border-color: var(--color-accent);
}

/* Search Box */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0 12px;
}

.search-box svg {
  color: var(--color-border);
}

.search-box input {
  background: transparent;
  border: none;
  padding: 10px 0;
  color: var(--color-foreground);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  width: 250px;
}

.search-box input:focus {
  outline: none;
}

.search-box input::placeholder {
  color: var(--color-border);
}

/* Table */
.table-responsive {
  overflow-x: auto;
}

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

.data-table th,
.data-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  font-family: var(--font-heading);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 14px 16px;
}

.data-table th:nth-child(1) { color: #64748B; }
.data-table th:nth-child(2) { color: #3B82F6; }
.data-table th:nth-child(3) { color: #22C55E; }
.data-table th:nth-child(4) { color: #F59E0B; }
.data-table th:nth-child(5) { color: #EF4444; }
.data-table th:nth-child(6) { color: #2563EB; }
.data-table th:nth-child(7) { color: #06B6D4; }
.data-table th:nth-child(8) { color: #EC4899; }

.data-table tbody tr {
  transition: background 150ms ease;
}

.data-table tbody tr:hover {
  background: rgba(51, 65, 85, 0.3);
}

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

.data-table code {
  background: var(--color-background);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8125rem;
  color: var(--color-accent);
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--color-accent);
}

.status-badge.blocked {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
}

.status-badge.expired {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
}

.online-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.online-badge.on {
  background: rgba(34, 197, 94, 0.15);
  color: var(--color-accent);
}

.online-badge.off {
  background: rgba(100, 116, 139, 0.15);
  color: #64748B;
}

/* Action Buttons */
.actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
}

.action-btn.power {
  color: var(--color-accent);
}

.action-btn.power:hover {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--color-accent);
}

.action-btn.unlock {
  color: var(--color-info);
}

.action-btn.unlock:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--color-info);
}

.action-btn.delete {
  color: var(--color-danger);
}

.action-btn.delete:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--color-danger);
}

/* Responsive */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
  
  .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

@media (max-width: 992px) {
  :root {
    --sidebar-width: 68px;
  }

  .sidebar {
    width: var(--sidebar-width);
    overflow: hidden;
  }
  
  .sidebar .logo span,
  .sidebar .subtitle,
  .sidebar .nav-item span,
  .sidebar .nav-menu a {
    font-size: 0;
  }

  .sidebar .nav-menu a svg {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
  }

  .sidebar .nav-item:not(.active) {
    display: none;
  }
  
  .sidebar .nav-item,
  .sidebar .nav-menu a {
    justify-content: center;
    padding: 12px;
  }
  
  .sidebar .nav-item.active {
    display: flex;
  }
  
  .main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: sticky;
    top: 0;
    bottom: auto;
    width: 100%;
    height: auto;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .layout,
  .dashboard {
    display: block;
  }

  .sidebar-header {
    display: none;
  }

  .sidebar-nav,
  .nav-menu {
    flex-direction: row;
    padding: 8px;
    gap: 6px;
  }

  .nav-menu li {
    flex: 0 0 auto;
  }

  .sidebar .nav-menu a {
    font-size: 0;
    min-width: 44px;
  }

  .sidebar .nav-menu a svg {
    width: 21px;
    height: 21px;
    flex-basis: 21px;
  }
  
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 14px;
  }
  
  .main-header,
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .page-title {
    font-size: 1.25rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  
  .card-actions {
    width: 100%;
    flex-direction: column;
  }
  
  .search-box {
    width: 100%;
  }
  
  .search-box input {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .card-body,
  .card-header {
    padding: 14px;
  }

  .maintenance-item {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .maintenance-item form {
    grid-column: 1 / -1;
  }

  .maintenance-item .btn,
  .form-actions .btn {
    width: 100%;
  }

  .info-item {
    display: block;
  }

  .info-value {
    display: block;
    margin-top: 4px;
    text-align: left;
  }
}

/* Focus States */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}


/* Terans Solutions - paleta azul masculina */
:root {
  --color-accent: #2563EB;
  --color-accent-dark: #1D4ED8;
  --color-success: #16A34A;
}
.btn-primary,
.nav-item.active,
button[type="submit"].btn-primary {
  background: linear-gradient(135deg, #2563EB, #1D4ED8) !important;
  color: #fff !important;
}
.btn-primary:hover,
button[type="submit"].btn-primary:hover {
  background: linear-gradient(135deg, #1D4ED8, #1E40AF) !important;
}
.affiliate-badge,
.user-avatar {
  background: linear-gradient(135deg, #2563EB, #1D4ED8) !important;
}
