:root {
  --bg: #0f1117;
  --panel: #171a22;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #5b9fd4;
  --form: #4a90d9;
  --view: #6abf69;
  --lookup: #c9a227;
  --agent: #c06060;
  --subform: #9b7bd4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.dxl-source-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.55rem;
  margin: 6px 0 0;
  font-size: 0.84rem;
  color: var(--text);
}

.dxl-source-line[hidden] {
  display: none;
}

.dxl-source-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.dxl-source-line code,
.dxl-file-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  color: #d7e7f7;
  background: rgba(91, 159, 212, 0.14);
  border: 1px solid rgba(91, 159, 212, 0.35);
  border-radius: 6px;
  padding: 0.12rem 0.45rem;
}

.dxl-file-pill {
  display: inline-block;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.overview-header .dxl-context {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.controls {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}

select, button {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.85rem;
}

button {
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.zoom-controls {
  display: flex;
  gap: 4px;
  align-items: flex-end;
}

.zoom-controls button {
  width: 36px;
  padding: 8px 0;
  font-size: 1rem;
  line-height: 1;
}

#fitBtn {
  width: auto;
  padding: 8px 12px;
  font-size: 0.8rem;
}

.upload-label {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  background: rgba(201, 162, 39, 0.12);
  border: 1px solid rgba(201, 162, 39, 0.5);
  border-radius: 6px;
  color: #e0bc40;
  font-size: 0.85rem;
  cursor: pointer;
}

.upload-label:hover {
  background: rgba(201, 162, 39, 0.22);
}

.upload-status {
  font-size: 0.75rem;
  color: var(--muted);
  max-width: 220px;
  line-height: 1.3;
}

.upload-status.success {
  color: #8ee08c;
}

.upload-status.error {
  color: #f28b82;
}

.view-tabs {
  display: flex;
  gap: 0;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.view-tabs .tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 18px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: -1px;
}

.view-tabs .tab:hover {
  color: var(--text);
  border-bottom-color: var(--border);
}

.view-tabs .tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 6px !important;
  font-size: 0.8rem !important;
  color: var(--text) !important;
  padding-bottom: 2px;
}

.checkbox-label input {
  accent-color: var(--accent);
}

.hidden {
  display: none !important;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
  width: 100%;
  max-width: 100vw;
  min-height: calc(100vh - 120px);
  overflow-x: hidden;
}

.layout.layout-full {
  grid-template-columns: minmax(0, 1fr);
}

.main-panel {
  position: relative;
  border-right: 1px solid var(--border);
  min-height: calc(100vh - 120px);
  min-width: 0;
  overflow-x: hidden;
}

.layout.layout-full .main-panel {
  border-right: none;
}

.graph-panel {
  position: relative;
}

.matrix-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.matrix-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.matrix-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.matrix-hint code {
  font-size: 0.75rem;
  color: var(--lookup);
}

.matrix-scroll {
  flex: 1;
  overflow: auto;
  padding: 12px;
  max-height: calc(100vh - 170px);
}

.lookup-matrix {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.72rem;
  min-width: max-content;
}

.lookup-matrix th,
.lookup-matrix td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: center;
  white-space: nowrap;
}

.lookup-matrix .corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 3;
  background: var(--panel);
  text-align: left;
  min-width: 160px;
}

.lookup-matrix .row-header {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--panel);
  text-align: left;
  font-weight: 500;
  cursor: pointer;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lookup-matrix .row-header:hover {
  color: var(--accent);
}

.lookup-matrix .col-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  font-weight: 500;
  writing-mode: horizontal-tb;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lookup-matrix .row-total {
  background: rgba(91, 159, 212, 0.08);
  font-weight: 600;
  color: var(--accent);
}

.lookup-matrix td.heat-0 {
  background: var(--bg);
  color: transparent;
}

.lookup-matrix td.heat-1 {
  background: rgba(201, 162, 39, 0.15);
  color: #e8d080;
}

