:root {
  --bg-gradient: radial-gradient(circle at top right, #1f2937, #030712);
  --surface: rgba(31, 41, 55, 0.55);
  --surface-hover: rgba(55, 65, 81, 0.5);
  --surface-border: rgba(255, 255, 255, 0.08);
  --ink: #f3f4f6;
  --muted: #9ca3af;
  --line: rgba(255, 255, 255, 0.06);
  --brand: #3b82f6;
  --brand-glow: rgba(59, 130, 246, 0.5);
  --brand-grad: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --cyan: #06b6d4;
  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.3);
  --amber: #f59e0b;
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.3);
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Outfit', "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg-gradient);
  background-attachment: fixed;
}

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

button,
input,
select,
textarea {
  font: inherit;
}

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

/* Sidebar */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 292px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 16px;
  color: #d1d5db;
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--surface-border);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  z-index: 10;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--brand-grad);
  color: #fff;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 15px var(--brand-glow);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.06em;
  background: -webkit-linear-gradient(#fff, #9ca3af);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand p,
.side-status small,
.sidebar-link small {
  margin: 3px 0 0;
  color: #6b7280;
  font-size: 12px;
}

.sidebar-nav {
  display: grid;
  gap: 7px;
  overflow: auto;
  padding-right: 4px;
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
}

.sidebar-link {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 11px;
  min-height: 54px;
  padding: 9px 10px;
  color: #9ca3af;
  text-decoration: none;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  transition: all 0.2s ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  transform: translateX(4px);
}

.sidebar-link.active {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.2);
  color: #fff;
  box-shadow: inset 3px 0 var(--brand);
}

.sidebar-link.accent {
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.15), transparent);
  border-left: 2px solid #8b5cf6;
}
.sidebar-link.accent:hover {
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.25), transparent);
}

.nav-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #d1d5db;
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  font-weight: 800;
  transition: all 0.2s;
}

.sidebar-link:hover .nav-icon,
.sidebar-link.active .nav-icon {
  background: var(--brand-grad);
  color: white;
  box-shadow: 0 2px 10px var(--brand-glow);
}

.sidebar-link b {
  display: block;
  font-size: 15px;
  font-weight: 500;
}

.side-status {
  display: none;
  margin-top: auto;
  padding: 15px;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
}

.side-status strong {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  color: #10b981;
}

.content {
  width: calc(100% - 292px);
  margin-left: 292px;
  padding: 24px;
}

.topbar {
  position: relative;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  min-height: 84px;
  padding: 16px 24px;
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  background: rgba(17, 24, 39, 0.4);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.title-wrap span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand);
}

.title-wrap h2 {
  margin: 4px 0 2px;
  font-size: 26px;
  font-weight: 700;
}

.title-wrap p {
  display: none;
}

.api-panel {
  display: none;
  gap: 7px;
}

.api-panel label,
label {
  color: #9ca3af;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}

.api-row,
.form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.api-row input {
  min-width: 0;
}

.view-host {
  padding-top: 24px;
  animation: fadeUp 0.4s ease-out forwards;
}

/* Glassmorphism Cards */
.card,
.config-box {
  margin-bottom: 20px;
  padding: 24px;
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fadeUp 0.5s ease-out forwards;
}

.card h2,
.config-box h2 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 600;
}

.card h3 {
  margin: 0 0 10px;
  font-weight: 500;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.section-title-row h2 {
  margin: 0;
}

.help-text {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
  outline: none;
  transition: all 0.2s ease;
  font-size: 15px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 4px var(--brand-glow);
}

input[readonly] {
  color: #6b7280;
  background: rgba(0, 0, 0, 0.1);
  cursor: not-allowed;
}

/* Beautiful Buttons */
button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 20px;
  cursor: pointer;
  color: #fff;
  background: var(--brand-grad);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.2);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

button:active {
  transform: translateY(0);
}

button.secondary {
  color: #d1d5db;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}
button.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

button.warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.2);
}
button.warning:hover {
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

button.success {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.2);
}
button.success:hover {
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

button.danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.2);
}
button.danger:hover {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  background: rgba(31, 41, 55, 0.85);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: fadeUp 0.3s ease-out forwards;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.icon-button {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.15);
}

.table-wrap::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}
.table-wrap::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 0 0 var(--radius) var(--radius);
}
.table-wrap::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.3);
  border-radius: 10px;
}
.table-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(156, 163, 175, 0.6);
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: #9ca3af;
  background: rgba(0, 0, 0, 0.2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

tbody tr {
  transition: background 0.2s;
}

tbody tr:hover td {
  background: rgba(255, 255, 255, 0.04);
}

/* Glowing Badges */
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(156, 163, 175, 0.1);
  color: #d1d5db;
  border: 1px solid rgba(255,255,255,0.05);
}

.badge.active {
  background: var(--green-glow);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.2);
  box-shadow: 0 0 10px var(--green-glow);
}

.badge.inactive {
  background: var(--red-glow);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.2);
  box-shadow: 0 0 10px var(--red-glow);
}

/* Messages */
.message {
  margin: 16px 0 0;
  padding: 14px 18px;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius);
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.1);
  line-height: 1.5;
  backdrop-filter: blur(4px);
}

.message.error {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
}

.message.success {
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.1);
}

.hidden {
  display: none !important;
}

.technical-card-hidden {
  display: none;
}

/* Paginador */
.table-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 16px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
}

.pager-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #9ca3af;
  font-size: 13px;
  white-space: nowrap;
}

.pager-summary strong {
  color: #f3f4f6;
  font-weight: 600;
}

.pager-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.pager-actions button {
  min-height: 36px;
  padding: 6px 12px;
  color: #d1d5db;
  background: rgba(255, 255, 255, 0.05);
  font-size: 13px;
  box-shadow: none;
  font-weight: 500;
}

.pager-actions button:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  transform: translateY(-1px);
}

.pager-actions button.active {
  color: #fff;
  background: var(--brand-grad);
  box-shadow: 0 2px 10px var(--brand-glow);
}

.pager-actions button:disabled {
  opacity: 0.3;
}

.pager-ellipsis {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  color: #6b7280;
  font-weight: 900;
}

/* Upload zone */
.import-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 20px;
}

.drop-zone {
  display: grid;
  gap: 12px;
  align-content: center;
  min-height: 220px;
  padding: 24px;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
  text-align: center;
}
.drop-zone:hover {
  border-color: var(--brand);
  background: rgba(59, 130, 246, 0.05);
}

.drop-zone input {
  padding: 10px;
  background: rgba(255,255,255,0.05);
  margin-top: 10px;
}

.result-panel {
  min-height: 220px;
  padding: 20px;
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.2);
}

.result-panel strong {
  display: block;
  margin-bottom: 10px;
  color: var(--brand);
}

.result-panel ul {
  margin: 10px 0 0;
  padding-left: 20px;
  color: #d1d5db;
}

#mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.7);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 9;
}

/* Responsive */
@media (max-width: 1080px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .content {
    width: 100%;
    margin-left: 0;
    padding: 16px;
  }

  #btn-mobile-menu {
    display: inline-flex !important;
  }
}

@media (max-width: 760px) {
  .form-grid,
  .import-grid,
  .sidebar-nav {
    grid-template-columns: 1fr;
  }

  .api-row,
  .form-row {
    align-items: stretch;
    flex-direction: column;
  }

  .actions button,
  .api-row button {
    width: 100%;
  }

  .section-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .table-pager {
    align-items: stretch;
    flex-direction: column;
  }

  .pager-actions {
    justify-content: flex-start;
  }
}
