:root {
  --ink: #14232b;
  --muted: #5a6b74;
  --line: #d6e0e3;
  --surface: #ffffff;
  --page: #f4f7f6;
  --brand: #0d5c4d;
  --brand-dark: #074337;
  --accent: #d6a12b;
  --good: #0a6b4d;
  --bad: #a3332a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 40, 35, 0.06), 0 8px 24px rgba(15, 40, 35, 0.05);
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
}

a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-dark); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--brand);
  color: white;
  padding: 0.75rem 1rem;
}
.skip-link:focus { left: 1rem; top: 1rem; color: white; }

.container { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; }

.site-header {
  background: var(--brand-dark);
  color: white;
  border-bottom: 4px solid var(--accent);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 72px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: white;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
}
.brand:hover { color: white; }
.brand-logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--brand);
  color: white;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.brand-logo-lg { width: 56px; height: 56px; border-radius: 14px; font-size: 1rem; margin: 0 auto 1rem; }

.nav-list { display: flex; gap: 1.25rem; align-items: center; list-style: none; margin: 0; padding: 0; }
.nav-list a, .link-button {
  color: white;
  text-decoration: none;
  font-size: 0.95rem;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
.nav-list a:hover, .link-button:hover { text-decoration: underline; }
.inline-form { display: inline; }

.site-header.navbar { padding: 0.6rem 0; }
.site-header .navbar-toggler { border-color: rgba(255, 255, 255, 0.45); }
.site-header .navbar-toggler-icon { filter: invert(1); }
.main-nav-list { gap: 0.25rem 0.75rem; }
.main-nav-list .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.92rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  text-decoration: none;
}
.main-nav-list .nav-link:hover,
.main-nav-list .nav-link:focus { color: white; background: rgba(255, 255, 255, 0.14); }

.main-content { padding: 2rem 0 3rem; min-height: 60vh; }

