:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17191d;
  --muted: #68707d;
  --line: #d9dee7;
  --blue: #1f6feb;
  --green: #27845f;
  --orange: #b76100;
  --red: #c8362b;
  --violet: #7157d9;
  --shadow: 0 10px 28px rgba(20, 28, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

.shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar,
.panel-head,
.actions,
.status-row,
.event-row,
.app-option {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow,
.metric-label,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  margin: 0 0 4px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  letter-spacing: 0;
}

.actions {
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 650;
  letter-spacing: 0;
  text-decoration: none;
}

.query-input {
  width: 240px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.query-input:focus {
  border-color: var(--blue);
  outline: 2px solid rgba(31, 111, 235, 0.16);
}

.compact-input {
  width: 100%;
}

.view-card {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

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

.inline-link {
  color: var(--blue);
  font-weight: 650;
  text-decoration: none;
}

.inline-link:hover,
.inline-link:focus {
  text-decoration: underline;
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.compact-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

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

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 16px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.status-list,
.event-list,
.app-picker {
  display: grid;
  gap: 8px;
}

.app-picker {
  max-height: 340px;
  overflow: auto;
  margin: 10px 0 22px;
  padding-right: 4px;
}

.app-picker-search {
  width: 100%;
}

.app-option {
  gap: 10px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfe;
}

.app-option-label {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  gap: 10px;
  cursor: pointer;
}

.app-option input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.app-option-main {
  flex: 1;
  min-width: 0;
}

.app-option strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.app-option .status-meta {
  margin-top: 2px;
  font-size: 12px;
}

.app-icon,
.game-icon,
.event-icon,
.icon-placeholder {
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: cover;
}

.app-icon,
.icon-placeholder {
  width: 34px;
  height: 34px;
}

.game-icon {
  width: 48px;
  height: 48px;
}

.event-icon {
  width: 16px;
  height: 16px;
  margin-right: 5px;
  vertical-align: -3px;
}

.icon-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e8edf5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.icon-upload-button {
  flex: 0 0 auto;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  padding: 0 9px;
}

.icon-upload-button:hover {
  color: var(--ink);
  border-color: var(--blue);
}

.status-row {
  align-items: flex-start;
  justify-content: flex-start;
  gap: 14px;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.status-row-loading {
  background: #f7f9fc;
}

.status-row-error {
  border-color: rgba(200, 54, 43, 0.28);
  background: rgba(200, 54, 43, 0.04);
}

.loading-copy {
  min-width: 0;
}

.loading-grid {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.loading-line {
  display: block;
  width: min(72%, 420px);
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e8edf5, #f2f5f9, #e8edf5);
}

.loading-line-wide {
  width: min(92%, 620px);
}

.loading-line-short {
  width: min(48%, 260px);
}

.status-main {
  min-width: 0;
  width: 100%;
}

.status-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.game-name-button {
  min-width: 0;
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
}

.game-name-button:hover strong,
.game-name-button:focus strong {
  color: var(--blue);
}

.game-name-button:focus {
  outline: none;
}

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

.status-main strong,
.event-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-icon-button {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.game-icon-button:focus {
  outline: 2px solid rgba(31, 111, 235, 0.2);
  outline-offset: 2px;
}

.game-icon-button:hover .game-icon,
.game-icon-button:focus .game-icon {
  box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.24);
}

.reorder-controls {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
}

.details-button,
.notify-button,
.reorder-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  line-height: 1;
}

.details-button {
  width: 30px;
  height: 30px;
  padding: 0;
}

.notify-button {
  position: relative;
  width: 34px;
  height: 30px;
  padding: 0;
}

.details-button:hover,
.notify-button:hover,
.reorder-button:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--ink);
}

.details-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.slack-icon {
  width: 19px;
  height: 19px;
  display: block;
}

.notify-count {
  position: absolute;
  right: -3px;
  top: -5px;
  min-width: 16px;
  height: 16px;
  border: 1px solid #fff;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 10px;
  font-weight: 750;
  line-height: 14px;
  text-align: center;
}

.reorder-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.notify-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.wide-dialog {
  width: min(860px, calc(100vw - 32px));
}

.notify-dialog::backdrop {
  background: rgba(23, 25, 29, 0.28);
}

.notify-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.notify-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.notify-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.notify-textarea {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  font: inherit;
}

.notify-textarea:focus {
  border-color: var(--blue);
  outline: 2px solid rgba(31, 111, 235, 0.16);
}

.notify-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.timeline-list {
  display: grid;
  gap: 8px;
  max-height: min(520px, 60vh);
  overflow: auto;
}

.timeline-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 180px;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
}

.timeline-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.timeline-row.is-reentry {
  border-color: rgba(183, 97, 0, 0.36);
  background: rgba(183, 97, 0, 0.06);
}

.version-history-list {
  display: grid;
  gap: 14px;
  max-height: min(620px, 68vh);
  overflow: auto;
  padding-right: 4px;
}

.version-history-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

.version-history-panel .version-panel-head {
  margin-bottom: 10px;
}

.status-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

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

.version-panel {
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

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

.version-panel-actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.version-panel-head strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.submission-meta {
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -2px 0 10px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid rgba(31, 111, 235, 0.2);
  border-radius: 999px;
  background: rgba(31, 111, 235, 0.08);
  color: #1f4f9f;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 650;
}

.tag-pill-api {
  border-color: rgba(18, 128, 90, 0.22);
  background: rgba(18, 128, 90, 0.08);
  color: #0f684c;
}

.tag-section-head {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.tag-presets,
.tag-api-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-preset {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  gap: 6px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 650;
}

.tag-preset input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--blue);
}

.tag-preset.is-selected {
  border-color: rgba(31, 111, 235, 0.3);
  background: rgba(31, 111, 235, 0.08);
  color: #1f4f9f;
}

.submission-items-popover {
  position: relative;
  display: inline-flex;
}

.submission-items-button {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  padding: 0 8px;
}

.submission-items-button:hover,
.submission-items-button:focus {
  border-color: var(--blue);
  color: var(--ink);
  outline: none;
}

.submission-items-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  display: none;
  width: min(360px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(20, 28, 38, 0.16);
  color: var(--ink);
  padding: 10px;
  text-align: left;
}

.submission-items-tooltip::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 18px;
  width: 10px;
  height: 10px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: #fff;
  transform: rotate(45deg);
}

.submission-items-popover:hover .submission-items-tooltip,
.submission-items-popover:focus-within .submission-items-tooltip {
  display: block;
}

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

.submission-items-list li {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.submission-items-list strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 12px;
}

.submission-items-list span,
.submission-items-list em,
.submission-items-list small,
.submission-items-empty {
  color: var(--muted);
  font-size: 12px;
}

.submission-items-list em {
  display: block;
  font-style: normal;
  line-height: 1.35;
}

.submission-items-list small {
  overflow-wrap: anywhere;
}

.version-panel-empty {
  color: var(--muted);
}

.funnel-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.funnel-step {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  min-height: 42px;
  padding-bottom: 10px;
}

.funnel-step::after {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 0;
  left: 6px;
  width: 2px;
  background: var(--line);
}

.funnel-step:last-child {
  min-height: auto;
  padding-bottom: 0;
}

.funnel-step:last-child::after {
  display: none;
}

.funnel-marker {
  position: relative;
  z-index: 1;
  width: 14px;
  height: 14px;
  margin-top: 2px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: #fff;
}

.funnel-copy {
  min-width: 0;
}

.funnel-label,
.funnel-meta {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.funnel-copy strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
}

.funnel-meta {
  margin-top: 2px;
}

.funnel-step:not(.funnel-not_observed):not(.funnel-not_reached):not(.funnel-unknown).funnel-state-waiting
  .funnel-marker {
  border-color: var(--orange);
  background: var(--orange);
}

.funnel-step:not(.funnel-not_observed):not(.funnel-not_reached):not(.funnel-unknown).funnel-state-review
  .funnel-marker {
  border-color: var(--blue);
  background: var(--blue);
}

.funnel-step:not(.funnel-not_observed):not(.funnel-not_reached):not(.funnel-unknown).funnel-state-ready
  .funnel-marker,
.funnel-step:not(.funnel-not_observed):not(.funnel-not_reached):not(.funnel-unknown).funnel-submitted
  .funnel-marker {
  border-color: var(--green);
  background: var(--green);
}

.funnel-step:not(.funnel-not_observed):not(.funnel-not_reached):not(.funnel-unknown).funnel-state-issue
  .funnel-marker {
  border-color: var(--red);
  background: var(--red);
}

.funnel-step:not(.funnel-not_observed):not(.funnel-not_reached):not(.funnel-unknown).funnel-state-other
  .funnel-marker {
  border-color: var(--violet);
  background: var(--violet);
}

.funnel-step:not(.funnel-not_observed):not(.funnel-not_reached):not(.funnel-unknown).funnel-submitted
  .funnel-marker {
  border-color: var(--green);
  background: var(--green);
}

.funnel-not_observed .funnel-marker,
.funnel-not_reached .funnel-marker,
.funnel-unknown .funnel-marker {
  background: #fff;
}

.chip {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 750;
}

.state-waiting {
  background: var(--orange);
}

.state-review {
  background: var(--blue);
}

.state-ready {
  background: var(--green);
}

.state-issue {
  background: var(--red);
}

.state-other {
  background: var(--violet);
}

.event-row {
  align-items: flex-start;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.event-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--blue);
}

