:root {
  --bg: #f6f3ec;
  --panel: #fffdfa;
  --ink: #202124;
  --muted: #68707a;
  --line: #d8d1c4;
  --accent: #0f766e;
  --accent-dark: #12413d;
  --danger: #b42318;
  --soft: #e7f4f1;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 250, .96);
  position: sticky;
  top: 0;
  z-index: 2;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 20px; }
h2 { margin-bottom: 12px; font-size: 18px; }
h3 { margin-bottom: 10px; font-size: 15px; }
main { max-width: 1180px; margin: 0 auto; padding: 18px; }

.stack { display: grid; gap: 16px; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; align-items: start; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.panel, .tournament-head {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.tournament-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.live-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}
.live-strip div {
  min-width: 0;
  border-right: 1px solid var(--line);
  padding: 0 10px;
}
.live-strip div:last-child { border-right: 0; }
.live-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.live-strip strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 15px;
}

label { display: grid; gap: 6px; margin: 8px 0; font-size: 13px; color: var(--muted); }
label.compact { min-width: 190px; margin: 0; }
input, textarea, select, button { font: inherit; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
}
input.number-input { min-width: 84px; max-width: 110px; }
input.short-input { min-width: 72px; max-width: 96px; }
textarea { min-height: 82px; resize: vertical; }
button {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
button.warn { background: var(--danger); }
button.small-button { padding: 7px 9px; white-space: nowrap; }
button.wide-action {
  flex: 1 1 220px;
  min-height: 44px;
  font-weight: 700;
}
button.hit-toggle {
  min-width: 44px;
  height: 40px;
  padding: 0;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  font-weight: 700;
}
button.hit-toggle.active { background: var(--accent-dark); color: #fff; border-color: var(--accent-dark); }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.button-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.action-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; }
.pill { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 9px; border-radius: 999px; background: var(--soft); color: #115e59; font-size: 13px; }
.hidden { display: none !important; }
.list { display: grid; gap: 8px; }
.item { border: 1px solid var(--line); border-radius: 6px; padding: 10px; background: #fff; }
.settings-form { display: grid; gap: 14px; }
fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 14px;
  background: #fff;
}
legend { padding: 0 6px; font-weight: 700; }
label.check {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  margin-right: 14px;
}
label.check input { width: auto; }
.university-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.team-order-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.team-order-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}
.team-order-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.team-order-summary strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 15px;
}
.team-order-list { display: grid; gap: 12px; }
.team-order-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}
.team-order-card h3 { margin-bottom: 2px; }
.team-order-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.team-order-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.team-order-reserves {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}
.team-order-reserves span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  background: #f8fafc;
}
.group-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.group-summary span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 5px 9px;
  font-size: 13px;
}
.warn-text { color: var(--danger); }
.schedule-list {
  display: grid;
  gap: 8px;
}
.schedule-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}
.schedule-item.dragging {
  opacity: .55;
}
.schedule-item strong,
.schedule-item span {
  display: block;
  overflow-wrap: anywhere;
}
.schedule-item span {
  color: var(--muted);
  font-size: 12px;
}
.drag-handle {
  color: var(--muted);
  cursor: grab;
  font-weight: 700;
  text-align: center;
}
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button.active { background: var(--accent-dark); }
.segmented-control {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.segmented-control button {
  min-width: 88px;
}
.segmented-control button.active {
  background: var(--accent-dark);
  color: #fff;
  border-color: var(--accent-dark);
}
.action-cell { align-self: end; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 14px; }

.status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.metric { border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: #fff; min-height: 92px; }
.metric span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.metric strong { display: block; font-size: 25px; line-height: 1.25; overflow-wrap: anywhere; }
.metric em {
  display: block;
  margin-top: 7px;
  color: var(--accent-dark);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}
.calling-summary {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.calling-summary div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fff;
}
.calling-summary span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}
.calling-summary strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 20px;
}
#callingRoster { margin-bottom: 14px; }

