/* DartControl — Shared Styles */
@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;500;600;700&family=Barlow:wght@300;400;500;600&display=swap');

:root {
  --bg:        #0e1010;
  --surface:   #141818;
  --surface2:  #1a1f1f;
  --surface3:  #202626;
  --border:    #272e2e;
  --border2:   #323b3b;
  --green:     #00cc88;
  --green-dim: rgba(0,204,136,0.12);
  --green-glow:rgba(0,204,136,0.06);
  --red:       #ff4545;
  --yellow:    #f5c842;
  --blue:      #4da8ff;
  --text:      #dde8e8;
  --muted:     #677878;
  --dim:       #2e3838;
  --radius:    6px;
  --radius-lg: 10px;
  --header-h:  56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow', sans-serif;
  font-weight: 300;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1.25rem;
  gap: 1rem;
}

.app-logo {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  color: var(--text);
  text-decoration: none;
}

.app-logo span { color: var(--green); }

.header-badge {
  font-size: 0.65rem;
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border2);
  padding: 0.15rem 0.5rem;
}

.header-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 0.75rem;
}

.header-team-name {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Bottom nav (mobile — captain/team view) ────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: 60px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
}

.bottom-nav a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.65rem;
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color 0.15s;
}

.bottom-nav a.active, .bottom-nav a:hover { color: var(--green); }

.bottom-nav a svg {
  width: 20px; height: 20px;
  stroke: currentColor; fill: none; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ── Page wrapper ───────────────────────────────────────── */
.page-body {
  padding-top: calc(var(--header-h) + 1.25rem);
  padding-bottom: 80px;
  padding-left: 1rem;
  padding-right: 1rem;
  max-width: 680px;
  margin: 0 auto;
}

.page-body.wide { max-width: 1100px; }

/* ── Section header ─────────────────────────────────────── */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.875rem;
}

.section-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.125rem;
  margin-bottom: 0.75rem;
}

.card-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.card-row:last-child { border-bottom: none; }

/* ── Fixture card ───────────────────────────────────────── */
.fixture-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.875rem 1rem;
  margin-bottom: 0.625rem;
  display: flex; align-items: center; gap: 0.75rem;
  text-decoration: none; color: inherit;
  transition: border-color 0.15s;
}
.fixture-card:hover { border-color: var(--border2); }

.fixture-date {
  text-align: center; flex-shrink: 0; width: 42px;
}
.fixture-date .fday {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.3rem; font-weight: 700;
  color: var(--text); line-height: 1;
}
.fixture-date .fmon {
  font-size: 0.65rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
}

.fixture-info { flex: 1; min-width: 0; }
.fixture-teams {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fixture-meta { font-size: 0.72rem; color: var(--muted); margin-top: 1px; }

.fixture-score {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.3rem; font-weight: 700;
  text-align: right; flex-shrink: 0;
  color: var(--text);
}

/* ── Status pills ───────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center;
  font-size: 0.65rem; font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.2rem 0.55rem; border-radius: 3px;
  font-weight: 600;
}
.pill-pending  { background: rgba(245,200,66,0.12);  color: var(--yellow); }
.pill-confirmed{ background: rgba(0,204,136,0.12);   color: var(--green); }
.pill-disputed { background: rgba(255,69,69,0.12);   color: var(--red); }
.pill-scheduled{ background: var(--surface2); color: var(--muted); }
.pill-played   { background: rgba(0,204,136,0.08);   color: var(--green); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600; letter-spacing: 0.06em;
  font-size: 0.85rem; text-transform: uppercase;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--green); color: #0a1210; border-color: var(--green); }
.btn-ghost   { background: transparent; color: var(--text); border-color: var(--border2); }
.btn-ghost:hover { background: var(--surface2); opacity: 1; }
.btn-danger  { background: transparent; color: var(--red); border-color: var(--red); }
.btn-sm { font-size: 0.75rem; padding: 0.35rem 0.75rem; }
.btn-full { width: 100%; }

/* ── Form elements ──────────────────────────────────────── */
.form-group { margin-bottom: 0.875rem; }
.form-label {
  display: block;
  font-size: 0.7rem; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 0.35rem;
}
.form-input, .form-select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Barlow', sans-serif;
  font-size: 0.9rem;
  padding: 0.6rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.form-input:focus, .form-select:focus { border-color: var(--green); }
.form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23677878' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }
.form-hint { font-size: 0.72rem; color: var(--muted); margin-top: 0.3rem; }

/* ── Table ──────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.65rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); padding: 0.5rem 0.75rem;
  text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .pos {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700; font-size: 1rem;
  color: var(--muted); text-align: center;
}
.data-table .pos.top3 { color: var(--green); }

/* ── Metric chips ───────────────────────────────────────── */
.metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 0.625rem; margin-bottom: 1.25rem;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.875rem;
}
.metric-label {
  font-size: 0.62rem; font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 0.25rem;
}
.metric-value {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.6rem; font-weight: 700; line-height: 1;
  color: var(--text);
}
.metric-value.green { color: var(--green); }

