:root {
  --bg: #050814;
  --panel: #0b1224;
  --panel-2: #101a31;
  --text: #e9f7ff;
  --muted: #8ca3b8;
  --cyan: #00e5ff;
  --blue: #2878ff;
  --danger: #ff3864;
  --warning: #ffc857;
  --line: rgba(0, 229, 255, .18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(40, 120, 255, .16), transparent 32%),
    radial-gradient(circle at 70% 20%, rgba(0, 229, 255, .12), transparent 28%),
    var(--bg);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(7, 12, 26, .88);
  padding: 24px;
}

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

.brand strong { display: block; letter-spacing: .04em; }
.brand small { color: var(--muted); }

.brand-logo {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border: 1px solid rgba(168, 85, 247, .62);
  border-radius: 50%;
  box-shadow: 0 0 22px rgba(168, 85, 247, .36), 0 0 14px rgba(0, 229, 255, .18);
}

.pulse {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 24px var(--cyan);
}

.nav-btn {
  width: 100%;
  border: 1px solid transparent;
  color: var(--muted);
  background: transparent;
  text-align: left;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.nav-btn.active,
.nav-btn:hover {
  color: var(--text);
  border-color: var(--line);
  background: linear-gradient(90deg, rgba(0, 229, 255, .14), rgba(40, 120, 255, .08));
}

.workspace {
  min-width: 0;
  padding: 28px;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 24px;
}

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

h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; }
h3 { font-size: 16px; margin-bottom: 14px; }
p, small, span { color: var(--muted); }

.login-panel {
  min-height: 70vh;
  display: grid;
  place-items: center;
}

.login-box,
.tool-panel,
.data-panel,
.stats-grid article {
  border: 1px solid var(--line);
  background: rgba(11, 18, 36, .84);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .24);
}

.login-box {
  width: min(420px, 100%);
  padding: 28px;
}

.login-box h2 { margin-bottom: 18px; }
.form-control {
  color: var(--text);
  background: #16233d;
  border: 1px solid rgba(140, 190, 220, .42);
  margin-bottom: 12px;
}

.form-control::placeholder {
  color: #a9bed4;
  opacity: 1;
}

.form-control:focus {
  color: var(--text);
  background: #192946;
  border-color: var(--cyan);
  box-shadow: 0 0 0 .2rem rgba(0, 229, 255, .14);
}

.field-label {
  display: block;
  color: #d9f4ff;
  font-size: 13px;
  font-weight: 700;
  margin: 10px 0 6px;
}

.panel-divider {
  border-color: rgba(0, 229, 255, .16);
  margin: 18px 0;
}

.combo {
  position: relative;
  margin-bottom: 12px;
}

.combo-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  background: #16233d;
  border: 1px solid rgba(140, 190, 220, .42);
  border-radius: 6px;
  padding: 9px 12px;
  min-height: 38px;
}

.combo.open .combo-trigger,
.combo-trigger:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 .2rem rgba(0, 229, 255, .14);
  outline: 0;
}

.combo-arrow {
  color: var(--cyan);
}

.combo-menu {
  display: none;
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  overflow: hidden;
  border: 1px solid rgba(0, 229, 255, .42);
  border-radius: 8px;
  background: #0b1629;
  box-shadow: 0 18px 45px rgba(0, 0, 0, .46);
  max-height: 230px;
  overflow: auto;
}

.combo.open .combo-menu {
  display: grid;
}

.combo-option {
  border: 0;
  color: #dff8ff;
  background: transparent;
  text-align: left;
  padding: 11px 14px;
}

.combo-option:disabled {
  color: #7e94aa;
  cursor: not-allowed;
}

