:root {
  --rh-blue: #0066cc;
  --rh-blue-dark: #004080;
  --rh-blue-deep: #002f5d;
  --rh-red: #c9190b;
  --rh-red-hover: #a30000;
  --rh-green: #3e8635;
  --rh-green-hover: #2f6f28;
  --bg: #eef1f4;
  --panel: #ffffff;
  --ink: #151515;
  --muted: #6a6e73;
  --line: #d2d2d2;
  --line-soft: #e6e8eb;
  --shadow: 0 8px 28px rgba(0, 47, 93, 0.12);
  --font: "Red Hat Text", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --radius: 8px;
  --scroll-thumb: #b7c0cc;
  --scroll-thumb-hover: #8b97a8;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  background: #fff;
  color: var(--rh-blue-deep);
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 700;
}
.skip-link:focus { top: 12px; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}
body.login-body { overflow: auto; }

a { color: var(--rh-blue); }

/* Thin scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: content-box; }

.brand-logo {
  width: min(180px, 70%);
  height: auto;
  object-fit: contain;
  background: transparent;
  display: block;
}

/* ===== Login ===== */
.login-body { min-height: 100%; background: #e9eef5; }
.login-shell {
  display: grid;
  grid-template-columns: minmax(300px, 42%) 1fr;
  min-height: 100vh;
}
.login-left {
  background:
    radial-gradient(1200px 600px at 20% 10%, rgba(255,255,255,0.16), transparent 55%),
    linear-gradient(165deg, var(--rh-blue-deep), var(--rh-blue) 55%, #1a7aef);
  color: #fff;
  padding: 48px 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 22px;
  max-width: 360px;
}
.login-brand .brand-home { gap: 22px; }
.login-brand .brand-logo {
  width: min(200px, 72%);
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.18));
}
.login-brand h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 1.9rem);
  letter-spacing: 0.08em;
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1.25;
}
.login-right {
  display: grid;
  place-items: center;
  padding: 40px 24px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(245,247,250,0.98)),
    repeating-linear-gradient(-45deg, rgba(0, 102, 204, 0.03) 0 12px, transparent 12px 24px);
}
.login-card {
  width: min(420px, 100%);
  border: 1px solid rgba(210, 210, 210, 0.9);
  border-radius: var(--radius);
  padding: 32px 28px 28px;
  box-shadow: var(--shadow);
  background: #fff;
}
.login-card-head { margin-bottom: 8px; text-align: center; }
.login-eyebrow {
  margin: 0 0 10px;
  color: var(--rh-blue);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}
.login-card h2 {
  margin: 0 0 8px;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.login-card h2 svg { width: 28px; height: 28px; color: var(--rh-blue); flex: 0 0 auto; }
.login-lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  text-align: center;
}
.login-card label {
  display: block;
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--muted);
}
.field-with-icon { position: relative; margin-bottom: 14px; }
.field-with-icon > svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.field-with-icon input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px 14px 12px 40px;
  margin: 0;
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field-with-icon input:focus {
  outline: none;
  border-color: var(--rh-blue);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.15);
}
.login-card button {
  width: 100%;
  border: 0;
  border-radius: 4px;
  padding: 12px 14px;
  margin-top: 4px;
  background: var(--rh-red);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.login-card button:hover { background: var(--rh-red-hover); }
.login-card button svg { width: 18px; height: 18px; flex: 0 0 auto; }

/* ===== App shell ===== */
.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}
.sidebar {
  background: linear-gradient(180deg, var(--rh-blue-deep), var(--rh-blue));
  color: #fff;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  overflow: hidden;
  position: sticky;
  top: 0;
}
.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}
.brand-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: inherit;
  text-decoration: none;
}
.brand-home:hover,
.brand-home:focus-visible {
  text-decoration: none;
  opacity: 0.92;
}
.sidebar .brand-logo { width: 150px; background: transparent; padding: 0; }
.sidebar h1 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  line-height: 1.3;
  text-transform: uppercase;
  font-weight: 700;
}
.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sidebar .meta {
  font-size: 0.78rem;
  opacity: 0.85;
  line-height: 1.4;
  text-align: center;
}
.btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--rh-red);
  border: 0;
  color: #fff;
  border-radius: 4px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.15s ease;
}
.btn-logout:hover { background: var(--rh-red-hover); }
.btn-logout svg { width: 18px; height: 18px; flex: 0 0 auto; }
.actions .btn-with-icon svg { color: currentColor; }

