:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --ink: #16201e;
  --muted: #61706b;
  --line: #d9e0db;
  --green: #147a42;
  --yellow: #9a6a00;
  --red: #b42318;
  --blue: #2359ff;
  --teal: #08746f;
  --shadow: 0 18px 50px rgba(22, 32, 30, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(35, 89, 255, 0.08), transparent 32%),
    linear-gradient(220deg, rgba(8, 116, 111, 0.08), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
}

button {
  min-height: 38px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
}

button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.file-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px;
  background: #fbfcfb;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 32px 18px;
}

.app-header h1 {
  max-width: 880px;
  margin: 0;
  font-size: clamp(28px, 4vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 248px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.account-chip span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 7px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 850;
}

.account-chip small {
  display: block;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  gap: 18px;
  padding: 0 32px 32px;
}

.sidebar {
  position: sticky;
  top: 18px;
  align-self: start;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.nav {
  justify-content: flex-start;
  width: 100%;
  text-align: left;
}

.nav.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.workspace {
  min-width: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(24px, 3vw, 36px);
}

h3 {
  font-size: 18px;
}

.scan-grid,
.two-column,
.summary-grid,
.trust-grid,
.proof-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
}

.two-column.wide-left {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
}

.site-card,
.risk-card,
.panel,
.metrics article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.site-card,
.risk-card,
.panel {
  padding: 18px;
}

.explain {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #cddbd4;
  border-radius: 8px;
  background: #f7fbf8;
}

.explain.tight {
  margin-bottom: 12px;
}

.explain strong {
  display: block;
  margin-bottom: 4px;
}

.explain p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.proof-grid {
  margin: 16px 0;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
}

.risk-card {
  display: grid;
  gap: 16px;
  align-content: start;
}

.field-row {
  margin-bottom: 14px;
}

.field-row label,
.check {
  display: block;
  margin-bottom: 6px;
  color: #33413d;
  font-size: 13px;
  font-weight: 750;
}

.help {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 0;
  line-height: 1.4;
}

.check input {
  width: auto;
  margin-top: 3px;
}

.badge {
  width: fit-content;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 850;
}

.badge.green {
  background: #dff3e6;
  color: var(--green);
}

.badge.yellow {
  background: #fff1c6;
  color: var(--yellow);
}

.badge.red {
  background: #fee4e2;
  color: var(--red);
}

.hero-number {
  display: block;
  font-size: 76px;
  line-height: 0.9;
}

.muted {
  color: var(--muted);
  line-height: 1.5;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--surface-2);
  color: #34413e;
  font-size: 12px;
  font-weight: 700;
}

.warning-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.warning {
  border-left: 4px solid var(--red);
  padding: 10px;
  border-radius: 6px;
  background: #fff7f6;
  color: #49130f;
}

.mini-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.mini-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfb;
  color: #34413e;
  font-size: 13px;
  line-height: 1.4;
}

.mini-item ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

pre {
  min-height: 250px;
  max-height: 390px;
  overflow: auto;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101917;
  color: #e9f2ee;
  font-size: 12px;
  white-space: pre-wrap;
}

.summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-card strong {
  display: block;
  margin-bottom: 8px;
}

.summary-card .status {
  display: inline-block;
  margin-bottom: 8px;
  border-radius: 999px;
  padding: 5px 8px;
  background: #edf1ee;
  color: #34413e;
  font-size: 12px;
  font-weight: 800;
}

.summary-card .status.detected {
  background: #dff3e6;
  color: var(--green);
}

.summary-card .status.missing {
  background: #fff1c6;
  color: var(--yellow);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.timeline,
.queue {
  display: grid;
  gap: 10px;
}

.timeline-item,
.queue-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfb;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metrics article {
  padding: 16px;
}

.metrics span {
  display: block;
  font-size: 34px;
  font-weight: 850;
}

.metrics small {
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #394642;
  font-size: 12px;
  text-transform: uppercase;
}

.trust-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ── Copilot redesign ───────────────────────────── */
.scan-input-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}

.scan-input-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.scan-btn {
  flex-shrink: 0;
  min-height: 42px;
  border-radius: 8px;
  font-size: 14px;
  white-space: nowrap;
}

.scan-meta-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.import-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.ghost-btn {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.ghost-btn:hover { background: var(--surface-2); color: var(--ink); }

.scan-status {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  min-height: 18px;
}

/* Results area */
.results-area { display: flex; flex-direction: column; gap: 16px; }

.risk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.risk-bar-left { display: flex; align-items: center; gap: 16px; }
.risk-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.risk-number { font-size: 48px; font-weight: 800; line-height: 1; color: var(--ink); }
.risk-guidance { font-size: 13px; color: var(--muted); max-width: 340px; margin: 0; }

.chips-row { display: flex; flex-wrap: wrap; gap: 7px; }

.findings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.finding-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.finding-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 12px;
}

.finding-list { display: flex; flex-direction: column; gap: 8px; }

.finding-item {
  font-size: 13px;
  line-height: 1.45;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 7px;
  color: var(--ink);
}

.finding-item strong { display: block; font-size: 12px; margin-bottom: 2px; }
.finding-item .fi-meta { font-size: 11px; color: var(--muted); }

.rights-item {
  font-size: 13px;
  padding: 7px 10px;
  border-left: 3px solid var(--teal);
  background: #f0faf9;
  border-radius: 0 6px 6px 0;
}

.mismatch-alerts { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.mismatch-alert {
  font-size: 12.5px;
  padding: 8px 10px;
  background: #fff8f0;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  color: #92400e;
}

.evidence-details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 18px;
}
.evidence-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.evidence-details pre {
  font-size: 11px;
  max-height: 200px;
  overflow: auto;
  margin: 12px 0;
  padding: 10px;
  background: var(--surface-2);
  border-radius: 6px;
}

@media (max-width: 700px) {
  .findings-grid { grid-template-columns: 1fr; }
  .scan-input-row { flex-direction: column; align-items: stretch; }
  .scan-btn { width: 100%; }
}

.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(22, 32, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.auth-modal-card {
  width: 420px;
  max-width: 90vw;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(22, 32, 30, 0.18);
}

.auth-modal-card h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.auth-modal-card .field-row {
  margin-bottom: 12px;
}

#clerk-sign-in:empty {
  display: none;
}

@media (max-width: 980px) {
  .app-header,
  .section-head {
    flex-direction: column;
  }

  .layout,
  .scan-grid,
  .two-column,
  .two-column.wide-left,
  .summary-grid,
  .trust-grid,
  .proof-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .layout {
    padding: 0 16px 24px;
  }

  .sidebar {
    position: static;
  }
}
