:root {
  --bg: #0f172a;
  --bg-soft: #020617;
  --card: #0b1220;
  --accent: #06b6d4;
  --accent-strong: #22d3ee;
  --text: #e5e7eb;
  --text-soft: #9ca3af;
  --text-muted: #6b7280;
  --danger: #f97373;
  --success: #22c55e;
  --warning: #eab308;
  --border: #1f2937;
  --radius: 16px;
}

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

body {
  font-family: "Inter", system-ui, sans-serif;
  background: radial-gradient(circle at top, #1e293b 0, #020617 45%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* LAYOUT */
.layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: 260px;
  background: rgba(15, 23, 42, 0.98);
  border-right: 1px solid rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(18px);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: radial-gradient(circle at 30% 0%, var(--accent-strong), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(34, 211, 238, 0.45);
  font-weight: 800;
  font-size: 18px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-text span:first-child {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent-strong);
  font-weight: 600;
}

.brand-text span:last-child {
  font-size: 13px;
  color: var(--text-soft);
}

.sidebar-section-title {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #6b7280;
  margin: 14px 0 8px;
}

.nav {
  list-style: none;
  margin-bottom: 10px;
}

.nav-item {
  margin-bottom: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-soft);
  text-decoration: none;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-link i {
  font-size: 13px;
  width: 18px;
  text-align: center;
}

.nav-link span {
  flex: 1;
}

.nav-link.active,
.nav-link:hover {
  color: var(--accent-strong);
  background: rgba(15, 118, 110, 0.2);
  border-color: rgba(45, 212, 191, 0.3);
}

.nav-link .badge {
  background: rgba(15, 23, 42, 0.8);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  color: #9ca3af;
}

/* TOAST NOTIFICATIONS */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  pointer-events: all;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease;
  min-width: 300px;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--accent); }

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--accent); }

.toast-content {
  flex: 1;
}

.toast-message {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 16px;
  opacity: 0.6;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.toast-close:hover {
  opacity: 1;
}

/* MAIN CONTENT */
.main {
  flex: 1;
  padding: 16px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.page-title h1 {
  font-size: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.page-title small {
  font-size: 12px;
  color: var(--text-soft);
}

.btn {
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  padding: 7px 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: var(--accent);
  color: #0f172a;
  font-weight: 600;
  transition: all 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

.btn-secondary {
  background: rgba(15, 23, 42, 0.5);
  color: var(--text);
  border-color: rgba(148, 163, 184, 0.4);
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  padding: 7px 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: rgba(15, 23, 42, 0.9);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 6px 8px;
  font-size: 14px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-strong);
}

.card {
  background: radial-gradient(circle at 0 0, rgba(34, 211, 238, 0.12), transparent 55%), #020617;
  border-radius: var(--radius);
  border: 1px solid rgba(148, 163, 184, 0.3);
  padding: 20px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.8);
}

.card-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #9ca3af;
  margin-bottom: 10px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.summary-card {
  background: rgba(15, 23, 42, 0.96);
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  padding: 16px;
  position: relative;
}

.summary-label {
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  margin-bottom: 8px;
}

.summary-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--accent-strong);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 10px;
}

.table thead {
  background: rgba(15, 23, 42, 0.9);
}

.table th,
.table td {
  padding: 10px;
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
  text-align: left;
}

.table th {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #9ca3af;
  font-weight: 500;
  font-size: 11px;
}

.table tbody tr:hover {
  background: rgba(15, 23, 42, 0.6);
}

.badge-status {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-success,
.badge-aprovada,
.badge-producao {
  color: var(--success);
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(22, 163, 74, 0.1);
}

.badge-warning,
.badge-pendente,
.badge-homologacao {
  color: var(--warning);
  border-color: rgba(234, 179, 8, 0.5);
  background: rgba(202, 138, 4, 0.1);
}

.badge-danger,
.badge-bloqueada {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.5);
  background: rgba(248, 113, 113, 0.08);
}

.badge-muted {
  color: var(--text-soft);
  border-color: rgba(156, 163, 175, 0.5);
  background: rgba(107, 114, 128, 0.1);
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

/* MODAL */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-soft);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(248, 113, 113, 0.1);
  color: var(--danger);
}

