:root {
  color-scheme: light;
  --bg: #f5f7f2;
  --panel: #ffffff;
  --ink: #16201c;
  --muted: #61706a;
  --line: #dbe3dd;
  --green: #0f766e;
  --green-dark: #115e59;
  --lime: #84cc16;
  --amber: #b45309;
  --red: #b42318;
  --blue: #2563eb;
  --shadow: 0 18px 50px rgba(22, 32, 28, 0.08);
  font-family: Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(rgba(245, 247, 242, 0.76), rgba(245, 247, 242, 0.9)),
    url("/oysterbayovalnballgardens-26.jpg-web.jpg");
  background-attachment: fixed;
  background-color: var(--bg);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  padding: 0 14px;
}

button:hover {
  border-color: #aab7b0;
}

button.primary {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
}

button.primary:hover {
  background: var(--green-dark);
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 999px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 190px;
  padding: 34px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid rgba(22, 32, 28, 0.22);
  background: #000000;
}

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

.brand-logo {
  width: clamp(64px, 8vw, 108px);
  height: clamp(64px, 8vw, 108px);
  object-fit: contain;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  color: #ffffff;
  font-size: clamp(2.2rem, 4vw, 4.4rem);
  line-height: 0.95;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.46);
}

h2 {
  font-size: 1.05rem;
}

main {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 40px) 46px;
}

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

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

.metrics article {
  min-height: 104px;
  padding: 16px;
}

.metrics span,
.panel-header span,
label span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.metrics strong {
  display: block;
  margin-top: 10px;
  font-size: 2.2rem;
  line-height: 1;
}

.metrics strong.goal-count {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 14px;
}

.metrics strong.record-count {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
}

.record-count .record-item,
.goal-count .goal-item {
  display: grid;
  gap: 4px;
  min-width: 62px;
}

.record-count .record-label,
.goal-count .goal-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.record-count .record-value,
.goal-count .goal-value {
  color: var(--ink);
  font-size: 2.2rem;
  font-weight: 850;
  line-height: 0.95;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 420px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.leaders-panel {
  margin-bottom: 14px;
}

.leader-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.leader-item {
  display: grid;
  gap: 7px;
  align-content: start;
  min-height: 122px;
  border-right: 1px solid var(--line);
  padding: 14px;
}

.leader-item:last-child {
  border-right: 0;
}

.leader-item span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.12;
  text-transform: uppercase;
}

.leader-item strong {
  font-size: 1.9rem;
  line-height: 1;
}

.leader-item small {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.25;
}

label {
  display: grid;
  gap: 7px;
}

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

input:focus,
select:focus {
  border-color: var(--green);
  outline: 3px solid rgba(15, 118, 110, 0.15);
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.table-scroll {
  overflow-x: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8faf8;
  color: #4f5d56;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  color: #26312d;
  font-size: 0.92rem;
}

td span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

td button {
  min-height: 34px;
  padding: 0 10px;
}

.match-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.match-card {
  display: grid;
  min-height: 72px;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 10px;
  text-align: left;
}

.match-card.active {
  border-color: var(--green);
  box-shadow: inset 4px 0 0 var(--green);
}

.match-card span {
  font-weight: 800;
}

.match-card strong {
  font-size: 1.35rem;
}

.match-card small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.result-w strong {
  color: #15803d;
}

.result-d strong {
  color: var(--blue);
}

.result-l strong {
  color: var(--red);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.yes {
  background: #e6f7f4;
  color: var(--green-dark);
}

.badge.no {
  background: #fff1cc;
  color: var(--amber);
}

dialog {
  width: min(980px, calc(100vw - 24px));
  max-height: min(860px, calc(100vh - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
  padding: 0;
}

dialog::backdrop {
  background: rgba(22, 32, 28, 0.36);
}

form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

form header,
form footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#dialogSubtitle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  overflow-y: auto;
  max-height: min(610px, calc(100vh - 210px));
  padding-right: 4px;
}

.fine-field {
  border-top: 3px solid rgba(15, 118, 110, 0.16);
  border-radius: 8px;
  padding-top: 8px;
}

label small {
  color: var(--green-dark);
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  transform: translateY(20px);
  border-radius: 8px;
  background: #17201d;
  color: #ffffff;
  opacity: 0;
  padding: 12px 14px;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1050px) {
  .leader-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .leader-item {
    border-bottom: 1px solid var(--line);
  }

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

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

  .actions {
    grid-column: 1 / -1;
    justify-content: start;
  }

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

@media (max-width: 760px) {
  .app-header {
    align-items: start;
    flex-direction: column;
  }

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

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

  .leader-item {
    min-height: auto;
    border-right: 0;
  }

  .actions button,
  form footer button {
    width: 100%;
  }

  form footer {
    align-items: stretch;
    flex-direction: column-reverse;
  }
}
