:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --ink: #162033;
  --muted: #657082;
  --line: #d7dce4;
  --accent: #1d6f8f;
  --accent-2: #235789;
  --good: #177245;
  --warn: #a16207;
  --bad: #b42318;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: .58;
}

.loading-screen,
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-build {
  position: fixed;
  left: 16px;
  bottom: 12px;
  max-width: calc(100vw - 32px);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.login-panel h1,
.page-title h1,
.panel h2,
.panel h3 {
  margin: 0;
  line-height: 1.2;
}

.stack-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  min-height: 36px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.button,
button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  min-height: 34px;
  padding: 7px 12px;
  font-weight: 700;
}

.button.secondary,
button.secondary {
  background: #fff;
  color: var(--accent-2);
  border-color: #9cb8c8;
}

.button.danger,
button.danger {
  background: var(--bad);
  border-color: var(--bad);
}

.button.good,
button.good {
  background: var(--good);
  border-color: var(--good);
  color: #fff;
}

.button-row,
.nav-actions,
.toolbar,
.table-actions,
.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.notice {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
}

.notice.error {
  border-color: #f2b8b5;
  background: #fff1f0;
  color: var(--bad);
}

.notice.success {
  border-color: #b8dfca;
  background: #edfdf5;
  color: var(--good);
}

.force-remove-error {
  overflow-wrap: anywhere;
  padding: 10px 12px;
  border: 1px solid #f2b8b5;
  border-radius: 6px;
  background: #fff1f0;
  color: var(--bad);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.app-frame {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 16px;
  align-items: center;
  background: #111827;
  color: #fff;
  padding: 10px 18px;
  box-shadow: var(--shadow);
}

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

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #fff;
  display: grid;
  place-items: center;
  color: #111827;
  font-weight: 900;
}

.brand-text {
  display: grid;
  min-width: 0;
}

.brand-text strong,
.brand-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-text span {
  color: #c5ced9;
  font-size: 12px;
}

.brand-text .running-sha-line {
  white-space: normal;
  overflow-wrap: anywhere;
}

.topbar button {
  min-height: 30px;
  padding: 5px 9px;
  border-color: #5e7188;
  background: transparent;
  color: #fff;
}

.topbar button.active {
  background: #fff;
  border-color: #fff;
  color: #111827;
}