.content {
  padding: 24px 28px 36px;
  min-width: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}
.content-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}
.content-header h2 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}
.steps {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.steps li {
  position: relative;
  background: #fff;
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
}
.steps li:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  color: #b0b7c0;
  font-size: 0.75rem;
}
.steps li:not(:last-child) { margin-right: 10px; }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .login-shell { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .sidebar {
    height: auto;
    position: relative;
    overflow: visible;
  }
  .content {
    height: auto;
    overflow: visible;
  }
  .login-left { min-height: 280px; }
  .dims-row { grid-template-columns: 1fr; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(0, 30, 60, 0.05);
  padding: 20px;
  min-width: 0;
  overflow: hidden;
}
.filters-card { overflow: visible; }
.card-title-row { margin-bottom: 8px; }
.card h3 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}
.card-lead {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.field-block { margin-top: 14px; min-width: 0; }
.field-block:first-of-type { margin-top: 8px; }
.field-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--rh-blue-deep);
  letter-spacing: 0.01em;
}
.field-ico {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.field-ico svg { width: 16px; height: 16px; }
.ico-form { background: #e7f1fa; color: #0066cc; }
.ico-table { background: #efe8ff; color: #5e40be; }
.ico-search { background: #e8f7ef; color: #3e8635; }
.ico-row { background: #fff4e5; color: #b35c00; }
.ico-col { background: #fce8ef; color: #a1185c; }
.ico-metrics { background: #e7f1fa; color: #004080; }
.ico-year { background: #eef2ff; color: #3d5afe; }
.ico-map { background: #e8f7ef; color: #2e7d32; }
.ico-file { background: #fff4e5; color: #c05600; }
.ico-tag { background: #f3e8ff; color: #7b1fa2; }

/* Clean search field (no browser search decoration) */
.search-field {
  position: relative;
  margin-bottom: 8px;
}
.search-field .search-ico {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #7a8490;
  pointer-events: none;
  display: flex;
}
.search-field .search-ico svg { width: 16px; height: 16px; }
.search-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px 10px 36px;
  background: #fafbfc;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.search-field input:focus {
  outline: none;
  background: #fff;
  border-color: var(--rh-blue);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.12);
}
.search-field input:disabled {
  opacity: 0.6;
  background: #f3f4f6;
}
.territory-search {
  margin: 12px 0;
}

/* Years / Subjects equal-height panels */
.dims-row {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 12px;
  margin-top: 14px;
  align-items: stretch;
}
.dim-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 320px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fcfdff, #f7f9fb);
}
.dim-panel .field-label { margin-bottom: 8px; }
.dim-panel select[multiple] {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  margin: 0;
}
.dim-panel .stat-bar { margin-top: 8px; }

.field-row { margin-top: 14px; }
.nested-row { gap: 12px; }

/* Rich select */
.rich-select { position: relative; width: 100%; }
.rich-select-trigger {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font-weight: 400;
  min-height: 44px;
}
.rich-select-trigger:disabled { opacity: 0.55; cursor: not-allowed; }
.rich-select.open .rich-select-trigger {
  border-color: var(--rh-blue);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.12);
}
.rich-select-value {
  flex: 1;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.rich-select-caret { color: var(--muted); line-height: 1; margin-top: 2px; }
.rich-select-panel {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: min(420px, 55vh);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
  padding: 4px;
}
.rich-select-option {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 0;
  border-radius: 4px;
  padding: 10px 12px;
  font-weight: 400;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.rich-select-option:hover { background: #e7f1fa; }
.rich-select-option.selected {
  background: #d0e4f7;
  color: var(--rh-blue-deep);
  font-weight: 600;
}

select, input, textarea, button { font: inherit; }
select, input, textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--rh-blue);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.12);
}
select {
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
select[multiple] {
  min-height: 200px;
  white-space: normal;
  overflow: auto;
  padding: 6px;
  line-height: 1.35;
}
#indicatorSelect { min-height: 240px; }

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}

.stat-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #e7f1fa;
  border: 1px solid #c5daf0;
  color: var(--rh-blue-deep);
  font-size: 0.78rem;
  font-weight: 700;
}
.stat-chip.muted-chip {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: var(--muted);
  font-weight: 600;
}
.stat-chip.ok-chip {
  background: #e8f7ef;
  border-color: #b7e0c2;
  color: #216e2a;
}
.stat-chip.warn-chip {
  background: #fff4e5;
  border-color: #f0d2a8;
  color: #8a4b00;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.sticky-actions {
  position: sticky;
  bottom: 0;
  padding-top: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0), #fff 28%);
}
button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--rh-blue);
  color: #fff;
  font-weight: 600;
}
.btn-with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-with-icon svg { width: 18px; height: 18px; flex: 0 0 auto; }
button.btn-green { background: var(--rh-green); }
button.btn-green:hover { background: var(--rh-green-hover); }
button.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.secondary:hover {
  background: #f7f7f7;
  border-color: #bdbdbd;
}
button.danger { background: var(--rh-red); }
button.danger:hover { background: var(--rh-red-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.hint, .muted { color: var(--muted); font-size: 0.85rem; margin-top: 8px; }
.provenance-note { max-width: 52rem; }
.error { color: #a30000; margin-top: 10px; font-size: 0.9rem; }
.ok { color: #3e8635; margin-top: 10px; font-size: 0.9rem; }

.coverage {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, #e7f1fa, #f3f8fd);
  border: 1px solid #b8d4f0;
  color: #002f5d;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.preset-list { display: grid; gap: 10px; margin-top: 14px; }
.preset-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fafbfc;
  min-width: 0;
}
.preset-item strong { display: block; font-size: 0.95rem; }
.preset-item .muted { margin-top: 2px; font-size: 0.75rem; }
.preset-item .actions { margin-top: 0; flex-wrap: nowrap; }
.job-item a.btn-green { display: inline-block; margin-top: 8px; text-decoration: none; padding: 8px 12px; }
.preset-item .actions button {
  padding: 8px 10px;
  font-size: 0.82rem;
}

.side-nav { display: grid; gap: 6px; margin-top: 8px; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: #fff;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.nav-btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}
.nav-btn:hover, .nav-btn:focus-visible { background: rgba(255,255,255,0.12); outline: 2px solid #fff; }
.nav-btn.active { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.35); }
.indicator-list, .territory-list {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 6px;
  display: grid;
  gap: 6px;
}
.indicator-card, .terr-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line-soft);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
}
.terr-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.terr-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex: 0 0 18px;
  border: 2px solid #8aa0b8;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}
.terr-item input[type="checkbox"]:checked {
  border-color: var(--rh-blue);
  background: var(--rh-blue) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.2' d='M3.5 8.2 6.6 11.2 12.5 4.8'/%3E%3C/svg%3E") center / 12px 12px no-repeat;
}
.terr-item span { flex: 1; line-height: 1.35; }
.terr-item small { color: var(--muted); }
.indicator-card.selected, .terr-item:has(input:checked) { border-color: var(--rh-blue); background: #e7f1fa; }
.indicator-card:focus-visible, .terr-item:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 1px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip,
button.chip {
  border: 1px solid #9db8d4;
  background: #e7f1fa;
  color: var(--rh-blue-deep);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
}
button.chip:hover {
  background: #d0e4f7;
  color: var(--rh-blue-deep);
}
.pager { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.inline-check { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.linkish { background: none; border: 0; color: var(--rh-blue); cursor: pointer; text-decoration: underline; }
.view-panel[hidden], [hidden] { display: none !important; }
@media (max-width: 720px) {
  .sticky-actions { position: sticky; bottom: 0; background: #fff; padding-top: 8px; z-index: 5; }
  .coverage, #btnExport, #btnRefreshCoverage, #btnReset { display: block; width: 100%; }
  .row, .nested-row { grid-template-columns: 1fr; }
  .content { padding: 16px 12px 80px; }
  .side-nav { grid-template-columns: 1fr 1fr; }
}
