:root {
  --bg: #0b0c10;
  --panel: #14151b;
  --soft: #1c1e27;
  --soft-hover: #242733;
  --text: #f5f6f8;
  --muted: #9195a3;
  --purple: #8b35ff;
  --purple-glow: rgba(139, 53, 255, 0.35);
  --purple-dark: #2a124a;
  --border: #252834;
  --border-light: #323646;
  --success: #10b981;
  --warning: #f59e0b;
  --info: #3b82f6;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button, input, select, textarea {
  font: inherit;
}

/* LOGIN SCREEN & AUTH OVERLAY */
#loginScreen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 25%, rgba(139, 53, 255, 0.18), transparent 60%), #0b0c10;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 20px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 38px 34px;
  width: 100%;
  max-width: 430px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 45px rgba(139, 53, 255, 0.12);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #6827f5, #9d00ff, #38bdf8);
}

.login-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.login-brand .pin {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6827f5, #9d00ff);
  display: grid;
  place-items: center;
  font-size: 22px;
  box-shadow: 0 0 25px var(--purple-glow);
  color: #fff;
}

.login-brand strong {
  display: block;
  font-size: 19px;
  letter-spacing: -0.3px;
  color: #fff;
}

.login-brand span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
}

.login-card h2 {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}

.login-card > p {
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 24px;
  line-height: 1.5;
}

.login-alert {
  display: none;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 20px;
  line-height: 1.4;
}

.login-alert.show {
  display: block;
  animation: fadeIn 0.25s ease;
}

.login-form .form-group {
  margin-bottom: 18px;
}

.login-form label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 7px;
  letter-spacing: 0.2px;
}

.login-form input {
  width: 100%;
  padding: 12px 14px;
  background: #0f1016;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  transition: all 0.2s ease;
}

.login-form input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139, 53, 255, 0.2);
  outline: none;
}

.btn-login {
  width: 100%;
  padding: 13px;
  font-size: 14.5px;
  font-weight: 600;
  border-radius: 10px;
  margin-top: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  background: #0e0f15;
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 26px;
  padding: 0 8px;
}

.brand .pin {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6827f5, #9d00ff);
  display: grid;
  place-items: center;
  font-size: 22px;
  box-shadow: 0 0 25px var(--purple-glow);
  color: #fff;
}

.brand strong {
  display: block;
  font-size: 18px;
  letter-spacing: -0.3px;
}

.brand span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

nav button {
  border: 0;
  background: transparent;
  color: #a6abb9;
  text-align: left;
  padding: 11px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.15s ease;
}

nav button:hover {
  background: rgba(139, 53, 255, 0.08);
  color: #fff;
}

nav button.active {
  background: rgba(139, 53, 255, 0.15);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--purple);
}

/* LOGIN SCREEN */
#loginScreen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 20%, rgba(139, 53, 255, 0.15) 0%, rgba(11, 12, 16, 0.98) 70%), #0b0c10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10000;
}

.login-card {
  background: #14151b;
  border: 1px solid var(--border-light);
  border-radius: 20px;
  width: 100%;
  max-width: 440px;
  padding: 36px 32px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(139, 53, 255, 0.1);
  text-align: center;
  position: relative;
}

