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

:root {
  --bg:          #0d1117;
  --bg2:         #161b22;
  --bg3:         #21262d;
  --border:      #30363d;
  --border-h:    #484f58;
  --text:        #e6edf3;
  --text2:       #8b949e;
  --text3:       #6e7681;
  --accent:      #2f81f7;
  --accent-h:    #388bfd;
  --green:       #3fb950;
  --yellow:      #d29922;
  --red:         #f85149;
  --blue:        #58a6ff;
  --purple:      #bc8cff;
  --radius:      10px;
  --radius-lg:   16px;
  --shadow:      0 4px 24px rgba(0,0,0,.4);
  --shadow-lg:   0 8px 48px rgba(0,0,0,.6);
  --transition:  .2s ease;
  --font:        'Inter', system-ui, sans-serif;
  --mono:        'JetBrains Mono', 'Fira Code', monospace;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ─────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: rgba(13,17,23,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-brand { display: flex; align-items: center; gap: 10px; }
.nav-icon  { font-size: 22px; }
.nav-title { font-weight: 700; font-size: 16px; letter-spacing: -.3px; }
.nav-badge {
  font-size: 10px; padding: 2px 8px; border-radius: 20px;
  background: linear-gradient(135deg, #1a3a6b, #2f81f7);
  color: #fff; letter-spacing: .5px; font-weight: 500;
}

.btn-signin {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 16px; border-radius: var(--radius);
  background: var(--accent); color: #fff; border: none;
  font: 500 13px var(--font); cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.btn-signin:hover { background: var(--accent-h); transform: translateY(-1px); }

.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border-h); }
.user-name { font-weight: 500; font-size: 13px; }
.btn-logout {
  font-size: 12px; color: var(--text2); padding: 4px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  transition: all var(--transition);
}
.btn-logout:hover { border-color: var(--red); color: var(--red); text-decoration: none; }

/* ── Main layout ─────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: flex; flex-direction: column; gap: 32px;
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero { text-align: center; padding: 20px 0 8px; }
.hero-title {
  font-size: 32px; font-weight: 700; letter-spacing: -.6px; margin-bottom: 10px;
  background: linear-gradient(135deg, #e6edf3, #58a6ff);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-sub { color: var(--text2); font-size: 15px; max-width: 560px; margin: 0 auto; }

/* ── Upload panel ────────────────────────────────────────────────────────── */
.upload-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex; flex-direction: column; gap: 22px;
  box-shadow: var(--shadow);
}

/* API key */
.api-key-section { display: flex; flex-direction: column; gap: 8px; }
.field-label {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .7px; color: var(--text2);
  display: flex; align-items: center; gap: 6px;
}
.api-key-row { display: flex; gap: 8px; align-items: center; }
.input-text {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px; color: var(--text);
  font-family: var(--mono); font-size: 13px;
  transition: border-color var(--transition);
}
.input-text:focus { outline: none; border-color: var(--accent); }
.input-text::placeholder { color: var(--text3); }
.field-hint { font-size: 11px; color: var(--text3); }

.btn-ghost {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; color: var(--text2);
  cursor: pointer; font-size: 13px; white-space: nowrap;
  transition: all var(--transition);
}
.btn-ghost:hover { border-color: var(--border-h); color: var(--text); }

/* Tooltip */
.tooltip {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg3); border: 1px solid var(--border);
  font-size: 10px; display: inline-flex; align-items: center; justify-content: center;
  cursor: help; color: var(--text3); position: relative;
}
.tooltip:hover::after {
  content: attr(data-tip);
  position: absolute; top: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg3); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 6px; font-size: 11px;
  white-space: nowrap; color: var(--text2); z-index: 10;
  box-shadow: var(--shadow);
}

/* Drop zone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(47,129,247,.06);
}
.dropzone-icon { font-size: 40px; }
.dropzone-text { font-size: 15px; font-weight: 500; }
.dropzone-sub  { font-size: 12px; color: var(--text2); }
.dropzone-file { font-size: 13px; color: var(--green); font-weight: 500; margin-top: 4px; }

/* Options */
.options-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.option-group { display: flex; flex-direction: column; gap: 8px; }
.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-card {
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all var(--transition);
}
.radio-card input[type="radio"] { display: none; }
.radio-card:hover { border-color: var(--border-h); background: var(--bg3); }
.radio-card.active { border-color: var(--accent); background: rgba(47,129,247,.1); color: var(--accent); }
.radio-sub { font-size: 11px; color: var(--text3); font-weight: 400; }
.radio-card.active .radio-sub { color: rgba(47,129,247,.7); }

