:root {
  color-scheme: light;
  --canvas: #f5f4f1;
  --panel: #fff;
  --ink: #22201b;
  --muted: #666158;
  --line: #e6e2da;
  --soft: #f6f4ef;
  --gold: #f4ba42;
  --gold-hover: #ffcb5c;
  --gold-soft: #fff0cf;
  --black: #191813;
  --sidebar-muted: #c3bdb0;
  --danger: #a62f23;
  --radius: 16px;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; background: var(--canvas); color: var(--ink); line-height: 1.55; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid #b36a09;
  outline-offset: 3px;
}
button:disabled { cursor: default; opacity: .55; }
.loading { padding: 2rem; text-align: center; color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.error { color: var(--danger); font-size: .875rem; }

.brand { display: flex; align-items: center; gap: .75rem; color: #fff; text-align: left; direction: ltr; }
.brand-mark { flex: none; position: relative; overflow: hidden; border-radius: 10px; background: #fff9eb;
  width: 52px; height: 47px; }
.brand-mark img { position: absolute; width: 140%; height: auto; top: 50%; left: 50%; transform: translate(-50%, -48.5%); }
.brand strong { display: block; font-size: .95rem; letter-spacing: -.035em; line-height: 1.25; }
.brand small { font-size: .7rem; color: var(--sidebar-muted); }
.workspace { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; background: var(--black); color: #fff; display: flex;
  flex-direction: column; padding: 1.6rem 1rem 1rem; }
.sidebar .brand { margin: 0 .25rem 2.5rem; }
.sidebar nav { display: grid; gap: .32rem; }
.nav-label { color: var(--sidebar-muted); padding: 0 .65rem .45rem; font-size: .82rem; }
.nav-button { display: flex; align-items: center; gap: .65rem; min-height: 44px; color: #e9e5da; padding: .55rem .65rem;
  text-align: start; background: transparent; border: 1px solid transparent; border-radius: 9px; font-size: .92rem; }
.nav-button:hover, .nav-button[aria-current="page"] { color: #fff3d8; background: #332a1b; border-color: #514127; }
.nav-icon { color: var(--gold); width: 1.25rem; text-align: center; font-weight: 700; }
.account { display: flex; align-items: center; gap: .55rem; border-top: 1px solid #37332a;
  padding: .85rem .2rem 0; margin-top: auto; }
.account strong { display: block; overflow-wrap: anywhere; line-height: 1.3; font-size: .88rem; }
.account small { color: var(--sidebar-muted); font-size: .75rem; }
.avatar { display: grid; place-items: center; width: 33px; height: 33px; flex: none; border-radius: 50%;
  color: var(--gold); background: #393021; font-weight: 700; }
.logout { margin-inline-start: auto; padding: .25rem; align-self: start; color: #f1c46e; border: 0;
  background: transparent; font-size: .78rem; }
.workarea { min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: .65rem; min-height: 65px;
  background: var(--panel); border-bottom: 1px solid var(--line); padding: .75rem clamp(1rem, 4vw, 3rem); }
.topbar p { font-size: .875rem; color: var(--muted); text-align: end; }
.content { max-width: 1300px; margin: auto; padding: 1.55rem clamp(1rem, 4vw, 3rem) 3rem; }
.hero { position: relative; isolation: isolate; overflow: hidden; padding: 1.65rem clamp(1.15rem, 3vw, 2.2rem);
  min-height: 165px; display: flex; justify-content: center; flex-direction: column; align-items: start;
  border-radius: var(--radius); color: #fff; background: radial-gradient(ellipse at 10% 90%, #553511, transparent 62%), #222018; }
.hero::before { content: ""; position: absolute; z-index: -1; inset: -69% auto auto -13%; width: 75%; height: 380%;
  transform: rotate(-33deg); opacity: .49;
  background: repeating-linear-gradient(90deg, transparent 0 37px, #bd762a 38px 39px, transparent 40px 56px);
  mask-image: linear-gradient(90deg, black, transparent 86%); }
.hero::after { content: ""; position: absolute; z-index: -1; inset: 14% auto auto 11%; width: 105px; aspect-ratio: 1;
  border: 1px solid #b87e3d; border-radius: 50%; box-shadow: 0 0 0 12px #b87e3d28, 0 0 0 27px #b87e3d18; }
.hero p { color: #ffcd70; font-size: .85rem; font-weight: 650; }
.hero h1 { margin: .13rem 0 .4rem; font-size: clamp(1.65rem, 4vw, 2.45rem); letter-spacing: -.055em; line-height: 1.16; }
.hero small { color: #f0e5d4; font-size: .85rem; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: .75rem; margin: 1.55rem 0 .8rem; }
.section-heading h2 { font-size: 1.4rem; line-height: 1.25; }
.section-heading p { margin-top: .15rem; font-size: .88rem; color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
.panel-heading { padding: 1rem 1.1rem .6rem; }
.panel-heading h3 { font-size: 1.05rem; }
.pad { padding: 1rem 1.1rem; }
.toolbar, .actions { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; }
.toolbar { padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1 1 11rem; min-width: 0; max-width: 24rem; }
.toolbar label { min-width: min(9rem, 100%); }

.button { display: inline-flex; justify-content: center; align-items: center; gap: .45rem; min-height: 42px;
  border: 1px solid var(--line); border-radius: 9px; padding: .45rem .85rem; background: #fff; color: var(--ink);
  font-weight: 650; white-space: nowrap; font-size: .875rem; }
.button:hover { background: var(--soft); }
.button.primary { background: var(--gold); color: #231704; border-color: #dba231; }
.button.primary:hover { background: var(--gold-hover); }
.button.danger { color: var(--danger); }
.button.compact { min-height: 35px; padding: .23rem .58rem; }
.empty { padding: 2.15rem 1rem; text-align: center; display: grid; justify-items: center; gap: .45rem; }
.empty p { color: var(--muted); font-size: .9rem; }
.empty-icon { display: grid; place-items: center; color: #7e4d0e; background: var(--gold-soft);
  border-radius: 13px; width: 43px; height: 43px; font-size: 1.1rem; margin-bottom: .2rem; }
.field { display: grid; gap: .28rem; font-size: .875rem; font-weight: 650; color: var(--ink); }
input:not([type="checkbox"]), select, textarea { width: 100%; min-height: 42px; padding: .42rem .64rem; border-radius: 8px;
  border: 1px solid #d7d1c6; background-color: white; color: var(--ink); font-size: 1rem; font-weight: 400; }
select { appearance: none; padding-inline-end: 1.8rem;
  background-image: linear-gradient(45deg, transparent 50%, #6b6256 50%), linear-gradient(135deg, #6b6256 50%, transparent 50%);
  background-position: left 15px center, left 10px center; background-repeat: no-repeat; background-size: 5px 5px; }
input[type="date"], input[type="number"] { direction: ltr; text-align: start; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: #986409; }
.check { display: inline-flex; gap: .3rem; align-items: center; font-size: .9rem; padding-inline-end: .85rem; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0; padding: .5rem .7rem; }
.access-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: .25rem .6rem; }
.access-options .check { padding: .3rem 0; min-height: 32px; }
.access-options input { width: 1.1rem; height: 1.1rem; flex: 0 0 auto; }
.access-panel [name="managedUser"] { max-width: 34rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: start; }
th, td { padding: .66rem 1.1rem; text-align: start; border-bottom: 1px solid var(--line); }
th { background: #f8f7f3; color: #575147; font-size: .83rem; font-weight: 650; }
td { font-size: .94rem; }
tbody tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }
.badge { display: inline-block; padding: .13rem .48rem; border-radius: 999px;
  font-size: .79rem; white-space: nowrap; background: var(--soft); color: #544d42; }
.badge.good { background: #e6f1e7; color: #275532; }
.badge.wait { background: var(--gold-soft); color: #74480e; }
.badge.bad { background: #f9e8e4; color: #84382e; }
.row-list { list-style: none; margin: 0; padding: 0; }
.row-item { display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .65rem 1.1rem; border-top: 1px solid var(--line); }
.row-item p { color: var(--muted); font-size: .83rem; }
.stack { display: grid; gap: .8rem; }
.session-actions { padding: .8rem 1.1rem; border-top: 1px solid var(--line); }
.rating-cell button { width: 100%; }

.login-layout { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login-side { display: grid; place-items: center; padding: 2rem; }
.login-side .stack { width: min(100%, 350px); }
.login-side h2 { font-size: 1.9rem; }
.login-side .button { margin-top: .25rem; width: 100%; }
.login-hero { min-height: 100%; border-radius: 0; padding: clamp(1.25rem, 6vw, 5rem); }
.login-hero .brand { margin-bottom: 1.6rem; }
.login-hero .brand-mark { width: 82px; height: 73px; }
.login-hero h1 { font-size: clamp(1.7rem, 5vw, 4rem); }
.portal-bar { background: var(--black); padding: .7rem clamp(.85rem, 4vw, 2rem); display: flex;
  justify-content: space-between; align-items: center; gap: .6rem; }
.portal-bar .actions { justify-content: end; gap: .3rem; }
.portal-content { max-width: 950px; margin: auto; padding: 1.05rem clamp(.85rem, 4vw, 2rem) 2rem; }
.portal-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: .7rem; margin-bottom: .9rem; }
.portal-heading h1 { font-size: clamp(1.55rem, 5vw, 2.25rem); line-height: 1.23; }
.portal-heading p, .coach-help { color: var(--muted); }
.portal-heading select { min-width: 8rem; }
.coach-help { margin-bottom: .6rem; }
.score-row { margin-bottom: .65rem; padding: .35rem .65rem .7rem; }
.score-row legend { color: var(--ink); padding: 0 .3rem; font-size: 1rem; font-weight: 700; }
.score-options { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .25rem; }
.score-options button { min-width: 0; min-height: 44px; border: 1px solid #ddd4c5; border-radius: 8px;
  background: #fff; color: var(--ink); padding: .15rem; font-weight: 700; }
.score-options button:hover { background: var(--soft); }
.score-options button[aria-pressed="true"] { background: var(--gold); border-color: #95611c; color: #211608; }
.score-options .absent-score { font-size: .875rem; }
.coach-dock { position: sticky; bottom: 0; z-index: 1; display: grid; gap: .55rem; padding: .65rem;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 -4px 18px #271e1112; }
.coach-progress { color: var(--muted); font-weight: 650; }
.family-hero { margin-bottom: .85rem; min-height: 170px; }
.family-hero h2 { font-size: 1.05rem; }
.family-hero .latest-score { font-size: clamp(1.55rem, 6vw, 2.55rem); }
.family-hero p { margin-top: .4rem; }
.metric-grid, .award-grid { display: grid; gap: .65rem; }
.metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1rem; }
.home-metrics:not(:empty) { margin-top: .8rem; }
.home-metrics > .metric:last-child { grid-column: auto; }
.swimmer-select input { width: 1.15rem; height: 1.15rem; }
.swimmer-batch { border-top: 1px solid var(--line); }
.metric { margin: 0; padding: .7rem .85rem; }
.metric-grid > :last-child { grid-column: 1 / -1; }
.metric h2, .panel-heading h2 { font-size: 1rem; }
.metric strong { font-size: 1.55rem; line-height: 1.3; }
.metric p { color: var(--muted); font-size: .875rem; }
.winner-list { margin: .4rem 0; padding: 0; list-style: none; }
.winner-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.winner-list li span:last-child { white-space: nowrap; }
details > .actions { margin-top: .8rem; }

dialog { width: min(92vw, 490px); max-height: 88dvh; padding: 0; border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--ink); box-shadow: 0 15px 60px #15110938; }
dialog::backdrop { background: #16140991; }
.dialog-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 1.18rem; }
.dialog-body { padding: 1.05rem 1.1rem; }
.password-panel { max-width: 480px; margin-inline: auto; }
.registration-preview { display: grid; gap: .65rem; }
dialog:has(.registration-preview) { width: min(94vw, 810px); }
.registration-row { display: grid; grid-template-columns: 1fr; align-items: end; gap: .45rem;
  padding: .65rem; border: 1px solid var(--line); border-radius: 9px; }
.registration-note { grid-column: 1 / -1; }
@media (min-width: 650px) {
  .registration-row { grid-template-columns: 1.3fr .9fr 1.2fr auto; }
}
#toast { position: fixed; z-index: 2; bottom: 1rem; inset-inline-end: 1rem; padding: .7rem .95rem;
  max-width: calc(100% - 2rem); color: white; background: #252218; border-radius: 10px; box-shadow: 0 6px 20px #15110930; }

@media (max-width: 800px) {
  .workspace { display: block; }
  .sidebar { height: auto; position: static; padding: .7rem .8rem; flex-direction: row; align-items: center; flex-wrap: wrap; gap: .7rem; }
  .sidebar .brand { margin: 0; }
  .sidebar nav { order: 3; width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .25rem; }
  .sidebar nav:has([data-tab="users"]) { grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); }
  .nav-label, .nav-icon { display: none; }
  .nav-button { justify-content: center; padding: .4rem .1rem; font-size: .86rem; }
  .account { margin: 0; margin-inline-start: auto; border: 0; padding: 0; }
  .account .avatar, .account small { display: none; }
  .logout { margin-inline-start: .15rem; }
  .topbar { min-height: 48px; }
  .content { padding-top: 1rem; }
}

@media (max-width: 560px) {
  .sidebar nav:has(.nav-button:nth-of-type(6)) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .swimmer-admin-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .swimmer-admin-table tbody, .swimmer-admin-table { display: block; }
  .swimmer-admin-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: .55rem .8rem; padding: .85rem .75rem; border-bottom: 1px solid var(--line); }
  .swimmer-admin-table td { padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
  .swimmer-admin-table [data-label]::before { display: block; content: attr(data-label); color: var(--muted); font-size: .78rem; }
  .swimmer-admin-table .swimmer-name, .swimmer-admin-table .swimmer-actions { grid-column: 1 / -1; }
  .swimmer-admin-table tr:has(.swimmer-select) .swimmer-name { grid-area: 1 / 1 / 2 / 2; }
  .swimmer-admin-table .swimmer-select { grid-area: 1 / 2 / 2 / 3; justify-self: end; }
  .login-layout { display: flex; flex-direction: column; }
  .login-hero { min-height: 222px; }
  .login-side { padding: 1.4rem 1.1rem 2rem; }
  .hero::after { width: 65px; inset: 32% auto auto -8px; opacity: .65; }
  .hero::before { inset-inline-end: auto; }
  .section-heading { align-items: center; }
  .toolbar { padding-inline: .75rem; }
  th, td { padding-inline: .65rem; }
  .workspace .brand small, .portal-bar .brand small { display: none; }
  .account strong { font-size: .75rem; }
  .brand strong { font-size: .81rem; }
  .brand-mark { height: 34px; width: 38px; }
}

@media (min-width: 620px) {
  .score-options { grid-template-columns: repeat(11, minmax(0, 1fr)); }
  .coach-dock { grid-template-columns: 1fr auto; align-items: center; }
  .coach-dock .error { grid-column: 1 / -1; grid-row: 2; }
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-grid > :last-child { grid-column: auto; }
  .award-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
