:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --ink: #18201f;
  --muted: #66706d;
  --line: #d9dfd8;
  --panel: #ffffff;
  --green: #27765f;
  --blue: #315f9d;
  --red: #ad514b;
  --amber: #b4782f;
  --soft-green: #e5f1ec;
  --soft-blue: #e8eef8;
  --shadow: 0 18px 50px rgba(30, 43, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border: 1px solid var(--line);
}

button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
}

button.secondary,
.presets button {
  background: #fff;
  color: var(--ink);
}

button:hover {
  filter: brightness(0.96);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 42px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: start;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.1;
  letter-spacing: 0;
}

.headline {
  min-width: 0;
}

.titleRow {
  width: 100%;
}

.titleRow h1 {
  min-width: 0;
}

.topbarAside {
  display: grid;
  gap: 14px;
  justify-items: end;
  min-width: min(100%, 560px);
}

.titleActions {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.visitorStats {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  justify-self: end;
  width: fit-content;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.visitorStats strong {
  color: var(--ink);
}

.homeLink,
.shareButton {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 11px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.homeLink {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}

.homeLink:hover {
  border-color: var(--green);
}

.homeLink svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.shareButton {
  min-width: 38px;
}

.shareButton svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

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

h2 {
  font-size: 17px;
  line-height: 1.25;
}

h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.heroCopy {
  max-width: 640px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(136px, 1fr)) minmax(92px, 120px) repeat(2, auto);
  gap: 10px;
  justify-content: end;
  align-items: end;
}

.filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  height: 40px;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.filters input {
  width: 100%;
}

.filters select {
  width: 100%;
}

.nativeDistrictSelect {
  display: none;
}

.districtPicker {
  position: relative;
}

.districtPickerButton {
  justify-content: space-between;
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.districtPickerButton::after {
  content: none;
}

.districtPickerMenu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  display: grid;
  max-height: 280px;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.districtPickerMenu[hidden] {
  display: none;
}

.districtOption {
  display: block;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.districtOption:hover,
.districtOption[aria-selected="true"] {
  background: var(--soft-green);
  color: var(--green);
}

.presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 22px 0;
  max-width: 360px;
}

.presets button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

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

.metrics article,
.panel,
.tableSection,
.chartBand {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics article {
  min-height: 96px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metrics strong {
  font-size: 30px;
  line-height: 1;
}

.estimatePanel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 180px) minmax(220px, auto);
  gap: 14px;
  align-items: center;
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.estimatePanel p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.estimatePanel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.estimateResult {
  display: grid;
  gap: 5px;
  justify-items: end;
  text-align: right;
}

.estimateResult strong {
  font-size: 20px;
  line-height: 1.2;
}

.estimateResult span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.chartBand {
  margin-top: 14px;
  padding: 20px;
}

.sectionTitle {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.sectionTitle p {
  color: var(--muted);
  font-size: 13px;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 260px;
}

.chartTooltip {
  position: fixed;
  z-index: 120;
  min-width: 176px;
  max-width: min(260px, calc(100vw - 16px));
  padding: 12px 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(17, 24, 23, 0.88);
  color: #fff;
  box-shadow: 0 14px 36px rgba(17, 24, 23, 0.22);
  pointer-events: none;
}

.chartTooltip[hidden] {
  display: none;
}

.chartTooltipTitle {
  margin-bottom: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.chartTooltipList {
  display: grid;
  gap: 6px;
}

.chartTooltipRow {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  line-height: 1.35;
}

.chartTooltipRow strong {
  color: #fff;
  font-weight: 900;
}

.grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 14px;
  margin-top: 14px;
}

.panel,
.tableSection {
  padding: 18px;
}

.bars {
  display: grid;
  gap: 12px;
}

.barRow {
  display: grid;
  gap: 7px;
}

.barButton {
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.barButton:hover {
  filter: none;
}

.barButton:hover .barTop span,
.barButton:focus-visible .barTop span {
  color: var(--green);
}

.barTop {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.barTrack,
.barSvg {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
}

.barSvg {
  display: block;
  width: 100%;
}

.barBase {
  fill: #edf0ee;
}

.barFill {
  fill: var(--blue);
}

.barFill.pending {
  fill: var(--amber);
}

.barFill.resolved {
  fill: var(--green);
}

.barFill.withdrawn {
  fill: var(--red);
}

.tableSection {
  margin-top: 14px;
}

.tableHead {
  align-items: end;
}

.tableWrap {
  width: 100%;
  overflow-x: auto;
}

.loadMoreRow {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.loadMoreButton {
  min-width: 160px;
}

.loadMoreButton[hidden] {
  display: none;
}

table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
}

.caseNo {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.favoriteCell {
  width: 72px;
}

.favoriteButton {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--amber);
  font-size: 18px;
  line-height: 1;
}

.favoriteButton:hover {
  filter: none;
  background: #fff8ec;
}

.favoriteRow td {
  background: #fffdf8;
}

.caseButton {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.caseButton:hover {
  filter: none;
  color: var(--green);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.status.pending {
  background: #fbefd9;
  color: #8b581d;
}

.status.resolved {
  background: var(--soft-green);
  color: var(--green);
}

.status.withdrawn {
  background: #f8e7e5;
  color: var(--red);
}

.syncLine {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.tableNote {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.seoSection {
  margin-top: 14px;
  padding: 18px;
}

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

.seoGrid article {
  display: grid;
  gap: 8px;
}

.seoGrid p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.empty,
.error {
  color: var(--muted);
  padding: 18px 0;
}

.error {
  color: var(--red);
}

.modalBackdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(24, 32, 31, 0.34);
}

.modalBackdrop[hidden] {
  display: none;
}

.detailModal {
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

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

.modalHead h3 {
  font-size: 18px;
}

.modalClose {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.modalClose:hover {
  filter: none;
  color: var(--ink);
}

.detailList {
  display: grid;
  gap: 9px;
}

.detailRow {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.detailRow:last-child {
  border-bottom: 0;
}

.detailRow strong {
  color: var(--ink);
}

@media (max-width: 860px) {
  .topbar,
  .grid,
  .metrics,
  .seoGrid,
  .estimatePanel {
    grid-template-columns: 1fr;
  }

  .topbarAside {
    justify-items: stretch;
    min-width: 0;
  }

  .titleActions {
    justify-content: flex-start;
  }

  .visitorStats {
    justify-self: start;
  }

  .filters {
    justify-content: flex-start;
    width: 100%;
  }

  .metrics article {
    min-height: 82px;
  }

  .estimateResult {
    justify-items: start;
    text-align: left;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 22px;
  }

  .filters {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .filters label:nth-child(3) {
    grid-column: 1 / -1;
  }

  .filters button {
    width: 100%;
    min-height: 38px;
    padding: 0 8px;
  }

  .presets {
    max-width: none;
    gap: 5px;
    margin: 16px 0;
  }

  .presets button {
    width: auto;
    min-height: 28px;
    padding: 0 6px;
    font-size: 12px;
  }

  .sectionTitle {
    display: grid;
  }

  .titleRow {
    align-items: flex-start;
  }

  .titleActions {
    gap: 6px;
  }

  .shareButton {
    min-width: 36px;
    min-height: 36px;
    padding: 0 9px;
  }

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

  .homeLink {
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    justify-content: center;
  }

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

  .tableWrap {
    overflow-x: visible;
  }

  table {
    display: block;
    min-width: 0;
  }

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

  tbody {
    display: grid;
    gap: 10px;
  }

  tr {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .favoriteRow td {
    background: transparent;
  }

  td {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 0;
    border-bottom: 0;
    font-size: 14px;
    white-space: normal;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
  }

  .caseNo {
    grid-column: 1 / -1;
    grid-row: 1;
    padding-right: 44px;
  }

  .favoriteCell {
    position: absolute;
    top: 10px;
    right: 10px;
    width: auto;
    justify-items: end;
  }

  .favoriteCell::before {
    content: "";
  }

  .caseButton {
    max-width: 100%;
    overflow-wrap: anywhere;
    text-align: left;
    line-height: 1.35;
  }

  .status {
    width: fit-content;
  }

}
