:root {
  --bg: #111418;
  --panel: #171c22;
  --panel-2: #1d232b;
  --border: #2a313b;
  --border-soft: rgba(255, 255, 255, 0.06);
  --text: #eef2f6;
  --muted: #9aa7b6;
  --accent: #7dd3fc;
  --good: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --rose: #fb7185;
  --neutral: #94a3b8;
  --shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select { font: inherit; }

.app-shell {
  padding: 24px;
  max-width: 1640px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 16px;
}

.brand-block {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.brand-logo {
  display: block;
  height: 44px;
  width: auto;
  max-width: none;
  margin: 0 0 18px 0;
}

h1, h2, h3 { margin: 0; }
.topbar h1 { font-size: 30px; line-height: 1.05; }
.topbar-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 760px;
  font-size: 14px;
  line-height: 1.5;
}
.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

input, select, button {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 14px;
}
input::placeholder { color: #7f8a97; }
#tokenInput { min-width: 320px; }
button {
  cursor: pointer;
  background: var(--panel-2);
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}
.full-width-row {
  width: 100%;
  text-align: left;
}
.pattern-row.is-selected {
  border-color: rgba(125, 211, 252, 0.55);
  background: rgba(125, 211, 252, 0.08);
}
.ghost-btn { background: transparent; }
.small-btn {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 13px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  background: rgba(255,255,255,0.02);
}
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.status-pill.neutral { color: var(--neutral); }
.status-pill.loading {
  color: var(--accent);
  border-color: rgba(125, 211, 252, 0.35);
  background: rgba(125, 211, 252, 0.08);
}
.status-pill.success {
  color: var(--good);
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.08);
}
.status-pill.error {
  color: var(--bad);
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
}
.status-text { color: var(--muted); font-size: 14px; }

.commercial-tabs {
  display: flex;
  gap: 10px;
  margin: 0 0 18px;
  flex-wrap: wrap;
}
.commercial-tab {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 999px;
}
.commercial-tab.active {
  border-color: rgba(125, 211, 252, 0.55);
  background: rgba(125, 211, 252, 0.10);
}
.commercial-source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  padding: 18px;
}
.commercial-source-chip {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.025);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 6px;
  min-width: 0;
}
.commercial-source-chip strong,
.commercial-source-chip span,
.commercial-source-chip small {
  min-width: 0;
  overflow-wrap: anywhere;
}
.commercial-source-chip span,
.commercial-source-chip small { color: var(--muted); font-size: 12px; }
.commercial-source-chip.success { border-color: rgba(52, 211, 153, 0.35); }
.commercial-source-chip.error { border-color: rgba(248, 113, 113, 0.35); }
.commercial-source-chip.neutral { border-color: rgba(148, 163, 184, 0.35); }
.header-metric.ready { color: var(--good); }
.header-metric.blocked { color: var(--bad); }
.commercial-main-grid { align-items: start; }
.selected-row {
  background: rgba(125, 211, 252, 0.08);
  outline: 1px solid rgba(125, 211, 252, 0.35);
}
.state-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  text-transform: capitalize;
}
.state-chip.high,
.state-chip.blocked { color: var(--bad); border-color: rgba(248,113,113,0.35); }
.state-chip.medium,
.state-chip.unknown { color: var(--warn); border-color: rgba(251,191,36,0.35); }
.state-chip.low { color: var(--neutral); }
.detail-section {
  border-bottom: 1px solid var(--border-soft);
  padding: 0 0 16px;
  margin: 0 0 16px;
}
.detail-section h3 {
  font-size: 14px;
  margin-bottom: 10px;
}
.detail-section p {
  color: var(--muted);
  line-height: 1.5;
}
.detail-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.detail-kpi-grid div,
.source-line {
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255,255,255,0.02);
}
.detail-kpi-grid span,
.source-line span,
.source-line small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
.case-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.value-pool-grid { margin-top: -4px; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.summary-card {
  padding: 18px;
  min-height: 112px;
}
.summary-card .label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}
.summary-card .value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}
.summary-card .subvalue {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.muted-cell {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
.value-pool-card .value { font-size: 24px; }
.replacement-burden-card { border-color: rgba(125, 211, 252, 0.32); }

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 16px;
}
.filter-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.filter-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
#searchInput { min-width: 340px; }
#deviceFilter,
#componentFilter { min-width: 260px; }
.filter-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.filter-label {
  color: var(--muted);
  font-size: 13px;
}
.cluster-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  font-size: 13px;
}