/* Model selector */
.model-select-section { display: flex; flex-direction: column; gap: 8px; }
.model-select-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.select-model {
  flex: 1; min-width: 200px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 14px;
  color: var(--text); font: 500 13px var(--font);
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  transition: border-color var(--transition);
}
.select-model:focus { outline: none; border-color: var(--accent); }
.select-model optgroup { color: var(--text2); font-size: 11px; }
.select-model option { background: var(--bg3); color: var(--text); }
.model-hint {
  font-size: 12px; color: var(--text3);
  display: flex; align-items: center; gap: 4px;
  transition: color var(--transition);
  white-space: nowrap;
}
.model-hint.hint-thinking { color: var(--purple); }
.model-hint.hint-pro      { color: var(--yellow); }


/* Primary button */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 28px; border-radius: var(--radius);
  background: linear-gradient(135deg, #1a5bc7, var(--accent));
  color: #fff; border: none; font: 600 15px var(--font);
  cursor: pointer; transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(47,129,247,.3);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(47,129,247,.45);
}
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-icon { font-size: 16px; }

.btn-secondary {
  padding: 10px 22px; border-radius: var(--radius);
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); font: 500 13px var(--font); cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover { border-color: var(--border-h); color: var(--text); }

/* ── Progress panel ──────────────────────────────────────────────────────── */
.progress-panel {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px;
  display: flex; flex-direction: column; gap: 20px;
  box-shadow: var(--shadow);
}
.progress-steps { display: flex; flex-direction: column; gap: 10px; }
.progress-step {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--text3);
  transition: color var(--transition);
}
.progress-step.active  { color: var(--accent); }
.progress-step.done    { color: var(--green); }
.step-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: var(--border); transition: background var(--transition);
}
.progress-step.active .step-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 1s infinite; }
.progress-step.done   .step-dot { background: var(--green); }

@keyframes pulse {
  0%,100% { box-shadow: 0 0 4px var(--accent); }
  50%      { box-shadow: 0 0 12px var(--accent); }
}

.progress-bar-wrap {
  height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden;
}
.progress-bar {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, #1a5bc7, var(--accent));
  transition: width .4s ease;
}
.progress-msg { font-size: 12px; color: var(--text3); text-align: center; }

/* ── Results panel ───────────────────────────────────────────────────────── */
.results-panel {
  display: flex; flex-direction: column; gap: 24px;
}

/* Health + stats header */
.results-header {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.health-badge {
  font-size: 22px; font-weight: 700; padding: 10px 22px;
  border-radius: var(--radius-lg); border: 2px solid;
  white-space: nowrap;
}
.health-GREEN  { color: var(--green);  border-color: var(--green);  background: rgba(63,185,80,.08); }
.health-YELLOW { color: var(--yellow); border-color: var(--yellow); background: rgba(210,153,34,.08); }
.health-RED    { color: var(--red);    border-color: var(--red);    background: rgba(248,81,73,.08); }

.stats-row {
  display: flex; gap: 12px; flex-wrap: wrap;
}
.stat-chip {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-val { font-size: 20px; font-weight: 700; line-height: 1; }
.stat-key { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; }

/* Download bar */
.download-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.btn-download {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius);
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font: 500 13px var(--font); cursor: pointer;
  transition: all var(--transition); text-decoration: none;
}
.btn-download:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-download.pdf   { border-color: var(--red);    }
.btn-download.pdf:hover { background: rgba(248,81,73,.08); }
.btn-download.md    { border-color: var(--purple); }
.btn-download.md:hover  { background: rgba(188,140,255,.08); color: var(--purple); }
.btn-download.disabled {
  opacity: .72;
  color: var(--text3);
  border-style: dashed;
  cursor: default;
}

/* Section title */
.section-title {
  font-size: 15px; font-weight: 600; color: var(--text);
  margin-bottom: 14px;
}

/* Finding cards */
.findings-panel {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
}
.findings-list { display: flex; flex-direction: column; gap: 10px; }

.finding-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: border-color var(--transition);
}
.finding-card:hover { border-color: var(--border-h); }
.finding-card.P0 { border-left: 3px solid var(--red); }
.finding-card.P1 { border-left: 3px solid var(--yellow); }
.finding-card.P2 { border-left: 3px solid var(--blue); }

