:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --ink: #17201c;
  --muted: #65706b;
  --line: #d9dfda;
  --accent: #c01828;
  --accent-2: #94111d;
  --shadow: 0 16px 38px rgba(23, 32, 28, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family:
    "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select {
  font: inherit;
}

.text-link {
  display: inline;
  min-height: 0;
  margin-left: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.text-link:hover {
  text-decoration: underline;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px;
  background: #101815;
  color: #f3f7f4;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--accent);
  font-weight: 800;
}

.brand-title {
  font-weight: 800;
  letter-spacing: 0;
}

.sidebar-note span,
.eyebrow,
.muted {
  color: var(--muted);
}

.sidebar-note span {
  color: #aebbb4;
}

.sidebar-note a {
  color: #f3f7f4;
  font-weight: 700;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #f3f7f4;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-secondary {
  margin-top: -14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-item-secondary {
  min-height: 34px;
  padding: 7px 10px;
  color: #aebbb4;
  font-size: 13px;
}

.nav-item-secondary.active {
  color: #f3f7f4;
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  display: grid;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 999px;
  background: #e8f0ec;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  width: fit-content;
}

.chip.neutral {
  background: #edf1ef;
  color: var(--muted);
}

.status-chip {
  min-width: max-content;
  max-width: 180px;
  border: 1px solid rgba(192, 24, 40, 0.16);
  background: #fff4f5;
  color: var(--accent-2);
}

.status-chip.ready-chip {
  border-color: rgba(47, 125, 82, 0.18);
  background: #eef8f1;
  color: #2f7d52;
}

.status-chip.muted-chip {
  border-color: #d8ddd9;
  background: #f3f5f3;
  color: #59645f;
}

.status-chip.priority-chip {
  border-color: rgba(192, 24, 40, 0.2);
  background: #fff0f1;
  color: var(--accent);
}

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

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

.topbar h1,
h2,
h3,
p {
  margin-top: 0;
}

.topbar h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.06;
  letter-spacing: 0;
}

.eyebrow {
  margin-bottom: 8px;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.metrics-panel {
  margin-bottom: 18px;
  padding: 22px;
}

.metric {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, #faf7f7 100%);
  display: grid;
  align-content: space-between;
  gap: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
}

.metric strong {
  display: block;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: 0;
}

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

.legend-panel {
  margin-bottom: 18px;
}

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

.legend-grid > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.legend-grid p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  gap: 20px;
  margin-bottom: 18px;
}

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

.route-panel {
  min-height: 55vh;
}

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

.route-card {
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink);
  display: grid;
  gap: 8px;
  align-content: start;
  text-align: left;
  cursor: pointer;
}

.route-card:hover {
  border-color: rgba(192, 24, 40, 0.42);
  background: #fff4f5;
}

.route-card span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

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

.route-card small {
  color: var(--muted);
  font-size: 14px;
}

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

.cluster-card {
  min-height: 142px;
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.bar-meta span {
  color: var(--muted);
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: #f1e6e7;
  overflow: hidden;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

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

.section-heading h2,
.section-heading h3 {
  margin-bottom: 0;
}

.sticky-heading {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 12px 0;
  background: var(--bg);
}

input,
select {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

input {
  min-width: 250px;
}

.mini-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.mini-card h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.mini-card p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.guide-panel {
  margin-bottom: 18px;
}

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

.guide-card {
  min-height: 230px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.guide-card h4,
.guide-checklist h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.guide-card p {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
}

.guide-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  font-size: 14px;
}

.guide-card li + li {
  margin-top: 5px;
}

.guide-checklist {
  margin-top: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffafa;
}

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

.checklist-grid span {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid rgba(192, 24, 40, 0.14);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.guide-note {
  margin-top: 12px;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: #fff4f5;
  color: var(--ink);
  font-size: 14px;
}

.example-block {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101815;
  color: #f3f7f4;
  overflow: hidden;
}

.example-block summary {
  padding: 13px 15px;
  cursor: pointer;
  font-weight: 800;
}

.example-block pre {
  max-height: 520px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: #0c1210;
}

.example-block code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
}

.tree {
  display: grid;
  gap: 10px;
}

.sitemap-root,
.sitemap-item {
  position: relative;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 14px;
  overflow: hidden;
}

.sitemap-root > summary,
.sitemap-item > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
}

.sitemap-root > summary::-webkit-details-marker,
.sitemap-item > summary::-webkit-details-marker {
  display: none;
}

.sitemap-root > summary {
  font-weight: 800;
}

.sitemap-root > summary::after,
.sitemap-item > summary::after {
  content: "+";
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 800;
  order: -1;
}

.sitemap-root[open] > summary::after,
.sitemap-item[open] > summary::after {
  content: "-";
  color: var(--accent);
}

.sitemap-summary-main {
  min-width: 0;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
}

.tree-title,
.tree-url,
.tree-subtitle {
  display: block;
}

.tree-title {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.25;
  font-size: 15px;
}

.tree-url {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.tree-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.sitemap-children {
  display: grid;
  gap: 8px;
  margin: 0 12px 12px 24px;
  padding-left: 16px;
  border-left: 1px solid #d8e3de;
}

.sitemap-root {
  background: #fff8f8;
  border-color: #e8bfc4;
}

.sitemap-root::before,
.sitemap-item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--accent);
}

.sitemap-item {
  background: var(--surface);
}

.sitemap-item.depth-1 {
  border-color: #bfd7ca;
  background: #f7fbf8;
}

.sitemap-item.depth-1::before {
  background: #2f7d52;
}

.sitemap-item.depth-2 {
  border-color: #d4dce8;
  background: #fbfcfe;
}

.sitemap-item.depth-2::before {
  background: #466b9f;
}

.sitemap-item.depth-1,
.sitemap-item.depth-2 {
  margin-left: 0;
}

.sitemap-detail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 14px 14px 52px;
  padding: 12px;
  border-top: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.sitemap-detail-item {
  display: grid;
  gap: 4px;
  align-content: start;
}

.sitemap-detail-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sitemap-detail-item strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 650;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-panel {
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
  max-height: 68vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.table-wrap.compact {
  max-height: 620px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: var(--surface);
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #edf3ef;
  color: var(--ink);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sort-button {
  width: 100%;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  text-transform: inherit;
  letter-spacing: inherit;
  font: inherit;
  cursor: pointer;
}

.sort-button:hover {
  color: var(--accent);
}

.sort-indicator {
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

td code,
.path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #101815;
  color: #f3f7f4;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .topbar,
  .section-heading,
  .grid.two,
  .legend-grid,
  .route-grid,
  .metric-grid,
  .sitemap-detail,
  .cluster-grid,
  .guide-grid,
  .checklist-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .filters {
    width: 100%;
  }

  input,
  select {
    width: 100%;
  }

  .sitemap-detail {
    margin-left: 42px;
  }
}

@media (max-width: 560px) {
  .main,
  .sidebar {
    padding: 16px;
  }

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

  .sitemap-children {
    margin-left: 8px;
    padding-left: 10px;
  }

  .sitemap-detail {
    margin-left: 14px;
  }
}
