:root {
  --page-bg: #cfcfcf;
  --panel: #eeeeee;
  --line-dark: #606060;
  --line-light: #ffffff;
  --blue: #003399;
  --red: #8b1a1a;
  --green: #0a5a2a;
  --text: #111111;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

a {
  color: var(--blue);
  display: block;
  margin: 8px 0;
  text-decoration: underline;
}

.page-shell {
  width: min(1180px, calc(100vw - 16px));
  margin: 8px auto;
  border-top: 2px solid var(--line-light);
  border-left: 2px solid var(--line-light);
  border-right: 2px solid var(--line-dark);
  border-bottom: 2px solid var(--line-dark);
  background: #dedede;
}

.portal-shell {
  width: min(1320px, calc(100vw - 16px));
}

.topbar {
  padding: 10px 12px;
  background: #0b3d91;
  color: white;
  border-bottom: 3px solid #9c9c9c;
}

.topnav {
  padding: 6px 10px;
  background: #d7d7d7;
  border-bottom: 2px solid #8c8c8c;
}

.topnav a {
  display: inline-block;
  margin: 2px 10px 2px 0;
  padding: 4px 8px;
  color: var(--blue);
  background: #eeeeee;
  border-top: 1px solid white;
  border-left: 1px solid white;
  border-right: 1px solid #777;
  border-bottom: 1px solid #777;
  font-weight: bold;
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: "Times New Roman", Times, serif;
  font-size: 24px;
  font-weight: bold;
}

.brand-logo {
  display: inline-block;
  width: 30px;
  height: 30px;
  object-fit: contain;
  background: white;
  border-top: 1px solid #7fa0d8;
  border-left: 1px solid #7fa0d8;
  border-right: 1px solid #001f4d;
  border-bottom: 1px solid #001f4d;
}

.host {
  float: right;
  padding-top: 7px;
  font-size: 12px;
}

.sidebar {
  width: 190px;
  background: #d7d7d7;
  border-right: 2px solid #8c8c8c;
  padding: 12px;
}

.nav-title {
  margin: 12px 0 6px;
  padding: 4px;
  color: white;
  background: #707070;
  font-weight: bold;
  border-top: 1px solid white;
  border-left: 1px solid white;
  border-right: 1px solid #333;
  border-bottom: 1px solid #333;
}

.status-box {
  min-height: 70px;
  padding: 7px;
  background: #efefef;
  border: 1px inset #aaaaaa;
  font-size: 12px;
  line-height: 1.45;
}

.content {
  padding: 12px;
}

.portal-content {
  display: block;
}

.hero {
  min-height: 150px;
  padding: 18px;
  border-top: 2px solid white;
  border-left: 2px solid white;
  border-right: 2px solid #777;
  border-bottom: 2px solid #777;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.7), rgba(255,255,255,0.25)),
    repeating-linear-gradient(0deg, #f7f7f7 0, #f7f7f7 22px, #e9e9e9 22px, #e9e9e9 23px);
}

h1 {
  margin: 0 0 8px;
  font-family: "Times New Roman", Times, serif;
  font-size: 38px;
  line-height: 1.05;
}

.hero p {
  max-width: 760px;
  margin: 0;
  font-size: 16px;
}

.gateway-hero {
  min-height: 116px;
}

.portal-hero {
  margin-bottom: 0;
}

.gateway-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
  max-width: 760px;
  margin-top: 14px;
}

.portal-board {
  display: grid;
  grid-template-columns: minmax(360px, 9fr) minmax(0, 16fr);
  gap: 8px;
  align-items: stretch;
  aspect-ratio: 16 / 9;
  min-height: 520px;
  max-height: 730px;
}

.portal-board > div,
.feature-row > div {
  min-width: 0;
}

.portal-board > div,
.feature-row > div,
.directory-card,
.dim-card,
.metric-card {
  position: relative;
  isolation: isolate;
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.portal-board > div:hover,
.feature-row > div:hover,
.directory-card:hover,
.dim-card:hover,
.metric-card:hover {
  transform: translate(-1px, -2px);
  box-shadow:
    3px 3px 0 #777777,
    0 0 0 1px rgba(255, 255, 255, 0.82);
}

.portal-rank {
  grid-row: span 1;
}

.portal-workbench .panel,
.portal-rank .panel {
  height: calc(100% - 29px);
}

.unit-panel {
  min-height: 180px;
  line-height: 1.45;
}

.unit-panel p {
  margin: 0 0 8px;
}

.matrix-board {
  display: grid;
  grid-template-columns: minmax(220px, 0.82fr) minmax(0, 1.55fr);
  gap: 8px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.matrix-controls {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 28px minmax(0, 1fr) 28px;
  gap: 6px;
  padding: 8px;
  background: #f7f7f7;
  border-top: 1px solid white;
  border-left: 1px solid white;
  border-right: 1px solid #999999;
  border-bottom: 1px solid #999999;
}

.matrix-model-picker {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: minmax(46px, 1fr);
  gap: 6px;
  align-content: stretch;
  min-height: 0;
  overflow: hidden;
}

.matrix-results {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
}

.matrix-page-button {
  min-height: 28px;
  padding: 2px 8px;
  line-height: 1;
}

.matrix-model-button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-height: 46px;
  padding: 5px;
  color: #111111;
  background: #ffffff;
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-right: 1px solid #777777;
  border-bottom: 1px solid #777777;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.matrix-model-slot {
  visibility: hidden;
}

.matrix-model-button:hover,
.matrix-model-button.active {
  color: #ffffff;
  background: #0b3d91;
}

.matrix-model-button.active {
  box-shadow: inset 0 0 0 2px #6ea6ff;
}

.matrix-model-icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-right: 1px solid #6d86ad;
  border-bottom: 1px solid #6d86ad;
}

.matrix-model-icon img {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.matrix-model-button:hover .matrix-model-icon,
.matrix-model-button.active .matrix-model-icon {
  background: #ffffff;
}

.matrix-model-icon.no-icon,
.model-icon.no-icon {
  visibility: hidden;
}

.matrix-model-text {
  min-width: 0;
}

.matrix-model-text b,
.matrix-model-text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matrix-model-text small {
  margin-top: 2px;
  color: #555555;
  font-size: 11px;
}

.matrix-model-button:hover small,
.matrix-model-button.active small {
  color: #dceaff;
}

.feature-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.feature-unit .panel,
.feature-unit .status-box {
  min-height: 190px;
}

.compact-metrics {
  max-width: 760px;
  margin-top: 12px;
  padding: 0;
  background: transparent;
  border: 0;
}

section {
  margin-top: 14px;
}

.section-title {
  width: 100%;
  margin-bottom: 0;
  color: white;
  background: #666666;
  border-top: 1px solid white;
  border-left: 1px solid white;
  border-right: 1px solid #222;
  border-bottom: 1px solid #222;
  font-weight: bold;
  position: relative;
  overflow: hidden;
}

.section-title td {
  padding: 5px 8px;
  position: relative;
  z-index: 1;
  background:
    linear-gradient(0deg, #0b3d91 0%, #0b3d91 100%) 0 100% / 100% 0% no-repeat,
    #666666;
  transition: color 180ms ease;
}

.section-title td::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 50% 92%, rgba(255, 255, 255, 0.72) 0 2px, transparent 3px),
    linear-gradient(0deg, #0b3d91, #0b3d91);
  clip-path: polygon(0 100%, 100% 100%, 100% 100%, 0 100%);
  opacity: 0;
}

.portal-board > div:hover .section-title td::before,
.feature-row > div:hover .section-title td::before,
section:hover > .section-title td::before {
  animation: titleRevealRip 1500ms steps(26, end) 1 forwards;
}

.portal-board > div:hover .section-title td,
.feature-row > div:hover .section-title td,
section:hover > .section-title td {
  animation: compactTitleBurn 1500ms steps(26, end) 1 forwards;
  color: white;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}

.right {
  text-align: right;
  font-weight: normal;
  font-size: 12px;
}

.table-wrap,
.panel,
.method-box,
.result-box {
  border: 1px inset #999999;
  background: var(--panel);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 7px 8px;
  border: 1px solid #9a9a9a;
  vertical-align: top;
}

.data-table th {
  background: #d0d0d0;
  text-align: left;
}

.model-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-icon {
  display: inline-flex;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-top: 1px solid #ffffff;
  border-left: 1px solid #ffffff;
  border-right: 1px solid #777777;
  border-bottom: 1px solid #777777;
}

.model-icon img {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.top-ranking-list {
  display: grid;
  grid-auto-rows: minmax(46px, 1fr);
  gap: 7px;
  height: 100%;
}

.top-rank-item {
  display: grid;
  grid-template-columns: 24px 30px minmax(0, 1fr) 42px;
  gap: 7px;
  align-items: center;
  min-height: 46px;
  padding: 6px;
  background: white;
  border: 1px inset #aaaaaa;
}

.rank-num {
  font-family: "Times New Roman", Times, serif;
  font-size: 18px;
  font-weight: bold;
  text-align: center;
}

.top-rank-main {
  min-width: 0;
}

.top-rank-main b,
.top-rank-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-rank-main small {
  color: #555555;
  font-size: 12px;
}

.top-rank-score {
  font-family: "Times New Roman", Times, serif;
  font-size: 22px;
  font-weight: bold;
  text-align: right;
}

.select-cell {
  text-align: center;
}

.select-cell input {
  width: auto;
}

.scorebar {
  width: 100%;
  min-width: 90px;
  height: 16px;
  background: white;
  border: 1px solid #777;
}

.scorebar span {
  display: block;
  height: 100%;
  background: #1e6b3a;
}

.dimension-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  background: #e6e6e6;
  border: 1px inset #999999;
}

.directory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  background: #e6e6e6;
  border: 1px inset #999999;
}

.dim-card {
  padding: 9px;
  background: #f2f2f2;
  border-top: 1px solid white;
  border-left: 1px solid white;
  border-right: 1px solid #777;
  border-bottom: 1px solid #777;
}

.directory-card {
  min-height: 170px;
  padding: 9px;
  background: #f2f2f2;
  border-top: 1px solid white;
  border-left: 1px solid white;
  border-right: 1px solid #777;
  border-bottom: 1px solid #777;
}

.dim-card h3 {
  margin: 0 0 5px;
  font-size: 15px;
}

.directory-card h3 {
  margin: 0 0 5px;
  font-size: 15px;
  display: inline-block;
  padding: 2px 4px;
  background:
    linear-gradient(0deg, #0b3d91, #0b3d91) 0 100% / 100% 0% no-repeat,
    #666666;
  color: white;
  transition: color 180ms ease;
}

.directory-card:hover h3,
.dim-card:hover h3 {
  animation: compactTitleBurn 1400ms steps(24, end) 1 forwards;
  color: white;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}

.dim-card p,
.dim-card ul {
  margin: 5px 0;
  line-height: 1.45;
}

.dim-card h3 {
  display: inline-block;
  padding: 2px 4px;
  background:
    linear-gradient(0deg, #0b3d91, #0b3d91) 0 100% / 100% 0% no-repeat,
    #666666;
  color: white;
  transition: color 180ms ease;
}

.directory-card p {
  min-height: 38px;
  margin: 5px 0;
  line-height: 1.45;
}

.dim-card ul {
  padding-left: 20px;
}

.link-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.link-list a {
  min-height: 48px;
  margin: 0;
  padding: 6px;
  background: #ffffff;
  border: 1px inset #aaaaaa;
  text-decoration: none;
}

.link-list small {
  display: block;
  margin-top: 3px;
  color: #555555;
}

.quick-link-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 6px;
}

.quick-link-grid a {
  min-height: 42px;
  margin: 0;
  padding: 6px;
  background: #ffffff;
  border: 1px inset #aaaaaa;
  text-decoration: none;
}

.quick-link-grid small,
.quick-line small {
  display: block;
  margin-top: 2px;
  color: #555555;
}

.quick-line {
  min-height: 36px;
  margin-bottom: 6px;
  padding: 5px;
  background: white;
  border: 1px inset #aaaaaa;
}

.demo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 8px 0;
}

.demo-list span {
  display: inline-block;
  padding: 4px 6px;
  background: white;
  border: 1px inset #aaaaaa;
  color: #0b3d91;
  font-size: 12px;
  font-weight: bold;
}

.compact-demo-list span {
  padding: 3px 5px;
  font-size: 11px;
}

.matrix-summary {
  margin: 8px 0;
}

.matrix-pick {
  padding: 6px;
  background: white;
  border: 1px inset #aaaaaa;
}

.matrix-pick b,
.matrix-pick small {
  display: block;
}

.matrix-pick small {
  margin-top: 3px;
  color: #555555;
  line-height: 1.35;
}

.mini-data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 12px;
}

