:root {
  --ink: #222528;
  --muted: #666b70;
  --canvas: #f4f4f3;
  --paper: #ffffff;
  --line: #dededc;
  --line-strong: #c7c8c7;
  --brand-red: #cf1f2c;
  --brand-red-dark: #99151e;
  --brand-black: #222528;
  --navy: var(--brand-black);
  --blue: var(--brand-red);
  --green: #16704a;
  --amber: #a86500;
  --red: #b8202b;
  --violet: #5f666b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 14px/1.45 Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
input,
select,
a {
  border-radius: 4px;
}

button {
  min-height: 36px;
  border: 1px solid transparent;
  padding: 0 13px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid #ef9ca3;
  outline-offset: 1px;
}

input,
select,
textarea {
  width: 100%;
  height: 38px;
  min-width: 0;
  border: 1px solid var(--line-strong);
  padding: 0 10px;
  background: var(--paper);
  color: var(--ink);
}

textarea {
  min-height: 78px;
  padding: 9px 10px;
  resize: vertical;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: 60px;
  padding: 0 26px;
  border-bottom: 3px solid var(--brand-red);
  background: var(--paper);
  box-shadow: 0 1px 4px rgba(22, 38, 50, .06);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.brand strong {
  color: var(--brand-red);
  font-size: 15px;
}

.brand span {
  color: var(--muted);
  font-weight: 650;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-left: 3px solid var(--amber);
  color: #485661;
  font-size: 12px;
}

.sync-status.good {
  border-left-color: var(--green);
}

.sync-status.bad {
  border-left-color: var(--red);
}

.icon-command,
.quiet {
  border-color: var(--line-strong);
  background: var(--paper);
}

.back-link {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.tabs {
  position: sticky;
  top: 60px;
  z-index: 19;
  display: flex;
  min-height: 45px;
  padding: 0 20px;
  overflow-x: auto;
  background: var(--navy);
}

.tabs button {
  min-height: 45px;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #d9e3e9;
  white-space: nowrap;
  font-size: 13px;
}

.tabs button:hover,
.tabs button.active {
  background: #111315;
  color: #fff;
}

.tabs button.active {
  border-bottom-color: var(--brand-red);
}

.tabs span {
  margin-left: 5px;
  color: #ffcbd0;
}

main {
  width: 100%;
  max-width: 1780px;
  margin: auto;
  padding: 18px 26px 54px;
}

.filter-shell {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
}

.filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--line);
}

.quick-ranges {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
}

.quick-ranges button {
  min-height: 32px;
  padding: 0 11px;
  color: #52606b;
  white-space: nowrap;
  font-size: 12px;
}

.quick-ranges button:hover {
  background: #edf1f3;
}

.quick-ranges button.active {
  background: var(--brand-red);
  color: #fff;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
}

.filters label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: #4d5b66;
  font-size: 12px;
  font-weight: 700;
}

.filters .advanced {
  display: none;
}

.filters.show-advanced .advanced {
  display: grid;
}

.filters.show-advanced .check {
  display: flex;
}

.check {
  align-items: center;
  gap: 7px;
  min-height: 38px;
}

.check input {
  width: 18px;
  height: 18px;
}

.filter-actions {
  display: flex;
  gap: 7px;
  align-items: end;
}

.primary {
  background: var(--brand-red);
  color: #fff;
}

.message {
  padding: 15px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  background: var(--paper);
}

.view-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 20px 0 12px;
}

.view-head h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.view-head p {
  max-width: 900px;
  margin: 4px 0 0;
  color: var(--muted);
}

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

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid #b8d5c6;
  border-radius: 999px;
  background: #edf7f1;
  color: #0f633e;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.chip.neutral {
  border-color: var(--line-strong);
  background: #f4f6f7;
  color: #52606b;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
}

.kpi {
  min-height: 105px;
  padding: 14px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--blue);
  border-radius: 4px;
  background: var(--paper);
}

.kpi span,
.kpi small {
  display: block;
  color: var(--muted);
}

.kpi strong {
  display: block;
  margin: 5px 0 2px;
  font-size: 23px;
  line-height: 1.2;
}

.kpi.good {
  border-top-color: var(--green);
}

.kpi.warn {
  border-top-color: var(--amber);
}

.kpi.bad {
  border-top-color: var(--red);
}

