:root {
  color-scheme: light;
  --ink: #162029;
  --muted: #5f6d7d;
  --line: #d7e0e8;
  --line-strong: #c3cfdb;
  --panel: #ffffff;
  --surface: #f7faf8;
  --surface-muted: #eef3f0;
  --paper: #edf2ef;
  --accent: #0f7a63;
  --accent-strong: #0a5a4a;
  --accent-soft: rgba(15, 122, 99, .1);
  --gold: #c9922e;
  --danger: #c23f3f;
  --success: #0f7a63;
  --win: #e8f6f1;
  --shadow-sm: 0 8px 24px rgba(22, 32, 41, .06);
  --shadow: 0 18px 42px rgba(22, 32, 41, .1);
  --shadow-lg: 0 24px 60px rgba(22, 32, 41, .14);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --sidebar: #121c25;
  --sidebar-elevated: #1a2732;
  --sidebar-text: #e8f0ec;
  --sidebar-muted: #9aabb8;
  --mobile-nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  line-height: 1.5;
  background:
    radial-gradient(circle at top left, rgba(15, 122, 99, .08), transparent 28%),
    radial-gradient(circle at top right, rgba(201, 146, 46, .05), transparent 24%),
    linear-gradient(180deg, #fcfdfb 0%, var(--paper) 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mobile-header,
.bottom-nav {
  display: none;
}

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

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
  border-right: 1px solid rgba(255, 255, 255, .06);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .04), transparent 18%),
    linear-gradient(180deg, var(--sidebar) 0%, #0f171f 100%);
  color: var(--sidebar-text);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  overflow: hidden;
  background: #f4f1e8;
  flex-shrink: 0;
}

.brand-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: .02em;
}

.brand p {
  margin: 4px 0 0;
  color: var(--sidebar-muted);
  font-size: 12px;
}

.nav-tabs {
  display: grid;
  gap: 6px;
}

.tab-button,
.ghost-button,
.danger-button,
.primary-button {
  min-height: 46px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0 16px;
  font-weight: 700;
  transition: transform .16s ease, background-color .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.tab-button:active,
.primary-button:active,
.ghost-button:active,
.danger-button:active {
  transform: translateY(1px);
}

.tab-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  color: var(--sidebar-muted);
  background: transparent;
  text-align: left;
}

.tab-button:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.tab-button.active {
  background: linear-gradient(90deg, rgba(15, 122, 99, .34), rgba(15, 122, 99, .12));
  color: #fff;
  box-shadow: inset 3px 0 0 #3fd0a8;
}

.tab-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
  font-size: 14px;
  flex-shrink: 0;
}

.tab-button.active .tab-icon {
  background: rgba(255, 255, 255, .14);
}

.status-panel {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .05);
  backdrop-filter: blur(8px);
}

.status-panel div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.status-panel strong {
  font-size: 18px;
}

.label {
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
}

.file-input {
  display: none;
}

.import-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.ghost-button {
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
}

.ghost-button:hover {
  background: var(--surface);
  border-color: var(--line-strong);
}

.danger-button {
  color: #fff;
  background: linear-gradient(180deg, #d45656, var(--danger));
  box-shadow: 0 8px 18px rgba(194, 63, 63, .22);
}

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

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
  align-content: start;
}

#summaryView.view.active {
  gap: 22px;
}

.event-name-panel {
  margin-bottom: 0;
  padding: 18px 20px;
  border: 1px solid rgba(15, 122, 99, .14);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #fff, var(--surface));
  box-shadow: var(--shadow-sm);
}

.event-name-field span {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.event-name-field input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
}

.view:not(#summaryView) > .page-head {
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .98), rgba(247, 250, 248, .98));
  box-shadow: var(--shadow-sm);
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h2,
h3 {
  margin: 0;
  letter-spacing: -.01em;
}

h2 {
  font-size: 32px;
  line-height: 1.15;
}

