:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-hover: #1c2333;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --danger: #f85149;
  --warning: #d29922;
  --success: #3fb950;
  --info: #58a6ff;
  --critical-bg: rgba(248,81,73,.15);
  --high-bg: rgba(210,105,30,.15);
  --medium-bg: rgba(210,153,34,.15);
  --low-bg: rgba(63,185,80,.15);
  --info-bg: rgba(88,166,255,.15);
  --radius: 8px;
  --transition: 150ms ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* Layout */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-header h1 .logo {
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #000;
  font-weight: 800;
}

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Scan Config */
.scan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.input-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input[type="text"], input[type="url"], select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color var(--transition);
  width: 100%;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88,166,255,.15);
}

.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover { background: var(--surface-hover); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

.scan-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

/* Scan type pills */
.scan-types {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.scan-type-pill {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.scan-type-pill:hover { border-color: var(--accent); color: var(--accent); }
.scan-type-pill.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }

/* Results / Activity */
.activity-list { list-style: none; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.activity-body { flex: 1; }
.activity-body strong { font-weight: 600; }
.activity-body .meta { font-size: 0.8rem; color: var(--text-muted); }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-critical { background: var(--critical-bg); color: var(--danger); }
.badge-high { background: var(--high-bg); color: #ff7b54; }
.badge-medium { background: var(--medium-bg); color: var(--warning); }
.badge-low { background: var(--low-bg); color: var(--success); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-completed { background: var(--low-bg); color: var(--success); }
.badge-running { background: var(--info-bg); color: var(--info); }
.badge-failed { background: var(--critical-bg); color: var(--danger); }
.badge-pending { background: rgba(139,148,158,.15); color: var(--text-muted); }

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.stat-card .value { font-size: 1.75rem; font-weight: 700; }
.stat-card .label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* Findings table */
.findings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.findings-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: rgba(88,166,255,.08);
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.findings-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.findings-table tr:hover { background: var(--surface-hover); }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  animation: slideIn .3s ease;
}

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }

/* Responsive */
@media (min-width: 768px) {
  .scan-grid { grid-template-columns: 1fr 1fr; }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.empty-state svg { width: 48px; height: 48px; opacity: .5; margin-bottom: 0.75rem; }

/* Executive summary */
.exec-summary {
  background: var(--info-bg);
  border: 1px solid rgba(88,166,255,.25);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* Finding cards */
.finding-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.finding-card.finding-critical { border-left: 3px solid var(--danger); }
.finding-card.finding-high { border-left: 3px solid #ff7b54; }
.finding-card.finding-medium { border-left: 3px solid var(--warning); }
.finding-card.finding-low { border-left: 3px solid var(--success); }
.finding-card.finding-info { border-left: 3px solid var(--info); }

.finding-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: rgba(255,255,255,.02);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.finding-num {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 24px;
}

.finding-body {
  padding: 0.75rem 1rem;
}

.finding-row {
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  line-height: 1.5;
}

.finding-row code {
  background: rgba(88,166,255,.08);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.82rem;
  word-break: break-all;
}

.finding-label {
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.3rem;
}

.finding-risk {
  background: rgba(210,153,34,.08);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  margin-top: 0.3rem;
}

/* CWE / OWASP tags */
.tag {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tag-cwe {
  background: rgba(248,81,73,.12);
  color: var(--danger);
  border: 1px solid rgba(248,81,73,.3);
}

.tag-owasp {
  background: rgba(210,153,34,.12);
  color: var(--warning);
  border: 1px solid rgba(210,153,34,.3);
}

/* Fix snippets */
.fix-snippets {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.fix-snippets > strong {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.snippet-block {
  margin-bottom: 0.5rem;
}

.snippet-lang {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(88,166,255,.1);
  color: var(--accent);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-bottom: 0.25rem;
}

.snippet-block pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.45;
}

.snippet-block code {
  color: var(--text);
  background: none;
  padding: 0;
}

/* Scan progress */
.scan-progress {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(88,166,255,.06);
  border: 1px solid rgba(88,166,255,.2);
  border-radius: var(--radius);
}

.scan-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.scan-progress-text { color: var(--text-muted); }
.scan-progress-count { font-weight: 600; color: var(--accent); }

.scan-progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.scan-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 4px;
  width: 0%;
  transition: width 0.25s ease;
}

.scan-progress-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.75rem;
}

.scan-progress-step {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: var(--surface-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.scan-progress-step.step-done {
  background: var(--low-bg);
  color: var(--success);
  border-color: rgba(63,185,80,.3);
}

.scan-progress-step.step-fail {
  background: var(--critical-bg);
  color: var(--danger);
  border-color: rgba(248,81,73,.3);
}

.scan-progress-step.step-pending {
  color: var(--text-muted);
}

/* Scan history filter */
.scan-history-options {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}

.checkbox-label input { cursor: pointer; }

.scan-filter-hint {
  font-size: 0.8rem;
  color: var(--accent);
}

/* Scan history: two-column layout */
.scan-history-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1rem;
  min-height: 280px;
}

.scan-sessions-column {
  border-right: 1px solid var(--border);
  padding-right: 1rem;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.session-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.session-row:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.session-row.selected {
  background: rgba(88,166,255,.12);
  border-color: var(--accent);
}

.session-datetime {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.session-counters {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.session-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 0.25rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}

.session-counter-critical {
  background: var(--danger);
}

.session-counter-medium {
  background: var(--warning);
  color: #1a1a2e;
}

.session-counter-low {
  background: var(--success);
}

/* Severity tabs */
.severity-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.severity-tab {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.severity-tab:hover {
  color: var(--text);
}

.severity-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-pane {
  display: block;
}

.tab-pane:not(.active) {
  display: none;
}

.tab-scan-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tab-scan-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.tab-scan-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tab-scan-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-scan-actions {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .scan-history-layout {
    grid-template-columns: 1fr;
  }

  .scan-sessions-column {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 1rem;
  }

  .session-list {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .session-row {
    min-width: 140px;
  }
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.6);
  cursor: pointer;
}

.modal-box {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 1rem;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
}

.modal-close:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.modal-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
