:root{
  --bg:#0b0b12;
  --panel:#12131b;
  --panel-2:#171926;
  --panel-3:#1d2030;
  --line:#2d3248;
  --text:#f5f7ff;
  --muted:#a7afc7;
  --purple:#8b5cf6;
  --purple-2:#6d28d9;
  --yellow:#f4d35e;
  --white:#ffffff;
  --shadow:0 0 0 1px rgba(139,92,246,.18), 0 12px 40px rgba(0,0,0,.35), 0 0 22px rgba(139,92,246,.12);
  --radius:18px;
}

/* LIGHT MODE */
body.light-mode {
  --bg:#f2f4f8;
  --panel:#ffffff;
  --panel-2:#f7f8fc;
  --panel-3:#eef0f6;
  --line:#dde0ee;
  --text:#1a1d2e;
  --muted:#5a6080;
  --purple:#7c3aed;
  --purple-2:#6d28d9;
  --yellow:#d4a012;
  --white:#ffffff;
  --shadow:0 0 0 1px rgba(124,58,237,.10), 0 4px 20px rgba(0,0,0,.06);
}

body.light-mode {
  background: #f2f4f8 !important;
  color: var(--text) !important;
}

/* No black anywhere in light mode */
body.light-mode * { color: inherit; }
body.light-mode .cw-card { background: #ffffff !important; border-color: #dde0ee !important; color: #1a1d2e; }
body.light-mode .cw-muted-box { background: #f7f8fc !important; border-color: #dde0ee !important; }
body.light-mode .cw-input { background: #eef0f6 !important; color: #1a1d2e !important; border-color: #dde0ee !important; }
body.light-mode .cw-select { background: #eef0f6 !important; color: #1a1d2e !important; border-color: #dde0ee !important; }
body.light-mode .cw-btn-dark { background: #eef0f6 !important; color: #1a1d2e !important; border-color: #dde0ee !important; }
body.light-mode .cw-btn-purple { background: #7c3aed !important; color: #ffffff !important; }
body.light-mode .cw-empty { color: #5a6080 !important; }
body.light-mode .cw-small { color: #5a6080 !important; }
body.light-mode .cw-muted { color: #5a6080 !important; }
body.light-mode .cw-article-title { color: #1a1d2e !important; }
body.light-mode .cw-section-subtitle { color: #5a6080 !important; }
body.light-mode .cw-label { color: #5a6080 !important; }
body.light-mode .cw-title { color: #1a1d2e !important; }
body.light-mode .cw-phase-panel-title { color: #1a1d2e !important; }
body.light-mode .cw-chip { background: #eef0f6 !important; color: #5a6080 !important; border-color: #dde0ee !important; }
body.light-mode .cw-chip.active { background: #7c3aed !important; color: #ffffff !important; border-color: #7c3aed !important; }
body.light-mode .cw-status { color: #5a6080 !important; }
body.light-mode .cw-status.ok { color: #059669 !important; }
body.light-mode .cw-hero-title { color: #1a1d2e !important; }
body.light-mode .cw-hero-sub { color: #5a6080 !important; }
body.light-mode .cw-progress-bar { background: #dde0ee !important; }

/* Sidebar in light mode */
body.light-mode #cw-sidebar { background: #ffffff !important; border-color: #dde0ee !important; }
body.light-mode #cw-sidebar .cw-card { background: #f7f8fc !important; }
body.light-mode #cw-sidebar .cw-muted-box { background: #eef0f6 !important; }

/* Inline dark backgrounds in JS-generated HTML */
body.light-mode [style*="background:#0f1117"] { background: #eef0f6 !important; }
body.light-mode [style*="background: #0f1117"] { background: #eef0f6 !important; }
body.light-mode [style*="background:#1a1d27"] { background: #f7f8fc !important; }
body.light-mode [style*="background:#12131b"] { background: #ffffff !important; }
body.light-mode [style*="background:#13151f"] { background: #ffffff !important; }
body.light-mode [style*="background:#1f2937"] { background: #eef0f6 !important; }
body.light-mode [style*="background:#374151"] { background: #dde0ee !important; }
body.light-mode [style*="color:#f9fafb"] { color: #1a1d2e !important; }
body.light-mode [style*="color:#e5e7eb"] { color: #1a1d2e !important; }
body.light-mode [style*="color:#9ca3af"] { color: #5a6080 !important; }
body.light-mode [style*="color:#6b7280"] { color: #5a6080 !important; }
body.light-mode [style*="border:1px solid #2d3148"] { border-color: #dde0ee !important; }
body.light-mode [style*="border:1px solid #374151"] { border-color: #dde0ee !important; }
body.light-mode [style*="border-color:#374151"] { border-color: #dde0ee !important; }

/* Score bars in light mode */
body.light-mode .score-bar-track { background: #dde0ee !important; }
body.light-mode .score-bar-val { color: #1a1d2e !important; }
body.light-mode .score-bar-label { color: #5a6080 !important; }

/* Competition panel in light mode */
body.light-mode .comp-panel { background: #f7f8fc !important; border-color: #dde0ee !important; }
body.light-mode .comp-row { background: #eef0f6 !important; border-color: #dde0ee !important; }
body.light-mode .comp-domain { color: #1a1d2e !important; }
body.light-mode .comp-title { color: #5a6080 !important; }
body.light-mode .comp-panel-title { color: #5a6080 !important; }

/* Theme toggle in light mode */
body.light-mode .theme-toggle { background: #ffffff !important; border-color: #dde0ee !important; color: #5a6080 !important; }

/* THEME TOGGLE BUTTON */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 9999;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.theme-toggle:hover { border-color: var(--purple); color: var(--text); }

/* SCORE BADGE */
.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.score-high { background: #065f46; color: #6ee7b7; }
.score-mid { background: #78350f; color: #fcd34d; }
.score-low { background: #4c1d95; color: #c4b5fd; }
.score-none { background: #1f2937; color: #9ca3af; }

/* COMPETITION PANEL */
.comp-panel {
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
}
.comp-panel-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.comp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
}
.comp-rank {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.comp-domain { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; }
.comp-title { font-size: 11px; color: var(--muted); }
.comp-link { font-size: 11px; color: var(--purple); text-decoration: none; }
.comp-link:hover { text-decoration: underline; }
.comp-has-content { display: flex; align-items: center; gap: 4px; font-size: 11px; }
.comp-has-yes { color: #6ee7b7; }
.comp-has-no { color: #f87171; }

/* SCORING BARS */
.score-bar-wrap { margin-top: 12px; }
.score-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.score-bar-label { font-size: 11px; color: var(--muted); width: 100px; flex-shrink: 0; }
.score-bar-track { flex: 1; height: 6px; background: var(--panel-3); border-radius: 3px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 3px; transition: width 0.4s; }
.score-bar-fill.green { background: #059669; }
.score-bar-fill.yellow { background: #d97706; }
.score-bar-fill.purple { background: var(--purple); }
.score-bar-val { font-size: 11px; font-weight: 700; color: var(--text); width: 32px; text-align: right; }

*{box-sizing:border-box}

html,body{
  margin:0;
  padding:0;
  background:
    radial-gradient(circle at top right, rgba(139,92,246,.14), transparent 28%),
    radial-gradient(circle at top left, rgba(244,211,94,.06), transparent 22%),
    linear-gradient(180deg,#0a0b11 0%, #0d0f16 100%);
  color:var(--text);
  font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}

body{
  min-height:100vh;
}

.ai-dashboard-topbar{
  width:100%;
  padding:18px 22px 0;
}

.ai-dashboard-client-picker{
  width:320px;
  max-width:100%;
}

.ai-dashboard-client-picker label{
  display:block;
  margin:0 0 8px;
  color:var(--muted);
  font-size:13px;
  font-weight:700;
  letter-spacing:.04em;
  text-transform:uppercase;
}

.ai-dashboard-client-picker select{
  width:100%;
  height:48px;
  border-radius:12px;
  border:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02)), var(--panel);
  color:var(--text);
  padding:0 14px;
  font-size:14px;
  font-weight:700;
  box-shadow:var(--shadow);
}

.dashboard-shell{
  width:100%;
  padding:18px 22px 28px;
}

#npj-ai-dashboard-root,
#ai-dashboard-root{
  width:100%;
}

.card{
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01)),
    var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:18px;
}

.muted-box,
.check-item,
.article-card{
  background:
    linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,.01)),
    var(--panel-2);
  border:1px solid var(--line);
  border-radius:16px;
  padding:16px;
}

h1,h2,h3{
  margin:0 0 10px;
  color:var(--white);
  line-height:1.1;
}

h1{font-size:34px;font-weight:900;letter-spacing:-.03em}
h2{font-size:24px;font-weight:850;letter-spacing:-.02em}
h3{font-size:20px;font-weight:850;letter-spacing:-.02em}

.label{
  font-size:13px;
  font-weight:800;
  color:var(--muted);
  margin:0 0 8px;
  text-transform:uppercase;
  letter-spacing:.05em;
}

.small{
  font-size:14px;
  line-height:1.5;
  color:var(--muted);
}

.mini-title{
  font-size:15px;
  font-weight:800;
  color:var(--white);
  margin:0 0 8px;
}

.article-title{
  font-size:18px;
  font-weight:850;
  line-height:1.25;
  margin:0 0 8px;
  color:var(--white);
}

.input,
.select,
.code{
  width:100%;
  background:var(--panel-3);
  border:1px solid #343a54;
  color:var(--white);
  border-radius:13px;
  padding:14px 16px;
  font-size:15px;
  line-height:1.4;
  outline:none;
  transition:.18s ease;
}

.input:focus,
.select:focus{
  border-color:rgba(139,92,246,.8);
  box-shadow:0 0 0 3px rgba(139,92,246,.14), 0 0 18px rgba(139,92,246,.12);
}

.code{
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;
  overflow:auto;
  color:#d8def8;
}

.btn-row{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:14px;
}

.btn{
  min-height:48px;
  border:none;
  border-radius:12px;
  padding:12px 18px;
  font-size:14px;
  font-weight:850;
  letter-spacing:.01em;
  cursor:pointer;
  transition:.18s ease;
}

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

.btn-dark{
  background:linear-gradient(180deg, #1b1d29, #11131d);
  color:var(--white);
  border:1px solid #313751;
  box-shadow:0 0 18px rgba(139,92,246,.08);
}

.btn-gray{
  background:linear-gradient(180deg, #2a2f43, #202538);
  color:var(--white);
  border:1px solid #39405c;
}

.btn-red{
  background:linear-gradient(180deg, #7c3aed, #5b21b6);
  color:#fff;
  border:1px solid rgba(255,255,255,.08);
  box-shadow:0 0 18px rgba(139,92,246,.2);
}

.btn-green{
  background:linear-gradient(180deg, #4b5563, #374151);
  color:#fff;
  border:1px solid #586174;
}

.status{
  margin-top:12px;
  font-size:14px;
  line-height:1.45;
}

.status.ok{color:#a7f3d0}
.status.warn{color:#f4d35e}
.status.muted{color:var(--muted)}

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

.check-list{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.phase-chip-row{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin:14px 0;
}

.phase-chip{
  border:none;
  border-radius:999px;
  padding:10px 14px;
  background:#23283b;
  color:#d8def8;
  font-size:13px;
  font-weight:800;
  cursor:pointer;
  border:1px solid #353c58;
}

.phase-chip.active{
  background:linear-gradient(180deg, #8b5cf6, #6d28d9);
  color:#fff;
  box-shadow:0 0 18px rgba(139,92,246,.25);
  border-color:transparent;
}

.phase-bars{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:8px;
  margin:8px 0 10px;
}

.phase-bar{
  height:12px;
  border-radius:999px;
  background:#23283b;
  border:1px solid #343a54;
}

.phase-red,
.phase-yellow,
.phase-blue,
.phase-green{
  background:linear-gradient(90deg, #8b5cf6, #6d28d9);
  box-shadow:0 0 14px rgba(139,92,246,.24);
  border-color:transparent;
}

.phase-text{
  color:var(--muted);
  font-size:13px;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.05em;
}

table{
  width:100%;
  border-collapse:collapse;
}

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

th{
  color:#cfd6f6;
  font-weight:800;
}

/* ================================
   CONTENT BUILD PANEL
================================ */

#content-build-panel{
  margin-top:24px;
  width:100%;
}

.content-build-panel,
.ai-content-build-panel{
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01)),
    var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:20px;
}

.content-build-header,
.ai-content-build-header{
  display:flex;
  justify-content:space-between;
  gap:16px;
  flex-wrap:wrap;
  margin-bottom:18px;
}

.content-build-header h2,
.ai-content-build-header h2{
  margin:0 0 6px;
}

.content-build-header p,
.ai-content-build-header p{
  margin:0;
  color:var(--muted);
  font-size:14px;
  line-height:1.5;
}

.cluster-progress-badge,
.ai-cluster-badge{
  background:linear-gradient(180deg, #8b5cf6, #6d28d9);
  color:#fff;
  border-radius:999px;
  padding:10px 14px;
  font-size:13px;
  font-weight:900;
  align-self:flex-start;
  box-shadow:0 0 18px rgba(139,92,246,.25);
}

.content-build-grid,
.ai-content-build-grid{
  display:grid;
  grid-template-columns:repeat(5,minmax(0,1fr));
  gap:14px;
  margin-bottom:18px;
}

.content-build-field,
.ai-content-field{
  background:var(--panel-2);
  border:1px solid var(--line);
  border-radius:14px;
  padding:14px;
}

.content-build-field label,
.ai-content-field label{
  display:block;
  margin:0 0 7px;
  color:var(--muted);
  font-size:12px;
  font-weight:900;
  letter-spacing:.05em;
  text-transform:uppercase;
}

.content-build-field strong,
.ai-content-field strong{
  color:var(--white);
  font-size:14px;
  line-height:1.4;
}

.content-build-field input,
.ai-content-field input{
  width:100%;
  background:var(--panel-3);
  border:1px solid #343a54;
  color:var(--white);
  border-radius:10px;
  padding:10px 12px;
  font-size:14px;
  font-weight:800;
}

.fase-row,
.ai-fase-row{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:10px;
  margin:16px 0 20px;
}

.fase-btn,
.ai-fase-btn{
  min-height:48px;
  border-radius:12px;
  border:1px solid #353c58;
  background:#23283b;
  color:#d8def8;
  padding:12px 14px;
  font-size:13px;
  font-weight:900;
  cursor:pointer;
  transition:.18s ease;
}

.fase-btn:hover,
.ai-fase-btn:hover{
  transform:translateY(-1px);
  border-color:rgba(139,92,246,.7);
}

.fase-btn.active,
.ai-fase-btn.active{
  background:linear-gradient(180deg, #8b5cf6, #6d28d9);
  color:#fff;
  border-color:transparent;
  box-shadow:0 0 18px rgba(139,92,246,.25);
}

.fase-btn.metrics,
.ai-fase-btn.metrics{
  border-color:rgba(244,211,94,.45);
  color:#f4d35e;
}

.fase-btn.metrics.active,
.ai-fase-btn.metrics.active{
  background:linear-gradient(180deg, #f4d35e, #b89422);
  color:#11131d;
}

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

.article-opportunity-card,
.ai-article-card{
  background:
    linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,.01)),
    var(--panel-2);
  border:1px solid var(--line);
  border-radius:16px;
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:12px;
  min-height:100%;
}

.article-opportunity-card h3,
.ai-article-card h3{
  margin:0;
  color:var(--white);
  font-size:18px;
  line-height:1.25;
  font-weight:900;
}

.article-meta,
.ai-article-meta{
  color:var(--muted);
  font-size:13px;
  line-height:1.5;
}

.article-meta strong,
.ai-article-meta strong{
  color:#d8def8;
}

.verify-url-input,
.ai-verify-input{
  width:100%;
  background:var(--panel-3);
  border:1px solid #343a54;
  color:var(--white);
  border-radius:10px;
  padding:11px 12px;
  font-size:13px;
  outline:none;
}

.verify-url-input:focus,
.ai-verify-input:focus{
  border-color:rgba(139,92,246,.8);
  box-shadow:0 0 0 3px rgba(139,92,246,.14);
}

.article-actions,
.ai-card-actions{
  display:grid;
  grid-template-columns:1fr;
  gap:8px;
  margin-top:auto;
}

.article-actions button,
.ai-card-actions button{
  min-height:42px;
  border-radius:10px;
  border:1px solid #353c58;
  background:#23283b;
  color:#fff;
  padding:10px 12px;
  font-size:13px;
  font-weight:900;
  cursor:pointer;
}

.article-actions button:hover,
.ai-card-actions button:hover{
  transform:translateY(-1px);
}

.article-actions .secondary,
.ai-card-actions .secondary{
  background:linear-gradient(180deg, #1b1d29, #11131d);
}

.article-actions .verify,
.ai-card-actions .verify{
  background:linear-gradient(180deg, #8b5cf6, #6d28d9);
  border-color:transparent;
}

.metrics-panel,
.ai-metrics-box{
  background:
    linear-gradient(180deg, rgba(244,211,94,.06), rgba(255,255,255,.01)),
    var(--panel-2);
  border:1px solid rgba(244,211,94,.28);
  border-radius:16px;
  padding:18px;
}

.metrics-panel h3,
.ai-metrics-box h3{
  margin:0 0 10px;
  color:#f4d35e;
}

.metrics-panel p,
.ai-metrics-box p{
  color:var(--muted);
  font-size:14px;
  line-height:1.55;
}

/* ================================
   RESPONSIVE
================================ */

@media (max-width: 1200px){
  .content-build-grid,
  .ai-content-build-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .article-opportunity-grid,
  .ai-article-list{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

@media (max-width: 980px){
  .grid-2{
    grid-template-columns:1fr;
  }

  .dashboard-shell,
  .ai-dashboard-topbar{
    padding-left:14px;
    padding-right:14px;
  }

  #npj-ai-dashboard-root > div,
  #ai-dashboard-root > div{
    grid-template-columns:1fr !important;
  }
}

@media (max-width: 700px){
  h1{font-size:28px}
  h2{font-size:22px}

  .content-build-grid,
  .ai-content-build-grid,
  .article-opportunity-grid,
  .ai-article-list,
  .fase-row,
  .ai-fase-row{
    grid-template-columns:1fr;
  }

  .phase-bars{
    grid-template-columns:repeat(4,1fr);
  }
}