:root {
  --navy: #1a2332;
  --navy-light: #243044;
  --steel: #4a7fb5;
  --forest: #2d8659;
  --amber: #b7791f;
  --red: #b42318;
  --bg: #ffffff;
  --bg-soft: #f4f6f8;
  --row-alt: #f8f9fb;
  --text: #1a1a1a;
  --text-secondary: #555f6f;
  --muted: #7b8494;
  --border: #d4d8dd;
  --shadow: 0 2px 10px rgba(26, 35, 50, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}

.eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 700;
}

h1, h2, h3, p { margin: 0; }

h1 {
  margin-top: 2px;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.2px;
}

#subtitle {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 12px;
}

.topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge, .headerButton {
  border-radius: 3px;
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.badge {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
}

.headerButton {
  min-height: 30px;
  border: 1px solid var(--steel);
  background: var(--steel);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 69px);
}

.sidebar {
  position: sticky;
  top: 69px;
  height: calc(100vh - 69px);
  overflow-y: auto;
  padding: 18px 16px;
  background: #f1f3f5;
  border-right: 1px solid var(--border);
}

.sidebar h3 {
  margin: 18px 0 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--muted);
}

.sidebar h3:first-child { margin-top: 0; }

.filter-label {
  display: block;
  margin: 12px 0 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.filter-input {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid #bcc4cc;
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font: inherit;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.filter-input:focus {
  outline: 2px solid rgba(74, 127, 181, 0.18);
  border-color: var(--steel);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  color: var(--text-secondary);
}

.method-box {
  margin-top: 14px;
  padding: 12px;
  border-left: 3px solid var(--steel);
  background: #fff;
  color: var(--text-secondary);
  box-shadow: var(--shadow);
}

.method-box strong {
  display: block;
  color: var(--navy);
  margin-bottom: 4px;
}

.main {
  padding: 24px 30px 40px;
  overflow-x: hidden;
}

.summary-box {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 20px;
  background: var(--navy);
  color: #fff;
  border-radius: 4px;
  overflow: hidden;
}

.summary-item {
  padding: 16px 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.summary-item:last-child { border-right: 0; }

.s-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.58);
  font-weight: 700;
}

.s-value {
  margin-top: 4px;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
}

.s-note {
  margin-top: 2px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.58);
}

.section {
  margin-bottom: 22px;
}

.section-title {
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--navy);
  color: var(--navy);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 800;
}

.takeaway-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.takeaway {
  min-height: 124px;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--navy);
  border-radius: 4px;
  background: var(--bg-soft);
}

.takeaway.signal { border-left-color: var(--steel); }
.takeaway.caution { border-left-color: var(--amber); }
.takeaway.watch { border-left-color: var(--forest); }

.takeaway-label {
  display: inline-block;
  margin-bottom: 7px;
  padding: 2px 7px;
  border-radius: 2px;
  background: var(--navy);
  color: #fff;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 800;
}

.takeaway.signal .takeaway-label { background: var(--steel); }
.takeaway.caution .takeaway-label { background: var(--amber); }
.takeaway.watch .takeaway-label { background: var(--forest); }

.takeaway strong {
  display: block;
  margin-bottom: 5px;
  color: var(--navy);
  font-size: 13px;
}

.takeaway p {
  color: var(--text-secondary);
  font-size: 12px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.kpi {
  min-height: 78px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: linear-gradient(180deg, #fff 0%, #f3f5f7 100%);
  box-shadow: var(--shadow);
}

.kpi .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  font-weight: 800;
}

.kpi .value {
  margin-top: 5px;
  color: var(--navy);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 21px;
  font-weight: 800;
}

.kpi .sub {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 11px;
}

.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 0;
  padding: 4px 4px 0;
  background: #d9dee4;
  border-radius: 6px 6px 0 0;
}

