:root {
  color-scheme: light;
  --bg: #f5f7f7;
  --paper: #ffffff;
  --paper-soft: #f9fbfb;
  --line: #dbe3e3;
  --line-strong: #c5d1d1;
  --text: #10201f;
  --muted: #657574;
  --accent: #00796b;
  --accent-weak: #e1f2ef;
  --danger: #c63b3b;
  --blue: #1f6ad5;
  --shadow: 0 12px 28px rgba(19, 44, 41, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 14px 16px 28px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82rem;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.42rem, 2.2vw, 1.9rem);
  line-height: 1.15;
}

h2 {
  font-size: 0.94rem;
}

h3 {
  font-size: 0.88rem;
}

.status {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.76rem;
  box-shadow: 0 3px 10px rgba(19, 44, 41, 0.04);
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}

.mode-tabs button,
.segmented button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  cursor: pointer;
  padding: 0 12px;
  font-weight: 800;
}

.mode-tabs button.active,
.segmented button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

.metric-card,
.panel,
.toolbar {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 4px 14px rgba(19, 44, 41, 0.04);
}

.metric-card {
  padding: 9px 10px;
}

.metric-label,
.metric-sub,
.detail-sub,
.entry-main span,
.ticket span,
.race-card-foot,
.meta-box span {
  color: var(--muted);
}

.metric-label {
  font-size: 0.78rem;
}

.metric-value {
  margin-top: 2px;
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1.1;
}

.metric-sub {
  margin-top: 3px;
  font-size: 0.78rem;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 160px 140px;
  gap: 7px;
  padding: 8px;
  margin-bottom: 10px;
}

.toolbar input,
.toolbar select {
  width: 100%;
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  color: var(--text);
}

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

.toggle {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(430px, 0.95fr) minmax(520px, 1.05fr);
  gap: 10px;
  align-items: start;
}

.panel {
  padding: 10px;
}

.compact-panel {
  margin-bottom: 10px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.section-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.race-list,
.candidate-list {
  display: grid;
  gap: 10px;
}

.race-card,
.candidate-card {
  position: relative;
  width: 100%;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  text-align: left;
  cursor: pointer;
}

.race-card {
  padding: 7px 8px;
}

.candidate-card {
  padding: 11px;
}

.race-card.active,
.candidate-card.active {
  border-color: var(--accent);
  border-left-color: var(--accent);
  box-shadow: 0 8px 18px rgba(19, 44, 41, 0.08);
  background: #fff;
}

.grade-card-S,
.grade-card-A {
  border-left-color: var(--accent);
}

.grade-card-B {
  border-left-color: var(--blue);
}

.grade-card-C {
  border-left-color: #c39126;
}

.grade-card-D {
  border-left-color: #a9b5b5;
}

.race-track-section {
  display: block;
}

.race-track-section[open] {
  display: grid;
  gap: 6px;
}

.track-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eef4f3;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.track-head::-webkit-details-marker {
  display: none;
}

.track-head::after {
  content: "+";
  display: inline-grid;
  min-width: 22px;
  min-height: 22px;
  margin-left: auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  font-weight: 900;
}

.race-track-section[open] .track-head::after {
  content: "-";
}

.track-head strong {
  font-size: 0.88rem;
}

.track-head span,
.track-head em {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 850;
}

.track-race-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 6px;
}

.deadline-pickup {
  display: grid;
  gap: 6px;
  padding: 7px;
  border: 1px solid #bfdad6;
  border-radius: 9px;
  background: #f1faf8;
  box-shadow: 0 8px 18px rgba(0, 121, 107, 0.06);
}

.pickup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
}

.pickup-head strong {
  color: var(--accent);
  font-size: 0.88rem;
}

.pickup-head span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.pickup-grid .race-card {
  border-left-color: var(--accent);
  background: #fff;
}

.race-card-head,
.candidate-top,
.race-card-foot,
.underdog-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.race-card-head {
  margin-bottom: 5px;
}

.time {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--accent);
  font-size: 0.82rem;
}

.race-name,
.race-title {
  min-width: 0;
  flex: 1;
  font-weight: 800;
}

.race-name small,
.race-title small {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.race-card-foot {
  margin-top: 5px;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.72rem;
}

.race-card-body {
  display: grid;
  gap: 3px;
}

.list-order-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
}