h3 {
  margin-bottom: 12px;
  font-size: 18px;
}

.race-chip {
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
}

.head-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.race-chip.over-limit,
.stake-preview.over-limit {
  border-color: rgba(179, 59, 59, .45);
  background: #fff5f5;
  color: var(--danger);
}

.entry-details {
  margin-bottom: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.entry-summary {
  padding: 18px 22px;
  color: var(--accent-strong);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
  background: linear-gradient(180deg, var(--surface), #fff);
  border-bottom: 1px solid transparent;
}

.entry-details[open] .entry-summary {
  border-bottom-color: var(--line);
}

.entry-summary::-webkit-details-marker {
  display: none;
}

.entry-summary::before {
  content: "▸ ";
}

.entry-details[open] .entry-summary::before {
  content: "▾ ";
}

.entry-form,
.toolbar,
.metric-grid,
.master-grid,
.summary-layout {
  display: grid;
  gap: 14px;
}

.entry-form {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  padding: 0 22px 22px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  transition: border-color .16s ease, box-shadow .16s ease;
}

textarea {
  min-height: 110px;
  padding: 12px 14px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(15, 122, 99, .45);
  box-shadow: 0 0 0 4px rgba(15, 122, 99, .12);
}

.wide {
  grid-column: span 2;
}

.selection-builder {
  display: grid;
  grid-column: 1 / -1;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--surface);
}

.selection-builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.selection-builder-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.selection-builder-head strong {
  color: var(--accent-strong);
  font-size: 14px;
  overflow-wrap: anywhere;
  text-align: right;
}

.selection-builder-head strong.over-limit {
  color: var(--danger);
}

.selection-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
}

.wide-submit {
  grid-column: 1 / -1;
}

.form-note,
.stake-preview,
.setting-note,
.share-lead,
.results-lead {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.form-note {
  min-height: 44px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--surface);
}

.stake-preview {
  min-height: 48px;
  border: 1px solid rgba(15, 122, 99, .18);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--win);
  color: var(--accent-strong);
  font-weight: 800;
}

.setting-note {
  margin: -4px 0 0;
}

.primary-button {
  color: #fff;
  background: linear-gradient(180deg, #18a383, var(--accent-strong));
  box-shadow: 0 10px 22px rgba(15, 122, 99, .24);
}

.primary-button:hover {
  background: linear-gradient(180deg, #1bb190, #0c6554);
}

.toolbar {
  grid-template-columns: 200px 200px minmax(220px, 1fr);
  margin-bottom: 0;
  align-items: end;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

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

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

th {
  color: var(--muted);
  background: linear-gradient(180deg, #f8fbfa, #f1f5f3);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr {
  transition: background-color .14s ease;
}

tbody tr:hover {
  background: rgba(15, 122, 99, .04);
}

td {
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.amount,
.profit,
.loss {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.profit {
  color: var(--accent-strong);
  font-weight: 800;
}

.loss {
  color: var(--danger);
  font-weight: 800;
}

.delete-row {
  min-width: 42px;
  min-height: 42px;
  border: 1px solid rgba(194, 63, 63, .18);
  border-radius: var(--radius-sm);
  background: #fff7f7;
  color: var(--danger);
  font-weight: 800;
  transition: background-color .16s ease, border-color .16s ease;
}

.delete-row:hover {
  background: #ffecec;
  border-color: rgba(194, 63, 63, .35);
}

.edit-row {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius-sm);
  background: var(--win);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.edit-row:hover {
  background: #dff3eb;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  background: var(--surface-muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.hit {
  background: var(--win);
  color: var(--accent-strong);
}

.badge.miss {
  background: #fff1f1;
  color: var(--danger);
}

.empty,
.empty-card {
  color: var(--muted);
  text-align: center;
}

.empty {
  height: 120px;
  vertical-align: middle;
}

.empty-card {
  padding: 36px 18px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin-bottom: 22px;
}

.metric {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.summary-layout {
  grid-template-columns: 1.2fr .8fr;
}

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

#summaryView .summary-top-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
}

#summaryView .summary-top-meta .summary-event-name {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

#summaryView .summary-top-meta .summary-hero-badge {
  margin-left: auto;
}

#summaryView .summary-hero {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(18, 109, 90, .18);
  border-radius: 22px;
  padding: 28px 30px;
  background:
    radial-gradient(circle at top right, rgba(201, 146, 46, .22), transparent 28%),
    linear-gradient(135deg, #0f5f4f 0%, #126d5a 48%, #1a8a72 100%);
  color: #f7fffb;
  box-shadow: var(--shadow);
}

#summaryView .summary-hero-glow {
  position: absolute;
  inset: auto -80px -120px auto;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  filter: blur(8px);
  pointer-events: none;
}

#summaryView .summary-hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

#summaryView .summary-hero-copy h2 {
  margin: 0;
  font-size: 38px;
  letter-spacing: .02em;
}

#summaryView .summary-hero-copy .eyebrow {
  color: rgba(255, 255, 255, .72);
}

#summaryView .summary-event-name {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, .88);
  font-size: 18px;
  font-weight: 700;
}

#summaryView .summary-hero-badge {
  min-width: 220px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 16px;
  background: rgba(255, 255, 255, .12);
  backdrop-filter: blur(8px);
  text-align: right;
}

