/* ===== Theme ===== */
:root{
  --bg: #0d1117;
  --panel: #11161d;
  --card: #1a2130;
  --border: #2a3342;
  --text: #e6edf3;
  --muted: #9aa4b2;

  --btn: #2d333b;
  --btn-border: #444c56;

  --primary: #238636;
  --primary-border: #2ea043;

  --danger: #da3633;
  --danger-border: #f85149;

  --link: #58a6ff;

  --crit-bg: rgba(248, 81, 73, 0.12);
  --high-bg: rgba(251, 143, 68, 0.12);
  --med-bg: rgba(245, 200, 66, 0.12);
  --low-bg: rgba(88, 166, 255, 0.12);
  --info-bg: rgba(148, 163, 184, 0.12);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* ===== Layout ===== */
.main-container{
  display:flex;
  height:100vh;
  overflow:hidden;
}

/* ===== Sidebar ===== */
.sidebar{
  width: 380px;
  min-width: 340px;
  background: var(--panel);
  padding: 18px;
  overflow-y:auto;
  border-right: 1px solid var(--border);
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
  padding: 10px 10px 16px 10px;
}
.brand-mark{
  width:44px;
  height:44px;
  border-radius: 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(88,166,255,0.08);
  border: 1px solid var(--border);
  font-size: 20px;
}
.brand-title{ font-weight: 800; font-size: 18px; }
.brand-sub{ color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ===== Cards ===== */
.card{
  background: var(--card);
  padding: 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}

.card h2{
  margin:0 0 10px 0;
  font-size: 15px;
  letter-spacing: .2px;
}

label{
  display:block;
  margin: 10px 0 6px 0;
  font-size: 12px;
  color: var(--muted);
}

input, select{
  width: 100%;
  padding: 10px 10px;
  background: #0f141b;
  border: 1px solid #30363d;
  border-radius: 10px;
  color: var(--text);
  outline: none;
}

input::placeholder{ color: #6b7280; }

.file{
  padding: 8px;
}

.file::file-selector-button{
  background: #6b7280;
  color: #fff;
  border: 1px solid #555;
  border-radius: 6px;
  padding: 8px 14px;
  margin-right: 12px;
  cursor: pointer;
  font-size: 13px;
}

.file::file-selector-button:hover{
  background: #7d8794;
}

.two-col{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.note{
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.note.warning{
  background: rgba(245, 200, 66, 0.12);
  border: 1px solid rgba(245, 200, 66, 0.3);
  border-radius: 8px;
  padding: 10px;
  color: #f5c842;
}

.note.warning strong{
  color: #ffd966;
}

.status{
  margin: 12px 0 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ===== Buttons ===== */
.buttons-row{
  margin-top: 12px;
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding: 10px 12px;
  background: var(--btn);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  cursor:pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.btn:hover{ background:#3a424d; }

.btn.primary{
  background: var(--primary);
  border-color: var(--primary-border);
}

.btn.primary:hover{ background:#2ea043; }

.btn.disabled{
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn.danger{
  background: var(--danger);
  border-color: var(--danger-border);
}

.btn.link{
  background: transparent;
  border-color: var(--border);
  color: var(--link);
}
.btn.link:hover{
  background: rgba(88,166,255,0.08);
}

.kv{
  display:grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 10px;
  margin-top: 8px;
  font-size: 12px;
}
.k{ color: var(--muted); }
.v{ color: var(--text); word-break: break-word; }
.v a{ color: var(--link); text-decoration:none; }

#repoDisplay{
  color: var(--muted);
  font-style: italic;
}

/* ===== Console ===== */
.log{
  margin: 10px 0 0 0;
  background: #0b1020;
  color: #d6e4ff;
  border-radius: 12px;
  padding: 12px;
  height: 220px;
  overflow:auto;
  font-size: 12px;
  line-height: 1.35;
  border: 1px solid rgba(88,166,255,0.12);
}

/* ===== Content ===== */
.content{
  flex:1;
  padding: 18px 18px 10px 18px;
  overflow-y:auto;
}

.content-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 14px;
  margin-bottom: 12px;
}

h1{
  margin: 4px 0 4px 0;
  font-size: 20px;
}
.muted{ color: var(--muted); }
.small{ font-size: 12px; }

.download-row{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

/* Summary cards */
.cards{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin: 10px 0 14px 0;
}

.summary-card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}
.summary-card .k{ font-size: 12px; color: var(--muted); }
.summary-card .v{ font-size: 18px; font-weight: 900; margin-top: 6px; }
.summary-card .v.small{ font-size: 12px; font-weight: 700; }

/* Panels */
.panel{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}

.panel-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.panel h2{ margin:0; font-size: 15px; }

/* Severity cards */
.sev-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.sev-card{
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: rgba(148,163,184,0.06);
}
.sev-card .k{ font-size: 11px; color: var(--muted); }
.sev-card .v{ font-size: 20px; font-weight: 900; margin-top: 6px; }

.sev-card.crit{ background: var(--crit-bg); }
.sev-card.high{ background: var(--high-bg); }
.sev-card.med{ background: var(--med-bg); }
.sev-card.low{ background: var(--low-bg); }
.sev-card.info{ background: var(--info-bg); }

/* Table */
.table-wrap{
  overflow:auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.table{
  width:100%;
  border-collapse: collapse;
  min-width: 980px;
  background: #0f141b;
}

.table th, .table td{
  padding: 10px 10px;
  border-bottom: 1px solid #222b38;
  text-align:left;
  vertical-align: top;
  font-size: 12px;
}

.table th{
  color: #cbd5e1;
  background: rgba(148,163,184,0.08);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.table td code{
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(88,166,255,0.10);
  border: 1px solid rgba(88,166,255,0.18);
  color: #cfe6ff;
  font-size: 11px;
}

.evidence-cell,
.recommendation-cell{
  max-width: 320px;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
}

.table-controls{
  margin-top: 10px;
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-label{
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.compact-select{
  width: auto;
  min-width: 84px;
  padding: 6px 10px;
  border-radius: 8px;
}

.footer{
  margin-top: 6px;
  padding: 10px 0 0 0;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid rgba(148,163,184,0.12);
}

/* Responsive */
@media (max-width: 980px){
  .main-container{ flex-direction: column; }
  .sidebar{
    width: auto;
    min-width: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .content-head{ flex-direction: column; align-items:flex-start; }
  .download-row{ justify-content:flex-start; }
}