.lookup-matrix td.heat-2 {
  background: rgba(201, 162, 39, 0.3);
  color: #f0e0a0;
}

.lookup-matrix td.heat-3 {
  background: rgba(201, 162, 39, 0.5);
  color: #fff;
  font-weight: 600;
}

.lookup-matrix td.heat-4 {
  background: rgba(201, 162, 39, 0.75);
  color: #fff;
  font-weight: 700;
}

.lookup-matrix td.clickable {
  cursor: pointer;
}

.lookup-matrix td.clickable:hover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.btn-focus {
  display: block;
  width: 100%;
  margin-bottom: 12px;
  padding: 8px;
  background: rgba(91, 159, 212, 0.12);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
}

.overview-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.overview-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  max-height: calc(100vh - 150px);
}

.overview-header h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.overview-sub {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.overview-section {
  margin-bottom: 24px;
}

.overview-section h2 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--accent);
}

.overview-section h3 {
  margin: 12px 0 6px;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.overview-table {
  width: 100%;
  font-size: 0.8rem;
}

.overview-table th,
.overview-table td {
  padding: 6px 10px;
}

.overview-list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.8rem;
  line-height: 1.6;
}

.edge-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.edge-pill {
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(91, 159, 212, 0.1);
  border: 1px solid var(--border);
  color: var(--muted);
}

.rules-list,
.lifecycle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rule-item,
.lifecycle-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.78rem;
  background: var(--panel);
}

.rule-item summary,
.lifecycle-item summary {
  cursor: pointer;
  font-weight: 500;
}

.rule-id {
  color: var(--accent);
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  margin-right: 6px;
}

.rule-meta {
  margin: 6px 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.btn-focus:hover {
  background: rgba(91, 159, 212, 0.22);
}

#network {
  width: 100%;
  height: calc(100vh - 150px);
  position: relative;
  background:
    radial-gradient(circle at 1px 1px, #1a1e28 1px, transparent 0) 0 0 / 24px 24px,
    var(--bg);
}

.graph-empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  pointer-events: none;
  z-index: 2;
}

.graph-empty-hint.hidden {
  display: none;
}