.combo-option:not(:disabled):hover,
.combo-option.active {
  color: #05111f;
  background: linear-gradient(90deg, #00e5ff, #35a7ff);
}

.btn-outline-danger {
  border-color: rgba(255, 56, 100, .72);
  color: #ff8da4;
}

.btn-outline-danger:hover {
  border-color: #ff3864;
  background: #ff3864;
  color: #fff;
}

.btn-outline-light {
  border-color: rgba(217, 244, 255, .55);
  color: #d9f4ff;
}

.btn-outline-light:hover {
  border-color: var(--cyan);
  background: rgba(0, 229, 255, .16);
  color: #fff;
}

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  width: min(560px, calc(100vw - 36px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast-item {
  opacity: 0;
  transform: translateY(12px);
  border: 1px solid rgba(0, 229, 255, .32);
  border-left: 4px solid var(--cyan);
  border-radius: 8px;
  color: var(--text);
  background: rgba(11, 18, 36, .96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .42);
  padding: 14px 16px;
  transition: opacity .2s ease, transform .2s ease;
}

.toast-item.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-item.success { border-left-color: var(--cyan); }
.toast-item.warning { border-left-color: var(--warning); }
.toast-item.danger { border-left-color: var(--danger); }

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  background: rgba(3, 7, 18, .72);
}

.confirm-box {
  width: min(440px, calc(100vw - 36px));
  border: 1px solid rgba(0, 229, 255, .34);
  border-radius: 8px;
  background: #0b1224;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .58);
  padding: 22px;
}

.confirm-box h3 {
  margin-bottom: 10px;
  font-size: 18px;
}

.confirm-box p {
  margin-bottom: 18px;
}

.confirm-box .form-control {
  margin-bottom: 6px;
}

.form-error {
  display: block;
  min-height: 18px;
  color: #ff8da4;
  margin-bottom: 14px;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.client-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.client-title h2 {
  margin-bottom: 4px;
}

.client-login {
  min-height: 64vh;
  display: grid;
  place-items: center;
}

.client-login-box {
  border-color: rgba(0, 229, 255, .28);
}

.client-login-box p {
  margin-bottom: 18px;
}

.client-panel {
  min-width: 0;
}

.client-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.client-summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 18, 36, .72);
  padding: 14px;
}

.client-summary span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.client-summary strong {
  display: block;
  color: var(--cyan);
  font-size: 26px;
  margin-top: 4px;
}

.client-license-card {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(140, 190, 220, .22);
  border-radius: 8px;
  background: rgba(16, 26, 49, .72);
  padding: 16px;
}

.client-license-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.client-license-main span,
.client-license-meta span,
.client-ip-inline label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.client-license-main strong {
  font-size: 20px;
}

.client-license-meta {
  display: grid;
  grid-template-columns: minmax(110px, .7fr) minmax(190px, 1fr) minmax(210px, 1fr);
  gap: 12px;
}

.client-license-meta div {
  min-width: 0;
  border: 1px solid rgba(140, 190, 220, .14);
  border-radius: 8px;
  background: rgba(11, 18, 36, .42);
  padding: 11px;
}

.client-license-meta strong,
.client-license-meta code {
  display: block;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-license-meta code {
  color: #ff5ccf;
}

.client-ip-inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.client-ip-inline label {
  grid-column: 1 / -1;
}

.client-ip-inline .form-control {
  margin-bottom: 0;
}

.current-ip-label {
  min-height: 38px;
  display: flex;
  align-items: center;
  overflow-wrap: anywhere;
  color: #dff8ff;
  background: rgba(16, 26, 49, .72);
  border: 1px solid rgba(140, 190, 220, .22);
  border-radius: 6px;
  padding: 8px 12px;
}

.client-reset-payment {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  border: 1px solid rgba(255, 200, 87, .38);
  border-radius: 8px;
  background: rgba(16, 26, 49, .72);
  padding: 12px;
}

.client-reset-payment img {
  width: 160px;
  height: 160px;
  border-radius: 8px;
  background: #fff;
}

.client-reset-payment strong {
  display: block;
  color: #d9f4ff;
  margin-bottom: 8px;
}

.client-reset-payment textarea {
  min-height: 84px;
}

.pix-preview {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  align-items: start;
  border: 1px solid rgba(0, 229, 255, .24);
  border-radius: 8px;
  background: rgba(16, 26, 49, .62);
  padding: 14px;
  margin-bottom: 16px;
}

.pix-preview img {
  width: 180px;
  height: 180px;
  border-radius: 8px;
  background: #fff;
}

.pix-preview textarea {
  min-height: 90px;
  margin-top: 10px;
}

.payment-note {
  display: block;
  color: #9ff4ff;
  font-size: 12px;
  margin-top: 6px;
}

.manual-payment-card {
  display: grid;
  grid-column: 1 / -1;
  gap: 10px;
}

.manual-payment-card strong {
  color: #d9f4ff;
}

.manual-payment-card span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

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

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

.obf-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 13px;
}

.obf-options label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.obf-select {
  color: var(--text);
  background: #16233d;
  border: 1px solid rgba(140, 190, 220, .42);
  border-radius: 6px;
  padding: 4px 8px;
}

.code-area {
  width: 100%;
  min-height: 520px;
  resize: vertical;
  color: #dff8ff;
  background: #08111f;
  border: 1px solid rgba(140, 190, 220, .32);
  border-radius: 8px;
  padding: 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.45;
}

.code-area:focus {
  outline: 0;
  border-color: var(--cyan);
  box-shadow: 0 0 0 .2rem rgba(0, 229, 255, .14);
}

.obf-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.obf-progress {
  border: 1px solid rgba(0, 229, 255, .24);
  border-radius: 8px;
  background: rgba(8, 17, 31, .82);
  padding: 12px;
  margin-top: 12px;
}

.obf-progress-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.obf-progress-top span {
  color: #d9f4ff;
  font-size: 13px;
  font-weight: 700;
}

.obf-progress-top strong {
  color: var(--cyan);
  font-size: 13px;
}

.obf-progress-track {
  position: relative;
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: rgba(140, 190, 220, .14);
}

.obf-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #00e5ff, #2878ff, #8b5cf6);
  box-shadow: 0 0 18px rgba(0, 229, 255, .42);
  transition: width .18s ease;
}

