@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #090d16;
  --surface: rgba(17, 25, 40, 0.65);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f3f4f6;
  --muted: #9ca3af;
  --blue: #3b82f6;
  --cyan: #06b6d4;
  --green: #10b981;
  --rose: #f43f5e;
  --yellow: #f59e0b;
  --orange: #f97316;
  --nav: rgba(9, 13, 22, 0.85);
  font-family: 'Outfit', 'Inter', Segoe UI, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

/* Premium Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at 50% 0%, #151d30 0%, #090d16 100%);
  background-attachment: fixed;
}

button,
select {
  font: inherit;
}

button {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border-radius: 6px;
  min-height: 32px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px 24px;
  background: var(--nav);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.brand strong {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.shield {
  color: #34d399;
  font-size: 20px;
  filter: drop-shadow(0 0 6px rgba(52, 211, 153, 0.4));
}

.account-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.account-bar select,
.account-bar .user {
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  border-radius: 6px;
  padding: 5px 12px;
}

.support {
  color: #fff;
  border: 0;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.support:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 12px;
  border-radius: 999px;
  color: #111827;
  font-size: 12px;
  font-weight: 700;
  background: #e5e7eb;
}

.warn {
  background: #f59e0b;
  color: #000;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.page {
  width: min(1200px, calc(100% - 32px));
  margin: 24px auto 64px;
}

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

.summary-card {
  min-height: 86px;
  padding: 18px;
  border-radius: 12px;
  color: #ffffff;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  backdrop-filter: blur(8px);
}

.summary-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  filter: brightness(1.2);
}

.summary-card:active {
  transform: translateY(-1px);
}

.summary-card span,
.summary-card small {
  display: block;
  font-size: 12px;
  font-weight: 500;
}

.summary-card span {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.8;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
  text-shadow: 0 2px 4px rgba(0,0,0,0.25);
}

.summary-card small {
  margin-top: 8px;
  opacity: 0.7;
}

.green { background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(5, 150, 105, 0.3) 100%); border-color: rgba(16, 185, 129, 0.25); }
.rose { background: linear-gradient(135deg, rgba(244, 63, 94, 0.15) 0%, rgba(225, 29, 72, 0.3) 100%); border-color: rgba(244, 63, 94, 0.25); }
.blue { background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(37, 99, 235, 0.3) 100%); border-color: rgba(59, 130, 246, 0.25); color: #fff; }
.yellow { background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.3) 100%); border-color: rgba(245, 158, 11, 0.25); }
.orange { background: linear-gradient(135deg, rgba(249, 115, 22, 0.15) 0%, rgba(234, 88, 12, 0.3) 100%); border-color: rgba(249, 115, 22, 0.25); }
.cyan { background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(8, 145, 178, 0.3) 100%); border-color: rgba(6, 182, 212, 0.25); }
.navy { background: linear-gradient(135deg, rgba(30, 41, 59, 0.3) 0%, rgba(15, 23, 42, 0.5) 100%); border-color: rgba(255, 255, 255, 0.05); color: #fff; }
.navy small { color: rgba(255, 255, 255, 0.72); }

.refresh {
  width: 100%;
  margin: 18px 0 10px;
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25);
  border-radius: 6px;
}

.refresh:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 16px rgba(6, 182, 212, 0.35);
}

.panel {
  margin-top: 18px;
  padding: 20px;
  border-radius: 16px;
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  cursor: pointer;
  user-select: none;
  padding: 6px 12px;
  margin-left: -12px;
  margin-right: -12px;
  border-radius: 8px;
  transition: background 0.2s;
}

.panel-title-row:hover {
  background: rgba(0, 0, 0, 0.02);
}

.panel-move-controls {
  display: inline-flex;
  gap: 4px;
  margin-right: 12px;
  align-items: center;
}

.panel-move-btn {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 4px;
  padding: 2px 8px;
  min-height: 24px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.panel-move-btn:hover {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.panel-move-btn:active {
  transform: scale(0.95);
}

.panel-title-row h1::after,
.panel-title-row h2::after {
  content: ' ▾';
  font-size: 16px;
  color: var(--muted);
  vertical-align: middle;
  transition: transform 0.2s;
  display: inline-block;
  margin-left: 8px;
}

.panel.collapsed .panel-title-row h1::after,
.panel.collapsed .panel-title-row h2::after {
  transform: rotate(-90deg);
}

.panel.collapsed {
  padding-bottom: 18px;
}

.panel.collapsed .panel-title-row {
  margin-bottom: 0;
}

.panel.collapsed > *:not(.panel-title-row) {
  display: none !important;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1,
h2 {
  font-size: 21px;
  text-transform: uppercase;
}

.panel-title-row select,
.panel-title-row input[type="date"] {
  min-width: 158px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  font-size: 15px;
  outline: none;
  font-family: inherit;
  color-scheme: dark;
  cursor: pointer;
  transition: all 0.2s ease;
}

.panel-title-row input[type="date"]:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.panel-title-row input[type="date"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 16px;
}

.analytics-grid.two-col {
  grid-template-columns: 1fr 1fr;
}

.panel-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.sync-subtable {
  margin-top: 12px;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.setup-card {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.setup-card.connected {
  border-left-color: #10b981;
  background: rgba(16, 185, 129, 0.05);
}

.setup-card.warning {
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.05);
}

.setup-card span,
.setup-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.setup-card strong {
  display: block;
  margin: 8px 0 7px;
  color: #fff;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.mini-table,
.chart-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}

.mini-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-size: 13px;
}

.mini-head button {
  color: var(--blue);
  border-color: rgba(59, 130, 246, 0.3);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--text);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 2px solid var(--line);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 10px;
  border-radius: 6px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.status-bot { background: linear-gradient(135deg, #f43f5e 0%, #be123c 100%); }
.status-clean { background: linear-gradient(135deg, #10b981 0%, #047857 100%); }
.status-normal { background: linear-gradient(135deg, #64748b 0%, #475569 100%); }
.status-white { background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); }
.status-blocked { background: linear-gradient(135deg, #991b1b 0%, #7f1d1d 100%); }

.tabs,
.action-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tabs button {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.tabs button.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.table-wrap {
  overflow-x: auto;
}

.data-table tbody tr {
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.clickable-ip {
  color: #60a5fa;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s ease;
}

.clickable-ip:hover {
  color: #93c5fd;
  text-decoration: underline;
}

.subline {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.score,
.bot-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  border-radius: 5px;
  color: #fff;
  font-weight: 800;
}

.score {
  background: #64748b;
}

.bot-score {
  background: #e11d48;
}

.primary,
.blue-btn {
  background: #2077f2;
  color: #fff;
  border-color: #2077f2;
}

.danger {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.green-btn {
  background: #18a75b;
  color: #fff;
  border-color: #18a75b;
}

.orange-btn {
  background: #f59a00;
  color: #111827;
  border-color: #f59a00;
}

.cyan-btn {
  background: #0fc4de;
  color: #06202b;
  border-color: #0fc4de;
}

.tiny {
  padding: 5px 8px;
  font-size: 12px;
  line-height: 1.1;
}

.related-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.related-head h4 {
  margin: 0;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.74);
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #5352ed 0%, #1e1b4b 100%);
  width: 100vw;
  height: 100vh;
}

.auth-overlay[hidden] {
  display: none !important;
}

.auth-card {
  width: min(440px, 100%);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: fadeInScale 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border: none;
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.auth-card-header {
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  padding: 24px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #ffffff;
}

.auth-shield {
  font-size: 32px;
  filter: drop-shadow(0 2px 8px rgba(255, 255, 255, 0.3));
}

.auth-card-header h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  text-transform: none;
  letter-spacing: 0.5px;
  color: #ffffff;
}

.auth-card-body {
  padding: 30px 24px 24px;
  background: #ffffff;
}

.auth-input-group {
  position: relative;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  width: 100%;
}

.auth-input-icon {
  position: absolute;
  left: 14px;
  color: #64748b;
  font-size: 16px;
  pointer-events: none;
}

.auth-card-body input {
  width: 100%;
  padding: 12px 12px 12px 42px !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 8px !important;
  font-size: 14px !important;
  color: #0f172a !important;
  background: #ffffff !important;
  transition: all 0.2s ease !important;
  margin: 0 !important;
  outline: none !important;
}

.auth-card-body input:focus {
  border-color: #5352ed !important;
  box-shadow: 0 0 0 3px rgba(83, 82, 237, 0.15) !important;
}

.auth-submit-btn {
  width: 100%;
  background: linear-gradient(135deg, #5352ed 0%, #3742fa 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(83, 82, 237, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin-bottom: 12px;
}

.auth-submit-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 16px rgba(83, 82, 237, 0.45);
  transform: translateY(-1px);
}

.auth-demo-btn {
  width: 100%;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 38px;
}

.auth-demo-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.auth-card-footer {
  background: #f8fafc;
  padding: 16px;
  text-align: center;
  border-top: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
}

.auth-card input:focus {
  border-color: var(--blue);
  background: rgba(255, 255, 255, 0.08);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(920px, 100%);
  max-height: calc(100vh - 56px);
  overflow: auto;
  border-radius: 16px;
  background: rgba(17, 25, 40, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-head h3 {
  font-weight: 600;
}

.modal-head button {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 30px;
  line-height: 1;
  padding: 0;
  min-height: auto;
}

.modal-tabs {
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
}

.modal-tabs button {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 0;
}

.modal-tabs button.active {
  color: #fff;
  border-bottom: 2px solid var(--blue);
  background: transparent;
  font-weight: 500;
}

.detail-grid {
  padding: 0 20px 20px;
}

.detail-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.detail-row strong {
  color: var(--text);
  font-weight: 500;
}

.related-block {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.related-block h4 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

.active-related td {
  background: rgba(59, 130, 246, 0.12);
}

.cluster-actions {
  min-width: 250px;
}

.cluster-actions button {
  margin: 0 4px 4px 0;
}

.recommendation-actions {
  display: block;
  margin-top: 8px;
}

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

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

.queue-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}

.queue-list {
  min-height: 88px;
  padding: 10px;
}

.queue-item {
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.queue-item:last-child {
  border-bottom: 0;
}

.queue-item strong,
.queue-item span {
  display: block;
}

.applied-actions {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

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

.evidence-grid div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.evidence-grid strong,
.evidence-grid span {
  display: block;
}

.evidence-grid strong {
  font-size: 20px;
  color: #fff;
}

.evidence-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

@media (max-width: 920px) {
  .queue-grid,
  .sync-summary {
    grid-template-columns: 1fr;
  }
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--line);
}

.flash {
  animation: flash 0.45s ease;
}

@keyframes flash {
  from { transform: translateY(-2px); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 920px) {
  .topbar,
  .panel-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .panel-title-row select {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100% - 18px, 1180px);
  }

  .panel {
    padding: 12px;
  }

  h1,
  h2 {
    font-size: 18px;
  }

  .account-bar {
    justify-content: flex-start;
  }

  .detail-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

.device-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  margin-left: 6px;
  vertical-align: middle;
}

.device-badge-info {
  background: rgba(29, 114, 243, 0.15);
  color: #1d72f3;
  border: 1px solid rgba(29, 114, 243, 0.25);
}

.device-badge-warn {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