.list-order-row > span:first-child {
  flex: 0 0 auto;
  color: var(--muted);
}

.list-order-row.actual {
  color: var(--text);
}

.list-line-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.list-line-summary span {
  display: inline-flex;
  max-width: 100%;
  min-height: 20px;
  align-items: center;
  padding: 2px 5px;
  border-radius: 6px;
  background: #f2f6f6;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 850;
  white-space: nowrap;
}

.scenario-hit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.scenario-hit-pill {
  display: inline-flex;
  min-height: 20px;
  align-items: center;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f8f6;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 900;
  white-space: nowrap;
}

.scenario-hit-pill.hit {
  border-color: #9ecdc3;
  background: #e8f6f2;
  color: var(--accent);
}

.scenario-hit-pill.miss {
  border-color: #ecc1bd;
  background: #fff1f0;
  color: var(--danger);
}

.scenario-hit-pill.pending {
  border-color: #d7d7c2;
  background: #fffdf4;
  color: #856416;
}

.scenario-value-mark {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
}

.scenario-value-mark span {
  display: inline-flex;
  flex: 0 0 auto;
  min-height: 20px;
  align-items: center;
  padding: 2px 6px;
  border-radius: 6px;
  background: #b35d10;
  color: #fff;
  font-size: 0.64rem;
  font-weight: 950;
  white-space: nowrap;
}

