:root {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

body {
  margin: 0;
  background: #0b0b0c;
  color: #f2f2f2;
}

.app {
  /* width: 100%; */
  margin: 0 auto;
  /* padding: 16px; */
}

.topbar h1 {
  font-size: 20px;
  font-weight: 700;
}

/* =========================
   Layout
   ========================= */

.appLayout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.leftPanel {
  flex: 1 1 auto;
  min-width: 560px;
}

.rightPanel {
  flex: 0 0 620px;
}

.panelTitle {
  margin: 0 0 10px 0;
  font-size: 16px;
  font-weight: 700;
  opacity: 0.95;
}

.radarWrap {
  background: #141418;
  border: 1px solid #2a2a33;
  border-radius: 12px;
  padding: 12px;
}

/* Radar SVG sizing */
#radar svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Responsive */
@media (max-width: 1180px) {
  .appLayout {
    flex-direction: column;
  }

  .rightPanel {
    flex: 1 1 auto;
    width: 100%;
  }

  .leftPanel {
    min-width: 0;
  }
}

/* ---- Radar selection ---- */
#radar .pt.selected {
  fill: #ffffff;
  stroke: rgba(160, 160, 255, 0.95);
  stroke-width: 3;
}

#radar text.axisSelected {
  fill: rgba(220, 220, 255, 0.98);
  font-weight: 800;
}

/* ---- Legend toggle ---- */
.legendToggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  opacity: 0.95;
  user-select: none;
}

.legendToggle input {
  transform: translateY(0.5px);
}

/* =========================
   Matrix container
   ========================= */

.matrixWrap {
  position: relative;
  overflow: auto;
  max-height: 82vh;
  background: #14141a;
  border: 1px solid #2a2a33;
  border-radius: 12px;
}

/* =========================
   Table
   ========================= */

table.sensTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

table.sensTable th,
table.sensTable td {
  border: 1px solid #252530;
  padding: 6px;
  color: #e9e9ef;
}

table.sensTable thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #171720;
  vertical-align: top;
  min-width: 160px;
  cursor: pointer;
}

table.sensTable thead th:hover {
  background: #1b1b27;
}

table.sensTable thead th:first-child {
  cursor: default; /* corner */
  min-width: 12px;
}

table.sensTable tbody th.rowHead {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #171720;
  min-width: 300px; /* più spazio per slider/field */
  vertical-align: top;
}

table.sensTable td.cell {
  width: 34px;
  height: 26px;
  padding: 0;
  background: #14141a;
  transition: background 120ms linear, filter 120ms linear, opacity 120ms linear;
}

/* =========================
   Row controls (inputs on rows)
   ========================= */

.rowTitle {
  font-weight: 700;
  margin-bottom: 4px;
}

.rowControls {
  display: grid;
  grid-template-columns: 1fr 64px 18px;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}

.rowControls input[type="range"] {
  width: 100%;
  display: block;
  grid-column: 1 / -1; /* full width */
}

.rowControls input[type="text"] {
  width: 64px;
  grid-column: 2;
  background: #101015;
  border: 1px solid #262632;
  border-radius: 8px;
  color: #f2f2f2;
  padding: 4px 6px;
}

.rowControls input[type="checkbox"] {
  grid-column: 3;
}

/* dim righe input lockate */
tr.rowLocked th.rowHead {
  opacity: 0.55;
}

/* dim celle della riga quando input lockato */
table.sensTable td.cell.rowDim {
  opacity: 0.55;
  filter: saturate(0.7) brightness(0.9);
}

/* opzionale: input escluso dalla sensitivity (affectSensitivity:false) */
tr.rowConst th.rowHead {
  opacity: 0.45;
}
tr.rowConst td.cell {
  opacity: 0.45;
}

/* =========================
   Column header content (measures)
   ========================= */

.colLabel {
  font-weight: 600;
  margin-bottom: 6px;
  display: block;
}

.colValue {
  opacity: 0.95;
  margin: 6px 0 6px;
  font-size: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

.colSmall {
  opacity: 0.8;
  font-size: 11px;
  margin-bottom: 6px;
}

/* =========================
   Inline bars in column header
   ========================= */

.strengthLine,
.pctLine{
  display:flex;
  align-items:center;
  gap:8px;
  margin: 6px 0;
}

.strengthVal,
.pctVal{
  width: 64px;
  text-align:right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  opacity: 0.95;
  white-space: nowrap;
}

.strengthBar,
.pctBar{
  flex: 1 1 auto;
  height: 8px;
  background: #232330;
  border: 1px solid #2a2a33;
  border-radius: 999px;
  overflow: hidden;
}

.strengthFill{
  height: 100%;
  width: 0%;
  background: rgba(170, 170, 255, 0.85);
}

.pctFill{
  height: 100%;
  width: 0%;
  background: rgba(140, 220, 200, 0.85);
}


/* =========================
   Derived override controls (now in column header)
   ========================= */

.overrideRow {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}

.overrideRow input[type="text"] {
  width: 110px;
  background: #101015;
  border: 1px solid #262632;
  border-radius: 8px;
  color: #f2f2f2;
  padding: 4px 6px;
}

/* Re-use for locked derived columns */
.locked {
  opacity: 0.6;
}

/* =========================
   Column selection highlight
   ========================= */

table.sensTable th.selectedColHead {
  outline: 2px solid rgba(200, 200, 255, 0.65);
  outline-offset: -2px;
}

table.sensTable td.selectedColCell {
  box-shadow: inset 0 0 0 2px rgba(200, 200, 255, 0.35);
}

/* (legacy) selezione riga - non più usata, ma innocua */
tr.selectedRow th.rowHead {
  outline: 2px solid rgba(200, 200, 255, 0.65);
  outline-offset: -2px;
}

/* =========================
   Legend
   ========================= */

.legendWrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  color: #e9e9ef;
  flex-wrap: wrap;
}

.legendBar {
  height: 10px;
  width: 220px;
  border-radius: 999px;
  border: 1px solid #2a2a33;
}

.legendTick {
  font-size: 11px;
  opacity: 0.85;
}

/* =========================
   Tooltip
   ========================= */

.cellTooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: rgba(20, 20, 26, 0.96);
  border: 1px solid #2a2a33;
  border-radius: 10px;
  padding: 8px 10px;
  color: #f2f2f2;
  font-size: 12px;
  max-width: 320px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: none;
}

.cellTooltip .ttTitle {
  font-weight: 700;
  margin-bottom: 6px;
}

.cellTooltip .ttMono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  opacity: 0.95;
}

/* =========================
   (legacy) column controls (vecchia matrice) - non usate ora
   ========================= */
.colControls {
  display: grid;
  grid-template-columns: 1fr 64px 18px;
  gap: 6px;
  align-items: center;
}

.colControls input[type="range"] {
  width: 100%;
  display: block;
  grid-column: 1 / -1;
}

.colControls input[type="number"] {
  width: 64px;
  grid-column: 2;
}

.colControls input[type="checkbox"] {
  grid-column: 3;
}

th.colLocked {
  opacity: 0.55;
}

table.sensTable td.cell.colDim {
  opacity: 0.55;
  filter: saturate(0.7) brightness(0.9);
}