.obf-progress-bar.running {
  width: 46%;
  animation: progressSweep 1.1s ease-in-out infinite;
}

@keyframes progressSweep {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(240%); }
}

.file-hint {
  color: #7ee8ff;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}

@media (max-width: 760px) {
  .client-summary,
  .client-license-meta,
  .client-ip-inline,
  .obfuscator-grid {
    grid-template-columns: 1fr;
  }
}

.client-nav-link {
  display: block;
  text-decoration: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 14px;
}

.stats-grid article { padding: 18px; }
.stats-grid strong {
  display: block;
  font-size: 30px;
  color: var(--cyan);
  margin-top: 8px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.metric-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 18, 36, .72);
  padding: 18px;
  min-width: 0;
}

.metric-panel.wide {
  grid-column: span 2;
}

.status-bars,
.mini-grid,
.highlight-list {
  display: grid;
  gap: 10px;
}

.mini-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.status-bars div,
.mini-grid div,
.highlight-list div,
.compact-list div {
  border: 1px solid rgba(140, 190, 220, .14);
  border-radius: 8px;
  background: rgba(16, 26, 49, .62);
  padding: 12px;
}

.status-bars span,
.mini-grid span,
.highlight-list span,
.compact-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-bars strong,
.mini-grid strong,
.highlight-list strong {
  display: block;
  color: var(--cyan);
  font-size: 22px;
  margin-top: 4px;
}

.compact-list {
  display: grid;
  gap: 8px;
}

.compact-list strong {
  display: block;
  color: var(--text);
}

.muted-note {
  color: var(--muted);
  margin: 0;
}

.view { display: none; }
.view.active { display: block; }

/* Database Management Styles */
.db-container {
  display: flex;
  gap: 1rem;
  height: calc(100vh - 180px);
}

.db-sidebar {
  width: 280px;
  min-width: 250px;
  background: #252730;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.db-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid #333645;
}

.db-sidebar-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #d9f4ff;
}

.db-tree {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.db-database-name {
  padding: 0.75rem 1rem;
  background: #1e1f25;
  border-radius: 6px;
  color: #fff;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.db-tables-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-left: 0.75rem;
}

.db-table-item {
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  color: #a5b4fc;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.db-table-item:hover {
  background: rgba(100, 116, 139, 0.2);
}

.db-table-item.active {
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.15), rgba(38, 99, 235, 0.1));
  color: #00e5ff;
}