/* ── Toast notifications ────────────────────────────────── */
.toast {
  position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%);
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem; color: var(--text);
  z-index: 200; opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.toast.show { opacity: 1; }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); }

/* ── Divider ────────────────────────────────────────────── */
.divider {
  border: none; border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* ── Empty state ────────────────────────────────────────── */
.empty {
  text-align: center; padding: 3rem 1rem;
  color: var(--muted); font-size: 0.875rem;
}
.empty-icon { font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.4; }

/* ── Utility ────────────────────────────────────────────── */
.green  { color: var(--green); }
.red    { color: var(--red); }
.yellow { color: var(--yellow); }
.muted  { color: var(--muted); }
.bold   { font-weight: 600; }
.mono   { font-variant-numeric: tabular-nums; }

/* ── Admin sidebar layout (desktop) ─────────────────────── */
@media (min-width: 768px) {
  .admin-layout {
    display: flex;
    min-height: 100vh;
    padding-top: var(--header-h);
  }
  .admin-sidebar {
    position: fixed;
    top: var(--header-h); bottom: 0; left: 0;
    width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1rem 0;
    flex-shrink: 0;
  }
  .admin-main {
    margin-left: 220px;
    padding: 1.5rem;
    flex: 1;
    min-width: 0;
    width: calc(100% - 220px);
  }
  .admin-layout .bottom-nav { display: none; }
}

.sidebar-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 1.1rem;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.9rem; letter-spacing: 0.04em;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.12s, background 0.12s;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
}
.sidebar-item:hover { color: var(--text); background: var(--surface2); }
.sidebar-item.active { color: var(--green); background: var(--green-glow); }
.sidebar-item svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; flex-shrink: 0; }

.sidebar-section {
  font-size: 0.6rem; font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--dim); padding: 0.75rem 1.1rem 0.3rem;
}

/* ── Modals (shared) ───────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.85); align-items: center; justify-content: center; padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
}
.modal h3 { font-family: 'Barlow Condensed', sans-serif; font-size: 1.3rem; font-weight: 700; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1.25rem; flex-wrap: wrap; }
.modal img { width: 100%; border-radius: var(--radius); margin-bottom: 0.875rem; }

/* ── Notices ───────────────────────────────────────────── */
.notice {
  border: 1px solid var(--border2); border-radius: var(--radius-lg);
  padding: 0.875rem 1rem; margin-bottom: 1rem; font-size: 0.85rem; background: var(--surface);
}
.notice.warn   { border-color: var(--yellow); background: rgba(245,200,66,0.06); }
.notice.danger { border-color: var(--red);    background: rgba(255,69,69,0.06); }
.notice.ok     { border-color: var(--green);  background: var(--green-dim); }
.notice-title  { font-family: 'Barlow Condensed', sans-serif; font-weight: 600; font-size: 1rem; margin-bottom: 0.2rem; }
.fixture-card.action { border-color: var(--yellow); }
textarea.form-input { resize: vertical; min-height: 80px; font-family: inherit; }

/* ── League switcher (admin header) ───────────────────── */
.league-switch { width: auto; max-width: 240px; padding: 0.3rem 2rem 0.3rem 0.6rem; font-size: 0.8rem; }
.league-current { font-size: 0.8rem; color: var(--muted); max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 600px) { .league-switch, .league-current { max-width: 130px; } }