#summaryView .summary-hero-badge-label {
  display: block;
  color: rgba(255, 255, 255, .72);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

#summaryView .summary-hero-badge strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

#summaryView .summary-hero-badge-meta {
  display: block;
  margin-top: 6px;
  color: rgba(255, 255, 255, .82);
  font-size: 14px;
  font-weight: 700;
}

#summaryView .summary-podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
}

#summaryView .podium-card {
  position: relative;
  padding: 22px 20px 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f7faf8 100%);
  box-shadow: 0 14px 30px rgba(28, 38, 49, .08);
}

#summaryView .podium-card.rank-1 {
  min-height: 290px;
  border-color: rgba(201, 146, 46, .45);
  background: linear-gradient(180deg, #fffdf7 0%, #fff7e8 100%);
  transform: translateY(-10px);
}

#summaryView .podium-card.rank-2 {
  min-height: 250px;
  border-color: rgba(120, 132, 148, .35);
}

#summaryView .podium-card.rank-3 {
  min-height: 230px;
  border-color: rgba(176, 118, 72, .35);
}

#summaryView .podium-name {
  margin: 12px 0 6px;
  font-size: 24px;
}

#summaryView .podium-profit {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 800;
}

#summaryView .podium-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

#summaryView .podium-stats div {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(18, 109, 90, .06);
}

#summaryView .podium-stats dt {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

#summaryView .podium-stats dd {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 800;
}

#summaryView .rank-badge {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  height: 42px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 800;
}

#summaryView .rank-badge.rank-1 {
  background: linear-gradient(180deg, #f6d57b, #c9922e);
  color: #5f4108;
  box-shadow: 0 8px 18px rgba(201, 146, 46, .28);
}

#summaryView .rank-badge.rank-2 {
  background: linear-gradient(180deg, #edf1f5, #b7c0cb);
  color: #42505f;
}

#summaryView .rank-badge.rank-3 {
  background: linear-gradient(180deg, #f0d2b4, #b87648);
  color: #5f3d22;
}

#summaryView .rank-badge.rank-other {
  background: #eef2ef;
  color: var(--accent-strong);
}

#summaryView .summary-table-section {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(247, 250, 248, .98)),
    var(--panel);
  box-shadow: 0 16px 36px rgba(28, 38, 49, .06);
}

#summaryView .summary-table-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

#summaryView .summary-table-head h3 {
  margin: 0;
  font-size: 22px;
}

#summaryView .summary-table-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

#summaryView .summary-table-wrap {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