.mini-data-table th,
.mini-data-table td {
  padding: 4px 5px;
  border: 1px solid #aaaaaa;
  vertical-align: top;
}

.mini-data-table th {
  background: #d0d0d0;
  text-align: left;
}

.mini-data-table small {
  color: #555555;
}

.portal-status {
  height: auto;
  margin: 0;
}

@keyframes titleRevealRip {
  0% {
    opacity: 0;
    clip-path: polygon(0 100%, 100% 100%, 100% 100%, 0 100%);
    filter: brightness(1);
  }
  8% {
    opacity: 1;
  }
  36% {
    clip-path: polygon(0 100%, 100% 100%, 100% 66%, 82% 70%, 64% 60%, 45% 69%, 25% 61%, 0 68%);
    filter: brightness(1.12);
  }
  68% {
    clip-path: polygon(0 100%, 100% 100%, 100% 28%, 82% 34%, 65% 22%, 44% 31%, 25% 19%, 0 30%);
    filter: brightness(1.22);
  }
  100% {
    opacity: 1;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    filter: brightness(1);
  }
}

@keyframes compactTitleBurn {
  0% {
    background-size: 100% 0%;
  }
  35% {
    background-size: 100% 42%;
  }
  70% {
    background-size: 100% 82%;
  }
  100% {
    background-size: 100% 100%;
  }
}