.login-brand {
  display: inline-flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.login-brand .pin {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #6827f5, #9d00ff);
  display: grid;
  place-items: center;
  font-size: 26px;
  box-shadow: 0 0 30px var(--purple-glow);
  color: #fff;
}

.login-brand strong {
  display: block;
  font-size: 22px;
  letter-spacing: -0.5px;
  text-align: left;
}

.login-brand span {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: block;
  text-align: left;
}

.login-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.login-card p {
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 24px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.login-alert {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  display: none;
  align-items: center;
  gap: 8px;
}

.login-alert.show {
  display: flex;
}

.btn-login {
  width: 100%;
  padding: 12px;
  font-size: 14.5px;
  margin-top: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

/* USER PROFILE IN SIDEBAR */
.sidebar-user {
  margin-top: auto;
  padding: 14px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--purple);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-text {
  overflow: hidden;
  min-width: 0;
}

.sidebar-user-text strong {
  font-size: 13px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-text span {
  font-size: 11px;
  color: var(--muted);
  display: block;
  word-break: break-all;
  line-height: 1.3;
}

.btn-logout {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-logout:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

/* MAIN CONTENT */
main {
  padding: 30px 36px 60px;
  overflow-y: auto;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 20px;
  flex-wrap: wrap;
}

h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

header p {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-wrapper {
  position: relative;
}

.search-wrapper input {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px 10px 36px;
  color: white;
  width: 270px;
  font-size: 13.5px;
  transition: border-color 0.2s;
}

.search-wrapper input:focus {
  outline: none;
  border-color: var(--purple);
}

.search-wrapper svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

button.primary {
  border: 0;
  background: linear-gradient(135deg, #7928ca, #9d00ff);
  color: white;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(157, 0, 255, 0.25);
  transition: transform 0.15s, box-shadow 0.15s;
}

button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(157, 0, 255, 0.4);
}

button.secondary {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s;
}

button.secondary:hover {
  background: var(--soft);
}

button.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

/* VIEWS */
.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KPIS */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpis article, .panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  position: relative;
  transition: border-color 0.2s;
}

.kpis article:hover, .panel:hover {
  border-color: var(--border-light);
}

.kpis span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.kpis strong {
  display: block;
  font-size: 26px;
  font-weight: 700;
  margin: 10px 0 6px;
  letter-spacing: -0.5px;
}

.kpis small {
  color: #34d399;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-title h2 {
  font-size: 16px;
  font-weight: 600;
}

.panel-title span {
  color: var(--muted);
  font-size: 12.5px;
}

.panel-title button {
  background: transparent;
  border: 0;
  color: var(--purple);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.funnel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.funnel div {
  background: var(--soft);
  padding: 16px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  text-align: center;
}

.funnel b {
  font-size: 20px;
  display: block;
  font-weight: 700;
  color: #fff;
}

.funnel span {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
  display: block;
}

.feed-stats p {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  margin: 0;
  font-size: 13.5px;
}
.feed-stats p:last-child {
  border-bottom: none;
}
.feed-stats span {
  color: var(--muted);
}

/* TABLES */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

th, td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tbody tr {
  transition: background 0.15s;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* TAGS & BADGES */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
}

.tag.green { background: #064e3b; color: #6ee7b7; border: 1px solid #047857; }
.tag.amber { background: #451a03; color: #fcd34d; border: 1px solid #b45309; }
.tag.blue { background: #0c4a6e; color: #7dd3fc; border: 1px solid #0284c7; }
.tag.red { background: #450a0a; color: #fca5a5; border: 1px solid #b91c1c; }
.tag.gray { background: #27272a; color: #d4d4d8; border: 1px solid #3f3f46; }
.tag.purple { background: #3b0764; color: #d8b4fe; border: 1px solid #7e22ce; }
.tag.pink { background: #500724; color: #f472b6; border: 1px solid #be185d; }

/* TOOLBAR & TABS */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 6px;
  background: var(--panel);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.tabs button {
  background: transparent;
  color: #a6abb9;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.tabs button:hover {
  color: #fff;
}

.tabs button.active {
  background: var(--soft);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* FEED RULES */
.rule {
  margin-top: 20px;
}
.rule h2 {
  font-size: 16px;
  margin-bottom: 14px;
}
.rule > div {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.rule label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.rule input, .form-control {
  background: var(--soft);
  border: 1px solid var(--border);
  color: white;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
}
.rule input:focus, .form-control:focus {
  outline: none;
  border-color: var(--purple);
}

/* MODALS */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  place-items: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: grid;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  padding: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #fff;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* TOASTS */
#toastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--soft);
  border: 1px solid var(--border);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.25s ease;
  min-width: 280px;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ACTION DROPDOWNS & BUTTONS */
.action-btns {
  display: flex;
  gap: 6px;
}

.btn-icon {
  background: var(--soft);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon:hover {
  color: #fff;
  border-color: var(--purple);
}

.btn-icon.danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* EMPTY STATES & LOADERS */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state h3 {
  color: #fff;
  margin-bottom: 6px;
  font-size: 16px;
}

.loading-spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  border-top-color: var(--purple);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* PAGINATION COMPONENT */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 12px;
  background: rgba(20, 21, 27, 0.4);
}

.pagination-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-info strong {
  color: #fff;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-page {
  background: var(--soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
}

.btn-page:hover:not(:disabled) {
  background: var(--soft-hover);
  border-color: var(--purple);
  color: #fff;
}

.btn-page.active {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
  box-shadow: 0 0 12px var(--purple-glow);
  font-weight: 700;
}

.btn-page:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--border);
}

@media(max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  main { padding: 20px; }
}

@media(max-width: 600px) {
  .kpis { grid-template-columns: 1fr; }
  .funnel { grid-template-columns: repeat(2, 1fr); }
  header { flex-direction: column; align-items: flex-start; }
  .header-actions { width: 100%; }
  .search-wrapper { flex: 1; }
  .search-wrapper input { width: 100%; }
}
.brand-logo { 
  max-width: 100%; 
  height: auto; 
  object-fit: contain; 
  display: block;
  margin: 0 auto;
}