#summaryView .summary-table {
  min-width: 0;
}

#summaryView .summary-table thead th {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f8fbf9, #f1f5f2);
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

#summaryView .summary-table tbody tr {
  transition: background-color .18s ease, transform .18s ease;
}

#summaryView .summary-table tbody tr:hover {
  background: rgba(18, 109, 90, .04);
}

#summaryView .summary-table tbody tr.rank-1 {
  background: linear-gradient(90deg, rgba(201, 146, 46, .12), rgba(201, 146, 46, .03));
}

#summaryView .summary-table tbody tr.rank-2 {
  background: linear-gradient(90deg, rgba(120, 132, 148, .12), rgba(120, 132, 148, .03));
}

#summaryView .summary-table tbody tr.rank-3 {
  background: linear-gradient(90deg, rgba(176, 118, 72, .12), rgba(176, 118, 72, .03));
}

#summaryView .summary-table td {
  padding: 20px;
  font-size: 20px;
}

#summaryView .summary-rank-cell {
  width: 88px;
  text-align: center;
}

#summaryView .summary-name-cell {
  min-width: 180px;
}

#summaryView .summary-participant-name {
  display: block;
  font-size: 24px;
  font-weight: 800;
}

#summaryView .summary-profit {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 700;
}

#summaryView .summary-table td.amount {
  font-size: 22px;
  font-weight: 700;
}

#summaryView .summary-card {
  padding: 22px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbf9 100%);
  box-shadow: 0 12px 28px rgba(28, 38, 49, .07);
}

#summaryView .summary-card.rank-1 {
  border-color: rgba(201, 146, 46, .45);
}

#summaryView .summary-card.rank-2 {
  border-color: rgba(120, 132, 148, .35);
}

#summaryView .summary-card.rank-3 {
  border-color: rgba(176, 118, 72, .35);
}

#summaryView .summary-card + .summary-card {
  margin-top: 14px;
}

#summaryView .summary-card-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

#summaryView .ticket-card-title {
  font-size: 22px;
  line-height: 1.35;
}

#summaryView .summary-card-profit {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 700;
}

#summaryView .summary-card-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

#summaryView .summary-card-stats div {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(18, 109, 90, .05);
}

#summaryView .summary-card-stats span {
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

#summaryView .summary-card-stats strong {
  margin-top: 6px;
  font-size: 22px;
}

#summaryView .empty-card {
  padding: 32px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .7);
  color: var(--muted);
  font-size: 18px;
  text-align: center;
}

.summary-layout > section,
.master-grid > section {
  min-width: 0;
}

.compact table {
  min-width: 560px;
}

.master-grid {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.panel-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, #fff, var(--surface));
  box-shadow: var(--shadow-sm);
}

.panel-card h3 {
  color: var(--accent-strong);
}

.wide-card {
  grid-column: 1 / -1;
}

.event-name-field {
  display: grid;
  gap: 8px;
}

.item-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: #fff;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.item-list li:hover {
  border-color: rgba(15, 122, 99, .22);
  box-shadow: var(--shadow-sm);
}

.ticket-card,
.summary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #fff, var(--surface));
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 90px;
  gap: 10px;
  margin-bottom: 14px;
}

.inline-form.stacked {
  grid-template-columns: 1fr;
}

.inline-form.stacked label {
  display: grid;
  gap: 6px;
}

