/* ── Reset & tokens ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0f172a;
  --surface:     #1e293b;
  --surface2:    #273548;
  --border:      #2d3f55;
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --primary:     #3b82f6;
  --primary-h:   #2563eb;
  --success:     #22c55e;
  --success-bg:  #14532d33;
  --warning:     #f59e0b;
  --warning-bg:  #78350f33;
  --danger:      #ef4444;
  --danger-bg:   #7f1d1d33;
  --radius:      10px;
  --font:        'Inter', system-ui, -apple-system, sans-serif;
}

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Header ─────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.logo-icon {
  width: 22px;
  height: 22px;
  color: var(--primary);
}

.logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: .75rem;
}

/* Health pill */
.health-pill {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .3rem .75rem;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: .8rem;
  color: var(--text-muted);
  transition: background .2s;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background .3s;
  flex-shrink: 0;
}

.health-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.health-dot.offline { background: var(--danger);  box-shadow: 0 0 6px var(--danger); }

.health-label.online  { color: var(--success); }
.health-label.offline { color: var(--danger); }

/* Icon button */
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: .35rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color .15s, background .15s;
}

.btn-icon:hover { color: var(--text); background: var(--surface2); }
.btn-icon svg   { width: 18px; height: 18px; }

/* ── Main ────────────────────────────────────────────────────── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Global Stats ───────────────────────────────────────────── */
.global-stats {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.25rem;
  margin-bottom: 2rem;
  animation: slide-up-stats .4s ease;
}

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

/* Gauge */
.gauge-container {
  gap: 2rem;
}

.gauge-wrap {
  position: relative;
  width: 130px;
  height: 130px;
  flex-shrink: 0;
}

.gauge {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: var(--surface2);
  stroke-width: 8;
}

.gauge-progress {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 282.7; /* 2 * PI * 45 */
  stroke-dashoffset: 282.7;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.3s;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1rem;
}

.gauge-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.gauge-label {
  font-size: .6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}

.gauge-info h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: .25rem;
  color: var(--text);
}

.gauge-info p {
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Counts */
.counts-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.count-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem;
  transition: transform .1s;
}

.count-item:hover { transform: translateY(-2px); }

.count-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
}

.count-label {
  font-size: .6rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--text-muted);
}

.count-item[data-sev="critical"] .count-value { color: var(--danger); }
.count-item[data-sev="high"]     .count-value { color: var(--warning); }
.count-item[data-sev="medium"]   .count-value { color: #fbbf24; }
.count-item[data-sev="low"]      .count-value { color: var(--success); }

@keyframes slide-up-stats {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@media (max-width: 850px) {
  .global-stats { grid-template-columns: 1fr; }
}

/* WAF Badge Styles */
.waf-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #64748b;
}

.waf-badge.detected {
  background: #fef2f2;
  color: #ef4444;
  border: 1px solid #fee2e2;
}

.waf-badge.bypassed {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #dcfce7;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.toolbar h1 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: 7px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .08s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover  { background: var(--primary-h); }
.btn-primary:active { transform: scale(.97); }

.btn-primary svg { width: 15px; height: 15px; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

thead th {
  background: var(--surface2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .75rem 1rem;
  text-align: left;
  white-space: nowrap;
}

tbody tr {
  border-top: 1px solid var(--border);
  transition: background .1s;
}
tbody tr:hover { background: var(--surface2); }

tbody td {
  padding: .85rem 1rem;
  color: var(--text);
  vertical-align: middle;
}

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-size: .9rem;
}

/* Domain cell */
.domain-cell {
  font-weight: 600;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .82rem;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .65rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-running {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid #f59e0b44;
}

.badge-done {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #22c55e44;
}

.badge-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #ef444444;
}

.badge-cancelled {
  background: rgba(156, 163, 175, 0.12);
  color: #9ca3af;
  border: 1px solid rgba(156, 163, 175, 0.3);
}

/* Cancel button for running scans */
.btn-cancel {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-cancel:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.6);
  transform: translateY(-1px);
}

.btn-cancel:active {
  transform: translateY(0);
}

/* Spinning dot for running */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.4s ease-in-out infinite;
}

/* Phase text */
.phase-text {
  color: var(--text-muted);
  font-size: .82rem;
  max-width: 220px;
}

/* Date & duration cells */
.date-text {
  color: var(--text-muted);
  font-size: .82rem;
  white-space: nowrap;
}

/* Report button */
.btn-report {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: .3rem .65rem;
  border-radius: 6px;
  font-size: .78rem;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-report:hover       { border-color: var(--primary); color: var(--primary); }
.btn-report:disabled    { opacity: .35; cursor: not-allowed; }

/* ── Modal / Overlay ─────────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(3px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem 2rem;
  width: 100%;
  max-width: 420px;
  animation: slide-up .18s ease;
}

@keyframes slide-up {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: .3rem;
}

.modal-sub {
  color: var(--text-muted);
  font-size: .85rem;
  margin-bottom: 1.1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: 1rem;
}

.field label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.btn-report {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-report:hover {
  background: var(--border);
  border-color: var(--text-muted);
}

.btn-report.lang-en:hover {
  border-color: #0096D6;
  color: #0096D6;
}

.btn-report.lang-fr:hover {
  border-color: #E53935;
  color: #E53935;
}

.btn-report.btn-util {
  color: var(--text-muted);
  font-weight: 400;
}

.btn-report.btn-util:hover {
  color: var(--text);
  border-color: var(--text-muted);
}
.field input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .6rem .8rem;
  border-radius: 7px;
  font-size: .9rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}

.field input:focus { border-color: var(--primary); }
.field input::placeholder { color: var(--text-muted); }

.field-hint {
  font-size: .75rem;
  color: var(--text-muted);
}

.modal-error {
  color: var(--danger);
  font-size: .82rem;
  min-height: 1.2rem;
  margin-bottom: .5rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  margin-top: 1rem;
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar        { width: 6px; }
::-webkit-scrollbar-track  { background: var(--bg); }
::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 3px; }

/* ── Report Drawer ───────────────────────────────────────────── */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
  z-index: 200;
}
.drawer-backdrop.open { display: block; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 75%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .28s cubic-bezier(.4, 0, .2, 1),
              visibility 0s linear .28s;
  overflow: hidden;
  will-change: transform;
}
.drawer.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform .28s cubic-bezier(.4, 0, .2, 1),
              visibility 0s linear 0s;
}

