/* Tennis Tournament Manager - single stylesheet, no build step. */

:root {
  --court:        #1a6b47;
  --court-deep:   #124d33;
  --court-light:  #e8f3ee;
  --ink:          #14231c;
  --ink-soft:     #5a6b62;
  --line:         #d8e2dc;
  --bg:           #f6f8f7;
  --card:         #ffffff;
  --amber:        #b06d14;
  --amber-bg:     #fdf3e2;
  --red:          #a32d24;
  --red-bg:       #fbeceb;
  --radius:       10px;
  --shadow:       0 1px 2px rgba(20, 35, 28, .06), 0 4px 14px rgba(20, 35, 28, .05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--court); }
a:hover { color: var(--court-deep); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 18px; }

/* ---------------------------------------------------------------- header */

.site-header {
  background: var(--court);
  color: #fff;
  box-shadow: var(--shadow);
}
.admin-header { background: #1d3a52; }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 12px;
  padding-bottom: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
}
.brand-mark { font-size: 22px; }

.site-nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.site-nav a { color: rgba(255,255,255,.9); text-decoration: none; font-size: 15px; }
.site-nav a:hover { color: #fff; text-decoration: underline; }

.link-button {
  background: none; border: 0; padding: 0;
  color: rgba(255,255,255,.9);
  font: inherit; font-size: 15px; cursor: pointer;
}
.link-button:hover { color: #fff; text-decoration: underline; }
.inline { display: inline; }

/* ----------------------------------------------------------------- main */

main.wrap { padding-top: 26px; padding-bottom: 60px; }

h1 { font-size: 27px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 20px; margin: 32px 0 12px; }
h3 { font-size: 16px; margin: 22px 0 8px; }

.page-head { margin-bottom: 22px; }
.page-head .sub { color: var(--ink-soft); margin: 0; }

.muted { color: var(--ink-soft); }
.small { font-size: 14px; }
.tiny  { font-size: 13px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-title { margin: 0 0 4px; font-size: 17px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* Event tile on the dashboard */
.event-tile {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--court);
  border-radius: var(--radius);
  padding: 15px 17px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}
.event-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(20,35,28,.08), 0 8px 20px rgba(20,35,28,.08);
  color: inherit;
}
.event-tile .cat { font-size: 20px; font-weight: 700; }
.event-tile .type { color: var(--ink-soft); font-size: 14px; }
.event-tile .count { font-size: 14px; margin-top: 8px; }

.stat-row { display: flex; gap: 26px; flex-wrap: wrap; margin: 6px 0 0; }
.stat { }
.stat .n { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: 13px; color: var(--ink-soft); }

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-open      { background: var(--court-light); color: var(--court-deep); }
.badge-confirmed { background: var(--court-light); color: var(--court-deep); }
.badge-paid      { background: var(--court-light); color: var(--court-deep); }
.badge-pending   { background: var(--amber-bg); color: var(--amber); }
.badge-unpaid    { background: var(--amber-bg); color: var(--amber); }
.badge-draft     { background: #eceff1; color: #52636e; }
.badge-completed { background: #eceff1; color: #52636e; }
.badge-waived    { background: #eceff1; color: #52636e; }
.badge-withdrawn { background: var(--red-bg); color: var(--red); }
.badge-rejected  { background: var(--red-bg); color: var(--red); }

/* --------------------------------------------------------------- tables */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  font-size: 15px;
}
th, td {
  padding: 9px 11px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  font-weight: 700;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.table-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.table-card > h3 { margin: 0; padding: 13px 15px; border-bottom: 1px solid var(--line); background: #fbfdfc; }

.qualifies td { background: rgba(26,107,71,.05); }
.qualifies td:first-child { box-shadow: inset 3px 0 0 var(--court); }

/* ---------------------------------------------------------------- forms */

form.stack { display: grid; gap: 14px; }

label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 5px; }
label .opt { font-weight: 400; color: var(--ink-soft); }

input[type=text], input[type=password], input[type=email], input[type=tel],
input[type=date], input[type=number], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(26,107,71,.35);
  outline-offset: 1px;
  border-color: var(--court);
}
textarea { min-height: 84px; resize: vertical; }
input[readonly] { background: #f4f6f5; }

.field-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.check { display: flex; align-items: flex-start; gap: 9px; font-weight: 400; }
.check input { margin-top: 4px; width: auto; }

.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.btn {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--court);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn:hover { background: var(--court-deep); color: #fff; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: #f2f5f4; color: var(--ink); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #872219; }
.btn-small { padding: 5px 11px; font-size: 13.5px; }
.btn-block { display: block; width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* --------------------------------------------------------------- notices */

.flash {
  padding: 11px 15px;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid;
  font-size: 15px;
}
.flash-success { background: var(--court-light); border-color: #bcdccc; color: var(--court-deep); }
.flash-error   { background: var(--red-bg); border-color: #f0c6c2; color: var(--red); }
.flash-info    { background: #eef4fa; border-color: #cbdcec; color: #1d3a52; }

.notice {
  background: var(--amber-bg);
  border: 1px solid #f0dcb8;
  color: var(--amber);
  padding: 12px 15px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.errors { margin: 0 0 16px; padding: 12px 15px 12px 32px; background: var(--red-bg); border: 1px solid #f0c6c2; border-radius: 8px; color: var(--red); }
.errors li { margin: 2px 0; }

.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* -------------------------------------------------------------- bracket */

.bracket {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding: 6px 2px 14px;
  -webkit-overflow-scrolling: touch;
}
.bracket-round { min-width: 210px; flex: 0 0 auto; display: flex; flex-direction: column; }
.bracket-round > h4 {
  margin: 0 0 10px;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-soft);
}
.bracket-matches {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex: 1;
  gap: 12px;
}
.bracket-match {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.bracket-side {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  font-size: 14px;
}
.bracket-side + .bracket-side { border-top: 1px solid var(--line); }
.bracket-side .who { overflow: hidden; text-overflow: ellipsis; }
.bracket-side.winner { background: var(--court-light); font-weight: 700; }
.bracket-side.tbd { color: var(--ink-soft); font-style: italic; }
.bracket-meta { padding: 5px 11px; background: #fbfdfc; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-soft); }

.champion {
  background: linear-gradient(135deg, var(--court), var(--court-deep));
  color: #fff;
  padding: 20px 22px;
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.champion .label { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.champion .who { font-size: 23px; font-weight: 700; margin-top: 3px; }

/* ----------------------------------------------------------------- live */

.live-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: baseline;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
}
.live-item:last-child { border-bottom: 0; }
.live-players { font-size: 15px; }
.live-players .w { font-weight: 700; }
.live-score { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.live-event { font-size: 12.5px; color: var(--ink-soft); }
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--court); margin-right: 7px; vertical-align: middle;
}

/* ---------------------------------------------------------------- login */

.centered-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: #1d3a52;
}
.centered-page main { width: 100%; max-width: 380px; }
.login-card { background: #fff; border-radius: 12px; padding: 30px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.login-card h1 { font-size: 21px; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--ink-soft); font-size: 14px; margin: 0 0 20px; }

/* --------------------------------------------------------------- footer */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px 0 30px;
  color: var(--ink-soft);
  font-size: 14px;
  background: var(--card);
}
.site-footer p { margin: 3px 0; }

/* --------------------------------------------------------------- mobile */

@media (max-width: 640px) {
  h1 { font-size: 23px; }
  .header-inner { gap: 10px; }
  .site-nav { gap: 14px; width: 100%; }
  .btn-block-mobile { display: block; width: 100%; }
  th, td { padding: 8px 9px; font-size: 14px; }
}

@media print {
  .site-header, .site-footer, .btn, .no-print { display: none !important; }
  body { background: #fff; }
  .card, .table-card { box-shadow: none; border-color: #ccc; }
}

/* ----------------------------------------------------------------- dark */

@media (prefers-color-scheme: dark) {
  :root {
    --ink:        #e6ede9;
    --ink-soft:   #9bafa5;
    --line:       #2b3a33;
    --bg:         #101713;
    --card:       #17211c;
    --court-light:#1d3a2c;
    --amber-bg:   #33260f;
    --red-bg:     #351a17;
  }
  input[type=text], input[type=password], input[type=email], input[type=tel],
  input[type=date], input[type=number], select, textarea {
    background: #0e1512; color: var(--ink); border-color: var(--line);
  }
  input[readonly] { background: #131c17; }
  tbody tr:hover { background: #1b2620; }
  .table-card > h3, .bracket-meta { background: #141d18; }
  .btn-secondary { background: #1b2620; color: var(--ink); }
  .btn-secondary:hover { background: #223029; color: var(--ink); }
  .empty { background: var(--card); }
  .badge-draft, .badge-completed, .badge-waived { background: #232f28; color: #a8bcb2; }
}
