/* rallio design system — light blue / white */
:root {
  --brand:        #2b8fcf;
  --brand-dark:   #1c7bbd;
  --brand-darker: #155f93;
  --sky:          #7cc3ec;
  --brand-50:     #f2f9fe;
  --brand-100:    #e4f2fc;
  --brand-200:    #cbe6f8;
  --brand-300:    #a9d6f1;
  --accent:       #b6e04a;      /* subtle tennis-ball green, used sparingly */
  --ink:          #15242f;
  --ink-soft:     #3a4b58;
  --muted:        #6a7c8a;
  --line:         #dbe8f2;
  --line-soft:    #eaf2f9;
  --bg:           #f4f9fd;
  --card:         #ffffff;
  --ok:           #1f9d6b;
  --ok-bg:        #e6f6ef;
  --warn:         #c9852b;
  --warn-bg:      #fbf1e0;
  --danger:       #d1495b;
  --danger-bg:    #fbe9ec;
  --radius:       14px;
  --radius-lg:    22px;
  --radius-sm:    9px;
  --shadow:       0 10px 30px rgba(23, 95, 147, 0.08);
  --shadow-sm:    0 4px 14px rgba(23, 95, 147, 0.07);
  --shadow-lg:    0 24px 60px rgba(21, 95, 147, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -0.01em; }
img, svg { max-width: 100%; }

/* ---------- wordmark ---------- */
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.02em; color: var(--brand-darker); }
.wordmark .logo { width: 1.35em; height: 1.35em; flex: none; }
.wordmark .name { font-size: 1.05em; }
.wordmark .name b { color: var(--brand); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 650; font-size: 15px; line-height: 1;
  padding: 12px 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--brand); color: #fff; cursor: pointer; transition: .15s ease;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.sec { background: #fff; color: var(--brand-dark); border-color: var(--line); }
.btn.sec:hover { background: var(--brand-50); border-color: var(--brand-200); }
.btn.ghost { background: transparent; color: var(--brand-dark); padding-left: 8px; padding-right: 8px; }
.btn.ghost:hover { background: var(--brand-100); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b93b4c; }
.btn.sm { padding: 8px 13px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn.lg { padding: 15px 28px; font-size: 16px; }

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; transition: .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-200);
}
input::placeholder { color: #9fb0bd; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card h2 { font-size: 18px; margin-top: 0; }
.card h3 { font-size: 15px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 650;
  padding: 3px 10px; border-radius: 999px; background: var(--brand-100); color: var(--brand-darker);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.mut { background: var(--line-soft); color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grow { flex: 1; }

/* ---------- app shell ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.appbar-inner { max-width: 1080px; margin: 0 auto; padding: 12px 18px; display: flex; align-items: center; gap: 18px; }
.appbar .wordmark { font-size: 20px; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav a {
  padding: 8px 13px; border-radius: 9px; font-weight: 600; font-size: 14.5px; color: var(--ink-soft);
}
.nav a:hover { background: var(--brand-50); text-decoration: none; color: var(--brand-dark); }
.nav a.active { background: var(--brand-100); color: var(--brand-darker); }
.container { max-width: 1080px; margin: 0 auto; padding: 24px 18px 60px; }
.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 26px; margin-bottom: 3px; }

/* ---------- booking grid ---------- */
.grid-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.grid { border-collapse: collapse; width: 100%; min-width: 520px; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line-soft); padding: 0; text-align: center; }
table.grid thead th {
  position: sticky; top: 0; background: var(--brand-50); font-size: 13px; font-weight: 700;
  color: var(--brand-darker); padding: 11px 8px; border-bottom: 1px solid var(--line);
}
table.grid tbody th { font-size: 12.5px; font-weight: 650; color: var(--muted); background: #fbfdff; padding: 0 12px; white-space: nowrap; width: 78px; }
.slot { display: block; width: 100%; min-height: 46px; border: 0; background: transparent; font: inherit; cursor: default; padding: 6px 4px; }
.slot.free { background: var(--brand-50); cursor: pointer; color: var(--brand-dark); font-weight: 650; font-size: 13px; }
.slot.free:hover { background: var(--brand-200); }
.slot.busy { background: #fff; color: var(--muted); font-size: 12px; }
.slot.mine { background: var(--ok-bg); color: var(--ok); font-weight: 650; font-size: 12px; }
.slot.tourn { background: #eef3fb; color: var(--brand-darker); font-size: 11.5px; font-weight: 600; }

/* ---------- lists ---------- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-bottom: 1px solid var(--line-soft); }
.list-item:last-child { border-bottom: 0; }
.list-item .ttl { font-weight: 650; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-100); color: var(--brand-darker); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: none; }

/* ---------- tournament bracket ---------- */
.round { margin-bottom: 14px; }
.round h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }
.match { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
.match .mt { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.match .side { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.match .side.win { font-weight: 700; color: var(--ink); }
.match .side .sc { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- toast + modal + spinner ---------- */
#toasts { position: fixed; z-index: 90; left: 50%; bottom: 26px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; width: 92%; max-width: 420px; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 11px; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 550; animation: pop .2s ease; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(21,50,72,.45); display: flex; align-items: center; justify-content: center; padding: 18px; animation: pop .15s ease; }
.modal { background: #fff; border-radius: var(--radius-lg); padding: 24px; width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto; }
.modal h3 { font-size: 19px; }

.spinner { width: 26px; height: 26px; border: 3px solid var(--brand-200); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; color: var(--muted); padding: 34px 16px; }
.empty .em { font-size: 30px; margin-bottom: 6px; }

/* ---------- auth screen ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background:
  radial-gradient(1100px 500px at 50% -10%, var(--brand-100), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand-top { text-align: center; margin-bottom: 20px; }
.auth-card .brand-top .wordmark { font-size: 30px; }
.auth-tabs { display: flex; gap: 4px; background: var(--brand-100); padding: 4px; border-radius: 11px; margin-bottom: 18px; }
.auth-tabs button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 8px; font: inherit; font-weight: 650; font-size: 14px; color: var(--brand-darker); cursor: pointer; }
.auth-tabs button.active { background: #fff; box-shadow: var(--shadow-sm); }

@media (max-width: 640px) {
  .container { padding: 18px 14px 60px; }
  .nav a { padding: 7px 10px; font-size: 14px; }
  .appbar .wordmark .name { display: none; }
  .page-head h1 { font-size: 22px; }
}
