/* Qualitative bands: 0–50 at risk, 50–80 watch, 80–100 on track (RAG / leadership readout) */
:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --text: #e8eef4;
  --muted: #8a9ba8;
  --accent: #3db8d1;
  /* band-poor: at risk; band-warn: watch; band-good: on track */
  --band-poor: #5c2a2d;
  --band-warn: #5c4a1e;
  --band-good: #1a3d2e;
  /* featured measure: high-contrast on bands (Few: strong primary bar) */
  --bar: #e2eef5;
  --comp: #f0c14a;
  --target: #82cfff;
  --border: #2a3542;
  --radius: 10px;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--bg) 0%, #151c25 100%);
  color: var(--text);
  line-height: 1.5;
  padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 3rem;
}

h1 {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 650;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.lede {
  max-width: 46rem;
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2.5rem;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

code {
  font-size: 0.88em;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.meta {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  min-width: 12rem;
}

.meta-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.meta-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent);
}

.meta-subl {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem 1.5rem;
  margin-bottom: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.field input,
.field select {
  min-width: 12rem;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  font: inherit;
}

.hint {
  margin: 0 0 0.15rem 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
  flex: 1;
  text-align: right;
  min-width: 8rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.leg-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.swatch {
  display: inline-block;
  width: 20px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.swatch.band {
  background: linear-gradient(
    90deg,
    var(--band-poor) 0%,
    var(--band-poor) 50%,
    var(--band-warn) 50%,
    var(--band-warn) 80%,
    var(--band-good) 80%,
    var(--band-good) 100%
  );
}
.swatch.val {
  background: var(--bar);
  height: 4px;
  width: 22px;
}
.swatch.comp {
  width: 2px;
  background: var(--comp);
  height: 12px;
}
.swatch.tgt {
  width: 2px;
  background: var(--target);
  height: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.1rem;
}

.tenant-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.tenant-card header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 0.75rem;
}

.tenant-name {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}

.state {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  white-space: nowrap;
}
.state--live {
  color: #7dcea0;
  background: rgba(39, 174, 96, 0.15);
}
.state--progress {
  color: #7dc3e0;
  background: rgba(61, 184, 209, 0.12);
}
.state--discussion {
  color: #c9a86c;
  background: rgba(233, 196, 106, 0.1);
}
.state--hold {
  color: #b0b0b0;
  background: rgba(150, 150, 150, 0.12);
}
.state--follow {
  color: #e0a37d;
  background: rgba(231, 111, 81, 0.1);
}

.spark {
  font-size: 0.9rem;
  color: #c5d3de;
  margin: 0;
  padding: 0.5rem 0.65rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

.tenant-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.tenant-meta strong {
  color: #9fb0bd;
  font-weight: 500;
}

.bowler-metric {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.bowler-metric__label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
}
.bowler-metric__val {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bowler {
  position: relative;
  height: 22px;
  border-radius: 3px;
  overflow: hidden;
  background: linear-gradient(
    90deg,
    var(--band-poor) 0%,
    var(--band-poor) 50%,
    var(--band-warn) 50%,
    var(--band-warn) 80%,
    var(--band-good) 80%,
    var(--band-good) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.bowler__value {
  position: absolute;
  left: 0;
  top: 4px;
  height: 12px;
  width: 0;
  min-width: 0;
  background: var(--bar);
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  z-index: 1;
  transition: width 0.35s ease;
}

.bowler__comp {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--comp);
  margin-left: -1px;
  z-index: 2;
  opacity: 0.9;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
}

.bowler__target {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  right: 0;
  background: var(--target);
  z-index: 2;
  border-radius: 0 1px 1px 0;
  opacity: 0.75;
}

.scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.foot {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
}
.foot details {
  max-width: 50rem;
}
.foot ol {
  padding-left: 1.2rem;
  margin: 0.5rem 0 0;
}
.foot li {
  margin: 0.4rem 0;
}
.foot .code {
  display: block;
  margin: 0.4rem 0 0.6rem 0.5rem;
  background: #111;
  color: #d0e0ea;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  overflow: auto;
  font-size: 0.8rem;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
  grid-column: 1 / -1;
}

@media (max-width: 600px) {
  .hint {
    text-align: left;
  }
}

/* App nav + view toggle */
.top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.nav-app {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-app a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  border: 1px solid transparent;
}

.nav-app a:hover {
  background: rgba(61, 184, 209, 0.1);
  border-color: rgba(61, 184, 209, 0.25);
}

.nav-app a[aria-current="page"] {
  background: rgba(61, 184, 209, 0.15);
  border-color: rgba(61, 184, 209, 0.35);
  pointer-events: none;
  cursor: default;
}

.inline-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid rgba(61, 184, 209, 0.35);
}

.inline-link:hover {
  color: #5ed4ed;
  border-bottom-color: #5ed4ed;
}

.view-root {
  position: relative;
}

.view-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.25rem;
}

.view-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 0 0.3rem 0 0.45rem;
}

.view-toggle button {
  font: inherit;
  font-size: 0.86rem;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
}

.view-toggle button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.view-toggle button.is-active {
  color: var(--text);
  background: rgba(61, 184, 209, 0.18);
  font-weight: 600;
}

/* List view table */
.list-container {
  width: 100%;
}

.list-scroll {
  overflow: auto;
  max-height: min(70vh, 720px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

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

.tenant-list {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.tenant-list th,
.tenant-list td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.tenant-list th {
  color: #9fb0bd;
  font-weight: 600;
  position: sticky;
  top: 0;
  background: #1e2630;
  z-index: 1;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tenant-list tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.tenant-list .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: #c5d3de;
}

.tenant-list .tenant-list-name {
  max-width: 12rem;
  font-weight: 600;
  color: var(--text);
}

.tenant-list .state-cell {
  white-space: nowrap;
}

.tenant-list .row-actions {
  text-align: right;
  width: 8rem;
}

.show-detail-btn,
.link-like {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
}

.show-detail-btn:hover,
.link-like:hover {
  color: #5ed4ed;
}

#board[hidden] {
  display: none !important;
}

#listView[hidden] {
  display: none !important;
}

#board:not([hidden]) {
  display: grid;
}

.tenant-card.card-flash {
  animation: card-flash 1.2s ease;
}

@keyframes card-flash {
  0%,
  30% {
    box-shadow: 0 0 0 2px var(--accent), 0 0 20px rgba(61, 184, 209, 0.35);
  }
  100% {
    box-shadow: none;
  }
}

/* Bowler chart page (circular / polar area layout) */
.bowler-chart-warn {
  color: #e0a37d;
  margin: 0 0 1rem;
  min-height: 1.25rem;
  font-size: 0.9rem;
}

.bowler-chart-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2rem;
  align-items: flex-start;
}

.bowler-chart-canvas-box {
  flex: 0 0 auto;
  max-width: min(92vw, 560px);
}

#bowlerChartAllTenantsCanvas {
  max-width: 100%;
  height: auto;
}

.bowler-chart-legend-box {
  flex: 1 1 220px;
  min-width: 200px;
}

.bowler-chart-table-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.list-scroll--bowler-chart {
  max-height: min(70vh, 600px);
}

.bowler-chart-tenant-table .sw {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 0.45rem;
  vertical-align: middle;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.foot p {
  margin: 0;
  font-size: 0.9rem;
}

/* Group by portfolio (index + bowler-chart page) */
.section-group-portfolio {
  margin-top: 2.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

.section-group-portfolio h2 {
  font-size: 1.2rem;
  font-weight: 650;
  margin: 0 0 0.4rem;
  color: #d0e4ef;
  letter-spacing: -0.02em;
}

.section-deck {
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 44rem;
  margin: 0 0 1.25rem;
  line-height: 1.45;
}

.group-by-wrap {
  margin-bottom: 1.5rem;
}

.bowler-chart-canvas-box--portfolio {
  max-width: min(88vw, 480px);
}

.section-group-portfolio--on-bowler-chart {
  margin-top: 2rem;
}

.portfolio-bowlers-h {
  font-size: 0.95rem;
  font-weight: 600;
  color: #9fb0bd;
  margin: 0 0 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.state--folio {
  color: #7dc3e0;
  background: rgba(61, 184, 209, 0.12);
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 0.72rem;
}

.portfolio-rollup-card {
  border-color: rgba(61, 184, 209, 0.22);
}

.portfolio-rollup-hint {
  font-size: 0.86rem;
}

.sub-portfolio-block {
  margin: 0.6rem 0 0.85rem;
  padding: 0.6rem 0.65rem 0.5rem;
  border-radius: 6px;
  background: rgba(8, 14, 20, 0.35);
  border: 1px solid rgba(42, 53, 66, 0.85);
}

.sub-portfolio-h {
  font-size: 0.8rem;
  font-weight: 600;
  color: #8fa6b8;
  margin: 0 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sub-portfolio-deck {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  line-height: 1.35;
}

.sub-portfolio-scroll {
  max-height: 12rem;
  overflow: auto;
  margin: 0 -0.1rem;
}

.sub-portfolio-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.sub-portfolio-table th,
.sub-portfolio-table td {
  padding: 0.28rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid rgba(42, 53, 66, 0.7);
  vertical-align: top;
}

.sub-portfolio-table thead th {
  color: #7d93a8;
  font-weight: 600;
  white-space: nowrap;
}

.sub-portfolio-table .sub-pf-name {
  max-width: 9rem;
  word-wrap: break-word;
  color: #c5d2dc;
  font-weight: 500;
}

.sub-portfolio-table .num--tight {
  white-space: nowrap;
}

.num--tight {
  font-variant-numeric: tabular-nums;
}

.portfolio-rollup-bowlers-h {
  font-size: 0.8rem;
  font-weight: 600;
  color: #8fa6b8;
  margin: 0.5rem 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tenant-list .cell--folio {
  max-width: 7.5rem;
  font-size: 0.82rem;
  color: #9fb0bd;
  line-height: 1.3;
  word-wrap: break-word;
}

#portfolioBowlerGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.1rem;
}

/* PDF / print export */
.export-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.btn-pdf {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(61, 184, 209, 0.45);
  background: rgba(61, 184, 209, 0.12);
  color: #b8e8f2;
  cursor: pointer;
}

.btn-pdf:hover {
  background: rgba(61, 184, 209, 0.22);
  color: var(--text);
}

.btn-pdf--secondary {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
  font-weight: 500;
}

.btn-pdf--secondary:hover {
  color: var(--text);
  border-color: #4a5f75;
}

@media print {
  .no-print {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #1a1a1a !important;
    padding: 0.4in;
  }

  .export-root,
  .export-root * {
    color: #1a1a1a !important;
  }

  .lede {
    color: #333 !important;
  }

  .meta {
    border-color: #ccc !important;
    background: #f8f9fa !important;
  }

  .meta-value {
    color: #0d5f73 !important;
  }

  .tenant-card,
  .portfolio-rollup-card {
    break-inside: avoid;
    page-break-inside: avoid;
    border-color: #ccc !important;
    background: #fff !important;
  }

  .list-scroll,
  .list-scroll--bowler-chart {
    max-height: none !important;
    overflow: visible !important;
    border-color: #ccc !important;
  }

  .bowler {
    border-color: #999 !important;
  }

  .bowler__value {
    background: #0d5f73 !important;
    box-shadow: none !important;
  }

  .spark {
    background: #f0f4f6 !important;
    color: #222 !important;
    border-left-color: #0d5f73 !important;
  }

  .state {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  a {
    color: #0d5f73 !important;
    text-decoration: none;
  }
}

@media (max-width: 800px) {
  .view-toggle {
    width: 100%;
    order: 3;
  }
}