.tab {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.tab.active {
  background: #fff;
  color: var(--navy);
  border-color: var(--border);
}

.tab-content {
  display: none;
  padding: 18px;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

.tab-content.active { display: block; }

.tab-content > .chart-container + .chart-container {
  margin-top: 16px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.chart-container {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fbfcfd;
}

.chart-title {
  margin-bottom: 10px;
  color: var(--navy);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 800;
}

.chart {
  display: grid;
  gap: 8px;
}

.barRow {
  display: grid;
  grid-template-columns: minmax(130px, 230px) 1fr 58px;
  gap: 10px;
  align-items: center;
}

.barLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.barTrack {
  height: 13px;
  background: #e5e9ee;
  border-radius: 2px;
  overflow: hidden;
}

.barFill {
  height: 100%;
  background: var(--steel);
}

.barValue {
  text-align: right;
  font-family: "IBM Plex Mono", Consolas, monospace;
  color: var(--navy);
}

.signal-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.signal-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}

.signal-card .name {
  color: var(--navy);
  font-weight: 800;
}

.signal-card .value {
  margin-top: 4px;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 18px;
  font-weight: 800;
}

.signal-card .note {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 11px;
}

.dossier-list {
  display: grid;
  gap: 16px;
}

.dossier {
  padding: 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--steel);
  border-radius: 4px;
  background: #fff;
}

.dossier-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  margin-bottom: 12px;
}

.dossier h3 {
  margin-bottom: 5px;
  color: var(--navy);
  font-size: 15px;
}

.dossier p {
  color: var(--text-secondary);
  font-size: 12px;
}

.dossier-metrics {
  display: grid;
  gap: 6px;
  min-width: 160px;
}

.dossier-metrics span {
  display: block;
  padding: 5px 8px;
  border-radius: 3px;
  background: var(--bg-soft);
  color: var(--navy);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  text-align: right;
}

.dossier-mix {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.dossier-mix div {
  min-height: 64px;
  padding: 9px;
  border: 1px solid #e4e8ec;
  border-radius: 3px;
  background: #f7f9fb;
  color: var(--text-secondary);
  font-size: 11px;
}

.dossier-mix strong {
  display: block;
  margin-bottom: 3px;
  color: var(--navy);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mini-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.mini-table {
  min-width: 960px;
}

.mini-table th {
  position: static;
}

.mini-table td:nth-child(2),
.mini-table td:nth-child(3) {
  font-family: "IBM Plex Mono", Consolas, monospace;
  text-align: right;
  color: var(--navy);
  white-space: nowrap;
}

.mini-table td:nth-child(5) {
  min-width: 260px;
}

.mini-table a {
  color: var(--steel);
  font-weight: 700;
}

.dossier-caveat {
  margin-top: 10px;
  padding: 9px 10px;
  border-left: 3px solid var(--amber);
  background: #fff8ec;
  color: var(--text-secondary);
  font-size: 12px;
}

.dossier-caveat strong {
  color: var(--navy);
}

.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 12px;
}

.watch-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--forest);
  border-radius: 4px;
  background: #fff;
}

.watch-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 3px;
  background: var(--navy);
  color: #fff;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
}

.watch-title {
  color: var(--navy);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.watch-title:hover {
  color: var(--steel);
  text-decoration: underline;
}

.watch-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.watch-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 8px 0;
}

.watch-tags span {
  padding: 3px 6px;
  border-radius: 2px;
  background: #e9f0f7;
  color: var(--navy);
  font-size: 10px;
  font-weight: 800;
}

.watch-body p {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

.watch-body strong {
  color: var(--navy);
}

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

.tableHeader p {
  color: var(--text-secondary);
  font-size: 12px;
}

#rowCount {
  color: var(--text-secondary);
  font-family: "IBM Plex Mono", Consolas, monospace;
  white-space: nowrap;
}

.tableWrap {
  max-height: 650px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 10px;
  background: var(--navy);
  color: #fff;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 10px;
}

td {
  padding: 8px 10px;
  border-bottom: 1px solid #e8eaed;
  vertical-align: top;
}

tbody tr:nth-child(even) td { background: var(--row-alt); }
tbody tr:hover td { background: #eef3f8; }

td a {
  color: var(--steel);
  font-weight: 700;
}

.qualityBody {
  display: grid;
  gap: 8px;
  color: var(--text-secondary);
}

.qualityBody div {
  padding-bottom: 7px;
  border-bottom: 1px solid #e7eaee;
}

.qualityBody strong { color: var(--navy); }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .takeaway-grid, .two-col, .summary-box {
    grid-template-columns: 1fr;
  }
  .dossier-head, .dossier-mix {
    grid-template-columns: 1fr;
  }
  .dossier-metrics span {
    text-align: left;
  }
  .summary-item { border-right: 0; border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .main { padding: 16px; }
  .tabs { overflow-x: auto; }
  .watchlist-grid { grid-template-columns: 1fr; }
  .watch-card { grid-template-columns: 1fr; }
}