.risk-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
}
.risk-low {
  color: var(--good);
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.08);
}
.risk-medium {
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
}
.risk-high {
  color: var(--bad);
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
}

.status-select {
  min-width: 150px;
  padding: 7px 9px;
  border-radius: 10px;
}

.detail-section {
  padding: 16px;
  border-bottom: 1px solid var(--border-soft);
}
.detail-section:last-child { border-bottom: 0; }
.detail-section p {
  color: var(--muted);
  line-height: 1.45;
}
.highlight-section {
  background: rgba(125, 211, 252, 0.05);
}
.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.kv-grid div {
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
}
.kv-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.kv-grid strong { font-size: 14px; }
.reason-list {
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.5;
}
.compact-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.compact-row:last-child { border-bottom: 0; }
.compact-row span { color: var(--muted); }
.section-warning {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid rgba(251, 191, 36, 0.32);
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.08);
  color: #fde68a;
}
.section-warning strong {
  color: #fef3c7;
  font-size: 13px;
}
.section-warning span {
  color: #fcd34d;
  font-size: 12px;
  line-height: 1.45;
}
.section-note {
  padding: 12px 14px;
  border: 1px solid rgba(125, 211, 252, 0.28);
  border-radius: 10px;
  background: rgba(125, 211, 252, 0.07);
  color: #bfdbfe;
  font-size: 12px;
  line-height: 1.45;
}
.compact-kv {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 8px 0 12px;
}
.detail-mini-list {
  display: grid;
  gap: 6px;
  padding: 12px 0;
  border-top: 1px solid var(--border-soft);
}
.detail-mini-list strong {
  font-size: 12px;
  color: var(--text);
}
.detail-mini-list span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.static-row {
  cursor: default;
}
@media (max-width: 980px) {
  .compact-kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.empty-state {
  color: var(--muted);
  padding: 16px;
}

.card-header {
  padding: 18px 20px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.card-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.split-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.header-metric {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  padding-top: 2px;
}

.main-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
}
.left-column,
.right-column {
  display: grid;
  gap: 18px;
}

.table-wrap {
  padding: 0 12px 14px;
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 14px;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 600;
}
.cell-strong { font-weight: 700; }
.selected-row td { background: rgba(125, 211, 252, 0.08); }
.asset-row { cursor: pointer; }

.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 0 16px 16px;
}
.pagination-info {
  color: var(--muted);
  font-size: 13px;
}
.pagination-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.page-size-label {
  color: var(--muted);
  font-size: 13px;
}
.page-size-select { min-width: 82px; }

.action-list {
  padding: 14px;
  display: grid;
  gap: 10px;
}
.action-item {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,0.02);
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.action-item:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.selected-action {
  border-color: rgba(125, 211, 252, 0.45);
  background: rgba(125, 211, 252, 0.06);
}
.action-title {
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: none;
}
.action-meta,
.action-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  padding: 14px;
}
.diagnostic-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255,255,255,0.02);
}
.diagnostic-card.ok { border-color: rgba(52, 211, 153, 0.24); }
.diagnostic-card.warning { border-color: rgba(251, 191, 36, 0.32); }
.diagnostic-card.info { border-color: rgba(125, 211, 252, 0.18); }
.diagnostic-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}
.diagnostic-value {
  font-size: 22px;
  font-weight: 700;
}
.breakdown-item { display: grid; gap: 8px; }
.breakdown-cluster-list {
  display: grid;
  gap: 8px;
}
.breakdown-cluster-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) 2fr 48px;
  align-items: center;
  gap: 10px;
}
.breakdown-cluster-label,
.breakdown-cluster-value {
  color: var(--muted);
  font-size: 12px;
}
.breakdown-cluster-value {
  text-align: right;
  color: var(--text);
  font-weight: 700;
}
.breakdown-cluster-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  overflow: hidden;
}
.breakdown-cluster-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}
.breakdown-cluster-fill.covered_profitable { background: var(--good); }
.breakdown-cluster-fill.covered_loss_making { background: var(--bad); }
.breakdown-cluster-fill.uncovered_profitable { background: var(--accent); }
.breakdown-cluster-fill.uncovered_loss_making { background: var(--rose); }
.breakdown-cluster-fill.covered_no_economics,
.breakdown-cluster-fill.uncovered_no_economics,
.breakdown-cluster-fill.no_economics { background: var(--warn); }

