:root {
  --bg: #f2f5f8;
  --surface: #ffffff;
  --surface-soft: #f6f8fa;
  --ink: #102a43;
  --muted: #53677d;
  --line: #d4dee8;
  --nav: #082f54;
  --nav-deep: #06243f;
  --primary: #174f86;
  --primary-soft: #e6f0f8;
  --accent: #c62026;
  --accent-soft: #fbeaec;
  --success: #1e7a50;
  --success-soft: #e5f5ec;
  --warning: #99600b;
  --warning-soft: #fff3d8;
  --danger: #a91f2a;
  --danger-soft: #fae8eb;
  --shadow: 0 12px 30px rgba(9, 47, 84, 0.07);
  --shadow-strong: 0 20px 50px rgba(4, 29, 52, 0.14);
  --font-display: "Thonburi", "Noto Sans Thai", Tahoma, sans-serif;
  --font-body: "Sukhumvit Set", "Leelawadee UI", "Noto Sans Thai", Tahoma, sans-serif;
  --font-data: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: var(--font-body);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(29, 78, 216, 0.3);
  outline-offset: 2px;
}

.app-hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 10%, rgba(37, 99, 235, 0.18), transparent 28%),
    radial-gradient(circle at 86% 92%, rgba(14, 116, 144, 0.16), transparent 30%),
    var(--bg);
}

.login-panel {
  width: min(440px, 100%);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 24px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-error {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: var(--nav);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #2563eb, #0e7490);
  color: #ffffff;
  font-weight: 900;
}

.brand h1 {
  margin: 2px 0 0;
  font-size: 17px;
  line-height: 1.35;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #9fb0c8;
}

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

.nav a {
  width: 100%;
  min-height: 48px;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: center;
  text-align: left;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.09);
  text-decoration: none;
  cursor: pointer;
}

.nav-icon {
  width: 32px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 11px;
  font-weight: 900;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: #b8c5d8;
  font-size: 13px;
}