.scenario-value-mark small {
  min-width: 0;
  overflow: hidden;
  color: #785215;
  font-size: 0.64rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-mini-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.line-mini {
  display: inline-flex;
  max-width: 100%;
  min-height: 28px;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.72rem;
}

.line-mini b {
  color: var(--text);
}

.line-mini em {
  font-style: normal;
}

.line-tactical-mini,
.line-tactical-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.line-tactical-main,
.line-tactical-tag,
.basis-pill {
  display: inline-flex;
  min-height: 23px;
  align-items: center;
  gap: 5px;
  border-radius: 7px;
  font-size: 0.68rem;
  line-height: 1;
}

.line-tactical-main {
  padding: 4px 7px;
  background: #eef6f4;
  color: var(--accent);
  font-weight: 800;
}

.line-tactical-tag {
  padding: 4px 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.line-tactical-tag b {
  color: var(--text);
}

.line-tactical-tag.initiative {
  border-color: #b7d8d0;
  background: #f0faf7;
}

.line-tactical-tag.break {
  border-color: #edd0a8;
  background: #fff8ec;
}

.line-tactical-tag.chaser,
.line-tactical-tag.upset,
.line-tactical-tag.upset_rider {
  border-color: #cbd7ee;
  background: #f3f7ff;
}

.line-tactical-tag.front_conflict,
.line-tactical-tag.line_detach,
.line-tactical-tag.front_dominance {
  border-color: #efc9bd;
  background: #fff3ef;
  color: #7a3b24;
}

.line-tactical-tag.line_escape {
  border-color: #b7d8d0;
  background: #f0faf7;
}

.line-tactical-tag em,
.basis-pill {
  color: var(--muted);
  font-style: normal;
}

.line-tactical-block {
  border-color: #cfded9;
  background: linear-gradient(180deg, #fbfefd, #ffffff);
}

.line-tactical-story {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.55;
}

.flow-question-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 8px;
}

.flow-question-card {
  position: relative;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid #d6dfde;
  border-radius: 8px;
  background: #f7f9f9;
}

.flow-question-card.good {
  border-color: #b8dcd5;
  background: #eef8f5;
}

.flow-question-card.warn {
  border-color: #efc9bd;
  background: #fff3ef;
}

.flow-question-card span,
.flow-question-card small,
.flow-question-card em {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.66rem;
  font-style: normal;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-question-card strong {
  display: block;
  min-height: 1.2em;
  margin: 2px 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-question-card em {
  position: absolute;
  top: 6px;
  right: 7px;
}

.scenario-list {
  display: grid;
  gap: 5px;
  margin: 0 0 8px;
}

.scenario-chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 5px 7px;
  align-items: baseline;
  padding: 6px 7px;
  border: 1px solid #d6dfde;
  border-radius: 8px;
  background: #f7f9f9;
}

.scenario-chip.front_conflict,
.scenario-chip.line_detach,
.scenario-chip.front_dominance {
  border-color: #efc9bd;
  background: #fff3ef;
}

.scenario-chip.line_escape {
  border-color: #b8dcd5;
  background: #eef8f5;
}

.scenario-chip span,
.scenario-chip em,
.scenario-chip small {
  color: var(--muted);
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 800;
}

.scenario-chip strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scenario-chip small {
  grid-column: 1 / -1;
  font-weight: 700;
  line-height: 1.35;
}

.scenario-bet-block {
  border-color: #d7d7c2;
  background: #fffdf4;
}

.scenario-bet-list {
  display: grid;
  gap: 6px;
}

.scenario-bet-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-items: center;
  padding: 7px;
  border: 1px solid #e6ddba;
  border-radius: 8px;
  background: #fff;
}

.scenario-bet-card.marked {
  border-color: #e2b05d;
  background: #fff9e9;
  box-shadow: inset 3px 0 0 #c9891f;
}

.scenario-bet-card span,
.scenario-bet-card small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.scenario-bet-card strong {
  display: block;
  margin-top: 2px;
  font-size: 0.92rem;
}

.scenario-bet-card em {
  display: inline-grid;
  min-width: 27px;
  height: 24px;
  padding: 0 7px;
  place-items: center;
  border-radius: 8px;
  background: #123f39;
  color: #fff;
  font-style: normal;
  font-weight: 900;
}

.scenario-bet-card.marked em {
  background: #b35d10;
}

.scenario-bet-card small {
  grid-column: 1 / -1;
  font-weight: 700;
  line-height: 1.45;
}

.scenario-bet-formation {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.scenario-bet-formation span {
  display: inline-grid;
  min-height: 26px;
  place-items: center;
  padding: 3px 7px;
  border: 1px solid #d7c57e;
  border-radius: 7px;
  background: #fff3bd;
  color: #2b2819;
  font-size: 0.8rem;
  font-weight: 950;
  line-height: 1.1;
  white-space: nowrap;
}

.scenario-bet-details {
  grid-column: 1 / -1;
}

.scenario-bet-details summary {
  width: fit-content;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  list-style-position: inside;
}

.scenario-bet-ticket-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 4px;
  margin-top: 4px;
}

.scenario-bet-ticket-grid span {
  display: inline-grid;
  min-height: 28px;
  place-items: center;
  padding: 3px 6px;
  border: 1px solid #eadfbd;
  border-radius: 6px;
  background: #fffaf0;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.line-tactical-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.line-tactical-metric {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.line-tactical-metric span,
.line-tactical-metric em {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-style: normal;
}

.line-tactical-metric strong {
  display: block;
  margin: 4px 0;
  color: var(--text);
}

.mini-car-row {
  display: inline-flex;
  gap: 2px;
}

.mini-car {
  display: inline-grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border: 1px solid #202626;
  border-radius: 5px;
  font-style: normal;
  font-weight: 800;
  font-size: 0.64rem;
  line-height: 1;
}

.mini-car-1 { background: #fff; color: #111; }
.mini-car-2 { background: #151515; color: #fff; }
.mini-car-3 { background: #d92525; color: #fff; }
.mini-car-4 { background: #1f67c9; color: #fff; }
.mini-car-5 { background: #ffd63b; color: #111; }
.mini-car-6 { background: #15925a; color: #fff; }
.mini-car-7 { background: #ee7f22; color: #111; }
.mini-car-8 { background: #f4a1bd; color: #111; }
.mini-car-9 { background: #8b4fc8; color: #fff; }

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

.detail-title-actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.share-button {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 0 12px;
  font-weight: 850;
  box-shadow: 0 4px 12px rgba(19, 44, 41, 0.12);
}

.share-button:focus-visible {
  outline: 3px solid rgba(0, 121, 107, 0.22);
  outline-offset: 2px;
}

.detail-title h2 {
  font-size: 1.12rem;
}

.detail-sub {
  margin-top: 2px;
  font-size: 0.76rem;
}

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

.detail-grid {
  margin-bottom: 10px;
}

.candidate-meta {
  margin-top: 10px;
}

.meta-box {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.meta-box span {
  display: block;
  margin-bottom: 2px;
  font-size: 0.68rem;
}

.meta-box strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.section-block {
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.section-block h3 {
  margin-bottom: 6px;
}

.order-compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.order-compare-card {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.order-compare-card > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
}

.accent-block {
  padding: 12px;
  border: 1px solid #b8ded8;
  border-radius: 8px;
  background: var(--accent-weak);
}

.car-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.car {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid #202626;
  border-radius: 7px;
  font-weight: 800;
  line-height: 1;
}

.car-1 {
  background: #fff;
  color: #111;
}

.car-2 {
  background: #151515;
  color: #fff;
}

.car-3 {
  background: #d92525;
  color: #fff;
}

.car-4 {
  background: #1f67c9;
  color: #fff;
}

.car-5 {
  background: #ffd63b;
  color: #111;
}

.car-6 {
  background: #15925a;
  color: #fff;
}

.car-7 {
  background: #ee7f22;
  color: #111;
}

.car-8 {
  background: #f4a1bd;
  color: #111;
}

.car-9 {
  background: #8b4fc8;
  color: #fff;
}

.grade,
.hit-pill {
  display: inline-flex;
  min-width: 28px;
  height: 23px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  padding: 0 6px;
  font-weight: 800;
  font-size: 0.72rem;
}

.grade-S,
.grade-A {
  background: #006b5f;
  color: #fff;
}

.grade-B {
  background: #1f6ad5;
  color: #fff;
}

.grade-C {
  background: #e7b13a;
  color: #111;
}

.grade-D {
  background: #d8dddd;
  color: #344;
}

.hit-pill {
  background: #eef1f1;
  color: var(--muted);
}

.hit-pill.hit,
.hit-pill.hit-perfect,
.hit-pill.hit-trio,
.hit-pill.hit-exact2,
.hit-pill.hit-pair2,
.hit-pill.hit-wide {
  background: #dcf4ed;
  color: #006b5f;
}

.hit-pill.hit-perfect {
  background: #006b5f;
  color: #fff;
}

.hit-pill.hit-trio,
.hit-pill.hit-exact2 {
  background: #dcecff;
  color: #0d4f9c;
}

.hit-pill.hit-axis {
  background: #fff3c6;
  color: #745000;
}

.hit-pill.hit-miss {
  background: #f4e7e7;
  color: #a33737;
}

.hit-pill.hit-pending {
  background: #eef1f1;
  color: var(--muted);
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.section-title-row h3 {
  margin-bottom: 0;
}

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

.hit-flag {
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.hit-flag span,
.hit-flag strong {
  display: block;
}

.hit-flag span {
  color: var(--muted);
  font-size: 0.68rem;
}

.hit-flag strong {
  margin-top: 2px;
  color: #a33737;
  font-size: 0.88rem;
}

.hit-flag.ok strong {
  color: #006b5f;
}

.line-dynamics-grid {
  display: grid;
  gap: 6px;
}

.line-card {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.line-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.line-card-head strong,
.line-card-sub {
  display: block;
}

.line-card-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
}

.composition-chip,
.line-type-chip {
  flex: 0 0 auto;
  padding: 3px 7px;
  border: 1px solid #b8ded8;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 800;
  font-size: 0.68rem;
}

.line-type-chip {
  border-color: #c7d4e8;
  background: #eef5ff;
  color: #174b83;
}

.line-chip-stack {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.order-chip {
  display: inline-flex;
  min-height: 21px;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  background: #eef1f1;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.66rem;
}

.order-chip.actual {
  background: #dcecff;
  color: #0d4f9c;
}

.order-chip.proxy {
  background: #fff3c6;
  color: #745000;
}

.line-warning {
  margin: -2px 0 6px;
  color: #9a5b00;
  font-size: 0.7rem;
  line-height: 1.35;
}

.line-card-cars {
  margin-bottom: 7px;
}

.line-role-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: -2px 0 8px;
}

.line-role-strip span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 3px;
  border: 1px solid #d8e1e1;
  border-radius: 999px;
  background: #fbfdfd;
  color: var(--ink);
  font-size: 0.66rem;
  font-weight: 750;
}

.line-role-strip .car {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 6px;
  font-size: 0.72rem;
}

.line-role-strip em {
  color: var(--muted);
  font-style: normal;
  font-weight: 700;
}

.line-power-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5eaea;
}

.line-power-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #00796b, #2a84d8);
}

.line-power-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.68rem;
}

.pattern-chip {
  padding: 2px 7px;
  border-radius: 999px;
  background: #e9f3ff;
  color: #0d4f9c;
  font-weight: 800;
}

.line-forecast {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px dashed #cfd9d9;
}

.line-forecast-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 5px;
}

.line-forecast-head span,
.line-forecast-head em,
.line-forecast-row span,
.line-forecast-row em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
}

.line-forecast-head strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-forecast-reading {
  margin: -1px 0 6px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.line-risk-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 8px;
}

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

.line-shape-chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 3px 8px;
  align-items: baseline;
  margin: 0 0 8px;
  padding: 6px 7px;
  border: 1px solid #d6dfde;
  border-radius: 8px;
  background: #f7f9f9;
}

.line-shape-chip span,
.line-shape-chip em {
  color: var(--muted);
  font-size: 0.66rem;
  font-style: normal;
  font-weight: 800;
}

.line-shape-chip strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-shape-chip em {
  grid-column: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-shape-chip small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.45;
}

.line-relative-chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  margin: 0 0 8px;
  padding: 6px 7px;
  border: 1px solid #d6dfde;
  border-radius: 8px;
  background: #f7f9f9;
}

.line-relative-chip span,
.line-relative-chip em {
  color: var(--muted);
  font-size: 0.66rem;
  font-style: normal;
  font-weight: 800;
}

.line-relative-chip strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-relative-chip.good {
  border-color: #b8dcd5;
  background: #eef8f5;
}

.line-relative-chip.warn {
  border-color: #efc9bd;
  background: #fff3ef;
}

.line-risk-chip {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid #d8e1e0;
  border-radius: 8px;
  background: #f6f8f8;
}

.line-risk-chip span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-risk-chip strong {
  color: var(--text);
  font-size: 0.72rem;
}

.line-risk-chip.good {
  border-color: #b9d9d1;
  background: #edf8f5;
}

.line-risk-chip.warn {
  border-color: #efc9bd;
  background: #fff3ef;
}

.line-forecast-bars {
  display: grid;
  gap: 4px;
}

.line-forecast-caption {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 850;
}

.line-forecast-row {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) 40px;
  gap: 6px;
  align-items: center;
}

.line-forecast-row b {
  display: block;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5eaea;
}

.line-forecast-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #0a7368;
}

.line-forecast-row em {
  text-align: right;
}

.entry-list {
  display: grid;
  gap: 6px;
}

.entry-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) minmax(164px, auto);
  gap: 8px;
  align-items: center;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.entry-main {
  min-width: 0;
}

.entry-main strong,
.entry-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-probs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  color: var(--muted);
  font-size: 0.7rem;
}

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

.ticket {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.ticket strong,
.ticket span {
  display: block;
}

.ticket span {
  margin-top: 4px;
  font-size: 0.82rem;
}

.reason-list,
.ticket-list {
  margin: 0;
  padding-left: 1.2em;
}

.reason-list li,
.ticket-list li {
  margin: 6px 0;
}

.ticket-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 920px) {
  .shell {
    padding: 12px;
  }

  .topbar {
    display: block;
  }

  .status {
    display: inline-flex;
    margin-top: 12px;
  }

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

  .toolbar {
    grid-template-columns: 1fr;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .track-race-grid {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }

  .detail-grid,
  .candidate-meta,
  .ticket-grid,
  .hit-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 520px) {
  .shell {
    padding: 8px;
  }

  .metric-grid {
    gap: 8px;
  }

  .metric-card {
    padding: 12px;
  }

  .metric-value {
    font-size: 1.32rem;
  }

  .panel {
    padding: 8px;
  }

  .mode-tabs {
    gap: 6px;
  }

  .mode-tabs button,
  .segmented button {
    min-height: 32px;
    padding: 0 9px;
    font-size: 0.82rem;
  }

  .track-race-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .detail-grid,
  .candidate-meta,
  .ticket-grid,
  .hit-summary-grid,
  .line-tactical-grid {
    grid-template-columns: 1fr;
  }

  .order-compare-grid {
    grid-template-columns: 1fr;
  }

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

  .entry-row {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .entry-probs {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .race-card-head,
  .candidate-top {
    align-items: flex-start;
  }

  .race-card-foot {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px 12px;
  }

  .line-card-head,
  .section-title-row {
    display: grid;
    justify-items: start;
  }

  .line-chip-stack {
    justify-content: flex-start;
  }

  .line-mini {
    font-size: 0.7rem;
  }
}
