:root {
  --bg: #080d1a;
  --bg-soft: #0f172a;
  --surface: #131d36;
  --card: #182342;
  --card-alt: #111931;
  --border: #2a3966;
  --border-bright: #415698;
  --text: #f1f5f9;
  --muted: #9fb1d8;
  --emerald: #10b981;
  --emerald-dark: #064e3b;
  --indigo: #6366f1;
  --indigo-soft: rgba(99, 102, 241, 0.16);
  --amber: #f59e0b;
  --rose: #ef4444;
  --cyan: #06b6d4;
  --radius: 14px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top right, #162146 0%, var(--bg) 52%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
}

a {
  color: #93c5fd;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 18px 64px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 18px 22px;
  background: rgba(19, 29, 54, 0.9);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--emerald), var(--indigo));
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 20px;
  color: #fff;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.header-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--card-alt);
  color: #dbeafe;
}

.pill-green {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.45);
  color: #6ee7b7;
}

.pill-indigo {
  background: var(--indigo-soft);
  border-color: rgba(99, 102, 241, 0.45);
  color: #c7d2fe;
}

.pill-amber {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fcd34d;
}

.pill-rose {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

/* Navigation Tabs */
.tabs-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.tab-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  gap: 9px;
}

.tab-btn:hover {
  border-color: var(--border-bright);
  color: var(--text);
  transform: translateY(-1px);
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.28), rgba(16, 185, 129, 0.18));
  border-color: #818cf8;
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.25);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Layout primitives */
.hero-banner {
  background: linear-gradient(135deg, #172349, #101831);
  border: 1px solid var(--border-bright);
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 22px;
}

.hero-banner h2 {
  margin: 0 0 8px;
  font-size: clamp(1.3rem, 2.4vw, 1.8rem);
}

.hero-banner p {
  margin: 0;
  color: var(--muted);
  max-width: 860px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

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

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.card-alt {
  background: var(--card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.card h3 {
  margin: 8px 0 8px;
  font-size: 1.15rem;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

/* Buttons */
.btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.14s ease, filter 0.14s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.07);
}

.btn-emerald {
  background: var(--emerald);
  color: #022c22;
}

.btn-indigo {
  background: var(--indigo);
  color: #ffffff;
}

.btn-amber {
  background: var(--amber);
  color: #291802;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-bright);
  color: #dbeafe;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.82rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card-alt);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(42, 57, 102, 0.65);
  vertical-align: top;
}

th {
  background: rgba(99, 102, 241, 0.12);
  color: #c7d2fe;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:last-child td {
  border-bottom: none;
}

/* Controls & Forms */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.segmented {
  display: inline-flex;
  background: #0a0f1f;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  gap: 4px;
  flex-wrap: wrap;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 7px;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--indigo);
  color: #fff;
}

.lead-selector {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.lead-chip {
  border: 1px solid var(--border);
  background: var(--card-alt);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.lead-chip.active {
  border-color: var(--emerald);
  background: rgba(16, 185, 129, 0.15);
  color: #a7f3d0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}

input[type="text"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #090e1c;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

textarea {
  resize: vertical;
  min-height: 165px;
  line-height: 1.5;
}

/* Score & Diagnostic UI */
.score-ring {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 7px solid var(--rose);
  background: rgba(239, 68, 68, 0.12);
  text-align: center;
}

.score-ring.warn {
  border-color: var(--amber);
  background: rgba(245, 158, 11, 0.12);
}

.score-ring.good {
  border-color: var(--emerald);
  background: rgba(16, 185, 129, 0.12);
}

.score-num {
  font-size: 1.9rem;
  font-weight: 900;
  line-height: 1;
}

.score-den {
  font-size: 0.75rem;
  color: var(--muted);
}

.check-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.check-item {
  padding: 11px 13px;
  border-radius: 10px;
  background: #0d1428;
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.check-item.fail {
  border-left: 4px solid var(--rose);
}

.check-item.pass {
  border-left: 4px solid var(--emerald);
}

/* Code viewer & Blurred Trojan Horse preview */
.code-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.code-block-wrap {
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #070b16;
  overflow: hidden;
}

pre.code-view {
  margin: 0;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.81rem;
  line-height: 1.5;
  color: #cbd5e1;
  overflow-x: auto;
  max-height: 310px;
}

.blurred-code {
  filter: blur(4px);
  user-select: none;
  pointer-events: none;
  opacity: 0.65;
}

.lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  background: linear-gradient(180deg, rgba(8, 13, 26, 0.45), rgba(8, 13, 26, 0.92));
}

/* KPI cards & Sliders */
.kpi-card {
  background: linear-gradient(160deg, #18254a, #101830);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.kpi-val {
  font-size: 1.55rem;
  font-weight: 900;
  color: #fff;
  line-height: 1.15;
}

.kpi-sub {
  font-size: 0.8rem;
  color: #6ee7b7;
  margin-top: 5px;
}

.slider-group {
  margin-bottom: 16px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 6px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--emerald);
  cursor: pointer;
}

.alert-box {
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 0.88rem;
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.1);
  color: #fde68a;
}

.alert-green {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.1);
  color: #a7f3d0;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 16, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 999;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  max-width: 560px;
  width: 100%;
  background: #131c36;
  border: 1px solid var(--border-bright);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--emerald);
  color: #022c22;
  font-weight: 800;
  padding: 11px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 1000;
}

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