.inline-form.stacked label span {
  font-size: 13px;
  color: var(--muted);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.race-title-fetch {
  display: grid;
  gap: 6px;
}

.race-title-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.race-title-status.is-success {
  color: var(--accent-strong);
}

.race-title-status.is-error {
  color: var(--danger);
}

.form-actions .wide-submit,
.form-actions .primary-button,
.form-actions .ghost-button {
  flex: 1 1 140px;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.item-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.item-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.item-meta {
  color: var(--muted);
  font-size: 12px;
}

.ticket-list-mobile,
.summary-cards {
  display: none;
}

.ticket-card + .ticket-card,
.summary-card + .summary-card {
  margin-top: 12px;
}

.ticket-card-head,
.summary-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.ticket-card-title {
  font-size: 17px;
  font-weight: 800;
}

.ticket-card-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.ticket-card-body {
  display: grid;
  gap: 8px;
}

.ticket-card-selection {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f7faf8;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  word-break: break-word;
}

.ticket-card-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ticket-card-meta div,
.summary-card-stats div {
  padding: 8px 10px;
  border-radius: 8px;
  background: #f7faf8;
}

.ticket-card-meta span,
.summary-card-stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.ticket-card-meta strong,
.summary-card-stats strong {
  display: block;
  margin-top: 2px;
  font-size: 15px;
}

.ticket-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.summary-card-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.summary-card-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--win);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.share-panel {
  max-width: 720px;
}

.draft-panel {
  margin-bottom: 0;
}

.draft-panel-head h3 {
  margin-bottom: 6px;
  font-size: 17px;
  color: var(--accent-strong);
}

.draft-panel-note,
.privacy-hint,
.compliance-notice,
.results-lead,
.share-lead {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.privacy-hint {
  border-style: dashed;
}

.compliance-notice {
  display: grid;
  gap: 4px;
  border-color: rgba(201, 146, 46, .32);
  background: #fffaf0;
}

.compliance-notice strong {
  color: #805a14;
  font-size: 13px;
}

.compliance-notice span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.privacy-notice {
  margin-bottom: 0;
  border: 1px solid rgba(15, 122, 99, .2);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--win), #fff);
  box-shadow: var(--shadow-sm);
}

.privacy-notice p {
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.7;
}

.draft-actions {
  display: grid;
  gap: 10px;
  margin: 14px 0 10px;
}

.draft-status {
  font-size: 13px;
  color: var(--muted);
}

.draft-status.is-success {
  color: var(--success);
  font-weight: 700;
}

.draft-status.is-error {
  color: var(--danger);
  font-weight: 700;
}

.share-actions {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.share-button {
  width: 100%;
}

.share-note {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.share-note h3 {
  margin-bottom: 8px;
  font-size: 15px;
  color: var(--accent-strong);
}

.share-note ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.share-danger {
  width: 100%;
  margin-top: 18px;
}

.usage-guide-link {
  margin: 0;
  padding: 12px 16px;
  border: 1px solid rgba(15, 122, 99, .12);
  border-radius: var(--radius-md);
  background: rgba(15, 122, 99, .05);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-strong);
  font: inherit;
  font-size: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-button:hover {
  color: #084a3d;
}

.tab-label--short {
  display: none;
}

.desktop-nav .tab-label--full {
  display: inline;
}

.guide-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}

.guide-layout--solo {
  grid-template-columns: 1fr;
  max-width: 760px;
}

.legal-document {
  display: grid;
  gap: 22px;
  padding: 24px 26px;
}

.legal-updated {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.legal-section h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.legal-section p,
.legal-section li {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.legal-section ul {
  margin: 0;
  padding-left: 1.25em;
}

.legal-section a {
  color: var(--accent-strong);
  word-break: break-all;
}

.legal-table-wrap {
  margin: 8px 0 12px;
}

.legal-table {
  width: 100%;
  font-size: 13px;
}

.legal-table th,
.legal-table td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.guide-card {
  display: grid;
  gap: 10px;
}

.guide-card h3 {
  margin-bottom: 2px;
}

.guide-card details {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  overflow: hidden;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.guide-card details[open] {
  border-color: rgba(15, 122, 99, .24);
  box-shadow: var(--shadow-sm);
}

.guide-card summary {
  padding: 14px 16px;
  color: var(--accent-strong);
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(180deg, var(--surface), #fff);
}

.guide-card p,
.guide-card ol {
  margin: 0;
  padding: 0 16px 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.guide-card ol {
  padding-left: 32px;
}

.guide-note {
  padding: 0;
}

.results-lead {
  margin: 0;
}

.results-import {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.results-import-head h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.results-import-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.results-import-link-row {
  margin: 8px 0 0;
}

.results-import-link {
  display: inline-flex;
  align-items: center;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.results-import-link:hover {
  color: var(--accent);
}

.results-import-fallback summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  user-select: none;
}

.results-import-fallback[open] summary {
  margin-bottom: 10px;
}

.results-import-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.results-target-race {
  display: grid;
  gap: 6px;
}

.results-target-race-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 28, 36, 0.45);
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: min(640px, 100%);
  max-height: min(84vh, 820px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, #fff, var(--surface));
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

.modal-head h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.modal-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.modal-body {
  display: grid;
  gap: 14px;
  margin: 16px 0;
}

.modal-summary {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--win);
}

.modal-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.modal-summary-row span {
  color: var(--muted);
}

.modal-summary-row strong {
  text-align: right;
}

.modal-warning {
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff4f0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.6;
}

.modal-section h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.modal-finish-list,
.modal-payout-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.7;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions .primary-button,
.modal-actions .ghost-button {
  min-width: 120px;
}

.results-import-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.results-import-status.is-success {
  color: var(--accent-strong);
  font-weight: 700;
}

.results-import-status.is-error {
  color: #b33b3b;
  font-weight: 700;
}

.jra-payout-reference {
  border-top: 1px dashed var(--line);
  padding-top: 14px;
}

.jra-payout-reference-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.jra-payout-reference-head h4 {
  margin: 0;
  font-size: 14px;
}

.jra-payout-reference-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.jra-payout-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.jra-payout-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfa;
  overflow: hidden;
}

.jra-payout-section h5 {
  margin: 0;
  padding: 8px 10px;
  background: #f3f5f2;
  font-size: 12px;
}

.jra-payout-section table {
  width: 100%;
  min-width: 0;
}

.jra-payout-section th,
.jra-payout-section td {
  padding: 6px 8px;
  font-size: 12px;
}

.results-manual {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.results-manual-head h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.results-manual-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.manual-finish-row {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.manual-payout-grid {
  display: grid;
  gap: 10px;
}

.manual-payout-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfa;
  padding: 12px;
}

.manual-payout-section h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.manual-payout-fields {
  display: grid;
  gap: 8px;
}

.manual-payout-field {
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(88px, 1fr) minmax(110px, 1fr);
  align-items: end;
}

.manual-payout-field span {
  color: var(--muted);
  font-size: 12px;
}

.manual-payout-field input {
  min-height: 40px;
}

.manual-payout-field .combo-preview {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.results-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
}

.results-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.results-toggle input {
  width: 18px;
  height: 18px;
  min-height: 18px;
}

.results-bulk {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.ticket-card.is-hit,
.result-card.is-hit {
  border-color: rgba(15, 122, 99, .3);
  background: linear-gradient(180deg, #f4fbf8, #fff);
  box-shadow: 0 10px 24px rgba(15, 122, 99, .08);
}

.ticket-card.is-miss,
.result-card.is-miss {
  border-color: rgba(194, 63, 63, .22);
  background: linear-gradient(180deg, #fff7f7, #fff);
}

.result-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #fff, var(--surface));
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

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

.result-card-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.result-card-fields label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.result-inline {
  display: grid;
  gap: 6px;
  min-width: 120px;
}

.result-inline span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.result-inline select,
.result-inline input {
  min-height: 40px;
  font-size: 13px;
}

.result-profit {
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ticket-card-result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.ticket-card-result label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.desktop-only-label {
  display: none;
}

@media (min-width: 981px) {
  .desktop-only-label {
    display: inline;
  }

  .ticket-list-desktop .result-inline {
    min-width: 108px;
  }

  .ticket-list-desktop .result-inline--payout {
    min-width: 100px;
  }

  .ticket-list-desktop td .result-profit {
    display: block;
    margin-top: 4px;
    font-size: 12px;
  }
}

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

  .side-panel {
    display: none;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px calc(14px + var(--safe-bottom));
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .04), transparent),
      linear-gradient(180deg, var(--sidebar) 0%, #0f171f 100%);
    color: var(--sidebar-text);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }

  .mobile-brand strong {
    display: block;
    font-size: 15px;
  }

  .mobile-brand span,
  .mobile-stats span {
    color: #b8c4ce;
    font-size: 11px;
  }

  .mobile-brand span {
    display: block;
    margin-top: 2px;
  }

  .mobile-stats {
    display: flex;
    gap: 14px;
    flex-shrink: 0;
  }

  .mobile-stats div {
    text-align: right;
  }

  .mobile-stats strong {
    display: block;
    margin-top: 2px;
    font-size: 16px;
  }

  .main-panel {
    padding: 16px 16px calc(16px + var(--mobile-nav-height) + var(--safe-bottom));
  }

  .bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    min-height: calc(var(--mobile-nav-height) + var(--safe-bottom));
    padding: 8px 8px calc(8px + var(--safe-bottom));
    border-top: 1px solid rgba(255, 255, 255, .1);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .04), transparent),
      linear-gradient(180deg, var(--sidebar) 0%, #0f171f 100%);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, .18);
  }

  .bottom-nav .tab-button {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-height: 52px;
    padding: 4px 2px;
    color: var(--sidebar-muted);
    font-size: 9px;
    text-align: center;
    border-radius: 12px;
  }

  .bottom-nav .tab-button.active {
    background: linear-gradient(180deg, rgba(15, 122, 99, .42), rgba(15, 122, 99, .18));
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
  }

  .bottom-nav .tab-label--short {
    display: inline;
  }

  .bottom-nav .tab-label--full {
    display: none;
  }

  .bottom-nav .tab-icon {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .entry-form,
  .selection-fields,
  .metric-grid,
  .summary-layout,
  .master-grid,
  .guide-layout {
    grid-template-columns: 1fr 1fr;
  }

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

  .toolbar-search {
    grid-column: 1 / -1;
  }

  .ticket-list-desktop,
  #summaryView .summary-layout .table-wrap,
  #summaryView .summary-podium {
    display: none;
  }

  .ticket-list-mobile,
  #summaryView .summary-cards {
    display: block;
  }

  .wide-card {
    grid-column: auto;
  }
}

  .result-card-fields,
  .ticket-card-result {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 901px) {
  #summaryView .summary-cards {
    display: none;
  }
}

@media (max-width: 900px) {
  #summaryView .summary-podium {
    display: none;
  }

  #summaryView .summary-hero-inner {
    flex-direction: column;
    align-items: stretch;
  }

  #summaryView .summary-hero-badge {
    text-align: left;
  }

  #summaryView .summary-table-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  #summaryView .summary-hero-copy h2 {
    font-size: 30px;
  }

  #summaryView .ticket-card-title {
    font-size: 20px;
  }

  #summaryView .summary-card-stats strong {
    font-size: 20px;
  }

  #summaryView .summary-table td,
  #summaryView .summary-table td.amount {
    font-size: 16px;
  }

  #summaryView .summary-participant-name {
    font-size: 18px;
  }
}

@media (max-width: 640px) {
  h2 {
    font-size: 24px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .head-chips {
    justify-content: stretch;
  }

  .entry-form,
  .selection-fields,
  .metric-grid,
  .summary-layout,
  .master-grid,
  .guide-layout,
  .inline-form,
  .inline-form.stacked,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .wide,
  .wide-submit {
    grid-column: auto;
  }

  .race-chip {
    max-width: none;
  }

  .metric strong {
    font-size: 20px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }
}

@media (min-width: 981px) {
  .entry-summary {
    display: none;
  }

  .entry-details {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

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