.panel {
  padding: 10px;
}

.admin-shell {
  width: min(1240px, calc(100vw - 16px));
}

.admin-hero {
  min-height: 120px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  background: #e6e6e6;
  border: 1px inset #999999;
}

.metric-card {
  min-height: 86px;
  padding: 10px;
  background: #f2f2f2;
  border-top: 1px solid white;
  border-left: 1px solid white;
  border-right: 1px solid #777;
  border-bottom: 1px solid #777;
}

.metric-label {
  font-weight: bold;
}

.metric-value {
  margin: 6px 0;
  font-family: "Times New Roman", Times, serif;
  font-size: 30px;
  line-height: 1;
}

.metric-note {
  color: #333333;
  font-size: 12px;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 120px;
  gap: 10px;
  align-items: end;
}

.provider-form {
  grid-template-columns: repeat(4, minmax(0, 1fr)) 110px;
}

.ranking-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ranking-tabs button {
  min-width: 84px;
}

.ranking-tabs button.active {
  color: white;
  background: #0b3d91;
  border-top-color: #7fa0d8;
  border-left-color: #7fa0d8;
  border-right-color: #001f4d;
  border-bottom-color: #001f4d;
}

.model-picker {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(150px, 1fr) 130px 100px 130px;
  gap: 10px;
  align-items: end;
}

