/* Enhanced styling for AIUC-AIVSS Crosswalk Dashboard */
:root {
  --bg: #0b0f14;
  --panel: #101826;
  --panel-light: #162032;
  --text: #e6edf3;
  --muted: #9fb0c0;
  --border: #243449;
  --accent: #5aa7ff;
  --accent-hover: #7ab8ff;
  --chip: #13243a;
  --success: #2ea043;
  --warning: #d29922;
  --danger: #f85149;
  --high: #2ea043;
  --medium: #d29922;
  --low: #f85149;
}

* { box-sizing: border-box; }

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

/* Header */
.header {
  background: linear-gradient(135deg, #0f172a, #0b1220);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
}

h1 {
  margin: 0 0 6px 0;
  font-size: 28px;
  letter-spacing: 0.2px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  margin: 0 0 10px 0;
  color: var(--muted);
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 20px 40px;
}

/* Navigation Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--panel);
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s;
}

.tab:hover {
  background: var(--panel-light);
  color: var(--text);
}

.tab.active {
  background: var(--accent);
  color: #07101d;
}

/* Tab Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.card h3 {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card .big {
  font-size: 28px;
  font-weight: 700;
}

.card .small {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* Chart Cards */
.chart-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.chart-card h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
}

.chart-card.full {
  width: 100%;
}

.chart-desc {
  margin: 0 0 16px 0;
  font-size: 13px;
  color: var(--muted);
}

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

/* Bar Charts */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bar-label {
  width: 240px;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-container {
  flex: 1;
  height: 24px;
  background: var(--chip);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  padding-left: 8px;
}

.bar-value {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

/* Confidence Chart */
.confidence-chart {
  display: flex;
  gap: 24px;
  justify-content: center;
  padding: 20px;
}

.conf-item {
  text-align: center;
}

.conf-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  position: relative;
  background: conic-gradient(var(--fill-color) var(--percent), var(--chip) 0);
}

.conf-circle::before {
  content: '';
  position: absolute;
  width: 70px;
  height: 70px;
  background: var(--panel);
  border-radius: 50%;
}

.conf-circle span {
  position: relative;
  z-index: 1;
}

.conf-label {
  font-size: 13px;
  color: var(--muted);
}

/* Review Status */
.review-status-chart {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.status-card {
  flex: 1;
  min-width: 150px;
  padding: 16px;
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s;
}

.status-card:hover {
  transform: scale(1.02);
}

.status-card .count {
  font-size: 32px;
  font-weight: 700;
}

.status-card .label {
  font-size: 12px;
  margin-top: 4px;
  opacity: 0.8;
}

.status-ok { background: linear-gradient(135deg, rgba(46,160,67,0.2), rgba(46,160,67,0.1)); border: 1px solid var(--success); }
.status-p1 { background: linear-gradient(135deg, rgba(210,153,34,0.2), rgba(210,153,34,0.1)); border: 1px solid var(--warning); }
.status-p2 { background: linear-gradient(135deg, rgba(90,167,255,0.2), rgba(90,167,255,0.1)); border: 1px solid var(--accent); }

/* Sankey Diagram */
.sankey-container {
  min-height: 400px;
  overflow: auto;
}

.sankey-svg {
  width: 100%;
}

.sankey-node {
  cursor: pointer;
}

.sankey-node rect {
  transition: opacity 0.2s;
}

.sankey-node:hover rect {
  opacity: 0.8;
}

.sankey-link {
  fill: none;
  stroke-opacity: 0.3;
  transition: stroke-opacity 0.2s;
}

.sankey-link:hover {
  stroke-opacity: 0.6;
}

/* ASI Bridge */
.asi-bridge {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.asi-card {
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  transition: transform 0.2s;
}

.asi-card:hover {
  transform: translateY(-2px);
}

.asi-id {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.asi-title {
  font-size: 13px;
  margin-bottom: 8px;
}

.asi-arrow {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.asi-target {
  font-size: 12px;
  padding: 4px 8px;
  background: var(--chip);
  border-radius: 6px;
  display: inline-block;
}

/* Heatmap */
.heatmap-container {
  overflow-x: auto;
}

.heatmap-table {
  border-collapse: collapse;
  width: 100%;
}

.heatmap-table th,
.heatmap-table td {
  padding: 10px;
  text-align: center;
  border: 1px solid var(--border);
  font-size: 12px;
}

.heatmap-table th {
  background: var(--panel-light);
  font-weight: 600;
}

.heatmap-table td {
  cursor: pointer;
  transition: transform 0.1s;
}

.heatmap-table td:hover {
  transform: scale(1.05);
}

.heatmap-cell {
  padding: 8px;
  border-radius: 6px;
  font-weight: 600;
}

/* Gaps Analysis */
.gaps-analysis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.gap-card {
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.gap-card h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.gap-card p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.gap-icon {
  font-size: 18px;
}

/* Controls / Filters */
.controls {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}

.field.grow {
  flex: 1;
  min-width: 200px;
}

label {
  font-size: 12px;
  color: var(--muted);
}

select, input[type="text"] {
  background: #0b1220;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  font-size: 13px;
}

select:focus, input:focus {
  border-color: var(--accent);
}

/* Buttons */
.btn {
  background: var(--accent);
  color: #07101d;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn.secondary {
  background: var(--panel-light);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.secondary:hover {
  background: var(--chip);
}

/* Results */
.results {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

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

.results-count {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 600px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead th {
  position: sticky;
  top: 0;
  background: #0b1220;
  color: var(--muted);
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid #1a2a3e;
  vertical-align: top;
}

tbody tr {
  cursor: pointer;
  transition: background 0.2s;
}

tbody tr:hover {
  background: var(--panel-light);
}

/* Chips */
.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  margin-right: 4px;
  white-space: nowrap;
}

.chip.high {
  border-color: var(--high);
  color: var(--high);
}

.chip.medium {
  border-color: var(--medium);
  color: var(--medium);
}

.chip.low {
  border-color: var(--low);
  color: var(--low);
}

/* Details Panel */
.details {
  display: none;
  position: fixed;
  right: 0;
  top: 0;
  width: 500px;
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 1000;
  overflow-y: auto;
  box-shadow: -10px 0 40px rgba(0,0,0,0.5);
}

.details.open {
  display: block;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--panel);
}

.details-header h2 {
  margin: 0;
  font-size: 18px;
}

.details-body {
  padding: 20px;
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  margin: 12px 0;
}

.kv .k {
  color: var(--muted);
  font-size: 12px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #0b1220;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 8px;
  font-size: 12px;
  margin: 0;
}

/* Footer */
.footer {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* Inline checkbox */
.inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

/* Responsive */
@media (max-width: 1100px) {
  .two-col { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .gaps-analysis { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .cards { grid-template-columns: 1fr; }
  .tabs { flex-wrap: wrap; }
  .tab { min-width: 100px; }
  .details { width: 100%; }
}