.kpi.violet {
  border-top-color: var(--violet);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.risk-rail {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid #dfb3b7;
  border-left: 4px solid var(--red);
  background: #fff8f8;
}

.risk-rail > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.risk-rail span {
  color: #7c333a;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.risk-rail strong {
  white-space: nowrap;
}

.risk-rail p {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #4f3a3d;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.risk-rail button {
  border-color: #c9898f;
  background: #fff;
  color: #8e2530;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin: 28px 0 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-strong);
}

.section-heading span {
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.section-heading h2 {
  margin: 1px 0 0;
  font-size: 18px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  text-align: right;
}

.panel,
.insight {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
}

.panel {
  padding: 15px;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.panel-head h2 {
  margin: 2px 0 0;
  font-size: 16px;
}

.panel-head b {
  color: #43525e;
  white-space: nowrap;
  font-size: 12px;
}

.eyebrow {
  color: var(--blue);
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 800;
}

.insight {
  padding: 14px 16px;
  border-left: 4px solid var(--navy);
}

.insight b {
  display: block;
  margin-bottom: 3px;
}

.insight p {
  margin: 0;
  color: #4d5a65;
}

.role-lenses {
  display: grid;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--paper);
}

.role-lenses section {
  min-width: 0;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}

.role-lenses section:last-child {
  border-bottom: 0;
}

.role-lenses span,
.role-lenses strong,
.role-lenses p {
  display: block;
}

.role-lenses span {
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.role-lenses strong {
  margin: 2px 0;
  font-size: 17px;
}

.role-lenses p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.legend {
  display: flex;
  gap: 14px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
}

.legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
}

.legend .provision {
  background: var(--blue);
}

.legend .expense {
  background: var(--green);
}

.cost-chart {
  display: flex;
  align-items: end;
  gap: 9px;
  height: 245px;
  padding: 12px 7px 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.cost-period {
  display: grid;
  grid-template-rows: 1fr 18px;
  align-items: end;
  min-width: 54px;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-weight: 400;
}

.cost-period:hover,
.cost-period:focus-visible {
  background: #edf3f6;
}

.cost-bars {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 3px;
  height: 100%;
}

.cost-bar {
  width: 18px;
  min-height: 2px;
  background: var(--blue);
}

.cost-bar.expense {
  background: var(--green);
}

.cost-period small {
  overflow: hidden;
  color: var(--muted);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.line-chart {
  width: 100%;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.line-chart svg {
  display: block;
  width: max(100%, 720px);
  height: 240px;
}

.line-chart text {
  fill: var(--muted);
  font: 10px Inter, "Segoe UI", Arial, sans-serif;
}

.grid-line {
  stroke: #e2e7ea;
  stroke-width: 1;
}

.line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.provision-line {
  stroke: var(--blue);
}

.expense-line {
  stroke: var(--green);
}

.portfolio-chart {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  min-height: 248px;
}

.donut {
  display: grid;
  width: 150px;
  height: 150px;
  place-items: center;
  border-radius: 50%;
  background: var(--segments);
}

.donut::before {
  grid-area: 1 / 1;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--paper);
  content: "";
}

.donut div {
  z-index: 1;
  grid-area: 1 / 1;
  text-align: center;
}

.donut strong,
.donut span {
  display: block;
}

.donut strong {
  font-size: 25px;
}

.donut span {
  color: var(--muted);
  font-size: 11px;
}

.portfolio-legend {
  display: grid;
  gap: 3px;
}

.portfolio-legend button {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 39px;
  padding: 4px 5px;
  border: 0;
  background: transparent;
  text-align: left;
}

.portfolio-legend button:hover {
  background: #f1f5f6;
}

.portfolio-legend i {
  width: 9px;
  height: 28px;
}

.portfolio-legend span,
.portfolio-legend b,
.portfolio-legend small {
  display: block;
  min-width: 0;
}

.portfolio-legend small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.rank-list {
  display: grid;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.2fr) minmax(120px, 2fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 39px;
  padding: 3px 5px;
  border: 0;
  background: transparent;
  text-align: left;
  font-weight: 400;
}

.rank-row:hover {
  background: #f1f5f6;
}

.rank-label {
  min-width: 0;
}

.rank-label strong,
.rank-label small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-label small {
  color: var(--muted);
}

.rank-track {
  height: 10px;
  background: #e9eef1;
}

.rank-track i {
  display: block;
  height: 100%;
  background: var(--green);
}

.rank-row b {
  min-width: 94px;
  text-align: right;
  font-size: 12px;
}

.variance-lanes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.variance-lane {
  min-width: 0;
}

.variance-lane h3 {
  margin: 0 0 9px;
  color: #465560;
  font-size: 13px;
}

.variance-lane > button {
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) minmax(100px, 1.7fr) auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  align-items: center;
  width: 100%;
  min-height: 50px;
  padding: 6px 5px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  font-weight: 400;
}

.variance-lane > button:hover {
  background: #f4f7f8;
}

.variance-lane > button > span {
  grid-row: 1 / 3;
  min-width: 0;
}

.variance-lane span b,
.variance-lane span small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.variance-lane span small,
.variance-lane > button > small {
  color: var(--muted);
  font-size: 10px;
}

.variance-lane > button > i {
  height: 9px;
  background: #edf0f2;
}

.variance-lane > button > i em {
  display: block;
  height: 100%;
  background: var(--red);
}

.variance-lane.warn > button > i em {
  background: var(--amber);
}

.variance-lane > button > strong,
.variance-lane > button > small {
  text-align: right;
}

.late-chart {
  display: flex;
  align-items: end;
  gap: 7px;
  max-width: 100%;
  height: 245px;
  padding: 18px 4px 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.late-chart button {
  display: grid;
  grid-template-rows: 18px 1fr 20px;
  align-items: end;
  width: 100%;
  min-width: 32px;
  height: 100%;
  min-height: 0;
  padding: 0 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 400;
}

.late-chart button:hover {
  background: #fff5f5;
}

.late-chart button span,
.late-chart button small {
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
}

.late-chart button i {
  justify-self: center;
  width: min(22px, 75%);
  min-height: 2px;
  background: var(--red);
}

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

.project-period {
  display: grid;
  grid-template-columns: 130px minmax(180px, 260px) minmax(220px, 1fr);
  gap: 10px;
  align-items: end;
  margin: 4px 0 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand-red);
  background: #fafafa;
}

.project-period label {
  display: grid;
  gap: 4px;
  color: #4d5154;
  font-size: 11px;
  font-weight: 800;
}

.project-period select {
  height: 34px;
}

.project-period > span {
  align-self: center;
  color: var(--muted);
  font-size: 11px;
}

.table-tools p {
  margin: 0;
  color: var(--muted);
}

.table-local-tools {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
}

.table-local-tools label {
  display: grid;
  grid-template-columns: auto minmax(220px, 420px);
  gap: 8px;
  align-items: center;
  color: #4d5b66;
  font-size: 11px;
  font-weight: 800;
}

.table-local-tools input {
  height: 34px;
}

.table-local-tools span {
  color: var(--muted);
  white-space: nowrap;
  font-size: 11px;
}

.table-wrap {
  max-height: 620px;
  overflow: auto;
  border: 1px solid var(--line);
}

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

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #edf1f3;
  color: #3c4b57;
}

.sort-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  width: 100%;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-align: inherit;
  white-space: nowrap;
  font-size: 11px;
}

.sort-header:hover {
  color: var(--brand-red);
}

.sort-header i {
  color: #7b858d;
  font-style: normal;
}

tbody tr:hover {
  background: #f5f8f9;
}

.num {
  text-align: right;
}

.open-detail {
  min-height: 30px;
  padding: 0 8px;
  border-color: #b6c7d2;
  color: #145b7a;
  font-weight: 800;
}

.event-cell {
  min-width: 230px;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  background: #f6f8f9;
  font-weight: 750;
}

.status.overrun,
.status.no_provision,
.status.late {
  border-color: #e3adb2;
  background: #fff0f1;
  color: #9a2430;
}

.status.pending,
.status.no_spend {
  border-color: #dfc28e;
  background: #fff7e8;
  color: #8b5700;
}

.status.balanced,
.status.on_time {
  border-color: #add2bf;
  background: #edf8f2;
  color: #11603d;
}

.status.exempt,
.status.no_event_date {
  color: #5f6c76;
}

.review-command {
  min-height: 28px;
  white-space: nowrap;
}

.review-reviewed {
  border-color: #add2bf;
  background: #edf8f2;
  color: #11603d;
}

.review-observed,
.review-pending {
  border-color: #dfc28e;
  background: #fff7e8;
  color: #8b5700;
}

.review-changed {
  border-color: #e3adb2;
  background: #fff0f1;
  color: #9a2430;
}

.review-guidance {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin: 14px 0;
  padding: 13px 15px;
  border-left: 4px solid var(--amber);
  background: var(--paper);
}

.review-guidance.ready {
  border-left-color: var(--green);
}

.review-guidance div {
  display: grid;
}

.review-guidance span,
.review-summary span {
  color: var(--muted);
  font-size: 12px;
}

.review-guidance p {
  margin: 0;
}

.review-panel {
  margin-top: 14px;
}

.review-dialog {
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100vh - 30px);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 22px 70px rgba(20, 28, 33, .28);
}