.finding-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; cursor: pointer;
  background: var(--bg3); user-select: none;
  transition: background var(--transition);
}
.finding-header:hover { background: color-mix(in srgb, var(--bg3) 80%, var(--text) 20%); }

.finding-id      { font-family: var(--mono); font-size: 12px; font-weight: 600; min-width: 46px; }
.finding-sev {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: .5px;
}
.sev-P0 { background: rgba(248,81,73,.2);    color: var(--red);    }
.sev-P1 { background: rgba(210,153,34,.2);   color: var(--yellow); }
.sev-P2 { background: rgba(88,166,255,.15);  color: var(--blue);   }

.finding-cat  { font-size: 11px; color: var(--text3); font-family: var(--mono); }
.finding-cell { font-size: 12px; color: var(--text2); font-family: var(--mono); margin-left: auto; }
.finding-chevron { font-size: 11px; color: var(--text3); transition: transform var(--transition); }
.finding-card.open .finding-chevron { transform: rotate(90deg); }

.finding-body {
  display: none; padding: 16px;
  background: var(--bg2); border-top: 1px solid var(--border);
}
.finding-card.open .finding-body { display: block; }
.finding-body table { width: 100%; border-collapse: collapse; font-size: 12px; }
.finding-body td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.finding-body td:first-child { color: var(--text2); font-weight: 500; width: 120px; white-space: nowrap; }
.finding-body code { font-family: var(--mono); font-size: 11px; background: var(--bg3); padding: 1px 5px; border-radius: 3px; word-break: break-all; }

.no-findings {
  text-align: center; padding: 40px; color: var(--green);
  font-size: 18px; font-weight: 600;
}

/* Layer 1 details */
.layer1-details {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px;
}
.layer1-details summary { cursor: pointer; list-style: none; }
.layer1-details summary::-webkit-details-marker { display: none; }
.layer1-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.l1-row {
  display: grid; grid-template-columns: 60px 80px 1fr auto;
  gap: 10px; align-items: center;
  padding: 8px 12px; background: var(--bg3); border-radius: 6px;
  font-size: 12px; font-family: var(--mono);
}
.sev-high   { color: var(--red); }
.sev-medium { color: var(--yellow); }
.sev-low    { color: var(--text3); }

/* Markdown preview */
.md-preview-details {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px;
}
.md-preview-details summary { cursor: pointer; list-style: none; }
.md-preview-details summary::-webkit-details-marker { display: none; }
.md-preview {
  margin-top: 16px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 20px; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
  font-family: var(--mono); font-size: 12px; color: var(--text2); max-height: 500px;
}

/* Footer */
.footer {
  text-align: center; padding: 24px;
  font-size: 12px; color: var(--text3);
  border-top: 1px solid var(--border);
}

/* License Badge */
.license-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  margin: 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.license-badge.active {
  background: rgba(63, 185, 80, 0.15);
  color: var(--green);
  border: 1px solid rgba(63, 185, 80, 0.3);
}

.license-badge.expired {
  background: rgba(248, 81, 73, 0.15);
  color: var(--red);
  border: 1px solid rgba(248, 81, 73, 0.3);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  animation: fadeIn 0.3s ease;
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.modal-body {
  padding: 24px;
  color: var(--text2);
}

.modal-body p {
  margin: 12px 0;
  line-height: 1.6;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-footer button {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  transition: all var(--transition);
}

.modal-footer .btn-primary {
  background: var(--green);
  color: white;
  border-color: var(--green);
  padding: 8px 24px;
}

.modal-footer .btn-primary:hover {
  background: #34a047;
  transform: translateY(-1px);
}

.modal-footer .btn-secondary:hover {
  border-color: var(--border-h);
  color: var(--text);
}

/* Prompt Review UI */
.prompt-review-panel {
  margin-top: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.header-with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.editor-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.editor-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.prompt-textarea {
  width: 100%;
  min-height: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}
.prompt-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Utility */
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .options-row { grid-template-columns: 1fr; }
  .hero-title  { font-size: 24px; }
  .results-header { flex-direction: column; align-items: flex-start; }
}

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.results-panel { animation: fadeIn .3s ease; }

/* ── Provider section ─────────────────────────────────────────────────────── */
.provider-section {
  margin-bottom: 20px;
}
.provider-section .radio-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.provider-section .radio-card {
  flex: 1;
  min-width: 140px;
}

/* Local models status indicator */
#localModelsStatus {
  font-size: 12px;
  color: var(--text2);
  margin-left: 4px;
}
