:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1c2128;
  --text-muted: #5b6472;
  --accent: #2f5ee0;
  --accent-dark: #1f45b0;
  --success-bg: #eefaf0;
  --success-border: #a9dfb4;
  --success-text: #1b7c34;
  --warning-bg: #fff8e8;
  --warning-border: #f0d68a;
  --warning-text: #8a6110;
  --error-bg: #fdeeee;
  --error-border: #f0aaaa;
  --error-text: #a3241f;
  --info-bg: #eef3fd;
  --info-border: #b9cdf3;
  --info-text: #29498a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

header.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  display: block;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

header.top h1 {
  font-size: 22px;
  margin: 0;
}

header.top p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  padding: 3px;
}
.mode-toggle button {
  border: none;
  background: transparent;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}
.mode-toggle button.active {
  background: var(--accent);
  color: white;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

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

textarea#logText {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  resize: vertical;
  background: #fbfbfc;
  color: var(--text);
}

.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--info-bg);
}

button.primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button.primary:hover { background: var(--accent-dark); }
button.primary:disabled { opacity: 0.55; cursor: default; }

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
}
button.ghost:hover { background: #f0f1f4; }

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

.small-muted { font-size: 12.5px; color: var(--text-muted); }

#results { display: none; }

.finding {
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.finding.success { background: var(--success-bg); border-color: var(--success-border); }
.finding.warning { background: var(--warning-bg); border-color: var(--warning-border); }
.finding.error   { background: var(--error-bg);   border-color: var(--error-border); }
.finding.info    { background: var(--info-bg);    border-color: var(--info-border); }

.finding .badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.finding.success .badge { background: var(--success-text); color: white; }
.finding.warning .badge { background: var(--warning-text); color: white; }
.finding.error .badge   { background: var(--error-text);   color: white; }
.finding.info .badge    { background: var(--info-text);    color: white; }

.finding h2 {
  margin: 0 0 8px;
  font-size: 18px;
}
.finding p.summary {
  margin: 0 0 12px;
  font-size: 15px;
}
.finding ol.steps {
  margin: 0;
  padding-left: 20px;
}
.finding ol.steps li {
  margin-bottom: 6px;
  font-size: 14px;
}

.support-detail {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed rgba(0,0,0,0.12);
  font-size: 13px;
  color: var(--text-muted);
}
.support-detail code {
  background: rgba(0,0,0,0.05);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.evidence-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 13px;
}
.evidence-table td {
  padding: 4px 8px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  vertical-align: top;
}
.evidence-table td:first-child {
  color: var(--text-muted);
  white-space: nowrap;
  width: 220px;
}

.call-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 20px;
  font-size: 13.5px;
}
.call-summary-grid .label { color: var(--text-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; }
.call-summary-grid .value { font-weight: 600; }

.secondary-findings summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 6px 0;
}

.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
}
.timeline li {
  display: grid;
  grid-template-columns: 175px 160px 1fr;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.timeline li .ts { color: var(--text-muted); font-family: monospace; font-size: 12px; }
.timeline li .label { font-weight: 600; }
.timeline li .detail { color: var(--text-muted); word-break: break-all; }

details.collapsible summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px;
}

.callflow-diagram {
  width: 100%;
  overflow-x: auto;
  padding: 6px 0 10px;
}
.callflow-diagram svg {
  width: 100%;
  max-width: 800px;
  height: auto;
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 11px;
}
.callflow-steps {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  border-top: 1px dashed rgba(0,0,0,0.1);
}
.callflow-steps li {
  padding: 5px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.callflow-steps li .ts {
  font-family: monospace;
  font-size: 11.5px;
  margin-right: 6px;
}

.clearing-summary {
  margin: 0 0 10px;
  font-size: 14.5px;
}
.clearing-table {
  margin-top: 0;
}

.footer-note {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 30px;
}

.error-banner {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.5);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