.page {
  width: min(1480px, calc(100% - 28px));
  margin: 18px auto 32px;
  display: grid;
  gap: 16px;
}

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title p {
  margin: 4px 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

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

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header .muted {
  color: var(--muted);
  font-size: 12px;
}

.recall-focus-summary {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px 14px;
  color: var(--muted);
  font-size: 12px;
}

.recall-focus-item {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

.recall-focus-item strong {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.recall-focus-item span,
.recall-focus-item code {
  color: var(--ink);
  font-size: 12px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.metric {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

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

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

.metric-button {
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

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

.metric-help {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.dashboard-panel-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.dashboard-panel-controls input {
  width: min(260px, 100%);
}

.tab-row {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px;
  background: var(--panel-2);
}

.tab-button {
  min-height: 30px;
  border-color: transparent;
  background: transparent;
  color: var(--accent-2);
  padding: 4px 10px;
}

.tab-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.dashboard-table-panel table {
  min-width: 0;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.table-pagination-pages {
  color: var(--text);
}

.table-pagination-buttons {
  display: inline-flex;
  gap: 5px;
}

@media (max-width: 680px) {
  .table-pagination {
    justify-content: flex-start;
  }
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef2f6;
  color: #334155;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.table-sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font-size: inherit;
  line-height: inherit;
  text-transform: inherit;
}

.table-sort-button:hover,
.table-sort-button:focus-visible,
.table-sort-button.active {
  color: var(--accent-2);
}

.table-sort-indicator {
  min-width: 10px;
  color: var(--accent-2);
  font-size: 10px;
}

tbody tr:hover {
  background: #f8fbfd;
}

tbody tr.selected-row,
tbody tr.selected-row:hover {
  background: #e4f7ec;
}

td.actions-cell {
  white-space: nowrap;
}

.row-action-menu {
  min-width: 150px;
  width: auto;
}

.small-button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}

.switch {
  width: 18px;
  height: 18px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 700;
  font-size: 12px;
}

.status.good {
  background: #e8f7ef;
  color: var(--good);
}

.status.warn {
  background: #fff7df;
  color: var(--warn);
}

.status.bad {
  background: #fff1f0;
  color: var(--bad);
}

.muted {
  color: var(--muted);
}

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

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

#recall-status:empty {
  display: none;
}

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

.form-grid {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px 12px;
  align-items: center;
}

.form-grid label {
  color: var(--muted);
}

.form-grid label,
.form-grid input,
.form-grid select,
.form-grid textarea {
  min-width: 0;
}

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

.warning-panel {
  margin-bottom: 16px;
  border-color: #f0c36d;
  background: #fff8e6;
}

.warning-panel p {
  margin: 0;
  color: #744c00;
}

.recall-grid {
  display: grid;
  gap: 0.75rem;
}

/* Ported from AZ1's GameRecall, with static class names for this non-React page. */
.az-recall-scroll {
  overflow: auto;
  width: 100%;
  max-width: 100%;
}

.az-recall-grid {
  --az-recall-columns: 7rem 7rem 7rem minmax(30rem, 1fr) 18rem 5.25rem 4.75rem 4.75rem 5.25rem;
  width: 100%;
  min-width: 90.5rem;
}

.az-recall-header,
.az-recall-row {
  display: grid;
  grid-template-columns: var(--az-recall-columns);
  align-items: center;
}

.az-recall-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8f9fa;
  color: #1f2937;
  font-weight: 700;
  border-bottom: 1px solid #e5e7eb;
}

.az-recall-header > div,
.az-cell {
  box-sizing: border-box;
  min-width: 0;
  padding: .85rem .9rem;
  border-bottom: 1px solid #f0f0f0;
  overflow: hidden;
  text-align: left;
}

/* Keep SVG sizing deterministic in Safari, which may otherwise use the
   asset's physical SVG dimensions while it resolves the intrinsic size. */
.az-recall-grid img {
  display: block;
  max-width: none;
}

.az-recall-row:nth-child(odd) { background: #f7f7f9; }
.az-recall-row:nth-child(even) { background: #fff; }
.az-recall-row { min-height: 12.25rem; contain: layout paint; }
.az-recall-row.az-recall-row-live {
  background: #fff8df;
  box-shadow: inset 4px 0 0 #c97f18;
}
.az-deck-index,
.az-number-cell { text-align: center; }
.az-deck-index {
  display: grid;
  gap: .45rem;
  overflow-wrap: anywhere;
  font-size: .78rem;
}
.az-live-state {
  color: #8a4b08;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.az-draw-cell,
.az-card-cell { display: flex; align-items: center; }
.az-draw-cell { justify-content: center; }
.az-card-cell { justify-content: flex-start; }
.az-recall-row-new { animation: az-recall-row-enter 45ms ease-out; }

@keyframes az-recall-row-enter {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.az-draw-col { width: 30rem; min-width: 30rem; padding: 0; }
.az-draw-row {
  display: flex;
  flex-direction: column;
  gap: .02rem;
  align-items: center;
  justify-content: flex-start;
  /* The 101-ball domain occupies seven 16-ball rows. */
  height: 10.97rem;
}
.az-draw-line {
  display: grid;
  grid-template-columns: repeat(16, 1.55rem);
  grid-auto-rows: 1.55rem;
  gap: 0 .08rem;
  opacity: 1;
}
.az-draw-item { position: relative; display: block; width: 1.55rem; height: 1.55rem; opacity: 0; }
.az-recall-static .az-draw-item { opacity: 1; }
.az-recall-animated .az-draw-item {
  animation: az-draw-ball-reveal 50ms ease-out forwards;
  animation-delay: var(--draw-delay, 0ms);
  will-change: opacity, transform;
}
@keyframes az-draw-ball-reveal {
  from { opacity: 0; transform: translateY(-.3rem) scale(.7); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.az-draw-ball { position: absolute; top: .05rem; left: .05rem; width: 1.45rem; height: 1.45rem; }
.az-draw-symbol { position: absolute; top: .17rem; left: .17rem; width: 1.22rem; height: 1.22rem; z-index: 1; }
.az-ball-text { position: absolute; top: .05rem; left: .05rem; z-index: 1; display: block; width: 1.45rem; height: 1.45rem; color: #1f2937; font-size: .7rem; line-height: 1.45rem; text-align: center; }

.az-bingo-card-cont { width: 250px; min-height: 175px; margin-left: .4rem; }
.az-bingo-spot-row { position: relative; width: 250px; height: 105px; padding: 0; margin: 0; }
.az-bingo-card-img {
  position: relative;
  display: block;
  width: 250px;
  height: 105px;
  max-width: none;
  max-height: none;
}
.az-card-spot-row { position: absolute; top: 0; left: 0; display: grid; grid-template-columns: repeat(5, 1fr); width: 250px; height: 105px; padding-top: 10px; overflow: hidden; }
.az-card-spot { position: relative; display: grid; place-items: center; min-width: 0; }
.az-spot-star { position: absolute; top: 40px; width: 35px; height: 35px; z-index: 1; opacity: 0; }
.az-recall-static .az-spot-star.is-hit { opacity: .7; }
.az-spot-star.is-miss { opacity: 0; }
.az-recall-animated .az-spot-star.is-hit {
  animation: az-card-daub 50ms ease-out forwards;
  animation-delay: var(--hit-delay, 0ms);
  will-change: opacity, transform;
  transform-origin: center;
}
@keyframes az-card-daub {
  0% { opacity: 0; transform: scale(1.65) rotate(-8deg); }
  70% { opacity: .85; transform: scale(.92) rotate(0); }
  100% { opacity: .7; transform: scale(1) rotate(0); }
}
.az-spot-symbol { position: relative; width: 35px; height: 35px; z-index: 0; }
.az-spot-text { position: relative; padding-top: 11px; padding-left: 2px; z-index: 0; font-size: 1.2rem; font-weight: 700; }
.az-prize-row { display: flex; align-items: center; width: 250px; min-height: 75px; margin: .55rem 0 0; }
.az-interim-prize,
.az-end-prize { opacity: 0; height: 75px; }
.az-interim-prize { width: 75px; }
.az-end-prize { width: 33%; }
.az-recall-static .az-interim-prize.is-visible,
.az-recall-static .az-end-prize.is-visible { opacity: 1; }
.az-recall-animated .az-interim-prize.is-visible,
.az-recall-animated .az-end-prize.is-visible {
  animation: az-prize-reveal 60ms ease-out forwards;
  animation-delay: var(--prize-delay, 0ms);
}
@keyframes az-prize-reveal {
  from { opacity: 0; transform: translateY(.4rem) scale(.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.bingo-tables {
  display: grid;
  gap: 8px;
}

.bingo-table-row {
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  color: var(--ink);
  border-color: var(--line);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, .48);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal {
  width: min(640px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(15, 23, 42, .28);
  padding: 18px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.identity-grid {
  display: grid;
  gap: 12px;
}

.identity-grid code {
  display: block;
  overflow-wrap: anywhere;
  font-size: 22px;
  line-height: 1.3;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

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

  .nav-actions {
    justify-content: flex-start;
  }

  .grid.two,
  .grid.three,
  .metric-row,
  .filters,
  .config-grid {
    grid-template-columns: 1fr;
  }

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

  .page {
    width: min(100% - 16px, 1480px);
  }
}