.event-dot.state-waiting {
  background: var(--orange);
}

.event-dot.state-review {
  background: var(--blue);
}

.event-dot.state-ready {
  background: var(--green);
}

.event-dot.state-issue {
  background: var(--red);
}

.event-dot.state-other {
  background: var(--violet);
}

.recent-head {
  margin-top: 22px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.list-note {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.admin-grid,
.metric-grid {
  display: grid;
  gap: 16px;
}

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

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

.metric-box {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

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

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-icon-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 170px;
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.factor-breakdowns {
  display: grid;
  gap: 18px;
}

.factor-breakdown h3 {
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing: 0;
}

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

.insight-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

.takeaway-panel {
  grid-column: 1 / -1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

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

.insight-card h3 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0;
}

.insight-guidance {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.readiness-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #e8edf5;
  color: var(--muted);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.readiness-directional .readiness-pill {
  background: rgba(183, 97, 0, 0.14);
  color: var(--orange);
}

.readiness-usable .readiness-pill {
  background: rgba(39, 132, 95, 0.12);
  color: var(--green);
}

.insight-table {
  margin-top: 8px;
}

.compact-empty {
  padding: 10px;
}

.takeaway-list {
  display: grid;
  gap: 10px;
}

.takeaway-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) auto minmax(220px, 0.9fr);
  gap: 12px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.takeaway-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.takeaway-title {
  font-size: 14px;
  font-weight: 760;
  line-height: 1.35;
}

.takeaway-meta {
  min-width: 112px;
  text-align: right;
}

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

.takeaway-links strong {
  display: block;
  margin: 2px 0;
  font-size: 13px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  border-top: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: #e8edf5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.status-pill.succeeded {
  background: rgba(39, 132, 95, 0.12);
  color: var(--green);
}

.status-pill.partial_failure {
  background: rgba(183, 97, 0, 0.14);
  color: var(--orange);
}

.status-pill.failed {
  background: rgba(200, 54, 43, 0.12);
  color: var(--red);
}

@media (max-width: 980px) {
  .layout,
  .version-grid,
  .metric-grid,
  .insight-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .takeaway-row {
    grid-template-columns: 1fr;
  }

  .takeaway-meta {
    text-align: left;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 24px, 1440px);
    padding-top: 18px;
  }

  .topbar,
  .status-row {
    align-items: stretch;
    flex-direction: column;
  }

  .actions,
  .layout,
  .version-grid,
  .metric-grid,
  .timeline-row,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    display: grid;
  }

  .takeaway-links {
    grid-template-columns: 1fr;
  }

  .query-input {
    width: 100%;
  }
}