.review-dialog.wide {
  width: min(690px, calc(100vw - 24px));
}

.review-dialog::backdrop {
  background: rgba(15, 29, 39, .46);
}

.review-dialog form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.review-dialog form > p {
  margin: 0;
  color: var(--muted);
}

.review-dialog label {
  display: grid;
  gap: 5px;
  color: #4c5962;
  font-size: 12px;
  font-weight: 700;
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.dialog-head span {
  color: var(--brand-red);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.dialog-head h2 {
  margin: 2px 0 0;
  font-size: 21px;
}

.dialog-close {
  width: 36px;
  padding: 0;
  border-color: var(--line-strong);
  font-size: 22px;
}

.form-error {
  padding: 9px 10px;
  border-left: 3px solid var(--red);
  background: #fff0f1;
  color: #9a2430 !important;
}

.review-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-block: 1px solid var(--line);
}

.review-summary div {
  display: grid;
  gap: 2px;
  padding: 11px 8px;
}

.review-decisions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  border: 0;
  padding: 0;
}

.review-decisions legend {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.review-decisions label {
  display: flex;
  min-height: 42px;
  align-items: center;
  border: 1px solid var(--line);
  padding: 7px;
  background: #fafafa;
}

.review-decisions input {
  width: 18px;
  height: 18px;
}

.review-history {
  display: grid;
  gap: 7px;
  max-height: 220px;
  overflow: auto;
}

.review-history h3,
.review-history p {
  margin: 0;
}

.review-history article {
  border-left: 3px solid var(--line-strong);
  padding: 7px 9px;
  background: #f7f8f8;
}

.review-history article div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.review-history article small {
  display: block;
  margin-top: 4px;
}

.risk-spectrum {
  display: grid;
  gap: 6px;
}

.risk-spectrum button {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  background: transparent;
  text-align: left;
}

.risk-spectrum button:hover,
.risk-spectrum button.active {
  border-color: var(--navy);
  background: #f0f4f6;
}

.risk-spectrum i {
  width: 10px;
  height: 38px;
  background: var(--violet);
}

.risk-spectrum i.critical {
  background: var(--red);
}

.risk-spectrum i.high {
  background: var(--amber);
}

.risk-spectrum span,
.risk-spectrum b,
.risk-spectrum small {
  display: block;
}

.risk-spectrum small {
  color: var(--muted);
  font-size: 11px;
}

.risk-spectrum strong {
  font-size: 22px;
}

.severity-filter {
  display: flex;
  gap: 3px;
  overflow-x: auto;
}

.severity-filter button {
  min-height: 30px;
  padding: 0 9px;
  border-color: var(--line);
  white-space: nowrap;
  font-size: 11px;
}

.severity-filter button.active {
  background: var(--navy);
  color: #fff;
}

.severity {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-left: 4px solid var(--violet);
  background: #f4f0f6;
  color: #654674;
  font-weight: 800;
}

.severity.critical {
  border-left-color: var(--red);
  background: #fff0f1;
  color: #8f202b;
}

.severity.high {
  border-left-color: var(--amber);
  background: #fff7e8;
  color: #815100;
}

.reason-cell {
  min-width: 250px;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compact-table {
  max-height: 420px;
}

.alert-link {
  min-height: 28px;
  padding: 0 7px;
  border-color: #e3adb2;
  color: #9a2430;
}

.load-more {
  display: block;
  margin: 12px auto 0;
  border-color: var(--line-strong);
}

.empty {
  padding: 42px 20px;
  border: 1px solid var(--line);
  background: var(--paper);
  text-align: center;
}

.empty h2 {
  margin: 0 0 5px;
  font-size: 19px;
}

.empty p {
  margin: 0;
  color: var(--muted);
}

.method-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.method-item {
  padding: 18px;
  background: var(--paper);
}

.method-item h2 {
  margin: 0 0 5px;
  font-size: 15px;
}

.method-item p {
  margin: 0;
  color: var(--muted);
}

.drill {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  width: min(760px, 92vw);
  height: 100vh;
  overflow: hidden;
  border-left: 1px solid var(--line-strong);
  background: var(--paper);
  box-shadow: -12px 0 35px rgba(20, 36, 48, .18);
}

.drill-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  min-height: 72px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}

.drill-head span {
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.drill-head h2 {
  margin: 2px 0 0;
  font-size: 18px;
}

.close-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border-color: var(--line-strong);
  font-size: 25px;
  line-height: 1;
}

.breadcrumb {
  display: flex;
  gap: 5px;
  padding: 9px 18px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #f5f7f8;
}

.breadcrumb button {
  min-height: 29px;
  padding: 0 8px;
  border-color: var(--line);
  white-space: nowrap;
  font-size: 11px;
}

.breadcrumb button:last-child {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}

.drill-content {
  height: calc(100vh - 123px);
  padding: 14px 18px 36px;
  overflow: auto;
}

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

.drill-summary div {
  padding: 10px;
  border: 1px solid var(--line);
}

.drill-summary span,
.drill-summary strong {
  display: block;
}

.drill-summary span {
  color: var(--muted);
  font-size: 11px;
}

.drill-summary strong {
  margin-top: 2px;
  font-size: 16px;
}

.drawer-shade {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 29, 39, .28);
}

