:root {
  color-scheme: light;
  --bg: #e9eeeb;
  --ink: #111816;
  --text: #17211f;
  --muted: #61706b;
  --panel: #fbfdfb;
  --panel-strong: #eff6f3;
  --line: #c9d6d1;
  --line-strong: #8fa49d;
  --accent: #0f766e;
  --accent-strong: #0a504b;
  --accent-hot: #d6ff3f;
  --accent-soft: #dff6ef;
  --warn: #9a3412;
  --danger: #b42318;
  --ok: #18794e;
  --shadow: 0 24px 70px rgba(17, 24, 22, 0.12);
  --shadow-tight: 5px 5px 0 rgba(15, 118, 110, 0.16);
  --radius: 8px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  font-family: "Arial", "Helvetica Neue", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 3%, rgba(15, 118, 110, 0.18), transparent 30rem),
    radial-gradient(circle at 96% 12%, rgba(214, 255, 63, 0.2), transparent 26rem),
    repeating-linear-gradient(135deg, rgba(17, 24, 22, 0.035) 0 1px, transparent 1px 12px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.skip-nav {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 20;
  padding: 10px 14px;
  color: #fff;
  background: var(--ink);
  border-radius: var(--radius);
  transform: translateY(-160%);
  transition: transform 180ms var(--ease);
}

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

.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: 0.55;
  mix-blend-mode: soft-light;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px clamp(16px, 3vw, 38px);
  background: rgba(233, 238, 235, 0.9);
  border-bottom: 2px solid var(--ink);
  backdrop-filter: blur(14px);
}

.topbar::before {
  position: absolute;
  inset: auto 0 -2px 0;
  height: 5px;
  content: "";
  background: repeating-linear-gradient(90deg, var(--accent), var(--accent) 34px, var(--accent-hot) 34px, var(--accent-hot) 46px);
}

.topbar h1,
.section-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(1.7rem, 4vw, 3.5rem);
  font-weight: 950;
  line-height: 0.92;
  text-transform: uppercase;
}

.dek {
  max-width: 72ch;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  color: var(--accent-strong);
  background: var(--accent-hot);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-tight);
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.primary-button,
.ghost-button,
.mini-button {
  min-height: 40px;
  border-radius: var(--radius);
  border: 2px solid var(--ink);
  padding: 0 14px;
  font-weight: 900;
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), background 180ms var(--ease);
}

.primary-button {
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow-tight);
}

.primary-button:hover,
.primary-button:focus-visible,
.ghost-button:hover,
.ghost-button:focus-visible,
.mini-button:hover,
.mini-button:focus-visible {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 rgba(17, 24, 22, 0.16);
  outline: none;
}

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

main {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 22px clamp(12px, 3vw, 38px) 48px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  position: relative;
  min-width: 0;
  padding: 16px;
  overflow: hidden;
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-tight);
  animation: rise 380ms var(--ease) both;
}

.metric::after {
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  content: "";
  background: linear-gradient(90deg, var(--accent), var(--accent-hot));
}

.metric-label {
  display: block;
  color: var(--muted);
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  overflow: hidden;
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  font-size: 1.9rem;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
}

.metric-wide strong {
  font-family: inherit;
  font-size: 1.08rem;
  white-space: normal;
}

.control-panel {
  display: grid;
  grid-template-columns: minmax(240px, 1.6fr) repeat(4, minmax(132px, 0.8fr));
  gap: 10px;
  padding: 12px;
  margin-bottom: 16px;
  background: rgba(251, 253, 251, 0.94);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.field {
  min-width: 0;
}

.field span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(214, 255, 63, 0.55);
}

.domain-strip,
.table-section {
  margin-top: 16px;
  overflow: clip;
  background: rgba(251, 253, 251, 0.96);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise 460ms var(--ease) both;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.08), transparent),
    var(--panel);
  border-bottom: 2px solid var(--ink);
}

.section-head h2 {
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  font-weight: 950;
  text-transform: uppercase;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.table-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.compact-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.compact-field select {
  min-height: 36px;
  padding: 0 28px 0 8px;
  background: #fff;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
}

.pager {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pager .mini-button {
  min-height: 36px;
}

.pager .mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

#pageStatus {
  min-width: 86px;
  color: var(--muted);
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.domain-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.domain-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 100%;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease);
}

.domain-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  content: "";
  background: repeating-linear-gradient(180deg, var(--accent), var(--accent) 20px, var(--accent-hot) 20px, var(--accent-hot) 28px);
}

.domain-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-tight);
}

.domain-card h3 {
  margin: 0;
  padding-left: 8px;
  font-size: 1rem;
  line-height: 1.25;
}

.domain-card p {
  margin: 0;
  padding-left: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.target-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-left: 8px;
}