/* ── Player list preview (batch add) ───────────────────── */
.pl-preview { margin-top: 0.5rem; max-height: 180px; overflow-y: auto; font-size: 0.8rem; }
.pl-preview:empty { display: none; }
.pl-count { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.2rem; }
.pl-row { padding: 0.15rem 0; border-bottom: 1px solid var(--border); }
.pl-row.dupe { opacity: 0.55; text-decoration: line-through; }
.pl-tag { font-size: 0.65rem; color: var(--yellow); text-decoration: none; display: inline-block; }

/* ── Admin header on phones: buttons get their own row ──── */
/* (admin + superadmin pages only — captain pages keep their single-row header) */
@media (max-width: 600px) {
  body:has(.admin-layout) { --header-h: 100px; }
  body:has(.admin-layout) .app-header { flex-wrap: wrap; align-content: center; row-gap: 0.45rem; }
  body:has(.admin-layout) .app-header .header-badge { display: none; }
  /* flatten so the league picker can sit beside the logo (row 1) and the buttons wrap to row 2 */
  body:has(.admin-layout) .app-header .header-right,
  body:has(.admin-layout) .app-header .header-right > div { display: contents !important; }
  body:has(.admin-layout) .app-header .league-switch,
  body:has(.admin-layout) .app-header .league-current { flex: 1 1 calc(100% - 9.5rem); min-width: 0; max-width: none; }
  body:has(.admin-layout) .app-header .header-right .btn { flex: 0 0 auto; padding-left: 0.6rem; padding-right: 0.6rem; }
}

/* ── Transfer requests ─────────────────────────────────── */
.tr-card { display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
           border: 1px solid var(--border); border-radius: var(--radius); padding: 0.65rem 0.8rem; margin-bottom: 0.5rem;
           background: var(--surface); font-size: 0.85rem; }
.tr-card.action { border-color: var(--yellow); }
.tr-meta { font-size: 0.72rem; color: var(--muted); margin-top: 0.15rem; }
.tr-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* Captain pages: bottom bar already has Dashboard, so drop the header copy on phones (keeps Sign Out visible) */
@media (max-width: 600px) {
  .app-header .header-right > a.btn[href="/captain/dashboard.html"] { display: none; }
  .app-header .header-badge { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ── Brand icon ─────────────────────────────────────────── */
.app-logo { display: inline-flex; align-items: center; }
.app-logo::before { content: ''; width: 28px; height: 28px; flex: 0 0 28px; border-radius: 6px; margin-right: 0.45rem;
                    background: url(/img/favicon-48.png) center / cover no-repeat; }
.login-logo-img { display: block; margin: 0 auto 1rem; width: 140px; height: 140px; }
@media (max-width: 600px) { .app-logo::before { width: 24px; height: 24px; flex-basis: 24px; } }

/* ── Admin menu on phones/tablets ─────────────────────────── */
.menu-toggle { display: none; }
@media (max-width: 767px) {
  .admin-layout { padding-top: var(--header-h); }
  .menu-toggle {
    display: flex; align-items: center; gap: 0.6rem; width: 100%;
    background: var(--surface); color: var(--text); border: 0; border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem; font: inherit; font-size: 0.9rem; text-align: left; cursor: pointer;
    position: sticky; top: var(--header-h); z-index: 20;
  }
  .menu-toggle .mt-icon { color: var(--green); font-size: 1.1rem; line-height: 1; }
  .menu-toggle .mt-label { flex: 1; font-weight: 500; }
  .menu-toggle .mt-chev { color: var(--muted); transition: transform 0.15s; }
  .menu-toggle.open .mt-chev { transform: rotate(180deg); }
  .admin-sidebar { display: none; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0.4rem 0 0.6rem;
                   position: sticky; top: calc(var(--header-h) + 2.9rem); z-index: 19; max-height: 70vh; overflow-y: auto;
                   box-shadow: 0 8px 18px rgba(0,0,0,0.35); }
  .admin-sidebar.open { display: block; }
  .admin-main { padding: 1rem 0.875rem 2rem; }
}

/* ── Push notification card (captain dashboard) ────────── */
.push-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 0.9rem; margin-bottom: 1rem; background: var(--surface); }
.push-card .pc-title { font-weight: 600; font-size: 0.88rem; margin-bottom: 0.2rem; }
.push-card .pc-text { font-size: 0.78rem; color: var(--muted); line-height: 1.45; }
.push-card .pc-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.6rem; }