@media (max-width: 1240px) {
  .filters {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .kpis {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8 {
    grid-column: span 6;
  }

  .portfolio-chart {
    grid-template-columns: 125px minmax(0, 1fr);
  }

  .donut {
    width: 120px;
    height: 120px;
  }

  .donut::before {
    width: 72px;
    height: 72px;
  }
}

@media (max-width: 760px) {
  .topbar {
    height: auto;
    min-height: 58px;
    padding: 8px 11px;
  }

  .brand {
    display: grid;
    gap: 0;
  }

  .sync-status,
  .icon-command {
    display: none;
  }

  .tabs {
    top: 58px;
    padding: 0;
  }

  main {
    padding: 12px 10px 42px;
  }

  .filter-toolbar {
    align-items: start;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-actions {
    grid-column: 1 / -1;
  }

  .view-head {
    display: block;
  }

  .risk-rail {
    grid-template-columns: 1fr auto;
  }

  .risk-rail p {
    grid-column: 1 / -1;
    grid-row: 2;
    white-space: normal;
  }

  .section-heading {
    display: block;
  }

  .section-heading p {
    margin-top: 4px;
    text-align: left;
  }

  .head-meta {
    justify-content: start;
    margin-top: 10px;
  }

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi strong {
    font-size: 20px;
  }

  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8,
  .span-12 {
    grid-column: span 12;
  }

  .portfolio-chart {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .portfolio-legend {
    width: 100%;
  }

  .variance-lanes {
    grid-template-columns: 1fr;
  }

  .rank-row {
    grid-template-columns: minmax(110px, 1fr) minmax(80px, 1fr);
  }

  .table-local-tools {
    display: grid;
    grid-template-columns: 1fr;
  }

  .project-period {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-period > span {
    grid-column: 1 / -1;
  }

  .table-local-tools label {
    grid-template-columns: 1fr;
  }

  .table-local-tools span {
    white-space: normal;
  }

  .rank-row b {
    grid-column: 2;
  }

  .rank-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .method-list {
    grid-template-columns: 1fr;
  }

  .drill {
    width: 100vw;
  }

  .drill-summary {
    grid-template-columns: 1fr;
  }

  .review-guidance,
  .review-summary,
  .review-decisions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .filters {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    grid-column: auto;
  }

  .kpis {
    grid-template-columns: 1fr;
  }

  .project-period {
    grid-template-columns: 1fr;
  }

  .project-period > span {
    grid-column: auto;
  }

  .risk-rail {
    grid-template-columns: 1fr;
  }

  .risk-rail > div {
    flex-wrap: wrap;
  }

  .risk-rail p,
  .risk-rail button {
    grid-column: auto;
  }

  .variance-lane > button {
    grid-template-columns: minmax(120px, 1fr) auto;
  }

  .variance-lane > button > i {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .back-link {
    padding: 0 9px;
    font-size: 12px;
  }
}

@media print {
  .topbar,
  .tabs,
  .filter-shell,
  .drill,
  .drawer-shade,
  .table-tools button {
    display: none !important;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .panel,
  .kpi,
  .insight {
    break-inside: avoid;
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
  }
}
