:root {
  color-scheme: light dark;
  --good: #1a7f37;
  --bad: #cf222e;
  --neutral: #6e7781;
  --border: #d0d7de;
  --highlight: #cfe3fc;
  --highlight-hover: #b9d6fb;
  --value-fg: currentColor;
  --chart-line: #0969da;
}

@media (prefers-color-scheme: dark) {
  :root {
    --border: #3d444d;
    --highlight: #1c3a5e;
    --highlight-hover: #234a78;
    --chart-line: #58a6ff;
  }
}

@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/outfit-bold.woff2') format('woff2');
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
  box-sizing: border-box;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 3.5rem;
  padding: 0 1.25rem;
  box-sizing: border-box;
  background: Canvas;
  border-bottom: 1px solid var(--border);
}

.app-header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  flex: none;
}

.app-logo {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 22%;
  object-fit: cover;
  display: block;
  flex: none;
}

.app-name {
  font-family: 'Outfit', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.profile-icon {
  width: 2rem;
  height: 2rem;
  flex: none;
  border-radius: 50%;
  background: var(--chart-line);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  user-select: none;
}

#auth-screen:not([hidden]) {
  display: flex;
  justify-content: center;
  padding-top: 3rem;
}

.auth-card {
  width: 100%;
  max-width: 320px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-card label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
}

#auth-toggle-btn {
  margin-top: 1rem;
  background: none;
  border: none;
  color: var(--chart-line);
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
}

.profile-dropdown {
  position: relative;
  align-items: center;
  margin: 0 0 0 auto;
  padding: 0;
  border: none;
  border-radius: 0;
}

.profile-dropdown:not([hidden]) {
  display: inline-flex;
}

.profile-dropdown > summary {
  list-style: none;
}

.profile-dropdown > summary::-webkit-details-marker {
  display: none;
}

.profile-menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  z-index: 10;
  min-width: 200px;
  background: Canvas;
  color: CanvasText;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#profile-email {
  margin: 0 0 0.5rem;
  word-break: break-all;
}

#admin-link {
  display: block;
  margin-bottom: 0.5rem;
}

/* The [hidden] attribute selector must out-specificity the plain ID rule
   above, or the browser's UA `[hidden] { display: none }` rule loses the
   cascade tie and the link stays visible to non-admins even while hidden. */
#admin-link[hidden] {
  display: none;
}

details {
  margin: 0.5rem 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

summary {
  cursor: pointer;
  font-weight: 600;
}

#practice-plan-list li {
  margin: 0.35rem 0;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 0.5rem;
}

th, td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: center;
  font-size: 0.85rem;
  vertical-align: top;
}

.notice {
  color: var(--neutral);
  font-style: italic;
}

.retired-row {
  color: var(--neutral);
  font-style: italic;
}

.trend-good { color: var(--good); font-weight: 600; }
.trend-bad { color: var(--bad); font-weight: 600; }
.trend-neutral { color: var(--neutral); }

.cell-value {
  color: var(--value-fg);
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.dashboard-table th.selectable {
  cursor: pointer;
}

.dashboard-table th.selectable:hover {
  background: rgba(127, 127, 127, 0.15);
}

.dashboard-table th.selected,
.dashboard-table td.selected {
  background: var(--highlight);
}

.dashboard-table th.disabled {
  color: var(--neutral);
}

.col-label {
  font-weight: 600;
}

.col-range {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--neutral);
  margin-top: 0.15rem;
}

#rounds-tbody tr:not(.editing),
#campaign-rounds-tbody tr:not(.editing) {
  cursor: pointer;
}

#rounds-tbody tr:not(.editing):hover,
#campaign-rounds-tbody tr:not(.editing):hover {
  background: rgba(127, 127, 127, 0.15);
}

#rounds-tbody tr.highlighted,
#campaign-rounds-tbody tr.highlighted {
  background: var(--highlight);
}

#rounds-tbody tr.highlighted:hover,
#campaign-rounds-tbody tr.highlighted:hover {
  background: var(--highlight-hover);
}

#rounds-tbody tr.editing td,
#campaign-rounds-tbody tr.editing td,
#kpi-catalog-tbody tr.editing td,
#tenet-catalog-tbody tr.editing td {
  padding: 0.3rem;
}

#rounds-tbody tr.editing input,
#rounds-tbody tr.editing select,
#campaign-rounds-tbody tr.editing input,
#campaign-rounds-tbody tr.editing select,
#kpi-catalog-tbody tr.editing input,
#kpi-catalog-tbody tr.editing select,
#tenet-catalog-tbody tr.editing input,
#tenet-catalog-tbody tr.editing select {
  width: 100%;
  box-sizing: border-box;
  padding: 0.3rem;
  font-size: 0.85rem;
}

#rounds-tbody tr.editing input[type="number"],
#campaign-rounds-tbody tr.editing input[type="number"] {
  -moz-appearance: textfield;
}

#rounds-tbody tr.editing input[type="number"]::-webkit-outer-spin-button,
#rounds-tbody tr.editing input[type="number"]::-webkit-inner-spin-button,
#campaign-rounds-tbody tr.editing input[type="number"]::-webkit-outer-spin-button,
#campaign-rounds-tbody tr.editing input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.required-marker {
  color: var(--neutral);
  margin-left: 0.25rem;
  font-weight: bold;
}

.required-marker.field-error {
  color: var(--bad);
}

#rounds-tbody tr.editing input.field-error,
#campaign-rounds-tbody tr.editing input.field-error {
  outline: 2px solid var(--bad);
  outline-offset: -1px;
}

.actions-cell {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.row-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
}

.row-btn.save-btn {
  border-color: var(--good);
  color: var(--good);
}

.row-btn.delete-btn {
  border-color: var(--bad);
  color: var(--bad);
}