.hero-band {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: white;
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow);
}
.hero-inner { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5rem; flex-wrap: wrap; }
.hero-band .eyebrow { color: #cfe6dd; }
.hero-band h1 { margin-bottom: 0.25rem; }
.hero-band .lede { color: #e3efeb; }
.hero-interval label { color: #e3efeb; font-weight: 600; }
.hero-interval select { min-width: 190px; }

.dashboard-section { margin-bottom: 1.75rem; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.9rem; }
.section-heading .section-title { display: inline-flex; align-items: center; gap: 0.5rem; }
.panel-head .section-title { display: inline-flex; align-items: center; gap: 0.5rem; }
.dashboard-section.panel { padding-bottom: 0; }

.site-footer { background: #e8eeec; border-top: 1px solid var(--line); padding: 1.25rem 0; color: var(--muted); font-size: 0.85rem; }
.site-footer p { margin: 0; }

.page-heading, .report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.72rem; font-weight: 700; color: var(--brand); margin: 0 0 0.25rem; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 0 0 0.35rem; line-height: 1.2; }
h2 { line-height: 1.3; }
.lede { color: var(--muted); margin: 0; max-width: 62ch; }
.section-title { font-size: 1.1rem; margin: 0; }
.muted { color: var(--muted); font-size: 0.85rem; }
.hint { display: block; color: var(--muted); font-size: 0.75rem; font-weight: 400; }

.breadcrumbs { font-size: 0.85rem; color: var(--muted); margin-bottom: 1rem; }
.breadcrumbs span { padding: 0 0.35rem; }

.interval-picker, .filter-bar { display: flex; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap; }
.interval-picker label, .field label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.25rem; }
select, input[type="number"], input[type="text"], input[type="password"], textarea {
  font: inherit;
  color: var(--ink);
  background: white;
  border: 1px solid #b8c7ca;
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  min-height: 40px;
}
input[type="number"] { width: 9rem; }
textarea { width: 100%; }
.filter-bar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.25rem; }

.button {
  display: inline-block;
  background: var(--brand);
  color: white;
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  min-height: 42px;
}
.button:hover { background: var(--brand-dark); color: white; text-decoration: none; }
.button-secondary { background: white; color: var(--brand); }
.button-secondary:hover { background: #eef4f2; color: var(--brand-dark); }
.action-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.25rem; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.card-grid.row { display: flex; margin-bottom: 1.75rem; }
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
}
.metric-card h2, .metric-card h3 { font-size: 1rem; margin: 0.1rem 0 0.75rem; }
.metric-code { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; color: var(--brand); margin: 0; }
.metric-value { font-size: 2.1rem; font-weight: 700; margin: 0; line-height: 1.1; }
.metric-unit { font-size: 0.8rem; font-weight: 400; color: var(--muted); }
.metric-change { display: flex; align-items: center; gap: 0.5rem; margin: 0.6rem 0; min-height: 1.5rem; }
.metric-description { color: var(--muted); font-size: 0.8rem; margin: 0.5rem 0 0; }

.badge { display: inline-block; border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.75rem; font-weight: 700; text-transform: capitalize; }
.trend-improved { background: #dff3e9; color: var(--good); }
.trend-worsened { background: #fae4e1; color: var(--bad); }
.trend-unchanged, .trend-no-data { background: #eceff0; color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.25rem; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
caption { text-align: left; }
th, td { text-align: left; padding: 0.7rem 1.25rem; border-bottom: 1px solid #edf1f2; vertical-align: top; }
thead th { background: #f8faf9; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
tbody th { font-weight: 600; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
.summary-row th, .summary-row td { background: #f1f7f5; color: var(--brand-dark); }
.summary-value { font-variant-numeric: tabular-nums; font-weight: 700; }
.tree-label { display: inline-block; padding-left: calc(var(--tree-depth, 0) * 1.25rem); }
.tree-parent th { display: flex; align-items: center; gap: 0.5rem; }
.tree-toggle { border: 0; background: transparent; color: var(--brand-dark); cursor: pointer; padding: 0.15rem 0.35rem; border-radius: 4px; }
.tree-toggle:hover, .tree-toggle:focus-visible { background: #dcebe6; outline-offset: 2px; }
.tree-children[hidden] { display: none; }
.empty { text-align: center; color: var(--muted); padding: 2rem; }

.notice { background: #e7f2ef; border: 1px solid #bcdcd3; color: var(--brand-dark); border-radius: 6px; padding: 0.75rem 1rem; margin-bottom: 1rem; }
.notice.error { background: #fae4e1; border-color: #e8bdb7; color: var(--bad); }
.messages .notice:last-child { margin-bottom: 1.25rem; }
.field { margin-bottom: 1rem; }
.field-error { color: var(--bad); font-size: 0.8rem; margin: 0.25rem 0 0; }
.weight-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.5rem 1.25rem; padding: 1rem 1.25rem; }
.weight-grid .field { margin: 0; }
.auth-card { max-width: 420px; margin: 2rem auto; background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.75rem; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.5rem; }

.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-main { width: 100%; max-width: 420px; }
.auth-main .auth-card { margin: 0; padding: 2.25rem 2rem; text-align: center; }
.auth-subtitle { color: var(--muted); font-size: 0.9rem; margin: 0 0 1.5rem; }
.auth-form { text-align: left; }
.auth-form .field { margin-bottom: 1rem; }
.auth-form .input-group-text {
  background: #f4f7f6;
  border: 1px solid #b8c7ca;
  border-right: 0;
  border-radius: 6px 0 0 6px;
  color: var(--muted);
}
.auth-form .input-group input {
  width: 100%;
  min-height: 44px;
  border-left: 0;
  border-radius: 0 6px 6px 0;
  box-shadow: none;
}
.auth-form .input-group input:focus { border-color: var(--brand); box-shadow: none; }
.auth-submit { width: 100%; margin-top: 0.5rem; }
.auth-footer { color: var(--muted); font-size: 0.8rem; text-align: center; margin: 1.25rem 0 0; }

.chart-wrap { padding: 1rem 1.25rem; overflow-x: auto; }
.chart-wrap svg { display: block; max-width: 100%; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 1rem; }
.panel-body { padding: 1.25rem; }
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-row .field { min-width: 140px; }
.upload-layout { display: grid; grid-template-columns: minmax(320px, 1.4fr) minmax(260px, 1fr); gap: 1rem; align-items: start; }
.code-list { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; list-style: none; padding: 0; margin: 0.5rem 0 1rem; }
code { background: #eef4f2; border-radius: 4px; padding: 0.05rem 0.35rem; font-size: 0.85em; }
input[type="file"] { font: inherit; max-width: 100%; }

.major-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.major-groups.row { display: flex; }
.major-group { display: flex; flex-direction: column; }
.major-cards { display: grid; gap: 0.6rem; padding: 0.9rem 1rem 1.1rem; }
.major-card { display: grid; gap: 0.25rem; border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 0.9rem; color: inherit; text-decoration: none; background: #fff; }
.major-card:hover, .major-card:focus-visible { border-color: var(--brand); box-shadow: var(--shadow); }
.major-card strong { font-size: 1rem; }
.major-value { font-size: 1.6rem; font-weight: 700; color: var(--brand); }
.major-value small { font-size: 0.7rem; font-weight: 500; color: var(--muted); }
.remark-list { margin: 0; padding-left: 1.1rem; }
.remark-list li { margin-bottom: 0.25rem; }
.priority { display: inline-block; border-radius: 999px; padding: 0.05rem 0.5rem; font-size: 0.75rem; font-weight: 700; }
.priority-high { background: #fde8e6; color: #8a2118; }
.priority-medium { background: #fff4d6; color: #7a5a00; }
.priority-low { background: #e8f2ef; color: #245c4b; }
.button-danger { background: #a3332a; }
.button-danger:hover { background: #83271f; }

.instrument-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.instrument-grid.row { display: flex; gap: 0; }
.instrument-card { display: flex; flex-direction: column; gap: 0.5rem; padding: 1.25rem; border-top: 4px solid var(--brand); }
.instrument-card h2, .instrument-card h3 { font-size: 1.05rem; margin: 0; }
.instrument-score { display: flex; align-items: baseline; gap: 0.35rem; margin: 0; color: var(--brand); font-size: 2rem; font-weight: 700; }
.instrument-score small { color: var(--muted); font-size: 0.8rem; font-weight: 500; }
.band-badge { align-self: flex-start; border-radius: 999px; padding: 0.2rem 0.65rem; background: var(--brand); color: var(--surface); font-size: 0.75rem; font-weight: 700; }
.score-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.6rem; }
.progress-track { height: 6px; margin-bottom: 0.75rem; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress-track > span { display: block; height: 100%; background: var(--brand); }
.instrument-subindices { margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: 0.85rem; }
.instrument-subindices li { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.2rem 0; border-bottom: 1px dotted var(--line); }
.instrument-subindices li:last-child { border-bottom: 0; }

.alert-carousel { margin-bottom: 1.75rem; }
.alert-carousel .panel-head { flex-wrap: wrap; }
.carousel-controls { display: flex; align-items: center; gap: 0.75rem; }
.carousel-count { white-space: nowrap; }
.carousel-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 32px;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--brand);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.carousel-toggle:hover { border-color: var(--brand); background: var(--page); }
.carousel-body { min-height: 7.5rem; }
.alert-carousel .alert-slide { display: none; }
.alert-carousel .alert-slide.is-active { display: block; }
.alert-carousel.is-static .alert-slide { display: block; }
.alert-carousel.is-static .alert-slide + .alert-slide { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.alert-carousel.is-static .carousel-progress { display: none; }
.slide-head { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.35rem; }
.slide-title { margin: 0; font-size: 1.05rem; }
.slide-meta { font-size: 0.8rem; }
.slide-comment { margin: 0; }
.carousel-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 1.25rem 1rem; }
.carousel-dots { display: flex; gap: 0.35rem; }
.carousel-dot { width: 10px; height: 10px; padding: 0; border: 1px solid var(--brand); border-radius: 50%; background: var(--surface); cursor: pointer; }
.carousel-dot.is-active { background: var(--brand); }
.carousel-progress { flex: 1; height: 3px; border-radius: 999px; background: var(--line); overflow: hidden; }
.carousel-progress > span { display: block; width: 0; height: 100%; background: var(--brand); }
.carousel-progress > span.is-running { animation: carousel-progress linear forwards; }
@keyframes carousel-progress { from { width: 0; } to { width: 100%; } }

@media (max-width: 820px) {
  .upload-layout { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .major-groups { grid-template-columns: 1fr; }
  .instrument-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .header-inner { padding: 0.75rem 0; }
  .nav-list { gap: 0.9rem; }
  .hero-band { padding: 1.5rem 1.25rem; }
  .hero-inner { align-items: flex-start; }
  .auth-main .auth-card { padding: 1.75rem 1.25rem; }
  .panel-head { flex-direction: column; align-items: flex-start; }
  th, td { padding: 0.6rem 0.75rem; }
}

@media print {
  body { background: white; }
  .site-header, .site-footer, .no-print, .breadcrumbs, .action-row, .skip-link { display: none !important; }
  .container { width: 100%; }
  .main-content { padding: 0; }
  .panel { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
  .metric-card { box-shadow: none; }
}

/* Agreed mockup fidelity for the overview and index detail pages. */
body { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.container { width: min(1160px, calc(100% - 2.5rem)); margin: 0 auto; }
.agreed-page.container { width: min(1160px, 100%); padding: 1.5rem 1.25rem 3rem; }
.site-header { background: var(--brand); color: #fff; border-bottom: 0; }
.site-header.navbar { padding: 0.75rem 0; }
.header-inner { min-height: 0; }
.brand-logo { display: none; }
.brand-name { color: #fff; font-weight: 700; letter-spacing: 0.04em; }
.main-content { padding: 1.5rem 0 3rem; }

.hero-band {
  background: var(--brand-dark);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: none;
}
.hero-band h1 { margin: 0 0 0.25rem; font-size: 1.6rem; }
.hero-band p { margin: 0; opacity: 0.85; }
.overview-picker { margin-bottom: 1.5rem; }
.overview-picker select { min-width: 190px; }

.agreed-page .dashboard-section { margin-bottom: 1.5rem; }
.agreed-page .panel { box-shadow: none; }
.agreed-page .instrument-grid.row { margin: 0 -0.6rem; }
.agreed-page .instrument-grid.row > div { flex: 0 0 33.3333%; padding: 0 0.6rem; }
.agreed-page .instrument-card.panel {
  display: block;
  height: 100%;
  margin-bottom: 0;
  overflow: visible;
  padding: 1.1rem;
  border-top: 4px solid var(--brand);
}
.agreed-page .metric-code { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; }
.agreed-page .instrument-card h3 { margin: 0 0 0.6rem; }
.agreed-page .instrument-card h3 a { color: var(--ink); text-decoration: none; }
.agreed-page .instrument-card h3 a:hover { color: var(--brand); text-decoration: underline; }
.agreed-page .instrument-score { margin: 0 0 0.35rem; }
.agreed-page .band-badge,
.agreed-page .badge { border-radius: 999px; padding: 0.18rem 0.6rem; font-size: 0.75rem; font-weight: 700; }
.agreed-page .trend-improved { background: #e8f2ef; color: var(--good); }
.agreed-page .trend-worsened { background: #fde8e6; color: #8a2118; }
.agreed-page .trend-unchanged { background: #eceff0; color: var(--muted); }

.agreed-page .panel-head,
.agreed-page .panel-body,
.agreed-page .carousel-foot { padding: 0.9rem 1rem; }
.agreed-page .panel-head .section-title { margin: 0; }
.agreed-page .section-heading .section-title { margin-bottom: 0.75rem; }
.agreed-page .alert-carousel { overflow: hidden; margin-bottom: 1.5rem; }
.agreed-page .alert-carousel .panel-head { flex-wrap: nowrap; }
.agreed-page .carousel-controls { gap: 0.6rem; }
.agreed-page .carousel-count { color: var(--muted); font-size: 0.8rem; }
.agreed-page .carousel-toggle { padding: 0.25rem 0.7rem; font-weight: 400; }
.agreed-page .carousel-body { min-height: 0; }
.agreed-page .slide-head { justify-content: space-between; flex-wrap: nowrap; gap: 0.5rem; }
.agreed-page .slide-title { font-size: 1rem; }
.agreed-page .slide-comment { margin: 0.35rem 0; }
.agreed-page .priority {
  display: inline-block;
  border-radius: 999px;
  padding: 0.08rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  margin-right: 0.35rem;
}
.agreed-page .carousel-foot { display: flex; gap: 0.6rem; border-top: 1px solid var(--line); }
.agreed-page .carousel-dot { width: 9px; height: 9px; border: 0; background: var(--line); }
.agreed-page .carousel-dot.is-active { background: var(--brand); }

.agreed-page table { font-size: 0.9rem; }
.agreed-page th { color: var(--muted); font-weight: 600; }
.agreed-page th,
.agreed-page td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line); }
.agreed-page thead th { background: transparent; font-size: inherit; text-transform: none; letter-spacing: 0; }
.agreed-page tbody tr:last-child th,
.agreed-page tbody tr:last-child td { border-bottom: 1px solid var(--line); }

@media (max-width: 820px) {
  .agreed-page .instrument-grid.row > div { flex: 0 0 100%; }
}