.db-main {
  flex: 1;
  background: #252730;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.db-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #333645;
}

.db-header h4 {
  margin: 0;
  color: #d9f4ff;
  font-size: 1.15rem;
}

.db-actions {
  display: flex;
  gap: 0.5rem;
}

.db-table-container {
  flex: 1;
  overflow: auto;
  padding: 1rem;
}

.db-table-container table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

.db-table-container th {
  background: #1e1f25;
  padding: 0.75rem 1rem;
  text-align: left;
  color: #00e5ff;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  border-bottom: 2px solid #333645;
  position: sticky;
  top: 0;
  z-index: 10;
}

.db-table-container td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #333645;
  color: #cbd5e1;
  font-size: 0.9rem;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.db-table-container tr:hover td {
  background: rgba(0, 229, 255, 0.05);
}

.db-action-buttons {
  display: flex;
  gap: 0.5rem;
}

.db-action-buttons .btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.db-add-form {
  margin-top: 0;
  padding: 1rem 1.25rem;
  border-top: 1px solid #333645;
  background: #1e1f25;
}

.db-add-form h5 {
  margin: 0 0 1rem 0;
  color: #d9f4ff;
}

.db-add-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.db-add-buttons {
  margin-top: 1.25rem;
  display: flex;
  gap: 0.75rem;
}

.db-add-grid .form-control {
  margin-bottom: 0;
}

.db-add-grid label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: #94a3b8;
}

/* Empty State */
.db-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #64748b;
}

.db-empty svg {
  width: 80px;
  height: 80px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.panel-row {
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.tool-panel,
.data-panel {
  min-width: 0;
  padding: 18px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  max-height: 68vh;
}

table {
  color: var(--text) !important;
  min-width: 720px;
}
td, th { border-color: rgba(140, 163, 184, .16) !important; vertical-align: middle; }
th {
  color: #d9f4ff;
  font-size: 13px;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.empty-state {
  border: 1px dashed rgba(140, 190, 220, .28);
  border-radius: 8px;
  color: var(--muted);
  padding: 26px;
  text-align: center;
}

.license-list {
  display: grid;
  gap: 10px;
}

.license-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) minmax(150px, .9fr) minmax(210px, 1.1fr) 90px 190px;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(140, 190, 220, .18);
  border-radius: 8px;
  background: rgba(16, 26, 49, .72);
}

.license-block {
  min-width: 0;
}

.license-block span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.license-block strong,
.license-block code,
.license-block small {
  display: block;
}

.license-block strong {
  color: var(--text);
  line-height: 1.35;
}

.license-block small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.script-name {
  color: #7ee8ff !important;
}

.key-block code {
  color: #ff5ccf;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-block .badge {
  width: fit-content;
}

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

.badge-active {
  background: #18ff72;
  color: #03160b;
  box-shadow: 0 0 18px rgba(24, 255, 114, .34);
}

.badge-pending {
  background: #ffc857;
  color: #1d1300;
  box-shadow: 0 0 18px rgba(255, 200, 87, .28);
}

.badge-inactive,
.badge-suspended,
.badge-expired,
.badge-blacklisted {
  background: #ff174d;
  color: #fff;
  box-shadow: 0 0 18px rgba(255, 23, 77, .34);
}

.log-stream {
  display: grid;
  gap: 10px;
  max-height: 72vh;
  overflow: auto;
}

.log-item {
  padding: 12px;
  background: rgba(16, 26, 49, .78);
  border-left: 3px solid var(--cyan);
  border-radius: 6px;
}

.log-item.critical { border-left-color: var(--danger); }
.log-item.warning { border-left-color: var(--warning); }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    display: flex;
    gap: 8px;
    overflow: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand { min-width: 190px; margin-bottom: 0; }
  .nav-btn { width: auto; white-space: nowrap; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .metric-panel.wide { grid-column: auto; }
  .panel-row { grid-template-columns: 1fr; }
  .license-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .license-actions {
    justify-content: flex-start;
  }
}
