/* ── Reset & base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --border:    #dde3ec;
  --blue:      #1f497d;
  --blue-mid:  #2e74b5;
  --blue-lt:   #ebf3fb;
  --green:     #288057;
  --amber:     #f9a825;
  --orange:    #e65200;
  --red:       #c62228;
  --text:      #1a1a2e;
  --muted:     #5c6880;
  --radius:    10px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
  --font:      'Segoe UI', system-ui, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────────────────── */
header {
  background: var(--blue);
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.header-inner { display: flex; align-items: baseline; gap: 16px; }
.logo  { font-size: 1.25rem; font-weight: 700; letter-spacing: .02em; }
.tagline { font-size: .8rem; opacity: .75; }

/* ── Main ─────────────────────────────────────────────────────── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 16px;
  gap: 24px;
}

/* ── Card ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 680px;
}
.card h2 { font-size: 1.2rem; color: var(--blue); margin-bottom: 8px; }
.hint { color: var(--muted); font-size: .9rem; margin-bottom: 20px; }

/* ── Drop zone ────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--blue-mid);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  user-select: none;
}
.drop-zone:hover,
.drop-zone.drag-over {
  background: var(--blue-lt);
  border-color: var(--blue);
}
.drop-icon  { font-size: 2.5rem; margin-bottom: 12px; }
.drop-label { color: var(--muted); font-size: .95rem; }
.drop-label .link { color: var(--blue-mid); text-decoration: underline; }

/* ── File info ────────────────────────────────────────────────── */
.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--blue-lt);
  border-radius: 6px;
  font-size: .9rem;
}
.file-icon { font-size: 1.2rem; }
.btn-clear {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}
.btn-clear:hover { color: var(--red); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  width: 100%;
  padding: 13px 24px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, opacity .15s;
}
.btn-primary:hover:not(:disabled) { background: var(--blue-mid); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 24px;
  background: none;
  color: var(--blue);
  border: 2px solid var(--blue);
  border-radius: 7px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--blue-lt); }

/* ── Progress ─────────────────────────────────────────────────── */
.progress-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
}
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--blue-mid);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#progress-text { color: var(--muted); font-size: .95rem; }

/* ── Results ──────────────────────────────────────────────────── */
.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
#result-title { font-size: 1.3rem; color: var(--blue); }
.result-meta  { color: var(--muted); font-size: .85rem; margin-top: 4px; }

/* Rating badge */
.rating-badge {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .95rem;
  color: #fff;
  background: var(--muted);
  white-space: nowrap;
}
.rating-Low      { background: var(--green); }
.rating-Medium   { background: var(--amber); color: #333; }
.rating-High     { background: var(--orange); }
.rating-VeryHigh { background: var(--red); }

/* Scope callout */
.scope-callout {
  background: var(--blue-lt);
  border-left: 4px solid var(--blue-mid);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 24px;
}
.callout-row   { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.callout-label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.callout-value { font-size: 1.05rem; font-weight: 700; color: var(--blue); }
.callout-value.dim { font-size: .9rem; font-weight: 400; color: var(--muted); }
.callout-note  { font-size: .88rem; color: var(--muted); margin-bottom: 12px; }
.callout-next-label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.callout-next  { font-size: .9rem; color: var(--text); }

/* Metrics grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.metric-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.metric-tile .m-label { font-size: .75rem; color: var(--muted); margin-bottom: 4px; }
.metric-tile .m-value { font-size: 1.15rem; font-weight: 700; color: var(--blue); }
.metric-tile.flag-yes .m-value { color: var(--orange); }

/* Rebuild + flag sections */
#rebuild-section,
#flags-section { margin-bottom: 20px; }
#rebuild-section h3,
#flags-section h3 { font-size: 1rem; color: var(--blue); margin-bottom: 10px; }

#rebuild-list { padding-left: 20px; color: var(--text); font-size: .9rem; line-height: 1.8; }

.flag-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.flag-pill {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  background: var(--blue-lt);
  color: var(--blue);
  border: 1px solid var(--blue-mid);
}
.flag-pill.warn { background: #fff3e0; color: var(--orange); border-color: var(--orange); }
.flag-pill.risk { background: #fce4e4; color: var(--red); border-color: var(--red); }

/* Issues table */
#issues-section { margin-bottom: 24px; }
#issues-section h3 { font-size: 1rem; color: var(--blue); margin-bottom: 10px; }
.issues-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.issues-table th {
  background: var(--blue-mid);
  color: #fff;
  padding: 8px 12px;
  text-align: left;
}
.issues-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); }
.issues-table tr:last-child td { border-bottom: none; }
.badge-error   { background: var(--red);    color: #fff; padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: .75rem; }
.badge-warning { background: var(--amber);  color: #333; padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: .75rem; }
.badge-note    { background: var(--border); color: var(--text); padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: .75rem; }

/* Result actions */
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}
.result-actions .btn-primary { width: auto; margin-top: 0; }
.result-actions .btn-secondary { text-decoration: none; }

/* Batch / multi-result extras */
.result-card + .result-card { margin-top: 16px; }
.result-filename { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.error-job-card { border-left: 4px solid var(--red); }
.error-detail   { color: var(--red); font-size: .9rem; margin-top: 8px; }
.metric-tile-wide { grid-column: span 2; }

/* Reset row below results */
.reset-row { display: flex; justify-content: center; padding: 16px 0 32px; }

/* ── Footer ───────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 20px;
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  .card { padding: 20px; }
  .result-header { flex-direction: column; }
  .rating-badge { align-self: flex-start; }
}