/* Very narrow phones: the team badge can't fit beside the buttons, so drop it */
@media (max-width: 420px) { body:not(:has(.admin-layout)) .app-header .header-badge { display: none; } }

/* ── "To do" counts on the admin menu ───────────────────── */
.todo-badge { margin-left: auto; min-width: 1.25rem; height: 1.25rem; padding: 0 0.35rem; border-radius: 999px;
              background: var(--yellow); color: #000; font-size: 0.7rem; font-weight: 700;
              display: inline-flex; align-items: center; justify-content: center; }
.menu-toggle .mt-icon { position: relative; }
.menu-toggle .mt-icon[data-count]:not([data-count=""])::after {
  content: attr(data-count); position: absolute; top: -0.45rem; right: -0.6rem; min-width: 1rem; height: 1rem; padding: 0 0.2rem;
  border-radius: 999px; background: var(--yellow); color: #000; font-size: 0.6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; }

/* ── League table: grouped Matches / Games columns ───────── */
.league-table .grp th, .standings-table .grp th { border-bottom: 0; padding-bottom: 0.1rem; }
.league-table .grp-start, .standings-table .grp-start { border-left: 1px solid var(--border); }
.league-table .act, .standings-table .act { color: var(--muted); }

/* League table polish: everything centred under its heading, Team takes a sensible width */
table:has(.grp) th.c, table:has(.grp) td.c { text-align: center; }
table:has(.grp) th.team-head, table:has(.grp) td.team-col { text-align: left; }
table:has(.grp) th.team-head { width: 30%; }
table:has(.grp) td.num { min-width: 2.2rem; }
table:has(.grp) .sub th { padding-top: 0.15rem; }
table:has(.grp) th.act, table:has(.grp) td.act { color: var(--muted); }
/* phones: Pos and Act stay put with Team when the table scrolls sideways */
.league-table .stick-act { position: sticky; left: 40px; min-width: 40px; width: 40px; background: var(--surface); z-index: 1; }
.league-table td.stick-act { box-shadow: inset 0 -1px 0 var(--border); border-bottom-color: transparent; }
.league-table:has(.stick-act) .stick2 { left: 80px; }

/* Only show the focus box for keyboard users, not after a tap/click */
button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }

/* ── Add to home screen banner ──────────────────────────── */
.install-banner { position: fixed; left: 0.6rem; right: 0.6rem; bottom: calc(env(safe-area-inset-bottom) + 0.6rem); z-index: 60;
  display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.8rem 2rem 0.8rem 0.8rem; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--green); box-shadow: 0 10px 30px rgba(0,0,0,0.55);
  animation: ib-in 0.25s ease-out; max-width: 520px; margin: 0 auto; }
.install-banner.above-nav { bottom: calc(env(safe-area-inset-bottom) + 72px); }
@keyframes ib-in { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.install-banner .ib-icon { width: 44px; height: 44px; border-radius: 10px; flex: 0 0 44px; }
.install-banner .ib-title { font-weight: 600; font-size: 0.92rem; margin-bottom: 0.15rem; }
.install-banner .ib-text { font-size: 0.8rem; color: var(--muted); line-height: 1.45; }
.install-banner .ib-how { margin-top: 0.4rem; color: var(--text); }
.install-banner .ib-share { width: 1.05em; height: 1.05em; vertical-align: -0.15em; fill: none; stroke: #2f9bff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.install-banner .ib-actions { display: flex; gap: 0.4rem; margin-top: 0.6rem; }
.install-banner .ib-close { position: absolute; top: 0.35rem; right: 0.5rem; background: none; border: 0; color: var(--muted); font-size: 1.3rem; cursor: pointer; }
