/* ── Base ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'Segoe UI', Arial, sans-serif; background: #f0f2f5; color: #1a1a2e; margin: 0; font-size: 16px; }
a { color: #4361ee; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.wrap { max-width: 1400px; margin: 24px auto; padding: 0 24px; }

/* ── Nav ─────────────────────────────────────────────────────────────────── */
.nav { background: #1a1a2e; padding: 0 24px; display: flex; gap: 28px; align-items: center; height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 19px; margin-right: auto; text-decoration: none; }
.brand:hover { text-decoration: none; }
.nav-logo { width: 34px; height: 34px; object-fit: contain; border-radius: 4px; }
.nav a { color: #a8c0ff; font-size: 15px; font-weight: 500; }
.nav a:hover { color: #fff; text-decoration: none; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 24px; margin: 16px 0; }
.card h2 { margin: 0 0 14px; font-size: 20px; }
.card h3 { margin: 14px 0 10px; font-size: 17px; color: #444; }

/* ── Stats ───────────────────────────────────────────────────────────────── */
.stats { display: flex; gap: 16px; flex-wrap: wrap; margin: 20px 0; }
.stat { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px 28px; min-width: 160px; flex: 1; }
.stat strong { display: block; font-size: 36px; color: #4361ee; line-height: 1.1; }
.stat span { font-size: 14px; color: #888; margin-top: 4px; display: block; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; }
.badge-chat { background: #dbeafe; color: #1d4ed8; }
.badge-email { background: #fce7f3; color: #9d174d; }
.badge-closed { background: #dcfce7; color: #15803d; }
.badge-escalated { background: #fef3c7; color: #92400e; }
.badge-contract { background: #ede9fe; color: #5b21b6; font-family: monospace; font-size: 12px; }
.badge-info { background: #f0fdf4; color: #166534; }

/* ── Pipeline trace ──────────────────────────────────────────────────────── */
.pipeline { display: flex; gap: 0; flex-wrap: wrap; margin: 16px 0; }
.pipe-step { background: #f8fafc; border: 1px solid #e2e8f0; padding: 10px 18px; font-size: 14px; position: relative; }
.pipe-step:not(:last-child)::after { content: '→'; position: absolute; right: -11px; top: 50%; transform: translateY(-50%); color: #aaa; z-index: 1; }
.pipe-step .label { font-weight: 700; font-size: 12px; color: #888; display: block; margin-bottom: 2px; }

/* ── Signal grid ─────────────────────────────────────────────────────────── */
.signals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 12px 0; }
.signal-item { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px 16px; }
.signal-item .key { font-size: 12px; color: #888; font-weight: 600; text-transform: uppercase; margin-bottom: 4px; }
.signal-item .val { font-size: 15px; font-weight: 500; color: #1a1a2e; word-break: break-word; }
.signal-item .val.missing { color: #ccc; font-style: italic; }

/* ── Contract cards ──────────────────────────────────────────────────────── */
.contract-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.contract-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 20px; }
.contract-card .kind { font-size: 12px; text-transform: uppercase; font-weight: 700; color: #888; margin-bottom: 8px; }
.contract-card h3 { margin: 0 0 10px; font-size: 17px; }
.contract-card .purpose { font-size: 14px; color: #666; margin-bottom: 12px; }

/* ── Ticket list ─────────────────────────────────────────────────────────── */
.ticket-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid #f0f0f0; }
.ticket-row:last-child { border-bottom: none; }

/* ── Resolution output ───────────────────────────────────────────────────── */
.resolution-box { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: 20px; margin: 12px 0; }
.resolution-box .label { font-size: 13px; text-transform: uppercase; font-weight: 700; color: #15803d; margin-bottom: 10px; }
.resolution-item { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; margin-bottom: 12px; }
.resolution-item .rank { font-size: 12px; color: #888; font-weight: 700; }
.resolution-item h4 { margin: 6px 0 8px; font-size: 16px; }
.resolution-item ul { margin: 6px 0; padding-left: 20px; font-size: 14px; }
.resolution-item p { font-size: 14px; }

/* ── Checks ──────────────────────────────────────────────────────────────── */
.check-box { background: #fefce8; border: 1px solid #fef08a; border-radius: 10px; padding: 18px; margin: 12px 0; }
.check-box .label { font-size: 13px; text-transform: uppercase; font-weight: 700; color: #a16207; margin-bottom: 10px; }
.check-row { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; }
.check-row .key { color: #666; }
.check-row .val { font-weight: 600; }
.val-true { color: #15803d; }
.val-false { color: #b91c1c; }
.val-null { color: #aaa; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; color: #333; }
input, select, textarea {
  width: 100%; padding: 12px 14px;
  border: 1px solid #e2e8f0; border-radius: 8px;
  font-size: 15px; outline: none; background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: #4361ee; box-shadow: 0 0 0 3px rgba(67,97,238,0.1); }
button.btn {
  background: #4361ee; color: #fff; border: none; border-radius: 8px;
  padding: 14px 28px; font-size: 16px; font-weight: 600;
  cursor: pointer; width: 100%; margin-top: 18px;
}
button.btn:hover { background: #3751d7; }

/* ── File picker dropdown ─────────────────────────────────────────────────── */
.drop-opt { display:flex;align-items:center;gap:10px;padding:10px 14px;cursor:pointer; }
.drop-opt:hover { background:#f0f4ff; }
.drop-thumb { width:64px;height:42px;object-fit:cover;border-radius:4px;border:1px solid #e2e8f0;flex-shrink:0; }

/* ── File picker ──────────────────────────────────────────────────────────── */
.file-picker { width: 100%; padding: 12px 14px; border: 1px dashed #c0c8d8; border-radius: 8px; font-size: 15px; color: #555; cursor: pointer; background: #f8fafc; }
.file-picker:hover { border-color: #4361ee; background: #f0f4ff; }

/* ── Result panel ─────────────────────────────────────────────────────────── */
#result-panel { display: none; margin-top: 24px; }
pre {
  background: #1e1e3f; color: #a8c0ff;
  padding: 18px; border-radius: 10px;
  overflow: auto; white-space: pre-wrap;
  font-size: 14px; max-height: 420px;
}

/* ── Tags list ────────────────────────────────────────────────────────────── */
.tags { display: flex; flex-wrap: wrap; gap: 7px; margin: 8px 0; }

/* ── JSON details ─────────────────────────────────────────────────────────── */
details summary { cursor: pointer; font-size: 14px; color: #4361ee; font-weight: 600; padding: 5px 0; }

/* ── Separator ────────────────────────────────────────────────────────────── */
hr { border: none; border-top: 1px solid #e2e8f0; margin: 22px 0; }

/* ── Candidate contracts ──────────────────────────────────────────────────── */
.candidates { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.candidate { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 20px; padding: 5px 14px; font-size: 13px; font-family: monospace; }
.candidate.selected { background: #ede9fe; border-color: #8b5cf6; color: #5b21b6; font-weight: 700; }

/* ── Two-column layout ────────────────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ── Page headings ────────────────────────────────────────────────────────── */
h1 { font-size: 28px; margin-bottom: 6px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