.campaign-dialog {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.5rem;
  max-width: 480px;
  width: 90%;
}

.campaign-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.handicap-history-dialog {
  max-width: 720px;
}

.handicap-history-scroll {
  overflow-x: auto;
}

.handicap-history-chart {
  height: auto;
  display: block;
}

.handicap-history-chart--fit {
  width: 100%;
}

.handicap-history-chart .history-line {
  fill: none;
  stroke: var(--chart-line);
  stroke-width: 2;
}

.handicap-history-chart .history-point {
  fill: var(--chart-line);
}

.handicap-history-chart .history-axis {
  stroke: var(--border);
}

.handicap-history-chart .history-axis-label {
  fill: var(--neutral);
  font-size: 0.7rem;
}

.handicap-history-chart .history-date-label {
  fill: var(--neutral);
  font-size: 0.65rem;
}

.wizard-step label {
  display: block;
  margin: 0.25rem 0;
}

.nav-btn {
  margin: 0;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  color: inherit;
  background: transparent;
  border: none;
}

.nav-btn:hover {
  background: rgba(127, 127, 127, 0.15);
}

.header-campaign-name {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  min-width: 0;
  flex-shrink: 1;
}

/* Same [hidden]-specificity fix as .campaigns-dropdown-slot[hidden]. */
.header-campaign-name[hidden] {
  display: none;
}

#campaign-name-display {
  font-size: 1rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 18rem;
}

.campaigns-dropdown-slot,
.campaign-gear-slot {
  display: inline-block;
}

/* The [hidden] attribute selector must out-specificity the plain class rule
   above, or the browser's UA `[hidden] { display: none }` rule loses the
   cascade tie and the dropdown stays visible to a logged-out user even
   while hidden. */
.campaigns-dropdown-slot[hidden] {
  display: none;
}

.campaigns-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
}

.campaigns-dropdown > summary {
  list-style: none;
}

.campaigns-dropdown > summary::-webkit-details-marker {
  display: none;
}

.campaigns-dropdown .campaigns-menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  z-index: 10;
  min-width: 220px;
  background: Canvas;
  color: CanvasText;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.campaigns-menu-create {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.25rem;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 600;
}

.campaigns-menu-create:hover {
  background: rgba(127, 127, 127, 0.15);
}

.campaigns-menu-limit-notice {
  margin: 0 0 0.4rem;
  padding: 0 0.5rem;
  font-size: 0.85rem;
}

.campaigns-menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
}

.campaigns-menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
}

.campaign-link {
  flex: 1;
  text-align: left;
  padding: 0.4rem 0.5rem;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: 4px;
}

.campaign-link:hover {
  background: rgba(127, 127, 127, 0.15);
}

.campaign-gear {
  position: relative;
  display: inline-block;
}

.campaign-gear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  font-size: 1rem;
  line-height: 1;
  border-radius: 4px;
}

.campaign-gear-btn:hover {
  background: rgba(127, 127, 127, 0.15);
}

.campaign-gear-popover {
  position: fixed;
  z-index: 11;
  min-width: 140px;
  background: Canvas;
  color: CanvasText;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
}

.campaign-gear-heading {
  margin: 0 0 0.3rem;
  padding: 0.2rem 0.5rem 0.3rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.85rem;
}

/* The [hidden] attribute selector must out-specificity the plain class rule
   above, or the browser's UA `[hidden] { display: none }` rule loses the
   cascade tie and the popover stays visible (and click-interceptable) even
   while hidden. */
.campaign-gear-popover[hidden] {
  display: none;
}

.campaign-gear-popover button {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: 4px;
}

.campaign-gear-popover button:hover {
  background: rgba(127, 127, 127, 0.15);
}

.campaign-gear-popover .campaign-gear-delete {
  color: var(--bad);
}

.suggestion-popover {
  position: fixed;
  z-index: 12;
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: Canvas;
  color: CanvasText;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Same [hidden]-specificity fix as .campaign-gear-popover[hidden]. */
.suggestion-popover[hidden] {
  display: none;
}

.suggestion-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.5rem;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: 4px;
}

.suggestion-item:hover,
.suggestion-item.highlighted {
  background: rgba(127, 127, 127, 0.15);
}

.handicap-widget {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

/* Same fix as .campaign-gear-popover[hidden]: the [hidden] attribute
   selector must out-specificity the plain class rule above, or the
   browser's UA `[hidden] { display: none }` rule loses the cascade tie. */
.handicap-widget[hidden] {
  display: none;
}

.handicap-label {
  font-weight: 600;
}

.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border: 1.5px solid var(--neutral);
  border-radius: 50%;
  background: transparent;
  color: var(--neutral);
  cursor: pointer;
  font-size: 0.7rem;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
  padding: 0;
}

.info-btn:hover {
  color: inherit;
  border-color: currentColor;
}

.export-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  border: 1.5px solid var(--neutral);
  border-radius: 4px;
  background: transparent;
  color: var(--neutral);
  cursor: pointer;
  padding: 0;
}

.export-btn:hover {
  color: inherit;
  border-color: currentColor;
}

.export-icon {
  width: 0.85rem;
  height: 0.85rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#rounds-details,
#campaign-rounds-details {
  position: relative;
}

#export-rounds-btn,
#export-campaign-rounds-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
}

.dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

/* Notice shares the toolbar row with the export button (see renderDashboard/
   renderCampaignDashboard) so the table starts right below one combined row
   instead of stacking a separate notice row above it. */
.dashboard-toolbar .dashboard-notice {
  margin: 0;
  margin-right: auto;
}

#handicap-info-dialog ul {
  padding-left: 1.25rem;
}

#handicap-info-dialog li {
  margin: 0.25rem 0;
}