.legend {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 12px;
  background: rgba(15, 17, 23, 0.88);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.7rem;
  color: var(--muted);
  backdrop-filter: blur(4px);
  z-index: 2;
  max-width: calc(100% - 24px);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.legend-row + .legend-row {
  margin-top: 6px;
  padding-top: 6px;
}

.legend-divider {
  display: inline-block;
  width: 1px;
  height: 14px;
  background: rgba(232, 234, 237, 0.25);
  margin-right: 4px;
}

.legend-issue .legend-dot {
  font-size: 0.85rem;
  line-height: 1;
  font-weight: 700;
}
.legend-issue .legend-dot.sev-CRITICAL { color: #f0a0a0; }
.legend-issue .legend-dot.sev-MEDIUM { color: #e0c860; }

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 2px solid;
}

.swatch.form { background: #1e3a5f; border-color: #4a90d9; }
.swatch.subform { background: #2d2450; border-color: #9b7bd4; }
.swatch.lookup_view {
  background: #3d3418;
  border-color: #c9a227;
  transform: rotate(45deg);
  border-radius: 1px;
}
.swatch.view { background: #1e3d2f; border-color: #6abf69; }
.swatch.agent { background: #3d1e1e; border-color: #c06060; border-radius: 50%; }
.swatch.script_library { background: #2a2a2a; border-color: #888; }

.caption {
  position: absolute;
  bottom: 8px;
  left: 12px;
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted);
}

.detail-panel {
  padding: 16px;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--panel);
  min-width: 0;
  max-height: calc(100vh - 120px);
  position: sticky;
  top: 0;
  align-self: start;
}

.detail-panel .btn-focus {
  max-width: 100%;
  white-space: normal;
}

.detail-panel h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.detail-panel h3 {
  margin: 16px 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.placeholder {
  color: var(--muted);
  font-size: 0.9rem;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  text-transform: capitalize;
}

.pill-form { background: #1e3a5f; border-color: #4a90d9; color: #b8d4f0; }
.pill-subform { background: #2d2450; border-color: #9b7bd4; color: #d4c8f0; }
.pill-lookup_view { background: #3d3418; border-color: #c9a227; color: #f0e0a0; }
.pill-view { background: #1e3d2f; border-color: #6abf69; color: #b8e8b8; }
.pill-agent { background: #3d1e1e; border-color: #c06060; color: #f0c0c0; }
.pill-script_library { background: #2a2a2a; border-color: #888; color: #ccc; }

.meta-grid {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  margin-bottom: 12px;
}

.meta-grid span { color: var(--muted); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

th, td {
  text-align: left;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
}

th { color: var(--muted); font-weight: 500; }

.edge-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.75rem;
}

.edge-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.code-issue-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  font-size: 0.75rem;
}

.code-issue-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.code-issue-label {
  flex: 1 1 120px;
  color: var(--text);
  line-height: 1.35;
}

.btn-view-fix {
  margin-left: auto;
  padding: 4px 8px;
  background: rgba(91, 159, 212, 0.12);
  border: 1px solid var(--accent);
  border-radius: 5px;
  color: var(--accent);
  font-size: 0.72rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-view-fix:hover {
  background: rgba(91, 159, 212, 0.22);
}

.error {
  color: #f28b82;
  padding: 12px;
}

.section-hint {
  margin: -4px 0 10px;
  font-size: 0.75rem;
  color: var(--muted);
}

.field-search {
  width: 100%;
  margin-bottom: 10px;
  padding: 7px 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
}

.field-list,
.logic-list,
.category-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-item,
.logic-item,
.category-group {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.78rem;
}

.field-item.has-formula summary {
  cursor: pointer;
}

.field-item summary,
.logic-item summary,
.category-group summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  cursor: pointer;
  list-style: none;
}

.field-item summary::-webkit-details-marker,
.logic-item summary::-webkit-details-marker,
.category-group summary::-webkit-details-marker {
  display: none;
}

.field-name {
  font-weight: 600;
  color: var(--text);
}

.field-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge-formula { color: #c9a227; border-color: rgba(201, 162, 39, 0.4); }
.badge-hw { color: #9b7bd4; border-color: rgba(155, 123, 212, 0.4); }
.badge-ref { color: #c06060; border-color: rgba(192, 96, 96, 0.4); }

.field-drill {
  padding: 0 8px 8px;
  border-top: 1px solid var(--border);
}

.field-empty {
  margin: 0;
  padding: 6px 8px 8px;
  font-size: 0.72rem;
  color: var(--muted);
}

.formula-block {
  margin-top: 8px;
}

.formula-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}

.formula-code {
  margin: 0;
  padding: 8px;
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.68rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c8d4e0;
  max-height: 200px;
  overflow-y: auto;
}

.logic-event {
  font-weight: 500;
  text-transform: lowercase;
}

.category-group {
  margin-bottom: 4px;
}

.category-group > summary {
  font-weight: 600;
  text-transform: capitalize;
  color: var(--accent);
}

.category-group .logic-list {
  padding: 4px 8px 8px;
}

/* Modernization score */
.score-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: linear-gradient(160deg, rgba(30, 40, 55, 0.9), rgba(18, 22, 30, 0.95));
}

.score-card.risk-low { border-color: #3d8f5a; }
.score-card.risk-moderate { border-color: #c9a227; }
.score-card.risk-high { border-color: #c06060; }

.score-main {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
}

.score-ring {
  min-width: 88px;
  height: 88px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 3px solid currentColor;
  background: rgba(0, 0, 0, 0.25);
}

.risk-low .score-ring { color: #6abf69; }
.risk-moderate .score-ring { color: #c9a227; }
.risk-high .score-ring { color: #e08080; }

.score-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}

.score-max {
  font-size: 0.7rem;
  opacity: 0.7;
}

.score-rating {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 600;
}

.score-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.score-metrics {
  display: grid;
  gap: 10px;
}

.metric-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.metric-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.metric-bar i {
  display: block;
  height: 100%;
  background: currentColor;
  opacity: 0.85;
}

.risk-low .metric-bar i { background: #6abf69; }
.risk-moderate .metric-bar i { background: #c9a227; }
.risk-high .metric-bar i { background: #e08080; }

.sev-pill {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 2px 6px;
  border-radius: 4px;
}
.sev-CRITICAL { background: rgba(192, 96, 96, 0.25); color: #f0a0a0; }
.sev-HIGH { background: rgba(224, 123, 57, 0.22); color: #f0b080; }
.sev-MEDIUM { background: rgba(201, 162, 39, 0.2); color: #e0c860; }
.sev-LOW { background: rgba(106, 191, 105, 0.15); color: #8ee08c; }

.status-pill {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.status-pill.status-unprotected {
  background: rgba(192, 96, 96, 0.22);
  color: #f0a0a0;
}
.status-pill.status-escape {
  background: rgba(192, 100, 140, 0.22);
  color: #f0a0c0;
}
.status-pill.status-partial {
  background: rgba(192, 140, 64, 0.22);
  color: #f0c080;
}
.status-pill.status-conditional {
  background: rgba(192, 170, 64, 0.2);
  color: #e0c860;
}
.status-pill.status-protected {
  background: rgba(106, 191, 105, 0.18);
  color: #8ee08c;
}
.status-pill.status-safe {
  background: rgba(120, 140, 160, 0.18);
  color: #b0bcc8;
}

.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 72px;
  margin-top: 12px;
  padding: 8px 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.trend-bar {
  flex: 1;
  min-width: 6px;
  max-width: 28px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
}
.trend-fill {
  display: block;
  width: 100%;
  height: var(--h, 20%);
  background: linear-gradient(180deg, #8ee08c 0%, #4a90d9 100%);
  border-radius: 3px 3px 0 0;
  opacity: 0.9;
}
.trend-crit {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--crit, 0%);
  background: rgba(240, 160, 160, 0.85);
  border-radius: 2px;
  pointer-events: none;
}

.inventory-table {
  margin-top: 14px;
}
.inventory-table tr.status-unprotected td:first-child code {
  color: #f0a0a0;
}
.inventory-table .inventory-row {
  cursor: pointer;
}
.inventory-table .inventory-row:hover {
  background: rgba(91, 159, 212, 0.08);
}

.inventory-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}
.inventory-metrics .metric {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  padding: 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.inventory-metrics .metric-label {
  color: var(--muted);
}

.coverage-explainer {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid rgba(224, 123, 57, 0.35);
  background: rgba(224, 123, 57, 0.08);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text);
}
.coverage-explainer p {
  margin: 0;
}
.coverage-explainer .coverage-sub {
  margin-top: 8px;
  color: var(--muted);
}
.risk-low .coverage-explainer {
  border-color: rgba(106, 191, 105, 0.35);
  background: rgba(106, 191, 105, 0.08);
}
.coverage-explainer strong {
  font-weight: 650;
}
.coverage-hint {
  margin: 10px 0 0;
}
.coverage-warning {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid rgba(196, 86, 66, 0.35);
  background: rgba(196, 86, 66, 0.08);
  color: inherit;
}

.findings-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.findings-filter {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.findings-filter:hover {
  color: var(--text);
  border-color: rgba(91, 159, 212, 0.45);
}
.findings-filter.active {
  color: var(--text);
  border-color: rgba(91, 159, 212, 0.7);
  background: rgba(91, 159, 212, 0.15);
}
.filter-count {
  opacity: 0.75;
  margin-left: 2px;
}

.ai-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.export-docx-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  box-sizing: border-box;
}

.code-cache-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin: 0.75rem 0 1.25rem;
}

.code-cache-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.triage-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0.75rem 0 1rem;
}

.inventory-row.is-fp {
  opacity: 0.55;
}

.ai-run-btn {
  border: 1px solid rgba(91, 159, 212, 0.55);
  background: rgba(91, 159, 212, 0.12);
  color: var(--text);
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.ai-run-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.ai-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}
.ai-badge-verified {
  background: rgba(106, 191, 105, 0.18);
  color: #8ee08c;
}
.ai-badge-fp {
  background: rgba(120, 140, 160, 0.2);
  color: #b0bcc8;
}
.ai-badge-blind {
  background: rgba(224, 123, 57, 0.22);
  color: #f0b080;
}
.ai-badge-perf {
  background: rgba(91, 159, 212, 0.2);
  color: #8ec0e8;
}
.ai-badge-deadlock {
  background: rgba(200, 60, 60, 0.22);
  color: #f0a0a0;
}

.perf-callout {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid rgba(91, 159, 212, 0.4);
  background: rgba(91, 159, 212, 0.1);
  font-size: 0.78rem;
}
.perf-callout p {
  margin: 6px 0 0;
  color: var(--muted);
}

.ai-note {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(91, 159, 212, 0.08);
  font-size: 0.78rem;
}
.ai-note p {
  margin: 6px 0 0;
  color: var(--muted);
}
.ai-note-verified {
  border-color: rgba(106, 191, 105, 0.35);
  background: rgba(106, 191, 105, 0.08);
}
.ai-note-fp {
  border-color: rgba(120, 140, 160, 0.35);
  background: rgba(120, 140, 160, 0.08);
}
.ai-note-blind {
  border-color: rgba(224, 123, 57, 0.4);
  background: rgba(224, 123, 57, 0.1);
}

.audit-table .audit-row {
  cursor: pointer;
}
.audit-table .audit-row:hover {
  background: rgba(91, 159, 212, 0.08);
}

.audit-deep-dive {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.audit-deep-dive.hidden {
  display: none;
}

.deep-dive-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.deep-dive-header h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.deep-dive-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}

.lifecycle-warning {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-left: 3px solid #c06060;
  background: rgba(192, 96, 96, 0.12);
  font-size: 0.78rem;
  line-height: 1.45;
}

.deep-dive-guides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

@media (max-width: 900px) {
  .deep-dive-guides { grid-template-columns: 1fr; }
}

.guide-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.2);
}

.guide-card h4 {
  margin: 0 0 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.guide-card p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #dce3ec;
}

.guide-card.problem {
  border-left: 3px solid #c06060;
}

.guide-card.fix {
  border-left: 3px solid #6abf69;
}

.snippet-lines {
  margin: 0;
  padding: 6px 0;
  max-height: 320px;
  overflow: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.68rem;
  line-height: 1.45;
  color: #c8d4e0;
}

.snippet-line {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px;
  padding: 1px 10px;
  white-space: pre;
}

.snippet-ln {
  color: var(--muted);
  text-align: right;
  user-select: none;
}

.snippet-tx {
  overflow-x: auto;
}

.snippet-line.is-highlight {
  background: rgba(224, 123, 57, 0.22);
  box-shadow: inset 3px 0 0 #e07b39;
}

.snippet-line.is-highlight .snippet-ln {
  color: #e07b39;
  font-weight: 700;
}

.snippet-line.is-highlight .snippet-tx {
  color: #ffe0c0;
}

.snippet-line.is-recycle {
  background: rgba(72, 180, 140, 0.18);
  box-shadow: inset 3px 0 0 #48b48c;
}

.snippet-line.is-recycle .snippet-ln {
  color: #7ddeb8;
  font-weight: 700;
}

.snippet-line.is-recycle .snippet-tx {
  color: #d4f5e8;
}

.diff-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

@media (max-width: 900px) {
  .diff-grid { grid-template-columns: 1fr; }
}

.diff-pane {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
}

.diff-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.diff-label.as-is { color: #e08080; background: rgba(192, 96, 96, 0.1); }
.diff-label.to-be { color: #6abf69; background: rgba(106, 191, 105, 0.1); }

.diff-code {
  margin: 0;
  padding: 10px;
  max-height: 320px;
  overflow: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.68rem;
  line-height: 1.45;
  white-space: pre;
  color: #c8d4e0;
}

.metric-sub {
  margin: 4px 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  word-break: break-all;
}

/* Business rules catalog */
.code-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rules-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: end;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.rules-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.rules-toolbar input[type="search"],
.rules-toolbar select {
  min-width: 180px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: inherit;
  border-radius: 6px;
  padding: 6px 8px;
}

.rules-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
}

.rules-scroll {
  flex: 1;
  overflow: auto;
  padding: 12px 16px 24px;
  max-height: calc(100vh - 200px);
}

.rules-group {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--panel);
}

.rules-group > summary {
  cursor: pointer;
  margin-bottom: 8px;
}

.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.rules-table th,
.rules-table td {
  border-top: 1px solid var(--border);
  padding: 8px 6px;
  vertical-align: top;
  text-align: left;
}

.rules-table th {
  color: var(--muted);
  font-weight: 600;
}

.formula-cell pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, monospace;
  font-size: 0.68rem;
  max-height: 120px;
  overflow: auto;
}

.failure-msg {
  margin: 6px 0 0;
  color: #e08080;
  font-size: 0.7rem;
}

.lookup-mini {
  margin: 0;
  padding-left: 16px;
  line-height: 1.45;
}

.field-meta,
.muted {
  color: var(--muted);
  font-size: 0.68rem;
}

.field-label {
  font-weight: 600;
  font-size: 0.82rem;
  margin-bottom: 2px;
}

.field-tech {
  font-size: 0.68rem;
  color: var(--accent);
}

.biz-summary {
  margin: 0 0 6px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #dce3ec;
}

.formula-details {
  margin-top: 4px;
}

.formula-details > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.68rem;
}

.formula-details pre {
  margin: 6px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, monospace;
  font-size: 0.66rem;
  max-height: 120px;
  overflow: auto;
  color: #9aa7b5;
}

.related-findings {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.related-findings h4 {
  margin: 0 0 4px;
  font-size: 0.85rem;
}

.related-findings-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.related-finding-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  text-align: left;
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.78rem;
}

.related-finding-row:hover {
  border-color: var(--accent);
}

.findings-panel {
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  overflow: hidden;
}

.findings-panel-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
  cursor: pointer;
  padding: 14px 16px;
  list-style: none;
}

.findings-panel-summary::-webkit-details-marker {
  display: none;
}

.findings-panel-summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 0.85rem;
}

.findings-panel[open] > .findings-panel-summary::before {
  content: "▾";
}

.findings-panel-title {
  font-weight: 600;
  font-size: 1rem;
}

.findings-panel > .overview-section {
  margin: 0;
  padding: 0 12px 12px;
}

.findings-panel .score-card {
  margin-top: 0;
}

.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin: 12px 0 10px;
}

.list-toolbar input[type="search"] {
  min-width: 180px;
  flex: 1;
  max-width: 280px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
}

.table-scroll {
  max-height: min(70vh, 900px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.table-scroll table {
  margin: 0;
}

.table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1c212b;
  box-shadow: 0 1px 0 var(--border);
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .layout.layout-full { grid-template-columns: 1fr; }
  .detail-panel {
    border-top: 1px solid var(--border);
    position: static;
    max-height: none;
  }
  #network { height: 55vh; }
}
