:root {
  --ink: #0C0C0B;
  --ink-raised: #141412;
  --bone: #F0EBE0;
  --bone-dim: #a8a297;
  --gold: #C8A96E;
  --moss: #8AA57F;
  --rust: #C06A50;
  --line: rgba(240,235,224,0.12);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100%;
}

.num { font-family: 'Space Grotesk', sans-serif; font-variant-numeric: tabular-nums; }

#login-screen,
#employee-login-screen {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 24px;
}

.mark {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.mark span { color: var(--gold); }

.mark-sub {
  color: var(--bone-dim);
  font-size: 14px;
  margin-bottom: 40px;
}

#login-form,
#employee-login-form,
#add-employee-form {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#add-employee-form {
  max-width: none;
}

input[type="password"], input[type="text"], input[type="date"], input[type="number"], select, textarea {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--bone);
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  padding: 10px 2px;
  outline: none;
  transition: border-color 0.15s ease;
  width: 100%;
}
input[type="password"]:focus, input[type="text"]:focus, input[type="date"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
  border-bottom-color: var(--gold);
}
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.85);
}

option {
  background: var(--ink-raised);
  color: var(--bone);
}

button,
a.admin-btn,
a.btn-ghost,
a.btn-link {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 15px;
  background: var(--gold);
  color: var(--ink);
  border: none;
  padding: 12px 20px;
  min-height: 44px;
  cursor: pointer;
  transition: opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
button:hover,
a.admin-btn:hover,
a.btn-ghost:hover { opacity: 0.85; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.btn-ghost {
  background: transparent;
  color: var(--bone);
  border: 1px solid var(--line);
}

.btn-danger {
  background: transparent;
  color: var(--rust);
  border: 1px solid var(--line);
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  font-size: 13px;
}

#login-error,
#employee-login-error,
#employee-manage-error {
  color: var(--rust);
  font-size: 13px;
  min-height: 18px;
}

.load-error {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 16px;
}
.load-error[hidden] { display: none !important; }
.load-error p {
  margin: 0;
  font-size: 16px;
  color: var(--bone);
}

.inline-error {
  color: var(--rust);
  font-size: 14px;
  margin: 0 0 16px;
}
.inline-error[hidden] { display: none !important; }

.site-footer {
  margin-top: 64px;
  padding-top: 8px;
  text-align: center;
}
.site-footer a {
  color: rgba(240, 235, 224, 0.28);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', sans-serif;
}
.site-footer a:hover { color: rgba(240, 235, 224, 0.5); }

.totm[hidden] { display: none !important; }

#dashboard,
#public-view,
#employee-view {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 48px 24px 96px;
  overflow-x: hidden;
}

#public-view { max-width: 640px; }
#public-view[hidden] { display: none !important; }

header.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 48px;
  flex-wrap: wrap;
  gap: 16px;
}

.month-label {
  color: var(--bone-dim);
  font-size: 14px;
}

.month-now {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  font-weight: 500;
  margin-top: 4px;
}

select.month-select,
select#month-select {
  border-bottom: 1px solid var(--line);
  margin-top: 4px;
}

.header-actions {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
}

section { margin-bottom: 56px; }

h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 18px;
  margin: 0 0 20px;
}

.score-row {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.score-row:first-child { border-top: 1px solid var(--line); }

.rank {
  font-size: 22px;
  font-weight: 600;
  color: var(--bone-dim);
  width: 20px;
}

.score-row.first .rank { color: var(--gold); }

.score-name {
  flex: 1;
  font-size: 17px;
  font-weight: 500;
}

.score-total {
  font-size: 24px;
  font-weight: 600;
}
.score-total.pos { color: var(--moss); }
.score-total.neg { color: var(--rust); }
.score-total.zero { color: var(--bone-dim); }

.flags {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--bone-dim);
}
.flag-good { color: var(--moss); }
.flag-bad { color: var(--rust); }

#entry-form {
  display: none;
  flex-direction: column;
  gap: 16px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
#entry-form.open { display: flex; }

.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: min(160px, 100%); }

label {
  display: block;
  font-size: 12px;
  color: var(--bone-dim);
  margin-bottom: 4px;
}

.preview-points,
.edit-hint {
  font-size: 13px;
  color: var(--bone-dim);
}

#custom-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#custom-fields[hidden],
#note-field[hidden],
.preview-points[hidden] {
  display: none !important;
}

.toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

.log-row {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}
.log-row.is-editable { cursor: pointer; }
.log-row.is-editing { background: rgba(200, 169, 110, 0.08); }
.log-date { color: var(--bone-dim); width: 64px; flex-shrink: 0; }
.log-emp { width: 80px; flex-shrink: 0; font-weight: 500; }
.log-action { flex: 1; color: var(--bone); min-width: 0; overflow-wrap: anywhere; }
.log-points { font-weight: 600; width: 40px; text-align: right; flex-shrink: 0; }
.log-points.pos { color: var(--moss); }
.log-points.neg { color: var(--rust); }
.log-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.empty-state {
  color: var(--bone-dim);
  font-size: 14px;
  padding: 24px 0;
}