.compact-box {
  padding: 8px 10px;
  margin: 0;
}

.benchmark-controls {
  grid-template-columns: 150px 130px 110px 70px minmax(0, 1fr);
}

.dim-group-row td {
  background: #d8d8d8;
  border-top: 2px solid #888888;
}

.dim-group-row button {
  min-height: 24px;
  padding: 2px 8px;
  font-size: 12px;
  width: 100%;
}

.muted {
  color: #666666;
}

.task-form {
  grid-template-columns: repeat(3, minmax(0, 1fr)) 120px;
}

.mini-button {
  width: 100%;
  min-height: 26px;
  padding: 3px 6px;
  font-size: 12px;
}

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

.wide {
  grid-column: 1 / -1;
}

label {
  display: block;
  margin-bottom: 4px;
  font-weight: bold;
}

textarea,
input,
select {
  width: 100%;
  padding: 7px;
  border: 1px inset #888888;
  background: white;
  font: inherit;
}

.form-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 120px;
  gap: 8px;
  align-items: end;
  margin-top: 10px;
}

button {
  min-height: 33px;
  padding: 6px 12px;
  border-top: 2px solid white;
  border-left: 2px solid white;
  border-right: 2px solid #555;
  border-bottom: 2px solid #555;
  background: #d8d8d8;
  font-weight: bold;
  cursor: pointer;
}

.section-title button {
  min-height: 22px;
  padding: 2px 10px;
  font-size: 12px;
}

button:active {
  border-top-color: #555;
  border-left-color: #555;
  border-right-color: white;
  border-bottom-color: white;
}

.hint {
  margin-top: 8px;
  color: #333333;
  font-size: 12px;
}

.method-box {
  padding: 10px;
  line-height: 1.55;
}

.result-box {
  min-height: 120px;
  margin: 0;
  padding: 10px;
  white-space: pre-wrap;
  overflow: auto;
}

.footer {
  padding: 8px 12px;
  color: #333333;
  background: #c2c2c2;
  border-top: 1px solid #888888;
  font-size: 12px;
}

.good {
  color: var(--green);
  font-weight: bold;
}

.bad {
  color: var(--red);
  font-weight: bold;
}

@media (max-width: 760px) {
  .page-shell,
  .page-shell tbody,
  .page-shell tr,
  .page-shell td {
    display: block;
    width: 100%;
  }

  .host {
    float: none;
    display: block;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 2px solid #8c8c8c;
  }

  .portal-board,
  .feature-row,
  .dimension-grid,
  .directory-grid,
  .two-col,
  .metric-grid,
  .admin-form,
  .task-form,
  .model-picker,
  .matrix-board,
  .gateway-search {
    grid-template-columns: 1fr;
  }

  .portal-board {
    aspect-ratio: auto;
    min-height: 0;
    max-height: none;
  }

  .matrix-board {
    height: auto;
  }

  .topnav a {
    display: block;
    margin-right: 0;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 30px;
  }
}
