/* Admin panel layout (admin.html, admin-comp.html), on top of style.css.
   Wide on a PC (side menu, tables, side panel); on a phone the menu folds
   into a top bar and tables become cards. Colours come from style.css's
   tokens, so dark mode follows automatically; the menu is deep navy in both. */

body.admin { padding: 0; background: var(--bg); }

#admin-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

/* ── Login ── */
.login-screen { padding: 12vh 1rem 3rem; max-width: 420px; }
.login-brand { padding: 0 2px 6px; }

/* ── Side menu ── */
.admin-nav {
  background: var(--brand-deep); color: #fff;
  display: flex; flex-direction: column; gap: 2px;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
:root[data-theme="dark"] .admin-nav, :root[data-theme="dark"] .admin-topbar { background: #071019; border-right: 1px solid var(--border); }
.admin-brand { padding: 2px 10px 16px; }
.admin-brand .brand { color: #fff; }
.admin-brand .brand-mark i:nth-child(2) { box-shadow: inset 0 0 0 1.5px #9FB4C9; }
.admin-profile { margin: 0 0 14px; padding: 10px 12px; border: 1px solid #1F3E5E; border-radius: 10px; }
.admin-profile-label { font-size: 13px; color: #9FB4C9; }
.admin-profile-name { font-size: 15px; font-weight: 700; margin-top: 1px; }
.admin-nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 9px;
  color: #C9D6E3; font-size: 15px; text-decoration: none;
  background: none; border: none; text-align: left; cursor: pointer; font-family: inherit; width: 100%;
}
.admin-nav-link:hover { background: #12304D; color: #fff; }
.admin-nav-link.active { background: #1A4672; color: #fff; font-weight: 700; box-shadow: inset 3px 0 0 #8DBDF0; }
.admin-nav-badge { background: var(--amber-strong); color: #1C1B19; border-radius: 6px; padding: 0 7px; font-size: 12px; font-weight: 700; margin-left: auto; }
.admin-nav-user { font-size: 13px; color: #9FB4C9; padding: 0 12px; word-break: break-all; }
.admin-signout { color: #9FB4C9; font-size: 14px; }
/* Theme, language and feedback live in the menu, not in a page footer. */
.admin-nav-tools { padding: 0 12px 12px; }
.admin-nav-tools .footer-tools { gap: 8px; }
.admin-nav-tools .icon-btn, .admin-nav-tools .theme-toggle, .admin-nav-tools .feedback-btn {
  background: transparent; border-color: #2B4D72; color: #E6EDF3; width: 38px; height: 38px;
}
.admin-nav-tools .theme-toggle:hover, .admin-nav-tools .feedback-btn:hover { border-color: #8DBDF0; }

.admin-topbar { display: none; }

/* ── Main area ── */
.admin-main { min-width: 0; display: flex; flex-direction: column; }
.admin-page { padding: 30px 36px 48px; display: flex; flex-direction: column; gap: 18px; }
.page-title-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.page-title { font-size: 34px; margin: 0; flex: 1; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar input[type=search], .toolbar select { width: auto; min-width: 190px; min-height: 42px; padding-top: 8px; padding-bottom: 8px; }
.toolbar .toolbar-search { min-width: 260px; }
.toolbar .pill { min-height: 36px; font-size: 14px; }
.btn-inline { display: inline-flex; width: auto; min-height: 42px; padding: 8px 16px; font-size: 15px; }
input[type=search], input[type=url], input[type=datetime-local] {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 16px; background: var(--surface); color: var(--text); font-family: inherit;
}
input[type=search]:focus, input[type=url]:focus, input[type=datetime-local]:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--blue-light);
}
input[type=file] { font: inherit; font-size: 15px; color: var(--text-muted); }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 700; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 8px 14px; margin-right: 12px; cursor: pointer;
}
.big-num { font-family: var(--font-display); font-size: 34px; font-weight: 700; line-height: 1.1; }

/* Plain links follow the theme (the browser's default blue is unreadable
   in dark mode). */
.admin-main a:not(.btn):not(.comp-tab):not(.row-link):not(.link-btn) { color: var(--blue-dark); }
.field-label .hint-muted { font-weight: 400; }

/* ── Competition header + tabs ── */
.comp-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 20px 36px 0; }
.crumbs { font-size: 14px; color: var(--text-muted); }
.crumbs a { color: var(--blue-dark); text-decoration: none; }
.comp-title-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.comp-title-row h1 { font-size: 32px; margin: 0; }
.comp-meta { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.comp-tabs { display: flex; gap: 28px; margin-top: 14px; overflow-x: auto; }
.comp-tab {
  padding: 11px 2px; font-size: 15px; color: var(--text-muted); text-decoration: none;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.comp-tab:hover { color: var(--text); }
.comp-tab.active { color: var(--text); font-weight: 700; border-bottom-color: var(--blue); }
:root[data-theme="dark"] .comp-tab.active { border-bottom-color: var(--brand); }

.phase { border-radius: 5px; padding: 2px 8px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.phase-upcoming { background: var(--blue-light); color: var(--blue-dark); }
.phase-live { background: var(--green-light); color: var(--green); }
.phase-ended, .phase-closed { background: var(--gray-light); color: var(--text-muted); }

/* ── Cards, grids ── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; }
.panel-title { font-family: var(--font-display); font-size: 21px; font-weight: 600; color: var(--text); margin: 0 0 12px; line-height: 1.2; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-tile .stat-label { font-size: 14px; color: var(--text-muted); }
.stat-tile .stat-value { font-family: var(--font-display); font-size: 40px; font-weight: 700; line-height: 1.1; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-tile .stat-sub { font-size: 13px; color: var(--text-muted); }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.check-row:last-child { border-bottom: none; }
.check-mark { width: 18px; font-weight: 700; flex-shrink: 0; text-align: center; }
.check-ok { color: var(--green); } .check-warn { color: var(--amber); } .check-todo { color: var(--gray); }
.warn-box { border-radius: var(--radius-sm); padding: 11px 13px; font-size: 15px; }
.warn-red { background: var(--red-light); color: var(--red-strong); }
.warn-amber { background: var(--amber-light); color: var(--amber); }
.warn-box a { color: inherit; text-decoration: underline; }
.hint-muted { font-size: 14px; color: var(--text-muted); }
.hint-error { font-size: 14px; color: var(--red-strong); }
.empty { padding: 28px; text-align: center; color: var(--text-muted); font-size: 15px; }

/* Share card: one row per public page, open or copy its link. */
.share-links { margin-top: 14px; border-top: 1px solid var(--border); }
.share-link { display: flex; align-items: center; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.share-link span { flex: 1; font-weight: 700; font-size: 15px; }

/* ── Tables ── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-size: 13px; font-weight: 700; color: var(--text-muted);
  padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); background: var(--gray-light);
}
.data-table td { font-size: 15px; padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: var(--gray-light); }
.data-table tr.selected td { background: var(--blue-light); }
.cell-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.cell-strong { font-weight: 700; }
.row-link { color: var(--blue-dark); text-decoration: none; font-weight: 700; }
.status-ok { color: var(--green); } .status-warn { color: var(--amber); } .status-bad { color: var(--red-strong); }
.table-actions { white-space: nowrap; text-align: right; }
.link-btn { background: none; border: none; color: var(--blue-dark); cursor: pointer; font-size: 14px; font-weight: 700; padding: 6px 8px; font-family: inherit; text-decoration: none; border-radius: 6px; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--red-strong); }

/* ── Athletes: table + side panel ── */
.split { display: flex; min-height: 0; align-items: flex-start; }
.split-main { flex: 1; min-width: 0; padding: 22px 24px 48px 36px; display: flex; flex-direction: column; gap: 12px; }
.side-panel {
  width: 420px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--border);
  padding: 20px 22px; display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 0; max-height: 100vh; overflow-y: auto; min-height: 100vh; box-sizing: border-box;
}
.side-head { display: flex; align-items: flex-start; gap: 10px; }
.side-head .who { flex: 1; min-width: 0; }
.side-sub { font-size: 13px; color: var(--text-muted); }
.side-name { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1.15; }
.side-section { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.side-panel .boulder-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.side-panel .boulder-btn { font-size: 17px; border-radius: 8px; }
.side-panel .boulder-attempt-badge { font-size: 10px; top: 3px; right: 4px; }
.side-panel .boulder-btn.topped::before { font-size: 10px; top: 2px; left: 4px; }
.boulder-detail { background: var(--gray-light); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.boulder-detail .bd-title { font-weight: 700; flex: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field-label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 700; color: var(--text); }
.field-label input, .field-label select { font-weight: 400; }
.field-label .req { color: var(--red); }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(10, 34, 56, .18);
  min-width: 280px; padding: 6px; display: flex; flex-direction: column;
}
.menu button { background: none; border: none; text-align: left; padding: 10px 12px; border-radius: 8px; font-size: 15px; color: var(--text); cursor: pointer; font-family: inherit; }
.menu button:hover { background: var(--gray-light); }

/* ── Settings ── */
.settings-layout { display: flex; gap: 28px; padding: 26px 36px 120px; }
.settings-nav { width: 190px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 16px; align-self: flex-start; }
.settings-nav a { padding: 8px 12px; border-radius: 9px; font-size: 15px; color: var(--text); text-decoration: none; }
.settings-nav a:hover { background: var(--gray-light); }
.settings-nav a.danger { color: var(--red-strong); }
.settings-body { flex: 1; min-width: 0; max-width: 880px; display: flex; flex-direction: column; gap: 20px; }
.settings-section { scroll-margin-top: 16px; }
.settings-section h2 { font-size: 24px; margin: 0 0 14px; }
.setting-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.setting-row .setting-text { flex: 1; font-size: 15px; }
.setting-row .setting-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
button.toggle { border: none; padding: 0; font: inherit; }
.party-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.party { display: flex; flex-direction: column; gap: 10px; }
.party-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--text); }
.danger-section { border-color: var(--red-border); }
.danger-section h2 { color: var(--red-strong); }
.save-bar {
  position: fixed; left: 240px; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 20px rgba(10, 34, 56, .1);
  padding: 12px 36px; display: flex; align-items: center; gap: 12px;
}
.save-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber-strong); flex-shrink: 0; }
.save-text { flex: 1; font-size: 15px; }

/* ── Logos page ── */
.logo-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.logo-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.logo-card .logo-img { height: 76px; background: #fff; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); }
.logo-card .logo-img img { max-height: 58px; max-width: 90%; object-fit: contain; }
.logo-add { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 14px; }
/* As the only thing in its own panel, the form needs no divider above it. */
.panel > .logo-add:first-child { border-top: none; padding-top: 0; }
.logo-add-title { font-family: var(--font-display); font-size: 21px; font-weight: 600; }

/* ── Dialogs, toasts ── */
.dialog-overlay { position: fixed; inset: 0; background: rgba(10, 22, 34, .55); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.dialog { background: var(--surface); color: var(--text); border-radius: 16px; padding: 22px 24px; max-width: 460px; width: 100%; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); display: flex; flex-direction: column; gap: 12px; }
.dialog.logo-modal { max-width: 580px; max-height: 90vh; overflow-y: auto; }
.dialog-title { font-size: 24px; margin: 0; }
.dialog-message { font-size: 15px; line-height: 1.5; white-space: pre-line; margin: 0; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.dialog-actions .btn { width: auto; min-height: 42px; padding: 8px 16px; }
.toast-box { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 1100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--brand-deep); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); transition: opacity .3s; max-width: 90vw; }
:root[data-theme="dark"] .toast { background: #E6EDF3; color: #0A1622; }
.toast-error, :root[data-theme="dark"] .toast-error { background: #A32D2D; color: #fff; }
.toast-out { opacity: 0; }

/* ── Phone ── */
@media (max-width: 900px) {
  #admin-shell { display: block; }
  .admin-topbar {
    display: flex; align-items: center; gap: 10px; background: var(--brand-deep); color: #fff;
    padding: 10px 14px; position: sticky; top: 0; z-index: 40;
  }
  .admin-topbar .admin-brand { padding: 0; }
  .admin-topbar .brand-name { font-size: 19px; }
  .admin-topbar .brand-mark { width: 28px; }
  .admin-topbar-profile { font-size: 13px; color: #9FB4C9; margin-left: auto; }
  /* Anchor jumps and scrollIntoView stop below the sticky top bar. */
  html { scroll-padding-top: 72px; }
  .admin-menu-btn { background: none; border: 1px solid #2B4D72; color: #fff; border-radius: 10px; width: 44px; height: 44px; font-size: 18px; cursor: pointer; }
  .admin-nav { display: none; position: fixed; top: 64px; left: 0; right: 0; bottom: 0; height: auto; z-index: 39; }
  .admin-nav.open { display: flex; }
  .admin-nav > .admin-brand { display: none; }
  .admin-page { padding: 18px 14px 36px; }
  .page-title { font-size: 28px; }
  .comp-header { padding: 14px 14px 0; }
  .comp-title-row h1 { font-size: 26px; }
  .comp-tabs { gap: 20px; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 > * { grid-column: 1 / -1; }
  .split-main { padding: 14px 14px 32px; }
  .side-panel { position: fixed; inset: 0; width: auto; min-height: 0; max-height: none; z-index: 50; border-left: none; }
  .settings-layout { padding: 16px 14px 120px; flex-direction: column; }
  .settings-nav { width: auto; flex-direction: row; overflow-x: auto; position: static; }
  .party-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .save-bar { left: 0; padding: 12px 14px; }
  .toolbar input[type=search], .toolbar .toolbar-search { flex: 1 1 100%; min-width: 0; }
  .toolbar select { flex: 1 1 40%; min-width: 0; }
  .toolbar .spacer { display: none; }
  .toolbar .btn-inline, .toolbar .menu-wrap { flex: 1 1 auto; }
  .toolbar .menu-wrap > .btn-inline { width: 100%; }
  /* Tables become compact cards: the main cell (data-label="") on its own
     line, the rest flowing after it, each labelled from data-label. */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr { display: block; width: 100%; }
  .data-table tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .data-table td { display: inline-block; border: none; padding: 1px 12px 1px 0; font-size: 14px; }
  .data-table td[data-label=""] { display: block; font-size: 16px; padding-bottom: 3px; }
  .data-table td.table-actions { display: block; padding-top: 4px; }
  .data-table td[data-label]:not([data-label=""])::before { content: attr(data-label) ": "; color: var(--text-muted); font-size: 13px; }
  .data-table .num { text-align: left; }
  .table-actions { text-align: left; }
}

/* ── Courses (admin.html#courses) ── */
.course-editor { display: flex; flex-direction: column; gap: 14px; max-width: 640px; margin-top: 16px; }
.hole-table-wrap { max-height: 60vh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.hole-table { margin: 0; }
.hole-table input { width: 88px; min-height: 36px; padding: 4px 8px; }
.hole-table thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.hole-table tfoot td { font-weight: 700; }
/* Tables that must stay tables on a phone (holes, cards, scorecards): the
   card layout above would scatter their columns. */
@media (max-width: 900px) {
  .data-table.keep-table { display: table; }
  .data-table.keep-table thead { display: table-header-group; }
  .data-table.keep-table tbody { display: table-row-group; }
  .data-table.keep-table tfoot { display: table-footer-group; }
  .data-table.keep-table tr { display: table-row; padding: 0; }
  .data-table.keep-table th, .data-table.keep-table td { display: table-cell; padding: 6px 8px; border-bottom: 1px solid var(--border); }
}

/* ── Rounds and cards (admin-comp.html#rounds) ── */
.round-list { display: flex; flex-direction: column; gap: 16px; }
.round-panel { display: flex; flex-direction: column; gap: 14px; }
.round-head { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.round-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.round-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.danger-text { color: var(--red); }
.cards-empty { display: flex; flex-direction: column; gap: 10px; }
.cards-empty p { margin: 0; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-muted); }
.inline-field input, .inline-field select { width: auto; min-height: 36px; padding: 4px 28px 4px 10px; }
.inline-field input[type=number] { width: 72px; padding-right: 8px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card-box { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.card-box-loose { border-style: dashed; }
.card-box-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-players { list-style: none; display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; }
.card-players li { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-size: 14px; }
.card-player { min-width: 0; display: flex; flex-wrap: wrap; gap: 0 6px; align-items: baseline; }
.card-players select { width: auto; min-height: 32px; padding: 2px 26px 2px 8px; font-size: 13px; flex-shrink: 0; }
.remake summary { cursor: pointer; color: var(--text-muted); font-size: 14px; }
.remake[open] summary { margin-bottom: 8px; }

/* ── Score corrections in the side panel ── */
.corr-round { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.corr-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.hole-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.hole-input-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--text-muted); }
.hole-input-cell span { font-weight: 700; color: var(--text); }
.hole-input { width: 100%; min-height: 36px; padding: 4px; text-align: center; font-size: 16px; }
.hole-input.changed { border-color: var(--amber-strong); background: var(--amber-light); }