.logout-link,
a.logout-link {
  color: var(--bone-dim);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0;
  min-height: 44px;
  font-family: 'Inter', sans-serif;
  font-weight: 400;
}
.logout-link:hover,
a.logout-link:hover { color: var(--bone); opacity: 1; }

.nav-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.league-wrap {
  border: 1px solid var(--line);
  background: var(--ink-raised);
  width: 100%;
  overflow: hidden;
}

.league-head,
.league-row {
  display: grid;
  grid-template-columns: 56px 44px minmax(0, 1fr) 72px;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  min-width: 0;
}

.league-head {
  color: var(--bone-dim);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.league-head .col-pts,
.league-row .league-pts {
  text-align: right;
}

a.league-row,
.league-row {
  width: 100%;
  border: none;
  border-top: 1px solid var(--line);
  background: transparent;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
  padding: 12px 16px;
  min-height: 56px;
  text-decoration: none;
}
.league-row:first-of-type { border-top: none; }
.league-row:hover,
.league-row:focus-visible {
  opacity: 1;
  background: rgba(240,235,224,0.05);
}

.league-rank-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.league-rank {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--bone-dim);
  flex-shrink: 0;
}
.league-row.first .league-rank { color: var(--gold); }

.rank-change {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  line-height: 1;
  flex-shrink: 0;
  letter-spacing: 0;
}
.rank-change.up { color: var(--moss); }
.rank-change.down { color: var(--rust); }
.rank-change.same { color: var(--bone-dim); }

.totm {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(200, 169, 110, 0.45);
  background: linear-gradient(90deg, rgba(200, 169, 110, 0.12), rgba(200, 169, 110, 0.04));
  min-width: 0;
}
.totm-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}
.totm-copy { min-width: 0; }
.totm-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 2px;
}
.totm-names {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1c1c18;
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--gold);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.avatar img.is-hidden {
  display: none;
}
.avatar .avatar-initials {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
}
.avatar.no-photo .avatar-initials {
  display: flex;
}
.avatar.lg {
  width: 56px;
  height: 56px;
  font-size: 20px;
}

.league-name {
  font-size: 16px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.league-pts {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 600;
}

.league-pts.pos { color: var(--moss); }
.league-pts.neg { color: var(--rust); }
.league-pts.zero { color: var(--bone-dim); }

.admin-btn {
  font-size: 13px;
  padding: 12px 16px;
  min-height: 44px;
  white-space: nowrap;
}

.emp-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.emp-hero-text { flex: 1; min-width: 0; }
.emp-hero-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 4px;
}
.emp-hero-meta {
  color: var(--bone-dim);
  font-size: 14px;
}
.emp-hero-total {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 36px;
  font-weight: 600;
}

select.month-select,
select#month-select {
  max-width: 100%;
  min-height: 44px;
}

.manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
  flex-wrap: wrap;
}
.manage-name {
  font-size: 16px;
  font-weight: 500;
}
.manage-meta {
  font-size: 13px;
  color: var(--bone-dim);
}

.section-note {
  color: var(--bone-dim);
  font-size: 13px;
  margin: -8px 0 16px;
}

@media (max-width: 520px) {
  #login-screen,
  #employee-login-screen {
    padding: 20px 16px;
  }

  #dashboard,
  #public-view,
  #employee-view {
    padding: 24px 16px 80px;
  }

  header.top {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 32px;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
    align-items: flex-end;
  }

  .league-head,
  .league-row {
    grid-template-columns: 48px 40px minmax(0, 1fr) 52px;
    gap: 8px;
    padding: 10px 12px;
  }

  .totm {
    padding: 12px;
    gap: 10px;
  }
  .totm-names { font-size: 16px; }
  .rank-change { font-size: 10px; }

  .league-row {
    min-height: 56px;
  }

  .league-rank { font-size: 16px; }
  .league-name { font-size: 15px; }
  .league-pts { font-size: 18px; }

  .emp-hero-name { font-size: 20px; }
  .emp-hero-total {
    width: 100%;
    font-size: 28px;
  }

  .score-row {
    gap: 12px;
    padding: 14px 0;
  }

  .score-name { font-size: 16px; }
  .score-total { font-size: 20px; }

  .log-emp { width: auto; min-width: 72px; }
  .log-action { flex-basis: 100%; }

  .form-row { flex-direction: column; }
  .form-row > div { min-width: 0; width: 100%; }

  h2 { font-size: 17px; }
}