.detail-pane {
  padding: 18px;
  display: grid;
  gap: 12px;
}
.detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}
.detail-title {
  font-size: 22px;
  font-weight: 700;
}
.detail-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.detail-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.pill,
.metric-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  font-size: 12px;
}
.pill.cluster { border-color: rgba(125, 211, 252, 0.26); }
.pill.coverage { border-color: rgba(52, 211, 153, 0.22); }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
.detail-field {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
}
.detail-field.span-2 { grid-column: span 2; }
.detail-field .k,
.detail-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.detail-value { font-size: 14px; }
.detail-section {
  margin-top: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,0.02);
}
.detail-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
}
.replacement-detail-section { border-color: rgba(125, 211, 252, 0.18); }
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.matrix-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}
.legend-dot.good { background: var(--good); }
.legend-dot.bad { background: var(--bad); }
.legend-dot.accent { background: var(--accent); }
.legend-dot.rose { background: var(--rose); }
.legend-dot.warn { background: var(--warn); }

.matrix-wrap {
  position: relative;
  padding: 18px 18px 18px 52px;
}
.matrix-axis {
  position: absolute;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.01em;
}
.axis-x {
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
}
.axis-y {
  left: 14px;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: left top;
}
.matrix {
  position: relative;
  min-height: 360px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.05);
  background:
    linear-gradient(rgba(255,255,255,0.05), rgba(255,255,255,0.05)) 50% 0 / 1px 100% no-repeat,
    linear-gradient(90deg, rgba(255,255,255,0.05), rgba(255,255,255,0.05)) 0 50% / 100% 1px no-repeat,
    linear-gradient(180deg, rgba(255,255,255,0.015), rgba(255,255,255,0.025));
  overflow: hidden;
}
.quadrant-label {
  position: absolute;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: rgba(17, 20, 24, 0.72);
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.05);
}
.q1 { right: 16px; top: 16px; }
.q2 { left: 16px; top: 16px; }
.q3 { right: 16px; bottom: 16px; }
.q4 { left: 16px; bottom: 16px; }
.q5 { left: 50%; top: 16px; transform: translateX(-50%); }
.q6 { left: 50%; bottom: 16px; transform: translateX(-50%); }
.matrix-point {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.matrix-point:hover {
  transform: translate(-50%, -50%) scale(1.04);
}
.matrix-point.selected {
  border-color: #ffffff;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.08), 0 10px 28px rgba(0,0,0,0.32);
}
.matrix-point.covered_profitable { background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.18), rgba(52, 211, 153, 0.92)); }
.matrix-point.covered_loss_making { background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.18), rgba(248, 113, 113, 0.92)); }
.matrix-point.uncovered_profitable { background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.18), rgba(125, 211, 252, 0.92)); }
.matrix-point.uncovered_loss_making { background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.18), rgba(251, 113, 133, 0.92)); }
.matrix-point.covered_no_economics,
.matrix-point.uncovered_no_economics,
.matrix-point.no_economics,
.matrix-point.unclassified { background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.18), rgba(251, 191, 36, 0.92)); }
.matrix-point-label {
  text-align: center;
  color: #0b0f13;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.empty-state,
.import-empty-state,
.cluster-item-meta,
.text-card-body,
.muted,
.panel-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.import-admin-section {
  margin-top: 18px;
}
.data-operations-section {
  margin-top: 18px;
}
.import-admin-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
  padding: 18px 20px 0;
}
.import-left,
.import-right {
  display: grid;
  gap: 14px;
}
.import-form-grid {
  display: grid;
  gap: 14px;
}
.import-form-grid-3 {
  grid-template-columns: 1fr 1fr 0.8fr;
}
.form-field {
  display: grid;
  gap: 8px;
}
.form-field label {
  color: var(--muted);
  font-size: 13px;
}
.form-field-span-2 {
  grid-column: span 2;
}
.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}
.checkbox-row input {
  width: 16px;
  height: 16px;
  padding: 0;
}
.import-button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.import-note-box {
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,0.02);
}
.import-note-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}
.import-note-text,
.import-file-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.import-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 12px;
}
.import-summary-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,0.02);
}
.import-summary-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.import-summary-value {
  font-size: 20px;
  font-weight: 700;
}
.import-badge.neutral { color: var(--neutral); }
.import-badge.loading { color: var(--accent); }
.import-badge.success { color: var(--good); }
.import-badge.warn { color: var(--warn); }
.import-badge.error { color: var(--bad); }
.import-results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 18px 20px 20px;
}
.import-history-panel {
  margin: 0 20px 20px;
}
.card-subpanel {
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  background: rgba(255,255,255,0.02);
  overflow: hidden;
}
.subpanel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.subpanel-metric {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}
.subpanel-body {
  padding: 14px 16px 16px;
  min-height: 180px;
}
.json-preview {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.workbench-section {
  margin-bottom: 18px;
}
.workbench-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 20px 8px;
}
.workbench-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.workbench-grid input {
  width: 100%;
  min-width: 0;
}
.workbench-result {
  padding: 8px 20px 20px;
}
.workbench-summary-grid {
  margin-bottom: 14px;
}
.workbench-table-wrap {
  overflow: auto;
}
.panel-card .panel-body { padding: 18px 20px 20px; }
.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 18px 20px 20px;
}
.admin-form input,
.admin-form select {
  width: 100%;
  min-width: 0;
}
.admin-form button {
  grid-column: 1 / -1;
}
.chart-panel { min-height: 250px; }
.pattern-grid { align-items: stretch; }
.pattern-list {
  display: grid;
  gap: 10px;
  min-height: 210px;
}
.pattern-item {
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.02);
}
.pattern-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.pattern-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
}
.pattern-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}
.pattern-metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.pattern-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 6px 0;
}
.pre-replacement-card { margin-bottom: 18px; }
.cluster-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}
.cluster-item,
.text-card {
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,0.02);
}
.cluster-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.text-card-header,
.action-metrics,
.cluster-item-metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.text-card-header { margin-bottom: 10px; }
.reliability-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.95fr);
}
.reliability-table-wrap { max-height: 520px; }
.clickable-row { cursor: pointer; }
.clickable-row.selected-row td { background: rgba(125, 211, 252, 0.08); }
.mini-table-wrap { overflow: auto; }
.mini-table {
  width: 100%;
  border-collapse: collapse;
}
.mini-table th,
.mini-table td {
  padding: 10px 8px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.mini-table th {
  color: var(--muted);
  font-weight: 600;
}

.bar-chart-row {
  display: grid;
  grid-template-columns: 170px 1fr 120px;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.bar-chart-label,
.bar-chart-value {
  font-size: 13px;
}
.bar-chart-track {
  height: 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.bar-chart-fill {
  height: 100%;
  border-radius: 999px;
}
.mode-warranty { background: linear-gradient(90deg, #60a5fa, #93c5fd); }
.mode-goodwill { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.mode-partial_goodwill { background: linear-gradient(90deg, #fb7185, #fda4af); }
.mode-paid_replacement { background: linear-gradient(90deg, #34d399, #6ee7b7); }
.mode-contract_covered { background: linear-gradient(90deg, #a78bfa, #c4b5fd); }
.mode-internal_writeoff { background: linear-gradient(90deg, #94a3b8, #cbd5e1); }

.waterfall-svg {
  width: 100%;
  height: 250px;
}
.wf-bar { fill: rgba(96, 165, 250, 0.85); }
.wf-total { fill: rgba(52, 211, 153, 0.92); }
.wf-label {
  fill: #9aa7b6;
  font-size: 11px;
}
.wf-value {
  fill: #eef2f6;
  font-size: 12px;
  font-weight: 700;
}
.waterfall-bridge {
  min-height: 270px;
}
.wf-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(112px, 1fr));
  gap: 14px;
  align-items: end;
  min-height: 236px;
}
.wf-step {
  display: grid;
  grid-template-rows: 160px minmax(18px, auto) minmax(34px, auto) minmax(14px, auto);
  gap: 6px;
  min-width: 0;
}
.wf-bar-area {
  position: relative;
  height: 160px;
  border-bottom: 1px solid rgba(255,255,255,0.18);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01)),
    linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), rgba(255,255,255,0.04) calc(100% - 1px));
}
.wf-floating-bar,
.wf-total-bar {
  position: absolute;
  left: 18%;
  right: 18%;
  min-height: 6px;
  border-radius: 6px 6px 0 0;
}
.wf-floating-bar {
  background: rgba(96, 165, 250, 0.86);
  box-shadow: 0 0 0 1px rgba(147, 197, 253, 0.16);
}
.wf-total-bar {
  bottom: 0;
  background: rgba(52, 211, 153, 0.92);
  box-shadow: 0 0 0 1px rgba(110, 231, 183, 0.18);
}
.wf-connector {
  position: absolute;
  left: 82%;
  width: calc(36% + 14px);
  border-top: 1px dashed rgba(255,255,255,0.2);
}
.wf-step-value {
  color: #eef2f6;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}
.wf-step-label {
  color: #9aa7b6;
  font-size: 11px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.wf-step-meta {
  color: #697586;
  font-size: 11px;
  min-height: 14px;
}
.wf-assumption {
  margin-top: 10px;
  color: #7f8ea3;
  font-size: 12px;
}

@media (max-width: 1280px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }
  .main-grid,
  .panel-grid,
  .import-admin-grid,
  .import-results-grid {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .topbar-actions {
    justify-content: flex-start;
  }
  .matrix-legend {
    justify-content: flex-start;
  }
  .brand-logo {
    height: 40px;
    max-width: none;
  }
}

@media (max-width: 820px) {
  .app-shell { padding: 16px; }
  .summary-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
  #tokenInput,
  #searchInput {
    min-width: 100%;
  }
  .filter-bar,
  .filter-bar-left,
  .filter-controls,
  .topbar-actions,
  .pagination-bar,
  .pagination-actions,
  .header-actions,
  .detail-head,
  .detail-badges,
  .import-button-row {
    flex-direction: column;
    align-items: stretch;
  }
  .detail-grid,
  .import-form-grid-3,
  .import-summary-grid {
    grid-template-columns: 1fr;
  }
  .detail-field.span-2,
  .form-field-span-2 {
    grid-column: span 1;
  }
  .bar-chart-row {
    grid-template-columns: 1fr;
  }
  .breakdown-cluster-row {
    grid-template-columns: 1fr;
  }
  .breakdown-cluster-value {
    text-align: left;
  }
  .waterfall-bridge {
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .wf-steps {
    grid-template-columns: repeat(5, 132px);
    min-width: 720px;
  }
  .matrix-wrap {
    padding-left: 18px;
    padding-bottom: 36px;
  }
  .axis-y { display: none; }
  .brand-logo {
    height: 40px;
    max-width: none;
  }
}

.value-pool-section { overflow: hidden; }
.value-pool-body { padding: 16px 20px 20px; }
.pf-value-matrix {
  position: relative;
  min-height: 390px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px) 50% 0 / 1px 100% no-repeat,
    linear-gradient(0deg, rgba(255,255,255,0.04) 1px, transparent 1px) 0 50% / 100% 1px no-repeat,
    radial-gradient(circle at 24% 24%, rgba(52, 211, 153, 0.12), transparent 30%),
    radial-gradient(circle at 78% 24%, rgba(251, 191, 36, 0.10), transparent 32%),
    rgba(255,255,255,0.018);
}
.pf-quadrant {
  position: absolute;
  display: grid;
  gap: 3px;
  max-width: 190px;
  padding: 12px;
  color: #dbe7f3;
  pointer-events: none;
}
.pf-quadrant strong { font-size: 13px; }
.pf-quadrant span { color: var(--muted); font-size: 11px; }
.pf-q-quick { left: 18px; top: 16px; }
.pf-q-board { right: 18px; top: 16px; text-align: right; }
.pf-q-cleanup { left: 18px; bottom: 34px; }
.pf-q-watch { right: 18px; bottom: 34px; text-align: right; }
.pf-axis {
  position: absolute;
  color: #7f8ea3;
  font-size: 11px;
  letter-spacing: 0;
  pointer-events: none;
}
.pf-axis-y {
  left: 12px;
  top: 50%;
  transform: rotate(-90deg) translateX(-50%);
  transform-origin: left top;
}
.pf-axis-x { right: 16px; bottom: 8px; }
.pf-value-bubble {
  position: absolute;
  transform: translate(-50%, 50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  min-height: 22px;
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 999px;
  color: #fff;
  padding: 0;
  text-align: center;
  line-height: 1;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0,0,0,0.28);
}
.pf-value-bubble.raise { background: rgba(52, 211, 153, 0.82); }
.pf-value-bubble.discount { background: rgba(248, 113, 113, 0.82); }
.pf-value-bubble.country { background: rgba(96, 165, 250, 0.82); }
.pf-value-bubble.market,
.pf-value-bubble.replacement { background: rgba(251, 191, 36, 0.86); color: #111827; }
.pf-value-bubble.block { background: rgba(148, 163, 184, 0.82); }
.pf-value-bubble.default { background: rgba(167, 139, 250, 0.82); }
.pf-value-bubble span { pointer-events: none; display: block; width: 100%; text-align: center; }
.pf-value-bubble.is-selected {
  outline: 3px solid rgba(255,255,255,0.92);
  outline-offset: 3px;
  z-index: 5;
}
.pf-value-bubble:hover,
.pf-value-bubble:focus-visible {
  transform: translate(-50%, 50%) scale(1.06);
  outline: 2px solid rgba(255,255,255,0.76);
  outline-offset: 2px;
  z-index: 4;
}
.pf-value-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 12px;
}
.pf-value-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.pf-value-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}
.pf-value-legend .raise { background: #34d399; }
.pf-value-legend .discount { background: #f87171; }
.pf-value-legend .country { background: #60a5fa; }
.pf-value-legend .market { background: #fbbf24; }
.pf-value-legend .block { background: #94a3b8; }
@media (max-width: 760px) {
  .pf-value-matrix { min-height: 300px; }
  .pf-quadrant { max-width: 140px; padding: 10px; }
  .pf-q-board,
  .pf-q-watch { right: 10px; }
  .pf-q-quick,
  .pf-q-cleanup { left: 10px; }
}

.divergence-section { overflow: hidden; }
.divergence-row .negative-metric { color: #fca5a5; }
.price-bridge {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.price-bridge-step {
  display: grid;
  grid-template-columns: 96px minmax(80px, 1fr) 92px;
  gap: 10px;
  align-items: center;
}
.price-bridge-label,
.price-bridge-value {
  color: var(--muted);
  font-size: 12px;
}
.price-bridge-value {
  color: var(--text);
  font-weight: 700;
  text-align: right;
}
.price-bridge-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.price-bridge-track span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #60a5fa, #93c5fd);
}
.price-bridge-step.target .price-bridge-track span {
  background: linear-gradient(90deg, #34d399, #6ee7b7);
}
@media (max-width: 760px) {
  .price-bridge-step {
    grid-template-columns: 1fr;
    gap: 5px;
  }
  .price-bridge-value { text-align: left; }
}

.detail-flash {
  animation: detailPulse 1.2s ease-out;
}
@keyframes detailPulse {
  0% { box-shadow: 0 0 0 0 rgba(125, 211, 252, 0.34); border-color: rgba(125, 211, 252, 0.78); }
  100% { box-shadow: var(--shadow); border-color: var(--border); }
}