.batch-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}
.csv-import { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.batch-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}
.archer-name { font-weight: 700; }
.batch-row .row {
  align-items: end;
  justify-content: space-between;
}
.hit-buttons { display: flex; flex-wrap: nowrap; gap: 6px; }
dialog {
  width: min(420px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
}
dialog::backdrop { background: rgba(32, 33, 36, .35); }
.dialog-card { padding: 16px; background: var(--panel); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; }

.hit-scoreboard {
  margin-top: 14px;
}
.hit-scoreboard:first-child {
  margin-top: 0;
}
.hit-scoreboard-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.hit-scoreboard-head h3 {
  margin-bottom: 0;
  font-size: 18px;
}
.hit-scoreboard-head span {
  color: var(--muted);
  font-size: 13px;
}
.hit-scoreboard-scroll {
  overflow-x: auto;
}
.hit-scoreboard table {
  min-width: 820px;
  border: 2px solid #4a4a4a;
  background: #fff;
}
.hit-scoreboard th,
.hit-scoreboard td {
  border: 1px solid #4a4a4a;
  padding: 10px 12px;
  text-align: center;
  vertical-align: middle;
}
.hit-scoreboard th:first-child,
.hit-scoreboard td:first-child {
  min-width: 220px;
  text-align: center;
}
.hit-scoreboard tbody tr:last-child td {
  border-bottom: 0;
}
.hit-scoreboard td:first-child strong,
.hit-scoreboard td:first-child span {
  display: block;
}
.hit-scoreboard td:first-child span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
.hit-marks {
  display: inline-block;
  min-width: 74px;
  font-family: "Times New Roman", serif;
  font-size: 18px;
  letter-spacing: 0;
  white-space: nowrap;
}
.hit-total {
  margin-left: 4px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.hit-log-scroll {
  overflow-x: auto;
}
.hit-log-scroll table {
  min-width: 1040px;
}
.hit-log-table tr.is-voided {
  color: var(--muted);
  background: #f7f5f0;
}
.status-pill {
  display: inline-flex;
  justify-content: center;
  min-width: 48px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}
.status-pill.active {
  border-color: #9bc7bf;
  background: var(--soft);
  color: var(--accent-dark);
}
.status-pill.voided {
  background: #eee9df;
  color: var(--muted);
}
label.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink);
  white-space: nowrap;
}
.switch-label input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}
.switch-ui {
  position: relative;
  inline-size: 42px;
  block-size: 24px;
  border-radius: 999px;
  background: #c9c2b6;
  transition: background .16s ease;
}
.switch-ui::after {
  content: "";
  position: absolute;
  inset-block-start: 3px;
  inset-inline-start: 3px;
  inline-size: 18px;
  block-size: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
  transition: transform .16s ease;
}
.switch-label input:checked + .switch-ui {
  background: var(--accent);
}
.switch-label input:checked + .switch-ui::after {
  transform: translateX(18px);
}
.switch-label input:focus-visible + .switch-ui {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .topbar, .tournament-head, .section-head { align-items: flex-start; flex-direction: column; }
  main { padding: 12px; }
  .grid, .status-grid { grid-template-columns: 1fr; }
  .calling-summary { grid-template-columns: 1fr; }
  .team-order-summary { grid-template-columns: 1fr 1fr; }
  .live-strip { grid-template-columns: 1fr 1fr; }
  .live-strip div { border-right: 0; border-bottom: 1px solid var(--line); padding: 4px; }
  .live-strip div:nth-last-child(-n + 2) { border-bottom: 0; }
  .schedule-item { grid-template-columns: 28px minmax(0, 1fr); }
  .schedule-item .action-buttons { grid-column: 2; }
  .span-2, .span-3, .span-4, .span-6, .span-8, .span-12 { grid-column: span 1; }
  .batch-row { grid-template-columns: 1fr; }
  .hit-buttons { flex-wrap: nowrap; }
  label.compact { width: 100%; }
  .hit-scoreboard-head { align-items: flex-start; flex-direction: column; }
  .hit-scoreboard table { min-width: 720px; font-size: 13px; }
  .hit-scoreboard th,
  .hit-scoreboard td { padding: 8px; }
}