/* HIDDEN SECTIONS */
.section {
  display: none;
}

.section.active {
  display: block;
}

/* LOGIN SCREEN */
.login-screen {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #1e293b 0, #020617 45%);
}

.login-screen.hidden {
  display: none;
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 40px;
  background: rgba(15, 23, 42, 0.98);
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-brand-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 20px;
  background: radial-gradient(circle at 30% 0%, var(--accent-strong), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(34, 211, 238, 0.45);
  font-weight: 800;
  font-size: 28px;
}

.login-brand h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.login-brand p {
  font-size: 14px;
  color: var(--text-soft);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.login-form label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.login-form input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.3s;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

.login-btn {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.4);
}

.login-btn:active {
  transform: translateY(0);
}

.login-error {
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(249, 115, 115, 0.1);
  border: 1px solid rgba(249, 115, 115, 0.3);
  color: var(--danger);
  font-size: 13px;
  display: none;
}

.login-error.show {
  display: block;
}

/* Desktop: Show table, hide mobile cards */
.table-wrapper {
  display: block;
}

.mobile-cards {
  display: none;
}

/* Mobile Menu Button */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1001;
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: 12px;
  width: 48px;
  height: 48px;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(34, 211, 238, 0.4);
  transition: all 0.2s ease;
}

.mobile-menu-btn:active {
  transform: scale(0.95);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 999;
  backdrop-filter: blur(4px);
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
    width: 280px;
  }

  .sidebar.active {
    left: 0;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .main {
    width: 100%;
    padding: 80px 16px 16px 16px;
  }

  .topbar {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .login-container {
    margin: 20px;
    padding: 32px 24px;
  }

  /* Mobile: Hide table, show cards */
  .table-wrapper {
    display: none;
  }

  .mobile-cards {
    display: block;
  }

  .mobile-card {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
  }

  .mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 8px;
  }

  .mobile-card-label {
    font-size: 11px;
    color: var(--text-soft);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 80px;
  }

  .mobile-card-value {
    font-size: 13px;
    color: var(--text);
    text-align: right;
    flex: 1;
    word-break: break-word;
  }

  .mobile-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
  }

  .table {
    font-size: 12px;
  }

  .card {
    padding: 16px;
  }

  .modal-content {
    padding: 20px;
    max-width: 100%;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  /* Dashboard Header Responsivo */
  .dashboard-header {
    flex-direction: column;
    gap: 12px;
    padding: 16px;
  }

  .header-search {
    display: none; /* Esconder busca em mobile */
  }

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

  .user-profile {
    font-size: 12px;
  }

  .user-avatar {
    width: 32px;
    height: 32px;
  }

  /* Cards de Métricas Responsivo */
  .metric-cards {
    grid-template-columns: 1fr !important; /* Coluna única */
  }

  .metric-card {
    padding: 16px;
  }

  .metric-value {
    font-size: 24px;
  }

  /* Tabelas Responsivas */
  .dash-section table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .dash-section table td,
  .dash-section table th {
    font-size: 12px;
    padding: 8px;
  }

  /* Clientes - Modo Card no Mobile */
  .clientes-table-view {
    display: none !important;
  }

  .clientes-card-view {
    display: block !important;
  }

  .cliente-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
  }

  .cliente-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }

  .cliente-card-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    margin-bottom: 4px;
  }

  .cliente-card-subtitle {
    font-size: 12px;
    color: var(--text-soft);
  }

  .cliente-card-body {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
  }

  .cliente-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
  }

  .cliente-card-label {
    color: var(--text-soft);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .cliente-card-value {
    color: var(--text);
    font-weight: 500;
  }

  .cliente-card-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }

  .cliente-card-actions button {
    flex: 1;
    padding: 8px;
    font-size: 12px;
  }
}

/* Tablet - 768px ~ 1024px */
@media (max-width: 1024px) {
  .metric-cards {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .header-search input {
    max-width: 200px;
  }

  .dash-section {
    padding: 20px;
  }

  /* Tabela mais compacta */
  .table {
    font-size: 13px;
  }

  .table th, .table td {
    padding: 10px 8px;
  }
}

/* Desktop pequeno - 1024px ~ 1280px */
@media (max-width: 1280px) {
  .main-content {
    padding: 24px;
  }

  .metric-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}