.target-chip,
.tag,
.money-badge,
.speed-badge,
.confidence,
.quartile-badge,
.difficulty {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 2px 8px;
  overflow: hidden;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.target-chip {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid #9ad7ca;
}

.domain-button {
  min-height: 38px;
  margin-top: auto;
  color: #fff;
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-tight);
  font-weight: 900;
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease);
}

.domain-button:hover,
.domain-button:focus-visible {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 rgba(17, 24, 22, 0.16);
  outline: none;
}

.target-chip:hover,
.target-chip:focus-visible {
  color: var(--ink);
  background: var(--accent-hot);
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

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

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

.col-journal {
  width: 30%;
}

.col-metrics {
  width: 15%;
}

.col-cost {
  width: 19%;
}

.col-speed {
  width: 17%;
}

.col-score {
  width: 9%;
}

.col-profile {
  width: 10%;
}

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

th {
  position: sticky;
  top: 96px;
  z-index: 2;
  color: var(--muted);
  background: #f7faf8;
  border-bottom: 2px solid var(--ink);
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr:hover td {
  background: #f7faf8;
}

.journal-title {
  display: block;
  color: var(--text);
  font-weight: 950;
  line-height: 1.25;
  text-decoration: none;
}

.journal-title:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.publisher,
.subtle {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.cell-stack {
  display: grid;
  gap: 7px;
}

.inline-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.quartile-badge {
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent-strong);
}

.quartile-badge.q2 {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.quartile-badge.q3 {
  color: #463b00;
  background: #fff2a8;
  border-color: #d0ab00;
}

.quartile-badge.q4 {
  color: #7a1f12;
  background: #ffd4c9;
  border-color: #e48975;
}

.quartile-badge.mixed,
.quartile-badge.q1-q2 {
  color: var(--ink);
  background: var(--accent-hot);
  border-color: var(--ink);
}

.tag {
  color: #25312f;
  background: #edf2f0;
  border: 1px solid var(--line);
}

.money-badge,
.speed-badge {
  min-height: 30px;
  width: 100%;
  justify-content: flex-start;
  overflow: visible;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font-size: 0.82rem;
  line-height: 1.25;
  text-overflow: clip;
  white-space: normal;
}

.money-badge {
  background: linear-gradient(90deg, #f3ffe2, #ffffff);
  border-color: var(--accent-strong);
}

.money-badge.unknown,
.speed-badge.unknown {
  color: #7a1f12;
  background: #fff0ee;
  border-color: #e48975;
}

.speed-badge {
  background: linear-gradient(90deg, #e8f8ff, #ffffff);
  border-color: #7aa8b8;
}

.cost-hint,
.speed-line {
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.35;
}

.confidence {
  color: #17443e;
  background: #e5f7ef;
  border: 1px solid #bde6cf;
}

.confidence.verified-index {
  color: var(--accent-strong);
  background: #f3ffe2;
  border-color: #c4e66e;
}

.confidence.partial {
  color: var(--warn);
  background: #fff3e8;
  border-color: #ffd7b0;
}

.confidence.needs-check {
  color: var(--danger);
  background: #fff0ee;
  border-color: #ffc9c2;
}

.difficulty {
  color: #34403d;
  background: #edf2f0;
}

.difficulty.reach {
  color: var(--danger);
  background: #fff0ee;
}

.difficulty.strong {
  color: var(--warn);
  background: #fff3e8;
}

.fit-meter {
  display: grid;
  gap: 6px;
}

.bar {
  position: relative;
  height: 9px;
  overflow: hidden;
  background: #e6eeeb;
  border: 1px solid #d4dfdb;
  border-radius: 999px;
}

.bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--score, 0%);
  background: repeating-linear-gradient(135deg, var(--accent), var(--accent) 8px, #21a173 8px, #21a173 16px);
  border-radius: inherit;
}

.details-row[hidden] {
  display: none;
}

.details-panel {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  padding: 14px;
  background:
    repeating-linear-gradient(135deg, rgba(15, 118, 110, 0.045) 0 1px, transparent 1px 10px),
    #fff;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
}

.details-panel h4 {
  margin: 0 0 6px;
  color: var(--muted);
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.details-panel p {
  margin: 0;
  line-height: 1.5;
}

.details-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: start;
}

.details-links a {
  color: var(--accent-strong);
  font-weight: 900;
}

.empty-state {
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@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: 1240px) {
  .summary-grid,
  .domain-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .control-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr;
  }

  .top-actions {
    width: 100%;
    justify-content: stretch;
  }

  .status-pill,
  .primary-button,
  .ghost-button {
    flex: 1 1 auto;
    justify-content: center;
  }

  main {
    padding-inline: 12px;
  }

  .summary-grid,
  .domain-grid,
  .control-panel {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-tools {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .pager,
  .compact-field {
    justify-content: space-between;
    width: 100%;
  }

  th {
    top: 0;
  }

  .details-panel {
    grid-template-columns: 1fr;
  }
}