.sidebar-footer p {
  margin: 0 0 4px;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h2 {
  margin: 4px 0 0;
  font-size: clamp(25px, 3vw, 34px);
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.content {
  display: grid;
  gap: 16px;
}

.panel,
.command-header,
.live-banner {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.command-header {
  padding: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  background:
    linear-gradient(120deg, rgba(219, 234, 254, 0.82), rgba(236, 254, 255, 0.65)),
    var(--surface);
}

.command-header h3 {
  margin: 4px 0 0;
  font-size: 23px;
}

.command-header p:not(.eyebrow) {
  margin: 7px 0 0;
  color: var(--muted);
}

.live-counter {
  min-width: 132px;
  padding: 12px 15px;
  border: 1px solid #93c5fd;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  display: grid;
  text-align: right;
}

.live-counter span {
  color: var(--success);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.live-counter strong {
  font-size: 25px;
}

.live-counter small {
  color: var(--muted);
}

.live-banner {
  padding: 12px 15px;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  box-shadow: none;
}

.live-banner.connected {
  border-color: #86efac;
  background: #f0fdf4;
}

.live-banner.reconnecting {
  border-color: #fcd34d;
  background: #fffbeb;
}

.live-banner.error {
  border-color: #fca5a5;
  background: #fff1f2;
}

.live-banner > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.live-banner small {
  color: var(--muted);
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.14);
}

.connected .live-dot {
  background: #22c55e;
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.14);
  animation: pulse 2s infinite;
}

.error .live-dot {
  background: #ef4444;
  box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.14);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

.read-only-badge,
.privacy-note {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.error-banner {
  padding: 12px 15px;
  border: 1px solid #fca5a5;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 700;
}

.filter-panel {
  box-shadow: none;
}

.filter-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.filter-panel-head h3 {
  margin: 3px 0 0;
  font-size: 21px;
}

.filter-panel-head p:not(.eyebrow) {
  margin: 5px 0 0;
  font-size: 13px;
}

.active-filter-summary {
  width: min(430px, 100%);
  padding: 11px 13px;
  border: 1px solid #93c5fd;
  border-radius: 11px;
  background: #eff6ff;
  display: grid;
  gap: 2px;
  color: #1e3a8a;
}

.active-filter-summary span,
.active-filter-summary small {
  color: #475569;
  font-size: 11px;
}

.filter-sections {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 14px;
  align-items: start;
}

.filter-group {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f8fafc;
}

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

.filter-group legend {
  padding: 0 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

.choice-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.subject-choices .choice-list,
.scope-choices .choice-list {
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
}

.choice-card {
  min-width: 0;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #ffffff;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.choice-card:hover {
  border-color: #60a5fa;
  background: #f8fbff;
}

.choice-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 1px rgba(29, 78, 216, 0.12);
}

.choice-card:focus-within {
  outline: 3px solid rgba(29, 78, 216, 0.28);
  outline-offset: 2px;
}

.choice-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.choice-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.choice-copy strong,
.choice-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
}

.choice-copy strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
}

.choice-copy small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.group-filter-tools {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(260px, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.group-filter-tools label {
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.group-choice-list {
  max-height: 280px;
  padding: 2px 4px 2px 2px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  overflow-y: auto;
}

label,
.compact-select {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #ffffff;
  color: var(--ink);
}

select:disabled {
  background: var(--surface-soft);
  color: var(--muted);
}

.analysis-tabs {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 8px;
  overflow-x: auto;
}

.analysis-tabs button {
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  display: flex;
  gap: 9px;
  align-items: center;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.analysis-tabs button span {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 900;
}

.analysis-tabs button strong {
  white-space: nowrap;
}

.analysis-tabs button.active {
  border-color: #60a5fa;
  background: var(--primary-soft);
  color: #1e3a8a;
}

.dashboard-body {
  display: grid;
  gap: 16px;
}

.dashboard-body.is-loading {
  opacity: 0.72;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
}

.score-kpi {
  min-width: 0;
  min-height: 116px;
  padding: 15px;
  border: 1px solid var(--line);
  border-top: 4px solid #64748b;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

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

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

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

.score-kpi span {
  font-size: 12px;
  font-weight: 800;
}

.score-kpi strong {
  display: block;
  margin: 7px 0 5px;
  overflow: hidden;
  font-size: clamp(20px, 2.2vw, 29px);
  line-height: 1.1;
  text-overflow: ellipsis;
}

.score-kpi small {
  font-size: 12px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

.section-head > div {
  min-width: 0;
}

.section-head h3,
.panel h3 {
  margin: 3px 0 0;
  font-size: 19px;
  line-height: 1.35;
}

.panel p {
  color: var(--muted);
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef4fb;
  color: #334155;
  font-size: 11px;
  white-space: nowrap;
}

tbody tr:hover {
  background: #f8fafc;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
}

.empty-state {
  padding: 30px 16px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

.bar-list {
  display: grid;
  gap: 8px;
  margin-bottom: 15px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(100px, 190px) minmax(100px, 1fr) 58px;
  gap: 9px;
  align-items: center;
  font-size: 12px;
}

.bar-row > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row > div {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.bar-row i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #0891b2);
}

.bar-row strong {
  text-align: right;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.tag.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.tag.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.tag.info {
  background: var(--primary-soft);
  color: var(--primary);
}

.ghost-button,
.primary-button,
.table-link {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 9px;
  font-weight: 800;
}

.ghost-button {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--ink);
}

.primary-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.table-link {
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 8px;
  margin-bottom: 14px;
}

.individual-lookup-panel {
  border-top: 4px solid var(--primary);
}

.student-lookup-divider {
  position: relative;
  height: 28px;
  margin: 3px 0 10px;
  display: grid;
  place-items: center;
}

.student-lookup-divider::before {
  position: absolute;
  inset: 50% 0 auto;
  height: 1px;
  background: var(--line);
  content: "";
}

.student-lookup-divider span {
  position: relative;
  padding: 3px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.student-directory {
  padding: 16px;
  border: 1px solid #c9d8e4;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: linear-gradient(135deg, #f8fafc, #ffffff);
}

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

.student-directory-head h4 {
  margin: 3px 0;
  color: var(--nav);
  font-family: var(--font-display);
  font-size: 17px;
}

.student-directory-head p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.student-directory-head > span {
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 1px solid #b8cada;
  border-radius: 5px;
  background: #eef4f8;
  color: var(--primary);
  font-family: var(--font-data);
  font-size: 9px;
  font-weight: 800;
}

.student-dropdown-label {
  display: grid;
  gap: 5px;
}

.student-dropdown-label > span {
  color: var(--nav);
  font-size: 10px;
  font-weight: 800;
}

.student-dropdown-label select {
  width: 100%;
  min-height: 48px;
  padding: 9px 40px 9px 12px;
  border: 1px solid #9fb8ce;
  border-radius: 7px;
  background-color: #ffffff;
  color: var(--ink);
  font-size: 12px;
}

.student-dropdown-label select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 79, 134, .12);
}

.student-directory-pagination {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.student-directory-pagination > span {
  color: var(--muted);
  font-size: 9px;
}

.student-directory-pagination > div {
  display: flex;
  gap: 7px;
  align-items: center;
}

.student-directory-pagination strong {
  min-width: 78px;
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 9px;
  text-align: center;
}

.student-directory-pagination .ghost-button {
  min-height: 31px;
  padding: 5px 9px;
  font-size: 9px;
}

@media (max-width: 700px) {
  .student-directory-head,
  .student-directory-pagination {
    display: grid;
  }

  .student-directory-head > span {
    justify-self: start;
  }

  .student-directory-pagination > div {
    justify-content: space-between;
  }
}

.student-identity {
  display: grid;
  grid-template-columns: minmax(240px, 0.75fr) minmax(0, 1.25fr);
  gap: 22px;
}

.student-identity h3 {
  font-size: 25px;
}

.student-identity dl,
.item-summary {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.student-identity dl div,
.item-summary div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}

.individual-section-nav {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.individual-section-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--nav);
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.individual-section-nav a:hover,
.individual-section-nav a:focus-visible {
  background: var(--primary-soft);
  color: var(--accent);
}

.individual-section-nav span {
  color: var(--accent);
  font-family: var(--font-data);
  font-size: 10px;
}

.individual-stat-section {
  scroll-margin-top: 18px;
}

.individual-stat-stack {
  display: grid;
  gap: 14px;
}

.individual-stat-section .section-head p:not(.eyebrow) {
  max-width: 680px;
  margin-top: 5px;
}

.individual-answer-cell {
  color: var(--nav);
  font-weight: 850;
}

.individual-item-set {
  white-space: nowrap;
}

.individual-item-dimension {
  display: grid;
  min-width: 112px;
  gap: 2px;
}

.individual-item-dimension strong {
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 11px;
}

.individual-item-dimension small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.school-section-nav,
.center-section-nav,
.provincial-edu-section-nav,
.regional-edu-section-nav,
.bureau-section-nav,
.national-section-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.center-section-nav,
.provincial-edu-section-nav,
.regional-edu-section-nav {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.bureau-section-nav {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.school-section-nav a,
.center-section-nav a,
.provincial-edu-section-nav a,
.regional-edu-section-nav a,
.bureau-section-nav a,
.national-section-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--nav);
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.school-section-nav a:hover,
.school-section-nav a:focus-visible,
.center-section-nav a:hover,
.center-section-nav a:focus-visible,
.provincial-edu-section-nav a:hover,
.provincial-edu-section-nav a:focus-visible,
.regional-edu-section-nav a:hover,
.regional-edu-section-nav a:focus-visible,
.bureau-section-nav a:hover,
.bureau-section-nav a:focus-visible,
.national-section-nav a:hover,
.national-section-nav a:focus-visible {
  background: var(--primary-soft);
  color: var(--accent);
}

.school-section-nav span,
.center-section-nav span,
.provincial-edu-section-nav span,
.regional-edu-section-nav span,
.bureau-section-nav span,
.national-section-nav span {
  color: var(--accent);
  font-family: var(--font-data);
  font-size: 10px;
}

.school-stat-stack,
.center-stat-stack,
.provincial-edu-stat-stack,
.regional-edu-stat-stack,
.bureau-stat-stack,
.national-stat-stack {
  display: grid;
  gap: 14px;
}

.school-stat-section,
.center-stat-section,
.provincial-edu-stat-section,
.regional-edu-stat-section,
.bureau-stat-section,
.national-stat-section {
  scroll-margin-top: 18px;
}

@supports (content-visibility: auto) {
  .individual-stat-section,
  .school-stat-section,
  .center-stat-section,
  .provincial-edu-stat-section,
  .regional-edu-stat-section,
  .bureau-stat-section,
  .national-stat-section {
    content-visibility: auto;
    contain-intrinsic-size: auto 460px;
  }
}

.national-geography-section {
  overflow: clip;
}

.geo-lineage-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 16px;
  padding: 11px 13px;
  border: 1px solid #bdd2e3;
  border-radius: 8px;
  background: #f2f7fb;
  color: var(--muted);
  font-size: 12px;
}

.geo-lineage-note > span {
  color: var(--accent);
  font-family: var(--font-data);
  font-size: 18px;
  line-height: 1;
}

.geo-lineage-note p {
  margin: 0;
}

.national-geography-drilldown {
  --geo-rail: #afc5d7;
  border: 1px solid #c3d2df;
  border-radius: 10px;
  background: #edf3f7;
  overflow: hidden;
}

.geo-drilldown-node {
  position: relative;
  border: 1px solid #cbd8e3;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.national-geography-drilldown > .geo-drilldown-node {
  border: 0;
  border-radius: 0;
}

.geo-drilldown-node summary,
.geo-drilldown-leaf-summary {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(330px, 0.82fr) 18px;
  gap: 16px;
  align-items: center;
  min-height: 76px;
  padding: 13px 15px;
}

.geo-drilldown-node summary {
  cursor: pointer;
  list-style: none;
}

.geo-drilldown-node summary::-webkit-details-marker {
  display: none;
}

.geo-drilldown-node summary:hover {
  background: #f7fafc;
}

.geo-drilldown-node[open] > summary {
  border-bottom: 1px solid #d7e1e9;
  background: #f6f9fb;
}

.geo-depth-0 > summary {
  min-height: 88px;
  background: var(--nav);
  color: #ffffff;
}

.geo-depth-0 > summary:hover,
.geo-depth-0[open] > summary {
  background: var(--nav-deep);
}

.geo-node-identity {
  min-width: 0;
  display: grid;
  justify-items: start;
  gap: 3px;
}

.geo-level-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.geo-depth-0 > summary .geo-level-badge {
  background: var(--accent);
  color: #ffffff;
}

.geo-depth-2 > summary .geo-level-badge { background: #e7f4f1; color: #17695e; }
.geo-depth-3 > summary .geo-level-badge { background: #fff2d6; color: #80520d; }
.geo-depth-4 > .geo-drilldown-leaf-summary .geo-level-badge { background: #f1ebf8; color: #63448a; }

.geo-node-title {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 900;
}

.geo-depth-0 > summary .geo-node-title {
  font-size: 19px;
}

.geo-node-title .code {
  font-size: 11px;
}

.geo-node-context {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.geo-depth-0 > summary .geo-node-context {
  color: #cbdbea;
}

.geo-node-statline {
  min-width: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(56px, 1fr));
  gap: 5px;
}

.geo-node-statline div {
  min-width: 0;
  padding: 7px 8px;
  border-left: 2px solid #b6c8d6;
  background: #f7f9fb;
}

.geo-node-statline dt {
  font-family: var(--font-data);
  font-size: 9px;
}

.geo-node-statline dd {
  overflow: hidden;
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 13px;
  text-overflow: ellipsis;
}

.geo-depth-0 > summary > .geo-node-statline div {
  border-left-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.08);
}

.geo-depth-0 > summary > .geo-node-statline dt { color: #b9cfe0; }
.geo-depth-0 > summary > .geo-node-statline dd { color: #ffffff; }

.geo-node-chevron {
  width: 9px;
  height: 9px;
  justify-self: center;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 160ms ease;
}

.geo-drilldown-node[open] > summary .geo-node-chevron {
  transform: rotate(225deg) translate(-1px, -1px);
}

.geo-node-actions {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  border-bottom: 1px solid #d7e1e9;
  background: #ffffff;
}

details.geo-drilldown-node:not([open]) > .geo-node-actions {
  display: none;
}

.geo-drilldown-leaf > .geo-node-actions {
  border-top: 1px solid #d7e1e9;
  border-bottom: 0;
}

.geo-export-caption {
  margin-right: auto;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.geo-export-button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid #c3d2df;
  border-radius: 5px;
  background: #ffffff;
  color: var(--nav);
  font: 800 10px/1.2 var(--font-sans);
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.geo-export-button span {
  min-width: 33px;
  padding: 3px 4px;
  border-radius: 3px;
  color: #ffffff;
  font-family: var(--font-data);
  font-size: 8px;
  letter-spacing: 0.03em;
  text-align: center;
}

.geo-export-button.pdf span { background: var(--accent); }
.geo-export-button.excel span { background: #17745e; }

.geo-export-button:hover {
  border-color: #7898b2;
  box-shadow: 0 3px 10px rgba(8, 47, 84, 0.1);
  transform: translateY(-1px);
}

.geo-export-button:focus-visible {
  outline: 3px solid rgba(23, 79, 134, 0.2);
  outline-offset: 2px;
}

.geo-export-button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.geo-export-button.loading::after {
  content: "";
  width: 10px;
  height: 10px;
  border: 2px solid #cbd8e3;
  border-top-color: var(--nav);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.geo-export-status:not(:empty) {
  max-width: 260px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.geo-drilldown-children {
  position: relative;
  display: grid;
  gap: 7px;
  padding: 9px 9px 9px 27px;
  background: #edf3f7;
}

.geo-drilldown-children::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 14px;
  width: 2px;
  background: var(--geo-rail);
}

.geo-drilldown-children > .geo-drilldown-node::before {
  content: "";
  position: absolute;
  top: 38px;
  left: -14px;
  width: 13px;
  height: 1px;
  background: var(--geo-rail);
}

.geo-lazy-placeholder,
.geo-drilldown-empty {
  min-height: 54px;
  display: grid;
  place-items: center;
  padding: 12px;
  border: 1px dashed #b7c7d5;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

dd {
  margin: 4px 0 0;
  font-weight: 700;
}

.item-summary {
  margin-bottom: 14px;
}

.methodology-panel {
  border-left: 5px solid var(--primary);
  box-shadow: none;
}

.methodology-panel p {
  margin: 5px 0 0;
}

.source-panel {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f8fafc;
}

.source-panel summary {
  padding: 12px 15px;
  cursor: pointer;
  color: #334155;
  font-weight: 800;
}

.source-panel-body {
  padding: 0 15px 15px;
}

.source-panel-body p {
  margin: 5px 0;
}

.source-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.source-chips span {
  padding: 4px 7px;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  background: #eff6ff;
  color: #1e40af;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.loading-panel {
  min-height: 180px;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  text-align: left;
}

.loading-panel p {
  margin: 4px 0 0;
}

.connection-overview {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--success);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.connection-overview.offline {
  border-left-color: var(--danger);
  background: #fffafa;
}

.connection-overview h3 {
  margin: 3px 0 0;
  font-size: 24px;
}

.connection-overview p:not(.eyebrow) {
  margin: 6px 0 0;
  color: var(--muted);
}

.overall-connection-state {
  min-width: 190px;
  padding: 12px 15px;
  border: 1px solid #86efac;
  border-radius: 11px;
  background: var(--success-soft);
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--success);
}

.connection-overview.offline .overall-connection-state {
  border-color: #fca5a5;
  background: var(--danger-soft);
  color: var(--danger);
}

.connection-indicator {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(21, 128, 61, 0.12);
}

.offline .connection-indicator {
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(185, 28, 28, 0.12);
}

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

.connection-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid #86efac;
  border-top: 4px solid var(--success);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  gap: 9px;
}

.connection-card.offline {
  border-color: #fca5a5;
  border-top-color: var(--danger);
}

.connection-card-head {
  display: grid;
  grid-template-columns: 11px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
}

.connection-card code {
  overflow: hidden;
  color: #1e3a8a;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-card small {
  color: var(--muted);
}

.connection-state {
  color: var(--success);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.connection-card.offline .connection-state {
  color: var(--danger);
}

.connection-detail-panel {
  box-shadow: none;
}

.connection-definition-list {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.connection-definition-list div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}

.connection-definition-list dd {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.database-details {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.connection-warning,
.connection-database-message {
  margin: 12px 0 0;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 12px;
}

.connection-warning {
  border: 1px solid #fcd34d;
  background: var(--warning-soft);
  color: var(--warning) !important;
  font-weight: 700;
}

.connection-database-message {
  border: 1px solid var(--line);
  background: #f8fafc;
}

.connection-settings-panel > .section-head p {
  margin: 5px 0 0;
}

.connection-settings-panel code {
  overflow-wrap: anywhere;
}

.connection-settings-form {
  display: grid;
  gap: 14px;
}

.connection-settings-form fieldset {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.connection-settings-form legend {
  padding: 0 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

.connection-settings-form legend strong,
.connection-settings-form legend small {
  display: block;
}

.connection-settings-form legend strong {
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 14px;
  letter-spacing: 0.03em;
}

.connection-settings-form legend small {
  margin-top: 2px;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
}

.password-setting {
  align-content: start;
}

.secret-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.secret-input button {
  min-width: 68px;
  min-height: 41px;
  padding: 0 12px;
  border: 1px solid #bdcad6;
  border-radius: 6px;
  background: #f6f8fa;
  color: var(--nav);
  font-size: 12px;
  font-weight: 800;
}

.secret-input button:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.credential-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  align-items: center;
  font-weight: 500;
}

.credential-meta small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.credential-status {
  width: fit-content;
  padding: 2px 7px;
  border: 1px solid #e2b6bb;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 9px;
  font-weight: 900;
}

.credential-status.configured {
  border-color: #a8d5bd;
  background: var(--success-soft);
  color: var(--success);
}

.connection-settings-form .wide-setting,
.connection-settings-form .settings-note {
  grid-column: 1 / -1;
}

.settings-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.connection-form-actions {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}

.connection-form-actions small {
  color: var(--muted);
}

.connection-message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--success) !important;
  font-weight: 800;
}

.connection-message.error {
  color: var(--danger) !important;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #dbeafe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1280px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .analysis-tabs {
    grid-template-columns: repeat(7, minmax(150px, 1fr));
  }

  .connection-card-grid,
  .database-details {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 14px 18px;
    flex-direction: row;
    align-items: center;
  }

  .sidebar .brand {
    max-width: 360px;
  }

  .sidebar .nav {
    margin-left: auto;
  }

  .sidebar-footer {
    display: none;
  }

  .main {
    padding: 18px;
  }

  .grid.two,
  .student-identity {
    grid-template-columns: 1fr;
  }

  .filter-panel-head {
    display: grid;
  }

  .active-filter-summary {
    width: 100%;
  }

  .filter-sections {
    grid-template-columns: 1fr;
  }

  .filter-group.wide {
    grid-column: auto;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .connection-settings-form fieldset {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 640px) {
  .main {
    padding: 12px;
  }

  .topbar,
  .command-header,
  .connection-overview {
    display: grid;
  }

  .live-counter {
    text-align: left;
  }

  .live-banner {
    grid-template-columns: 12px minmax(0, 1fr);
  }

  .read-only-badge {
    grid-column: 2;
    justify-self: start;
  }

  .group-filter-tools,
  .kpi-grid,
  .student-identity dl,
  .item-summary {
    grid-template-columns: 1fr;
  }

  .choice-list,
  .subject-choices .choice-list,
  .scope-choices .choice-list,
  .group-choice-list {
    grid-template-columns: 1fr;
  }

  .connection-card-grid,
  .connection-definition-list,
  .database-details,
  .connection-settings-form fieldset {
    grid-template-columns: 1fr;
  }

  .overall-connection-state {
    min-width: 0;
  }

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

  .bar-row {
    grid-template-columns: 105px minmax(80px, 1fr) 50px;
  }

  .sidebar {
    display: block;
  }

  .sidebar .nav {
    margin-top: 12px;
  }
}

/* NIETS brand redesign — National Assessment Ledger */

html {
  min-width: 320px;
  background: var(--bg);
  color-scheme: light;
}

body {
  min-width: 320px;
  line-height: 1.5;
  background:
    linear-gradient(rgba(8, 47, 84, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(8, 47, 84, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
}

h1,
h2,
h3,
strong,
legend {
  font-family: var(--font-display);
}

code,
.code,
.score-kpi strong,
.bar-row strong,
.live-counter strong {
  font-family: var(--font-data);
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  padding: 9px 13px;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  transform: translateY(-150%);
  transition: transform 180ms ease-out;
}

.skip-link:focus {
  transform: translateY(0);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(198, 32, 38, 0.3);
  outline-offset: 3px;
}

.login-screen {
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    linear-gradient(90deg, var(--nav-deep) 0 38%, rgba(242, 245, 248, 0.96) 38%),
    var(--bg);
}

.login-screen::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 38%;
  content: "";
  opacity: 0.24;
  background:
    radial-gradient(circle, transparent 0 6px, rgba(255,255,255,0.42) 7px 8px, transparent 9px)
      32px 32px / 48px 48px;
  mask-image: linear-gradient(115deg, transparent, #000 32%, transparent 86%);
}

.login-thesis {
  position: absolute;
  z-index: 1;
  left: 5.5vw;
  top: 50%;
  width: min(26vw, 330px);
  color: #ffffff;
  transform: translateY(-50%);
}

.login-thesis p {
  margin: 0 0 11px;
  color: #9eb6cb;
  font-family: var(--font-data);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.login-thesis strong {
  display: block;
  font-size: clamp(30px, 3.2vw, 48px);
  line-height: 1.28;
  letter-spacing: -0.035em;
}

.login-thesis span {
  display: block;
  margin-top: 18px;
  padding-top: 15px;
  border-top: 3px solid var(--accent);
  color: #c9d7e4;
  font-size: 13px;
}

.login-panel {
  position: relative;
  width: min(560px, 100%);
  margin-left: min(28vw, 360px);
  padding: 34px;
  overflow: hidden;
  border: 1px solid #ccd8e4;
  border-top: 6px solid var(--accent);
  border-radius: 10px;
  box-shadow: var(--shadow-strong);
}

.login-panel::before {
  position: absolute;
  top: 0;
  right: 22px;
  width: 3px;
  height: 64px;
  content: "";
  background: var(--accent);
  box-shadow: 8px 0 0 var(--accent);
}

.login-brand {
  margin-bottom: 22px;
}

.login-form {
  gap: 16px;
}

.login-form .primary-button {
  min-height: 46px;
  margin-top: 3px;
}

.login-exam-selection {
  margin: 0;
  padding: 0;
  border: 0;
}

.login-exam-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.login-exam-grid select {
  min-height: 45px;
  border-color: #aebfce;
  color: var(--nav);
  font-weight: 800;
}

.login-contact {
  margin-top: 20px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.login-contact > strong {
  display: block;
  margin-bottom: 10px;
  color: var(--nav);
  font-size: 13px;
}

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

.login-contact-grid > a,
.login-contact-grid > span {
  min-width: 0;
  padding: 8px 9px;
  border-left: 3px solid #1875d1;
  background: #f2f7fc;
  display: grid;
  gap: 2px;
  color: var(--nav);
  text-decoration: none;
}

.login-contact-grid > * > span:first-child {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.login-contact-grid b,
.login-contact-grid a {
  overflow-wrap: anywhere;
  font-size: 11px;
}

.login-contact-grid > a:hover,
.login-contact-web a:hover {
  color: #075fb6;
}

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

.login-contact-web {
  align-items: center;
  grid-template-columns: auto 1fr;
  gap: 10px;
}

.login-contact-web a {
  color: #075fb6;
  font-weight: 900;
  text-decoration: none;
}

body.single-panel-login .login-screen {
  overflow: auto;
  background: var(--bg);
}

body.single-panel-login .login-screen::before,
body.single-panel-login .login-thesis {
  display: none;
}

body.single-panel-login .login-panel {
  margin: 0;
}

.app-shell {
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  isolation: isolate;
  padding: 25px 17px 20px;
  overflow-y: auto;
  gap: 18px;
  border-top: 6px solid var(--accent);
  background:
    linear-gradient(145deg, rgba(255,255,255,0.045), transparent 42%),
    var(--nav-deep);
}

.sidebar::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  opacity: 0.22;
  background:
    radial-gradient(circle, transparent 0 4px, rgba(255,255,255,0.22) 5px 6px, transparent 7px)
      calc(100% - 21px) 20px / 28px 28px;
  mask-image: linear-gradient(to bottom, #000, transparent 48%);
}

.brand {
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 13px;
}

.brand-mark {
  position: relative;
  width: 58px;
  height: 58px;
  padding: 7px 5px 5px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 7px;
  background: #ffffff;
  color: var(--nav);
  display: grid;
  place-content: center;
  gap: 0;
  text-align: center;
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  left: 0;
  width: 100%;
  height: 3px;
  content: "";
  background: var(--accent);
}

.brand-mark::before { top: 0; }
.brand-mark::after { bottom: 0; }

.brand-mark span {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 900;
  line-height: 1.05;
}

.brand-mark small {
  color: var(--primary);
  font-family: var(--font-data);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.login-panel .brand-mark {
  border-color: var(--line);
  box-shadow: 0 5px 16px rgba(8,47,84,0.09);
}

.brand {
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
}

.brand-logo {
  display: block;
  width: 188px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.sidebar .brand-logo {
  width: 202px;
  padding: 5px;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 5px 16px rgba(0,0,0,0.15);
}

.brand h1 {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.45;
}

.eyebrow {
  color: #4c6177;
  font-family: var(--font-data);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.11em;
}

.sidebar .eyebrow {
  color: #a9bed2;
}

.sidebar-section-label {
  margin: 7px 8px -7px;
  color: #8ea8bf;
  font-family: var(--font-data);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.nav {
  gap: 5px;
}

.nav a {
  position: relative;
  min-height: 47px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  color: #dbe7f1;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.nav a::before {
  position: absolute;
  left: -18px;
  top: 8px;
  width: 4px;
  height: calc(100% - 16px);
  border-radius: 0 3px 3px 0;
  content: "";
  background: transparent;
  transition: background-color 180ms ease;
}

.nav a:hover {
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.07);
  color: #ffffff;
}

.nav a.active {
  border-color: rgba(255,255,255,0.16);
  background: #ffffff;
  color: var(--nav);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.nav a.active::before {
  background: var(--accent);
}

.tab-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #b9cada;
  background: rgba(255,255,255,0.08);
}

.tab-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.nav a.active .tab-icon {
  color: var(--accent);
  background: var(--accent-soft);
}

.sidebar-footer {
  padding-top: 15px;
  border-color: rgba(255,255,255,0.13);
  display: flex;
  gap: 10px;
  align-items: center;
  color: #c4d4e2;
}

.sidebar-footer p {
  font-size: 11px;
}

.sidebar-footer strong {
  font-size: 12px;
}

.sidebar-live-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #42c282;
  box-shadow: 0 0 0 5px rgba(66,194,130,0.12);
}

.main {
  min-width: 0;
  padding: 23px 28px 36px;
}

.topbar,
.content {
  width: min(100%, 1600px);
  margin-inline: auto;
}

.topbar {
  min-height: 66px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #cbd7e2;
  align-items: center;
}

.topbar h2 {
  margin-top: 2px;
  color: var(--nav);
  font-size: clamp(24px, 2.7vw, 34px);
  letter-spacing: -0.025em;
}

.topbar-actions {
  align-items: center;
}

.user-context {
  padding-right: 12px;
  border-right: 1px solid var(--line);
  display: grid;
  gap: 0;
  text-align: right;
}

.user-context span {
  color: var(--muted);
  font-size: 10px;
}

.user-context strong {
  color: var(--nav);
  font-size: 12px;
}

.content {
  gap: 13px;
}

.panel,
.command-header,
.live-banner {
  border-color: #cfdae5;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 17px;
}

.command-header {
  position: relative;
  isolation: isolate;
  min-height: 142px;
  padding: 25px 26px 23px 31px;
  overflow: hidden;
  border-top: 5px solid var(--accent);
  background: #ffffff;
}

.command-header::before {
  position: absolute;
  z-index: -1;
  top: 0;
  right: 15px;
  width: 210px;
  height: 100%;
  content: "";
  opacity: 0.48;
  background:
    radial-gradient(circle, transparent 0 7px, rgba(23,79,134,0.19) 8px 9px, transparent 10px)
      0 1px / 31px 31px;
  mask-image: linear-gradient(90deg, transparent, #000 35%, #000);
}

.command-header::after {
  position: absolute;
  z-index: -1;
  top: 0;
  right: 0;
  width: 5px;
  height: 100%;
  content: "";
  background: var(--accent);
  box-shadow: -8px 0 0 rgba(198,32,38,0.3);
}

.command-header > div {
  position: relative;
  z-index: 1;
}

.command-header h3 {
  max-width: 820px;
  margin-top: 5px;
  color: var(--nav);
  font-size: clamp(24px, 2.6vw, 34px);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.command-header p:not(.eyebrow) {
  max-width: 760px;
  margin-top: 7px;
  color: #4c6177;
}

.command-eyebrow span {
  margin-right: 7px;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--accent);
  color: #ffffff;
  letter-spacing: 0.08em;
}

.live-counter {
  min-width: 148px;
  padding: 12px 15px 10px;
  border: 1px solid #bdcad7;
  border-left: 4px solid var(--success);
  border-radius: 7px;
  background: rgba(255,255,255,0.94);
  text-align: left;
  box-shadow: 0 8px 26px rgba(8,47,84,0.08);
}

.live-counter span {
  font-family: var(--font-data);
  font-size: 9px;
}

.live-counter strong {
  margin: 2px 0;
  color: var(--nav);
  font-size: 34px;
  line-height: 1;
}

.live-counter strong em {
  margin-left: 4px;
  font-family: var(--font-body);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}

.live-banner {
  padding: 10px 14px;
  border-left: 4px solid var(--warning);
  background: #ffffff;
}

.live-banner.connected {
  border-color: #bfd9cc;
  border-left-color: var(--success);
  background: #f7fcf9;
}

.live-banner.reconnecting {
  border-color: #e7d7ad;
  border-left-color: var(--warning);
  background: #fffdf7;
}

.live-banner.error {
  border-color: #e5bdc1;
  border-left-color: var(--danger);
  background: #fffafb;
}

.live-banner strong {
  color: var(--nav);
  font-size: 13px;
}

.live-banner small {
  font-size: 11px;
}

.read-only-badge,
.privacy-note {
  min-height: 25px;
  border: 1px solid #bfd0df;
  border-radius: 5px;
  background: #ffffff;
  color: var(--primary);
  font-family: var(--font-data);
  font-size: 9px;
  letter-spacing: 0.07em;
}

.analysis-tabs {
  display: none !important;
}

.filter-panel {
  padding: 0;
  overflow: hidden;
  border-top: 3px solid var(--accent);
  box-shadow: none;
}

.filter-panel-head {
  min-height: 78px;
  margin: 0;
  padding: 13px 15px;
  border: 0;
  display: grid;
  grid-template-columns: minmax(230px, 0.9fr) minmax(330px, 1.3fr) auto;
  gap: 14px;
  align-items: center;
  list-style: none;
  cursor: pointer;
  background: #ffffff;
}

.filter-panel-head::-webkit-details-marker {
  display: none;
}

.filter-panel-head:hover {
  background: #fbfcfd;
}

.filter-title {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.filter-title > strong {
  color: var(--nav);
  font-size: 19px;
}

.filter-title > small {
  color: var(--muted);
  font-size: 11px;
}

.active-filter-summary {
  width: 100%;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid #c5d4e1;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--nav);
}

.active-filter-summary span,
.active-filter-summary small {
  color: #54687c;
  font-size: 10px;
}

.filter-toggle-label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.filter-toggle-label svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: transform 180ms ease;
}

.filter-panel[open] .filter-toggle-label svg {
  transform: rotate(180deg);
}

.filter-toggle-label .when-closed,
.filter-panel:not([open]) .when-open {
  display: none;
}

.filter-panel:not([open]) .when-closed {
  display: inline;
}

.filter-sections {
  padding: 15px;
  border-top: 1px solid var(--line);
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 11px;
  background: #f7f9fb;
}

.filter-group {
  padding: 11px;
  border-color: #d0dbe5;
  border-radius: 7px;
  background: #ffffff;
  grid-column: span 6;
}

.filter-group.grade-choices { grid-column: 1 / -1; }
.filter-group.wide { grid-column: 1 / -1; }

.filter-group legend {
  color: var(--nav);
  font-size: 12px;
}

.choice-list {
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 7px;
}

.subject-choices .choice-list,
.scope-choices .choice-list {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.choice-card {
  min-height: 49px;
  padding: 7px 9px;
  border-color: #c9d4df;
  border-radius: 6px;
  background: #ffffff;
  transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.choice-card:hover {
  border-color: #7395b4;
  background: #f7fafc;
}

.choice-card.selected {
  border-color: var(--primary);
  background: #eef4f9;
  box-shadow: inset 4px 0 0 var(--accent);
}

.choice-card input[type="checkbox"] {
  accent-color: var(--accent);
}

.choice-copy strong {
  color: var(--nav);
  font-size: 12px;
}

.choice-copy small {
  color: #607489;
  font-size: 10px;
}

input,
select {
  min-height: 41px;
  border-color: #bdcad6;
  border-radius: 6px;
}

input:hover,
select:hover {
  border-color: #7894ad;
}

.dashboard-body {
  gap: 13px;
}

.dashboard-body.is-loading {
  opacity: 0.62;
}

.kpi-grid {
  gap: 10px;
}

.score-kpi {
  min-height: 108px;
  padding: 13px 14px;
  border: 1px solid #cdd8e2;
  border-top: 1px solid #cdd8e2;
  border-left: 4px solid #7f93a7;
  border-radius: 8px;
  box-shadow: 0 7px 20px rgba(8,47,84,0.055);
}

.score-kpi.primary { border-left-color: var(--accent); }
.score-kpi.success { border-left-color: var(--success); }
.score-kpi.warning { border-left-color: var(--warning); }

.score-kpi span {
  font-size: 11px;
}

.score-kpi strong {
  margin: 8px 0 5px;
  color: var(--nav);
  font-size: clamp(20px, 2vw, 28px);
  letter-spacing: -0.04em;
}

.score-kpi small {
  font-size: 10px;
}

.grid {
  gap: 13px;
}

.section-head {
  margin-bottom: 12px;
}

.section-head h3,
.panel h3 {
  color: var(--nav);
  font-size: 18px;
}

.table-wrap {
  border-color: #cbd7e1;
  border-top: 3px solid var(--primary);
  border-radius: 7px;
}

table {
  font-size: 12px;
}

th,
td {
  padding: 8px 10px;
  border-color: #dce4eb;
}

th {
  background: #e9f0f6;
  color: var(--nav);
  font-family: var(--font-display);
  font-size: 10px;
}

tbody tr:nth-child(even) {
  background: #fbfcfd;
}

tbody tr:hover {
  background: #eef4f8;
}

.bar-row > div {
  height: 9px;
  border-radius: 3px;
  background: #e2e9ef;
}

.bar-row i {
  position: relative;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary) 0 94%, var(--accent) 94% 100%);
}

.tag {
  border-radius: 4px;
  border: 1px solid #b7d8c6;
}

.tag.warning { border-color: #ead19b; }
.tag.bad { border-color: #e6b9be; }
.tag.info { border-color: #bdd0e0; }

.ghost-button,
.primary-button,
.table-link {
  border-radius: 6px;
}

.ghost-button {
  border-color: #b9c7d3;
  color: var(--nav);
}

.ghost-button:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
}

.primary-button:hover {
  border-color: #9f181d;
  background: #9f181d;
}

.table-link {
  color: var(--primary);
}

.source-panel {
  border-radius: 7px;
}

.source-chips span {
  border-color: #c4d4e2;
  border-radius: 4px;
  background: #f0f5f9;
  color: var(--nav);
  font-family: var(--font-data);
}

.methodology-panel {
  border-left-color: var(--accent);
}

.spinner {
  border-color: #d8e3ec;
  border-top-color: var(--accent);
}

.connection-overview {
  border-left-color: var(--success);
  border-radius: 9px;
}

.connection-card-grid {
  gap: 10px;
}

.connection-card {
  border-color: #bedbcb;
  border-top: 1px solid #bedbcb;
  border-left: 4px solid var(--success);
  border-radius: 8px;
  box-shadow: 0 7px 20px rgba(8,47,84,0.055);
}

.connection-card.offline {
  border-color: #e2b6bb;
  border-left-color: var(--danger);
}

.connection-card code {
  color: var(--nav);
  font-family: var(--font-data);
}

.connection-definition-list div,
.student-identity dl div,
.item-summary div {
  border-color: #d1dbe5;
  border-radius: 6px;
  background: #f6f8fa;
}

.connection-settings-form fieldset {
  border-radius: 7px;
}

.empty-state {
  border-radius: 7px;
}

@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .main {
    padding-inline: 20px;
  }

  .filter-panel-head {
    grid-template-columns: minmax(210px, 0.8fr) minmax(300px, 1.2fr) auto;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    padding: 14px 18px;
    overflow: visible;
    border-top-width: 4px;
    display: grid;
    grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
    gap: 14px;
    align-items: center;
  }

  .sidebar::before,
  .sidebar-section-label,
  .sidebar-footer {
    display: none;
  }

  .sidebar .brand {
    max-width: none;
  }

  .sidebar .nav {
    margin: 0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(155px, 1fr);
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }

  .nav a::before {
    left: 8px;
    top: auto;
    bottom: -1px;
    width: calc(100% - 16px);
    height: 3px;
  }

  .filter-panel-head {
    grid-template-columns: minmax(220px, 0.8fr) minmax(290px, 1.2fr) auto;
  }
}

@media (max-width: 760px) {
  .app-shell,
  .sidebar,
  .main {
    width: 100%;
    min-width: 0;
    max-width: 100vw;
  }

  .login-screen {
    background:
      linear-gradient(180deg, var(--nav-deep) 0 28%, rgba(242,245,248,0.97) 28%),
      var(--bg);
  }

  .login-screen::before {
    width: 100%;
    height: 28%;
  }

  .login-thesis {
    display: none;
  }

  .login-panel {
    margin: 16vh 0 0;
    padding: 26px;
  }

  .sidebar {
    display: block;
    overflow: hidden;
  }

  .sidebar .nav {
    width: 100%;
    min-width: 0;
    max-width: calc(100vw - 36px);
    margin-top: 12px;
    overflow-x: auto;
  }

  .main {
    padding: 15px;
  }

  .topbar {
    min-height: 58px;
  }

  .user-context {
    display: none;
  }

  .command-header,
  .connection-overview {
    display: grid;
  }

  .command-header {
    min-height: 0;
    padding: 21px;
  }

  .command-header::before {
    width: 120px;
  }

  .live-counter {
    width: min(100%, 210px);
  }

  .filter-panel-head {
    grid-template-columns: 1fr auto;
  }

  .active-filter-summary {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .filter-sections {
    grid-template-columns: 1fr;
  }

  .filter-group,
  .filter-group.grade-choices,
  .filter-group.wide {
    grid-column: 1;
  }

  .login-exam-grid,
  .login-contact-grid {
    grid-template-columns: 1fr;
  }

  .login-contact-grid .login-contact-wide {
    grid-column: 1;
  }

  .grid.two,
  .student-identity {
    grid-template-columns: 1fr;
  }

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

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

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

  .provincial-edu-section-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .regional-edu-section-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

}

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

  .brand-logo {
    width: 152px;
  }

  .individual-section-nav,
  .school-section-nav,
  .center-section-nav,
  .provincial-edu-section-nav,
  .regional-edu-section-nav,
  .bureau-section-nav,
  .national-section-nav {
    grid-template-columns: 1fr;
  }

  .brand-mark {
    width: 50px;
    height: 50px;
  }

  .brand h1 {
    font-size: 13px;
  }

  .sidebar .nav {
    grid-auto-columns: 145px;
  }

  .nav a {
    min-height: 43px;
    font-size: 11px;
  }

  .tab-icon {
    width: 28px;
    height: 28px;
  }

  .topbar h2 {
    font-size: 23px;
  }

  .topbar-actions {
    align-self: flex-start;
  }

  .command-header h3 {
    font-size: 24px;
  }

  .command-header::before {
    opacity: 0.28;
  }

  .filter-panel-head {
    padding: 12px;
  }

  .filter-title > strong {
    font-size: 17px;
  }

  .filter-title > small {
    display: none;
  }

  .filter-toggle-label .when-open,
  .filter-toggle-label .when-closed {
    display: none;
  }

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

  .score-kpi {
    min-height: 102px;
  }

  .connection-card-grid,
  .connection-definition-list,
  .database-details,
  .connection-settings-form fieldset {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 23px;
  }
}

/* Data Mapping View — live NIETS schema, dictionary, and calculation lineage */
.dictionary-hero {
  position: relative;
  overflow: hidden;
  min-height: 180px;
  padding: 28px 30px;
  border-radius: 10px;
  background:
    linear-gradient(115deg, rgba(8, 47, 84, 0.98), rgba(12, 69, 113, 0.94)),
    repeating-linear-gradient(135deg, transparent 0 24px, rgba(255,255,255,.035) 24px 25px);
  box-shadow: var(--shadow-strong);
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: flex-end;
}

.dictionary-hero::after {
  position: absolute;
  inset: auto 0 0;
  height: 5px;
  background: var(--accent);
  content: "";
}

.dictionary-hero > div:first-child {
  max-width: 820px;
}

.dictionary-hero .eyebrow {
  color: #b9d2e7;
}

.dictionary-hero h3 {
  max-width: 720px;
  margin: 8px 0 10px;
  color: #ffffff;
  font-family: var(--font-display);
  font-size: clamp(25px, 3vw, 39px);
  line-height: 1.2;
}

.dictionary-hero p:not(.eyebrow) {
  margin: 0;
  color: #d9e7f2;
  font-size: 13px;
  line-height: 1.7;
}

.dictionary-hero code {
  color: #ffffff;
  font-family: var(--font-data);
}

.dictionary-method-chips {
  min-width: 175px;
  display: grid;
  gap: 7px;
}

.dictionary-method-chips span {
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 5px;
  background: rgba(255,255,255,.08);
  color: #e8f2f9;
  font-size: 10px;
  font-weight: 700;
}

.dictionary-kpis {
  margin-top: 14px;
}

.pipeline-panel {
  border-top: 4px solid var(--accent);
}

.dictionary-pipeline {
  padding: 12px 2px 14px;
  overflow-x: auto;
  display: flex;
  gap: 7px;
  align-items: stretch;
}

.pipeline-step {
  min-width: 175px;
  min-height: 78px;
  padding: 10px;
  border: 1px solid #c8d5e0;
  border-radius: 7px;
  background: #f8fafc;
  color: var(--ink);
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  text-align: left;
}

.pipeline-step > span {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--nav);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 800;
}

.pipeline-step div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.pipeline-step strong {
  color: var(--nav);
  font-size: 12px;
}

.pipeline-step small {
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 9px;
  line-height: 1.4;
}

.pipeline-step > b {
  color: var(--primary);
  font-family: var(--font-data);
  font-size: 11px;
}

.pipeline-step:hover,
.pipeline-step.active {
  border-color: var(--accent);
  background: #fff7f7;
  box-shadow: 0 7px 18px rgba(198, 32, 38, .08);
}

.pipeline-step.active > span {
  background: var(--accent);
}

.pipeline-arrow {
  color: #8ea2b5;
  align-self: center;
  font-size: 17px;
  font-style: normal;
}

.dictionary-legend {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.dictionary-badge {
  min-height: 23px;
  padding: 4px 7px;
  border: 1px solid #bac9d7;
  border-radius: 4px;
  background: #eff4f8;
  color: var(--nav);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.3;
}

.dictionary-badge.nature-raw {
  border-color: #9bc7b0;
  background: #eaf7f0;
  color: #176543;
}

.dictionary-badge.nature-reference {
  border-color: #9fbdd7;
  background: #eaf2f9;
  color: #174f86;
}

.dictionary-badge.nature-calculated {
  border-color: #d7b46b;
  background: #fff7df;
  color: #795006;
}

.dictionary-badge.nature-system {
  border-color: #d9a8ad;
  background: #fceff0;
  color: #8f1b23;
}

.dictionary-badge.relation-declared_fk {
  border-color: #7bb89b;
  background: #e3f4eb;
  color: #176543;
}

.dictionary-badge.relation-inferred_join {
  border-style: dashed;
  border-color: #8ea9bf;
  background: #f3f7fa;
}

.dictionary-badge.relation-calculation_lineage {
  border-color: #d8ad58;
  background: #fff5d8;
  color: #755006;
}

.dictionary-badge.baseline {
  background: #f7f9fb;
}

.legend-note {
  margin-left: auto;
  color: var(--muted);
  font-size: 9px;
}

.dictionary-schema-map-panel {
  padding: 0;
  overflow: hidden;
  border-top: 4px solid var(--nav);
  background: #ffffff;
}

.dictionary-map-toolbar {
  padding: 17px 18px 14px;
  border-bottom: 1px solid #d5dfe8;
  display: grid;
  grid-template-columns: minmax(290px, 1fr) minmax(290px, 0.8fr) auto;
  gap: 16px;
  align-items: end;
}

.dictionary-map-toolbar h3 {
  margin: 3px 0 2px;
  color: var(--nav);
  font-size: 20px;
}

.dictionary-map-toolbar p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.dictionary-map-object-picker {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.dictionary-map-object-picker > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.dictionary-map-object-picker select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #b8c9d8;
  border-radius: 6px;
  background: #f9fbfc;
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 10px;
  font-weight: 700;
}

.dictionary-map-controls {
  display: flex;
  gap: 5px;
  align-items: center;
}

.dictionary-map-controls .ghost-button {
  min-width: 36px;
  min-height: 36px;
  padding: 7px 9px;
}

.dictionary-map-controls strong {
  min-width: 48px;
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 10px;
  text-align: center;
}

.dictionary-map-legend {
  min-height: 43px;
  padding: 9px 18px;
  border-bottom: 1px solid #dbe3ea;
  background: #f7f9fb;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.dictionary-map-legend > span:last-child {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 9px;
}

.dictionary-map-viewport {
  height: min(690px, 72vh);
  min-height: 520px;
  overflow: auto;
  overscroll-behavior: contain;
  cursor: grab;
  background:
    linear-gradient(rgba(29, 78, 118, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 78, 118, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 50% 30%, rgba(198, 32, 38, 0.045), transparent 34%),
    #f8fafb;
  background-size: 24px 24px, 24px 24px, auto, auto;
  scrollbar-color: #9fb1c2 #edf1f4;
}

.dictionary-map-viewport.is-panning {
  cursor: grabbing;
  user-select: none;
}

.dictionary-map-surface {
  --map-zoom: 1;
  position: relative;
  isolation: isolate;
  min-width: 1380px;
  min-height: 650px;
  padding: 54px 55px 90px;
  display: grid;
  grid-template-columns: 300px 370px 300px;
  column-gap: 150px;
  align-items: start;
  zoom: var(--map-zoom);
}

.dictionary-map-lines {
  position: absolute;
  z-index: 2;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.dictionary-map-edge {
  fill: none;
  stroke-linecap: round;
  stroke-width: 1.65;
  opacity: 0.52;
  pointer-events: stroke;
  cursor: pointer;
  transition: opacity 160ms ease, stroke-width 160ms ease;
}

.dictionary-map-edge:hover,
.dictionary-map-edge.active {
  stroke-width: 4;
  opacity: 1;
  filter: drop-shadow(0 2px 3px rgba(8, 47, 84, 0.2));
}

.dictionary-map-edge.relation-declared_fk {
  stroke: #1b7a5b;
}

.dictionary-map-edge.relation-inferred_join {
  stroke: #356f9f;
  stroke-dasharray: 5 4;
}

.dictionary-map-edge.relation-calculation_lineage {
  stroke: #b12b66;
}

#map-arrow-declared path {
  fill: #1b7a5b;
}

#map-arrow-inferred path {
  fill: #356f9f;
}

#map-arrow-lineage path {
  fill: #b12b66;
}

.dictionary-map-column {
  position: relative;
  z-index: 4;
  min-width: 0;
  display: grid;
  gap: 18px;
  align-content: start;
}

.dictionary-map-column.focus {
  padding-top: 92px;
}

.dictionary-map-column > header {
  min-height: 42px;
  padding: 7px 9px;
  border: 1px solid #cad6e1;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.94);
  display: flex;
  gap: 8px;
  align-items: center;
  box-shadow: 0 8px 20px rgba(8, 47, 84, 0.06);
}

.dictionary-map-column > header > span {
  width: 27px;
  height: 27px;
  border-radius: 5px;
  background: var(--nav);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-family: var(--font-data);
  font-size: 8px;
  font-weight: 800;
}

.dictionary-map-column > header div {
  display: grid;
}

.dictionary-map-column > header strong {
  color: var(--nav);
  font-size: 10px;
}

.dictionary-map-column > header small {
  color: var(--muted);
  font-size: 8px;
}

.dictionary-map-column.focus > header > span {
  background: var(--accent);
}

.schema-map-node {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #aebdca;
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(7, 42, 73, 0.1);
}

.schema-map-node.selected {
  border: 2px solid var(--accent);
  box-shadow: 0 15px 36px rgba(198, 32, 38, 0.17);
}

.schema-map-node-header {
  width: 100%;
  min-height: 53px;
  padding: 9px 10px;
  border: 0;
  background: var(--nav);
  color: #ffffff;
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  text-align: left;
}

.stage-reference .schema-map-node-header {
  background: #1e745e;
}

.stage-raw_input .schema-map-node-header {
  background: #0d7186;
}

.stage-scoring .schema-map-node-header {
  background: #9e2630;
}

.stage-aggregation .schema-map-node-header {
  background: #174f86;
}

.stage-item_analysis .schema-map-node-header {
  background: #684b87;
}

.schema-map-node-header:hover {
  filter: brightness(1.08);
}

.schema-map-table-icon {
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 15px;
}

.schema-map-node-header > span:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.schema-map-node-header strong,
.schema-map-node-header small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schema-map-node-header strong {
  font-family: var(--font-data);
  font-size: 10px;
  letter-spacing: -0.02em;
}

.schema-map-node-header small {
  color: rgba(255, 255, 255, 0.78);
  font-size: 8px;
}

.schema-map-node-header > b {
  min-width: 24px;
  padding: 4px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.18);
  font-family: var(--font-data);
  font-size: 8px;
  text-align: center;
}

.schema-map-field-list {
  display: grid;
}

.schema-map-field {
  position: relative;
  width: 100%;
  min-height: 34px;
  padding: 5px 8px;
  border: 0;
  border-bottom: 1px solid #e1e7ec;
  background: #ffffff;
  color: var(--ink);
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) 8px;
  gap: 6px;
  align-items: center;
  text-align: left;
}

.schema-map-field:hover,
.schema-map-field.active {
  background: #edf5fb;
}

.schema-map-field.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.schema-field-key {
  width: 22px;
  color: #8b6516;
  font-family: var(--font-data);
  font-size: 7px;
  font-weight: 900;
  text-align: center;
}

.schema-map-field.nature-raw .schema-field-key {
  color: #0d7186;
}

.schema-map-field.nature-calculated .schema-field-key {
  color: #a22661;
}

.schema-map-field > span:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.schema-map-field code,
.schema-map-field small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schema-map-field code {
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 8.5px;
  font-weight: 800;
}

.schema-map-field small {
  color: #708295;
  font-size: 7px;
}

.schema-map-field > i {
  width: 6px;
  height: 6px;
  border: 1px solid #356f9f;
  border-radius: 50%;
  background: #ffffff;
}

.schema-map-node > footer {
  min-height: 30px;
  padding: 6px 8px;
  background: #f5f7f9;
  color: #667b8f;
  display: flex;
  justify-content: space-between;
  gap: 7px;
  font-size: 7px;
}

.dictionary-map-empty {
  padding: 18px;
  border: 1px dashed #b9c8d5;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

.dictionary-map-inspector {
  min-height: 82px;
  padding: 13px 18px;
  border-top: 1px solid #cdd9e3;
  background: #ffffff;
  display: grid;
  grid-template-columns: 38px minmax(160px, 0.7fr) 24px minmax(160px, 0.7fr) minmax(250px, 1.2fr);
  gap: 10px;
  align-items: center;
}

.inspector-index {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-family: var(--font-data);
  font-weight: 900;
}

.inspector-route {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.inspector-route small {
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
}

.inspector-route button {
  min-width: 0;
  padding: 7px 8px;
  overflow: hidden;
  border: 1px solid #cbd7e1;
  border-radius: 5px;
  background: #f8fafb;
  text-align: left;
}

.inspector-route button:hover {
  border-color: #8eabc0;
  background: #edf5fb;
}

.inspector-route code {
  display: block;
  overflow: hidden;
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 8.5px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dictionary-map-inspector > i {
  color: var(--accent);
  font-style: normal;
  font-weight: 900;
  text-align: center;
}

.inspector-explanation {
  min-width: 0;
  padding-left: 12px;
  border-left: 1px solid #d8e1e8;
}

.inspector-explanation p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.dictionary-workspace {
  display: grid;
  grid-template-columns: minmax(285px, 0.32fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.dictionary-object-browser {
  position: sticky;
  top: 14px;
  padding: 14px;
}

.dictionary-object-browser .section-head > b {
  min-width: 34px;
  height: 28px;
  padding: 5px;
  border-radius: 5px;
  background: var(--nav);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-data);
  font-size: 10px;
}

.dictionary-search-form {
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.dictionary-search-form input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #b8c8d6;
  border-radius: 6px;
}

.dictionary-search-form #dictionary-search-clear {
  grid-column: 1 / -1;
}

.dictionary-object-list {
  max-height: 720px;
  padding-right: 4px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.dictionary-object-option {
  min-width: 0;
  padding: 10px;
  border: 1px solid #d0dbe4;
  border-left: 3px solid transparent;
  border-radius: 6px;
  background: #fafbfc;
  display: grid;
  gap: 3px;
  text-align: left;
}

.dictionary-object-option > span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.dictionary-object-option code {
  overflow: hidden;
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 10px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dictionary-object-option small,
.dictionary-object-option b {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dictionary-object-option b {
  margin-top: 2px;
  color: #6d8296;
  font-family: var(--font-data);
  font-size: 8px;
}

.dictionary-object-option:hover,
.dictionary-object-option.active {
  border-color: #a9bfd1;
  border-left-color: var(--accent);
  background: #fff7f7;
}

.dictionary-detail-stack {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.dictionary-object-detail {
  border-top: 4px solid var(--nav);
}

.object-detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.object-detail-header h3 {
  margin: 4px 0 2px;
  font-size: clamp(18px, 2.2vw, 27px);
}

.object-detail-header h3 code {
  color: var(--nav);
  font-family: var(--font-data);
}

.object-detail-header > div > strong {
  color: var(--primary);
  font-size: 12px;
}

.object-detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
}

.object-story-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 8px;
}

.object-story-grid > div {
  min-width: 0;
  padding: 11px;
  border: 1px solid #d3dde6;
  border-radius: 6px;
  background: #f7f9fb;
}

.object-story-grid span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.object-story-grid p {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.55;
}

.object-story-grid p.code {
  font-family: var(--font-data);
  font-size: 9px;
  overflow-wrap: anywhere;
}

.relationship-panel {
  border-left: 4px solid var(--primary);
}

.relationship-map {
  display: grid;
  gap: 6px;
}

.relationship-row {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #d0dbe4;
  border-radius: 6px;
  background: #fbfcfd;
  display: grid;
  grid-template-columns: 46px minmax(110px, .85fr) 18px minmax(110px, .85fr) auto;
  gap: 7px;
  align-items: center;
  text-align: left;
}

.relationship-row:hover {
  border-color: #9db6ca;
  background: #f0f6fa;
}

.relationship-row code {
  min-width: 0;
  overflow: hidden;
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 8.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relationship-row > i {
  color: var(--accent);
  font-style: normal;
  text-align: center;
}

.relationship-direction {
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
}

.relationship-row > small {
  grid-column: 2 / -1;
  color: var(--muted);
  font-size: 8.5px;
}

.mapping-overflow-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.dictionary-fields-panel {
  border-top: 4px solid var(--primary);
}

.dictionary-field-filters {
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dictionary-filter-chip {
  min-height: 31px;
  padding: 5px 8px;
  border: 1px solid #bac9d6;
  border-radius: 5px;
  background: #f8fafc;
  color: var(--nav);
  font-size: 9px;
  font-weight: 800;
}

.dictionary-filter-chip b {
  margin-left: 6px;
  color: var(--primary);
  font-family: var(--font-data);
}

.dictionary-filter-chip.active {
  border-color: var(--nav);
  background: var(--nav);
  color: #fff;
}

.dictionary-filter-chip.active b {
  color: #fff;
}

.dictionary-filter-chip:disabled {
  cursor: not-allowed;
  opacity: .35;
}

.dictionary-field-list {
  display: grid;
  gap: 7px;
}

.dictionary-field-card {
  padding: 11px;
  border: 1px solid #d2dce5;
  border-radius: 6px;
  background: #ffffff;
}

.dictionary-field-card.has-formula {
  border-left: 4px solid #d39a28;
}

.dictionary-field-card header {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.field-order {
  width: 25px;
  height: 25px;
  border-radius: 4px;
  background: #e8eff5;
  color: var(--nav);
  display: grid;
  place-items: center;
  font-family: var(--font-data);
  font-size: 8px;
}

.dictionary-field-card header > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.dictionary-field-card header code {
  overflow: hidden;
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
}

.dictionary-field-card header small {
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 8px;
}

.key-pill {
  padding: 3px 5px;
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-data);
  font-size: 8px;
  font-weight: 900;
}

.dictionary-field-card > p {
  margin: 9px 0 7px 33px;
  color: var(--ink);
  font-size: 10.5px;
  line-height: 1.55;
}

.dictionary-field-card footer {
  margin-left: 33px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  color: var(--muted);
  font-size: 8px;
}

.field-formula {
  margin: 10px 0 0 33px;
  padding: 9px 10px;
  border: 1px solid #e4cf9e;
  border-radius: 5px;
  background: #fffbef;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 9px;
  align-items: start;
}

.field-formula strong {
  color: #76520a;
  font-size: 9px;
}

.field-formula code {
  color: #5f4309;
  font-family: var(--font-data);
  font-size: 9px;
  overflow-wrap: anywhere;
}

.field-formula small {
  grid-column: 2;
  color: #806929;
  font-size: 8px;
}

.formula-catalog-panel {
  border-top: 4px solid #d39a28;
}

.formula-catalog-panel .section-head p:not(.eyebrow) {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.formula-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.formula-card {
  min-width: 0;
  padding: 13px;
  border: 1px solid #d4dde5;
  border-top: 3px solid var(--nav);
  border-radius: 6px;
  background: #f9fafb;
}

.formula-card > span {
  color: var(--primary);
  font-family: var(--font-data);
  font-size: 8px;
  font-weight: 800;
}

.formula-card h4 {
  margin: 5px 0 8px;
  color: var(--nav);
  font-size: 12px;
}

.formula-card code {
  min-height: 45px;
  padding: 8px;
  border-radius: 4px;
  background: #eaf0f5;
  color: #153b60;
  display: block;
  font-family: var(--font-data);
  font-size: 9px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.formula-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.dictionary-methodology {
  border-left: 4px solid var(--success);
}

.methodology-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.methodology-grid > div {
  position: relative;
  padding: 13px 13px 13px 49px;
  border: 1px solid #d1dde5;
  border-radius: 6px;
  background: #f8fafc;
}

.methodology-grid b {
  position: absolute;
  top: 13px;
  left: 13px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-data);
  font-size: 9px;
}

.methodology-grid strong {
  color: var(--nav);
  font-size: 11px;
}

.methodology-grid p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

@media (max-width: 1100px) {
  .dictionary-map-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .dictionary-map-controls {
    grid-column: 1 / -1;
  }

  .dictionary-map-inspector {
    grid-template-columns: 38px minmax(0, 1fr) 22px minmax(0, 1fr);
  }

  .inspector-explanation {
    grid-column: 2 / -1;
    padding: 9px 0 0;
    border-top: 1px solid #d8e1e8;
    border-left: 0;
  }

  .dictionary-workspace {
    grid-template-columns: 1fr;
  }

  .dictionary-object-browser {
    position: static;
  }

  .dictionary-object-list {
    max-height: 360px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .object-story-grid,
  .methodology-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .dictionary-hero {
    padding: 22px 18px;
    display: grid;
  }

  .dictionary-method-chips {
    min-width: 0;
    grid-template-columns: repeat(3, 1fr);
  }

  .dictionary-map-toolbar {
    grid-template-columns: 1fr;
  }

  .dictionary-map-controls {
    grid-column: auto;
    flex-wrap: wrap;
  }

  .dictionary-map-legend > span:last-child {
    width: 100%;
    margin-left: 0;
  }

  .dictionary-map-viewport {
    min-height: 470px;
    height: 62vh;
  }

  .dictionary-map-inspector {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .dictionary-map-inspector > i {
    display: none;
  }

  .inspector-route,
  .inspector-explanation {
    grid-column: 2;
  }

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

  .relationship-row {
    grid-template-columns: 44px minmax(0, 1fr) 15px;
  }

  .relationship-row code:nth-of-type(2),
  .relationship-row .dictionary-badge {
    grid-column: 2 / -1;
  }

  .relationship-row > small {
    grid-column: 2 / -1;
  }

  .object-detail-header {
    display: grid;
  }

  .object-detail-badges {
    justify-content: flex-start;
  }

  .dictionary-field-card header {
    grid-template-columns: 25px minmax(0, 1fr) auto;
  }

  .dictionary-field-card header .dictionary-badge {
    grid-column: 2 / -1;
    justify-self: start;
  }
}

/* Page-scoped statistics navigation and filters */
.nav-system-label {
  margin: 10px 9px 1px;
  padding-top: 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
  color: #8ea8bf;
  font-family: var(--font-data);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.locked-scope-card {
  min-height: 76px;
  border-left: 4px solid var(--accent);
  display: grid;
  grid-template-columns: minmax(145px, 0.45fr) minmax(180px, 0.75fr) minmax(260px, 1.8fr);
  gap: 12px;
  align-items: center;
  background: linear-gradient(90deg, #fff5f5, #ffffff 42%);
}

.locked-scope-card > span {
  color: #607489;
  font-size: 11px;
  font-weight: 700;
}

.locked-scope-card > strong {
  color: var(--nav);
  font-size: 15px;
}

.locked-scope-card > small {
  color: #607489;
  font-size: 11px;
  line-height: 1.5;
}

.embedded-analysis-section {
  display: grid;
  gap: 13px;
  margin-top: 8px;
  padding-top: 22px;
  border-top: 3px solid var(--nav);
}

.embedded-section-heading {
  padding: 4px 2px;
}

.embedded-section-heading h3 {
  margin-top: 4px;
  color: var(--nav);
  font-size: clamp(20px, 2vw, 28px);
}

.embedded-section-heading p:not(.eyebrow) {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1080px) {
  .nav-system-label {
    display: none;
  }
}

@media (max-width: 760px) {
  .locked-scope-card {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* Overview comparison and score-distribution small multiples */
.overview-group-comparison {
  border-top: 4px solid var(--accent);
}

.comparison-heading {
  align-items: flex-start;
}

.comparison-heading h3 {
  margin-bottom: 4px;
}

.comparison-heading p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.comparison-totals {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.comparison-totals span {
  padding: 7px 9px;
  border: 1px solid #c5d2de;
  border-radius: 6px;
  background: #f7f9fb;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.comparison-totals b {
  margin-right: 3px;
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 12px;
}

.group-score-grid {
  margin: 14px 0 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 9px;
}

.group-score-card {
  min-width: 0;
  padding: 13px;
  border: 1px solid #cad6e1;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f7f9fb 100%);
}

.group-score-card.primary {
  border-color: #d79498;
  box-shadow: inset 4px 0 0 var(--accent);
  background: linear-gradient(180deg, #ffffff 0%, #fff5f5 100%);
}

.group-score-card header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.group-score-card header span,
.group-score-card header code {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.group-score-card h4 {
  min-height: 39px;
  margin: 7px 0 10px;
  overflow: hidden;
  color: var(--nav);
  font-size: 12px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.group-score-value {
  padding-bottom: 9px;
  border-bottom: 1px solid #d8e1e9;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.group-score-value span {
  color: var(--muted);
  font-size: 10px;
}

.group-score-value strong {
  color: var(--primary);
  font-family: var(--font-data);
  font-size: 26px;
}

.group-score-card.primary .group-score-value strong {
  color: var(--accent);
}

.group-score-card dl {
  margin: 9px 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 10px;
}

.group-score-card dl div {
  min-width: 0;
}

.group-score-card dt {
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
}

.group-score-card dd {
  margin: 2px 0 0;
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 800;
}

.empty-state.compact {
  padding: 18px 8px;
  font-size: 10px;
}

.cell-code {
  margin-top: 2px;
  display: block;
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 9px;
}

@media (max-width: 700px) {
  .comparison-heading {
    display: grid;
  }

  .comparison-totals {
    justify-content: flex-start;
  }

  .group-score-grid {
    grid-template-columns: 1fr;
  }

}

/* Staged filters and on-demand Sandbox refresh */
.live-banner > .live-actions {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  justify-content: flex-end;
}

.refresh-button {
  min-height: 31px;
  padding: 5px 9px;
  border: 1px solid #9db4c8;
  border-radius: 5px;
  background: #ffffff;
  color: var(--primary);
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.refresh-button:hover:not(:disabled) {
  border-color: var(--primary);
  background: #eef4f9;
}

.refresh-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.refresh-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.filter-submit-row {
  padding: 12px 15px;
  border-top: 1px solid #c8d5e1;
  background: #ffffff;
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}

.filter-submit-row > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.filter-submit-row strong {
  color: var(--nav);
  font-size: 13px;
}

.filter-submit-row small {
  color: var(--muted);
  font-size: 11px;
}

.filter-submit-row .primary-button {
  min-width: 210px;
  min-height: 41px;
  flex: 0 0 auto;
}

.pending-filter-panel {
  min-height: 190px;
  border-left: 5px solid var(--accent);
  background: linear-gradient(135deg, #ffffff, #f4f7fa);
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: center;
}

.pending-filter-panel > div {
  max-width: 680px;
}

.pending-filter-panel h3 {
  margin-top: 4px;
  color: var(--nav);
  font-size: 21px;
}

.pending-filter-panel p:not(.eyebrow) {
  margin-top: 7px;
  color: var(--muted);
}

.pending-filter-icon {
  width: 50px;
  height: 50px;
  border: 1px solid #b9cad9;
  border-radius: 50%;
  background: #ffffff;
  color: var(--accent);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.pending-filter-icon svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

@media (max-width: 760px) {
  .live-banner > .live-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .filter-submit-row {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-submit-row .primary-button {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .live-banner > .live-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .refresh-button {
    width: 100%;
  }

  .pending-filter-panel {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Multi-organization selection and comparison */
.selected-group-strip {
  margin: 9px 0;
  padding: 9px;
  border: 1px solid #c7d4df;
  border-radius: 6px;
  background: #f7f9fb;
  display: grid;
  gap: 7px;
}

.selected-group-strip > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.selected-group-strip > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selected-group-chip {
  min-height: 29px;
  padding: 4px 8px;
  border: 1px solid #9cb2c6;
  border-radius: 999px;
  background: #ffffff;
  color: var(--nav);
  display: inline-flex;
  gap: 7px;
  align-items: center;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.selected-group-chip.primary {
  border-color: #d68b8f;
  background: #fff6f6;
  color: #8f171c;
}

.selected-group-chip b {
  font-size: 15px;
  line-height: 1;
}

.group-notice {
  margin: 0 0 8px;
  padding: 7px 9px;
  border-left: 3px solid var(--warning);
  background: #fffaf0;
  color: #72540c;
  font-size: 11px;
}

.group-comparison-panel {
  border-top: 4px solid var(--primary);
}

.comparison-subject {
  padding: 5px 8px;
  border: 1px solid #b9cad9;
  border-radius: 4px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
}

.group-scorecards {
  margin: 13px 0 17px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.group-scorecard {
  min-width: 0;
  padding: 12px;
  border: 1px solid #cbd6e0;
  border-radius: 7px;
  background: #f7f9fb;
  display: grid;
  gap: 3px;
}

.group-scorecard.primary {
  border-color: #d79a9d;
  border-left: 4px solid var(--accent);
  background: #fff8f8;
}

.group-scorecard > span,
.group-scorecard > small {
  color: var(--muted);
  font-size: 9px;
}

.group-scorecard > strong {
  min-height: 38px;
  color: var(--nav);
  font-size: 12px;
  line-height: 1.45;
}

.group-scorecard > b {
  color: var(--primary);
  font-family: var(--font-data);
  font-size: 26px;
}

.comparison-layout {
  display: grid;
  grid-template-columns: minmax(310px, 0.8fr) minmax(440px, 1.2fr);
  gap: 17px;
  align-items: start;
}

.comparison-layout h4,
.item-group-comparison h4 {
  margin: 0 0 9px;
  color: var(--nav);
  font-size: 12px;
}

.comparison-ranking {
  display: grid;
  gap: 7px;
}

.comparison-rank-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 28px minmax(125px, 0.9fr) minmax(90px, 1.1fr) 50px;
  gap: 8px;
  align-items: center;
}

.comparison-rank {
  color: #7b8fa3;
  font-family: var(--font-data);
  font-size: 10px;
}

.comparison-rank-label {
  min-width: 0;
  display: grid;
}

.comparison-rank-label strong {
  overflow: hidden;
  color: var(--nav);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comparison-rank-label small {
  color: var(--muted);
  font-size: 9px;
}

.comparison-track {
  height: 11px;
  overflow: hidden;
  border-radius: 2px;
  background: #e2e9ef;
}

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

.comparison-rank-row.primary .comparison-track i {
  background: var(--accent);
}

.comparison-value {
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 12px;
  text-align: right;
}

.primary-row td {
  background: #fff5f5;
}

.detail-primary-note {
  border-left-color: var(--accent);
}

.item-group-comparison {
  margin: 13px 0;
  padding: 12px;
  border: 1px solid #cbd7e2;
  border-radius: 7px;
  background: #f8fafc;
}

.item-group-comparison .comparison-ranking {
  margin-bottom: 12px;
}

@media (max-width: 1050px) {
  .comparison-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .selected-group-strip > div {
    display: grid;
  }

  .selected-group-chip {
    width: 100%;
    justify-content: space-between;
  }

  .group-scorecards {
    grid-template-columns: 1fr;
  }

  .comparison-rank-row {
    grid-template-columns: 24px minmax(0, 1fr) 44px;
  }

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

.table-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.table-progress b {
  color: var(--nav);
  font-family: var(--font-data);
}

.choice-list-limit-note {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

/* Report-first navigation and shared geographic filters */
@media (min-width: 1081px) {
  .app-shell {
    grid-template-columns: 326px minmax(0, 1fr);
  }

  .nav a {
    min-height: 43px;
    align-items: start;
    line-height: 1.35;
  }
}

.tab-icon.report-index {
  color: #d9e6f0;
  font-family: var(--font-data);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.nav a.active .tab-icon.report-index {
  color: var(--accent);
}

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

.report-filter-field {
  min-width: 0;
  padding: 11px;
  border: 1px solid #d0dbe5;
  border-radius: 7px;
  background: #ffffff;
}

.report-filter-field > span {
  color: var(--nav);
  font-size: 12px;
  font-weight: 800;
}

.report-filter-field select {
  min-width: 0;
  font-weight: 700;
}

@media (max-width: 980px) {
  .report-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .report-filter-grid {
    grid-template-columns: 1fr;
  }
}

.metric-reconciliation {
  overflow: hidden;
  border: 1px solid #bfd8cd;
  border-left: 5px solid #247a61;
  background: #fbfefd;
}

.metric-reconciliation.warning {
  border-color: #dfc486;
  border-left-color: #b78621;
  background: #fffdf7;
}

.metric-reconciliation-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.metric-reconciliation-head h3 {
  margin: 3px 0 5px;
  color: var(--nav);
  font-size: 18px;
}

.metric-reconciliation-head p:not(.eyebrow) {
  max-width: 900px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.metric-reconciliation-status {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #9fc8b8;
  border-radius: 999px;
  background: #e7f5ef;
  color: #205d48;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.metric-reconciliation.warning .metric-reconciliation-status {
  border-color: #dfc486;
  background: #fff4d9;
  color: #795c18;
}

.metric-grain-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.metric-grain-grid article {
  min-width: 0;
  padding: 12px;
  border: 1px solid #d3e0e7;
  border-radius: 8px;
  background: #ffffff;
}

.metric-grain-grid span,
.metric-grain-grid small {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.metric-grain-grid strong {
  display: block;
  margin: 2px 0;
  color: var(--nav);
  font-family: var(--font-data);
  font-size: 24px;
}

.metric-grain-grid p {
  min-height: 34px;
  margin: 0 0 5px;
  color: #526b7f;
  font-size: 10px;
  line-height: 1.55;
}

.metric-grain-grid code,
.metric-overlap-note code {
  color: var(--primary);
  font-family: var(--font-data);
  font-size: 9px;
  font-weight: 800;
}

.metric-grain-grid small {
  margin-top: 5px;
}

.metric-overlap-note {
  margin-top: 10px;
  padding: 11px 12px;
  border-radius: 7px;
  background: #edf6f2;
  color: #345c4d;
  display: grid;
  gap: 3px;
  font-size: 10px;
  line-height: 1.6;
}

.metric-overlap-note p {
  margin: 2px 0 0;
}

.national-hero-metrics {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 1100px) {
  .national-hero-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .metric-reconciliation-head {
    display: grid;
  }

  .metric-reconciliation-status {
    justify-self: start;
  }

  .metric-grain-grid {
    grid-template-columns: 1fr;
  }

  .metric-grain-grid p {
    min-height: 0;
  }

  .national-hero-metrics {
    grid-template-columns: 1fr;
  }

  .table-progress {
    align-items: stretch;
    flex-direction: column;
  }

  .geo-drilldown-node summary,
  .geo-drilldown-leaf-summary {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .geo-drilldown-node summary {
    position: relative;
  }

  .geo-node-identity {
    padding-right: 28px;
  }

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

  .geo-node-chevron {
    position: absolute;
    top: 22px;
    right: 17px;
  }

  .geo-node-actions {
    flex-wrap: wrap;
    padding: 9px 12px;
  }

  .geo-export-caption,
  .geo-export-status:not(:empty) {
    width: 100%;
    max-width: none;
  }

  .geo-export-button {
    flex: 1 1 132px;
    justify-content: center;
  }

  .geo-drilldown-children {
    padding-left: 17px;
  }

  .geo-drilldown-children::before {
    left: 8px;
  }

  .geo-drilldown-children > .geo-drilldown-node::before {
    left: -8px;
    width: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .geo-node-chevron {
    transition: none;
  }
}