@media (max-width: 768px) { .drawer { width: 100%; } }

/* Drawer header */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-title  { display: flex; flex-direction: column; gap: .2rem; }
.drawer-domain {
  font-size: 1rem;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text);
}
.drawer-date { font-size: .78rem; color: var(--text-muted); }

/* Summary bar */
.drawer-summary {
  display: flex;
  gap: 2rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.summary-stat         { display: flex; flex-direction: column; gap: .1rem; }
.summary-stat-value   { font-size: 1.35rem; font-weight: 700; line-height: 1; }
.summary-stat-label   {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}

/* Scrollable body */
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

/* Finding card */
.finding-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.finding-card.sev-critical { border-left-color: #ef4444; }
.finding-card.sev-high     { border-left-color: #f97316; }
.finding-card.sev-medium   { border-left-color: #f59e0b; }
.finding-card.sev-low      { border-left-color: #3b82f6; }

/* Top row: CVE | badges | score */
.finding-top {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-wrap: wrap;
}
.finding-cve {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .875rem;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}
.finding-badges {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  align-items: center;
  flex: 1;
}
.finding-score {
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--text-muted);
}
.finding-score.sev-critical { color: #f87171; }
.finding-score.sev-high     { color: #fb923c; }
.finding-score.sev-medium   { color: #fbbf24; }
.finding-score.sev-low      { color: #60a5fa; }

.finding-meta {
  font-size: .78rem;
  color: var(--text-muted);
  display: flex;
  gap: .75rem 1.25rem;
  flex-wrap: wrap;
}
.finding-meta span { white-space: nowrap; }

.finding-desc {
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* Severity badges */
.sev-badge {
  display: inline-flex;
  align-items: center;
  padding: .18rem .5rem;
  border-radius: 4px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.sev-badge.sev-critical { background: #7f1d1d55; color: #f87171; border: 1px solid #ef444455; }
.sev-badge.sev-high     { background: #7c2d1255; color: #fb923c; border: 1px solid #f9731655; }
.sev-badge.sev-medium   { background: #78350f55; color: #fbbf24; border: 1px solid #f59e0b55; }
.sev-badge.sev-low      { background: #1e3a5f55; color: #60a5fa; border: 1px solid #3b82f655; }
.sev-badge.sev-unknown  { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }

/* Confidence badges */
.conf-badge {
  display: inline-flex;
  align-items: center;
  padding: .18rem .5rem;
  border-radius: 4px;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.conf-confirmed { background: #14532d44; color: #4ade80; border: 1px solid #22c55e44; }
.conf-potential { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }

/* Empty / loading states */
.drawer-empty, .drawer-loading {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: .9rem;
}
