:root {
  --color-bg: #ffffff;
  --color-text: #1f2933;
  --color-border: #d7dbe0;
  --color-header-bg: #2f3e46;
  --color-header-text: #ffffff;
  --color-muted: #f4f5f6;
  --color-theoretical: #31ff48;
  --color-holiday: #fcd8b0;
  --color-holiday-ferie: #fcd8b0;
  --color-disabled: #ececec;
  --color-danger: #c0392b;
  --color-success: #2e7d32;
  --color-warning: #b8860b;
  --logo-position: flex-start;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 15px;
  line-height: 1.4;
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: var(--logo-position);
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

header.topbar .logo {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

header.topbar .logo img {
  height: 64px;
  display: block;
}

.role-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-left: 0.7rem;
  border-left: 2px solid var(--color-border);
  padding-right: 0.7rem;
  border-right: 2px solid var(--color-border);
}

.role-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-header-bg);
}

.season-label {
  font-size: 0.6rem;
  color: var(--color-text);
  opacity: 0.7;
  text-align: center;
}

.debug-badge {
  color: #c0392b;
  border: none;
}

header.topbar nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: 1rem;
  flex-wrap: wrap;
}

header.topbar nav a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
}

.nav-menu {
  position: relative;
}

.nav-menu > summary {
  color: var(--color-text);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.nav-menu > summary::-webkit-details-marker {
  display: none;
}

.nav-menu > summary::after {
  content: " \25be";
}

.nav-menu-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  min-width: 12rem;
  padding: 0.3rem 0;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

header.topbar nav .nav-menu-panel a {
  padding: 0.4rem 0.8rem;
  font-weight: normal;
  white-space: nowrap;
}

header.topbar nav .nav-menu-panel a:hover {
  background: var(--color-border);
}

header.topbar .spacer {
  flex: 1;
}

main {
  padding: 1rem;
  max-width: 100%;
  overflow-x: auto;
}

.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.flash-container {
  position: fixed;
  top: 0.8rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: max-content;
  max-width: min(90vw, 40rem);
}

.flash {
  padding: 0.5rem 0.8rem;
  border-radius: 4px;
  border: 1px solid transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  background: var(--color-bg);
}

.flash.success {
  background: #eaf6ec;
  border-color: var(--color-success);
  color: var(--color-success);
}

.flash.error {
  background: #fbeceb;
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.flash.warning {
  background: #fdf3e0;
  border-color: var(--color-warning);
  color: var(--color-warning);
}

table.grid {
  border-collapse: collapse;
  width: max-content;
  margin-right: 10px;
}

table.grid th,
table.grid td {
  border: 1px solid var(--color-border);
  padding: 0.25rem 0.4rem;
  text-align: center;
  font-size: 0.85rem;
}

table.grid th.day-header {
  background: var(--color-header-bg);
  color: var(--color-header-text);
}

table.grid th.day-start,
table.grid td.day-start {
  box-shadow: inset 1.5px 0 0 var(--color-header-bg);
}

table.grid th.day-header.day-start {
  box-shadow: inset 1.5px 0 0 var(--color-header-text);
}

table.grid td.holiday {
  background: var(--color-holiday);
}

table.grid td.holiday-ferie {
  background: var(--color-holiday-ferie);
}

table.grid tr.coach-group-end td {
  border-bottom: 2px solid var(--color-header-bg);
}

table.grid td.out-of-month {
  background: var(--color-disabled);
  color: #9aa5b1;
}

table.grid th.vertical-header {
  height: 9rem;
  min-width: 1.8rem;
  max-width: 2.4rem;
  padding: 0.3rem 0.1rem;
  vertical-align: bottom;
}

table.grid th.vertical-header .vertical-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  margin: 0 auto;
  font-weight: normal;
}

table.grid input.cell-input {

  width: 2.8rem;
  text-align: center;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 0.15rem 0.3rem;
}

table.grid input.cell-input:disabled {
  background: transparent;
  border-color: transparent;
}

.cell-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  vertical-align: middle;
  width: 1.6rem;
  height: 1.6rem;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  background: white;
  font-weight: 700;
}

.cell-toggle.holiday {
  background: var(--color-holiday);
  border-color: var(--color-header-bg);
}

.cell-toggle.holiday-ferie {
  background: var(--color-holiday-ferie);
  border-color: var(--color-header-bg);
}

.cell-toggle.theoretical {
  background: var(--color-theoretical);
}

.cell-toggle.checked {
  background: var(--color-header-bg);
  color: white;
}

.cell-toggle.theoretical.checked {
  background: var(--color-theoretical);
  color: #000;
}

.cell-toggle[data-disabled] {
  cursor: default;
  opacity: 0.6;
}

.chip {
  display: inline-block;
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  background: #f2f2f2;
  border: 1px solid #d8d8d8;
  border-radius: 4px;
  padding: 1px 6px;
  margin: 1px 3px 1px 0;
  font-size: 0.85em;
}

table.synthese {
  border-collapse: collapse;
  max-width: 900px;
}

table.synthese th,
table.synthese td {
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.6rem;
  text-align: center;
}

table.synthese th {
  background: var(--color-muted);
}

table.synthese tr.total {
  font-weight: 700;
  background: var(--color-muted);
}

table.synthese.striped tbody tr:nth-child(even) td {
  background: var(--color-muted);
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.validate-month {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.2rem;
}

.button {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--color-header-bg);
  background: var(--color-header-bg);
  color: white;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.9rem;
}

.button.secondary {
  background: white;
  color: var(--color-header-bg);
}

.button.danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
}

.btn-holiday {
  background: var(--color-holiday-ferie);
  border-color: var(--color-holiday-ferie);
  color: var(--color-text);
}

.btn-holiday:hover,
.btn-holiday:focus {
  filter: brightness(0.92);
  color: var(--color-text);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button[hidden] {
  display: none;
}

.row-delete-form {
  display: inline;
}

.row-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-left: 0.4rem;
  font-size: 0.9rem;
  line-height: 1;
  vertical-align: middle;
}

.row-label {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  width: 100%;
}

.row-label-text {
  overflow-wrap: anywhere;
}

.row-label .week-comment-btn {
  margin-left: auto;
}

.week-comment-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 0;
  flex: none;
}

.week-comment-icon {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
}

.week-comment-btn.is-empty {
  color: var(--color-success);
}

.week-comment-btn.has-comment {
  color: var(--color-danger);
}

.week-comment-dots {
  fill: var(--color-bg);
}

.week-comment-btn.is-empty .week-comment-dots {
  display: none;
}

.week-comment-btn:hover,
.week-comment-btn:focus {
  filter: brightness(1.25);
}

.filters {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: end;
}

.filters label {
  display: block;
  font-size: 0.8rem;
  color: #555;
  margin-bottom: 0.2rem;
}

.coach-block {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.8rem;
  margin-bottom: 1.2rem;
}

.coach-block h3 a {
  color: var(--color-header-bg);
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge.locked {
  background: var(--color-disabled);
  color: #555;
}

.badge.validated {
  background: var(--color-theoretical);
  color: var(--color-success);
}

.card {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}

dialog.modal {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.2rem;
  max-width: 90vw;
  width: 24rem;
}

dialog.modal[open] {
  display: block;
  position: fixed;
  inset: 0;
  margin: auto;
  height: fit-content;
  overflow: visible;
}

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

dialog.modal h3 {
  margin-top: 0;
}

dialog.week-comment-modal {
  width: 30rem;
}

.week-comment-context {
  margin: 0 0 0.6rem 0;
  font-weight: 600;
}

.week-comment-input {
  width: 100%;
  resize: vertical;

  font-family: inherit;
  font-size: inherit;
}

.week-comment-readonly {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 50vh;
  overflow-y: auto;
}

.planning-table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1.5rem;
  table-layout: fixed;

  --planning-subcol-width: 4.5em;
}

.planning-table th,
.planning-table td {
  border: 1px solid var(--color-border);
  padding: 0.3rem;
  text-align: center;
  font-size: 0.85rem;
  overflow-wrap: break-word;
}

.planning-table th {
  background: var(--color-header-bg);
  color: var(--color-header-text);
}

.planning-table td.time-col {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  background: var(--color-muted);
}

.planning-table td.planning-cell {
  padding: 0;
  position: relative;
}

.planning-parallel {

  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
}

.planning-parallel .planning-entry {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem;
  border-right: 1px solid var(--color-border);
  overflow-wrap: break-word;
  text-align: center;
}

.planning-parallel .planning-entry:last-child {
  border-right: none;
}

@media (max-width: 720px) {
  table.grid.desktop-grid {
    display: none;
  }

  .desktop-only {
    display: none;
  }

  .mobile-day-picker {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    margin-bottom: 0.8rem;
  }

  .mobile-day-picker button {
    flex: 0 0 auto;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--color-border);
    background: white;
    border-radius: 4px;
  }

  .mobile-day-picker button.active {
    background: var(--color-header-bg);
    color: white;
  }

  .mobile-day-block {
    display: none;
  }

  .mobile-day-block.active {
    display: block;
  }

  .mobile-category-card {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.6rem;
    margin-bottom: 0.6rem;
  }

  .mobile-category-card h4 {
    margin: 0 0 0.4rem 0;
  }

  .mobile-cell-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--color-muted);
  }
}

@media (min-width: 721px) {
  .mobile-only {
    display: none;
  }

  table.grid.desktop-grid th.sticky-col-1,
  table.grid.desktop-grid td.sticky-col-1 {
    position: sticky;
    left: 0;
    width: 9rem;
    min-width: 9rem;
    max-width: 9rem;
    background: var(--color-bg);
  }

  table.grid.desktop-grid th.sticky-col-2,
  table.grid.desktop-grid td.sticky-col-2 {
    position: sticky;
    left: 9rem;
    width: 9rem;
    min-width: 9rem;
    max-width: 9rem;
    background: var(--color-bg);
    box-shadow: 2px 0 4px -2px rgba(0, 0, 0, 0.25);
  }

  table.grid.desktop-grid th.sticky-col-1,
  table.grid.desktop-grid th.sticky-col-2 {
    z-index: 3;
  }

  table.grid.desktop-grid td.sticky-col-1,
  table.grid.desktop-grid td.sticky-col-2 {
    z-index: 1;
  }
}

.impersonate-form select {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--color-header-bg);
  border-radius: 4px;
  background: white;
  color: var(--color-header-bg);
  cursor: pointer;
}

.admin-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-menu .nav-link,
.admin-menu .dropdown-toggle {
  padding: 0;
}

.admin-menu .dropdown-menu a {
  font-weight: normal;
}

.copy-icon {
  display: inline-block;
  width: 1.2em;
  text-decoration: none;
  cursor: pointer;
  color: var(--color-header-bg);
}

.icon-mono {
  filter: grayscale(1);
  text-decoration: none;
}

.app-footer {
  text-align: center;
  font-size: 0.7rem;
  color: #999;
  padding: 0.8rem;
}

.text-left { text-align: left !important; }
.nowrap { white-space: nowrap; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-block { display: block; }
.w-full { width: 100%; }
.mt-3 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.ml-3 { margin-left: 1rem; }
.icon-col { width: 2rem; }

.auth-card {
  max-width: 400px;
  margin: 3rem auto;
}
.auth-card.wide { max-width: 480px; }
.auth-card.compact { margin: 2rem auto; }
.auth-card.centered { text-align: center; }

.plain-list {
  list-style: none;
  padding: 0;
}

.icon-btn {
  background: none;
  border: none;
  padding: 0;
}

.sort-link {
  color: inherit;
  white-space: nowrap;
}
.sort-link.inactive,
.sort-icon-inactive {
  opacity: 0.4;
}

.grid-coach-label {
  text-align: left !important;
  font-weight: 600;
}

.coach-profile-table {
  max-width: 500px;
  margin-bottom: 1rem;
}
.coach-categories-table { max-width: 400px; }
.rate-input { width: 6rem; }

.coachs-table {
  width: 100%;
  max-width: none;
}
.coach-phone-col { width: 15%; }

.contacts-table {
  width: auto;
}
.contacts-snug-col { padding-right: calc(0.6rem + 10px); }

table.synthese .contacts-group-row td {
  text-align: left;
  font-weight: 700;
  border: none;
  background: none;
}

table.synthese .contacts-spacer-row td {
  border: none;
  background: none;
  padding: 0.5rem 0;
}

.category-select {
  width: 100%;
  margin-top: 0.3rem;
}

.dialog-actions {
  margin-top: 1.2rem;
  margin-bottom: 0;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.rate-warning { color: #c00; }

.table-scroll { overflow-x: auto; }
.time-col-width { width: 4.5em; }
.day-col-width { width: calc(var(--planning-subcol-width) * 3); }

.list-buttons-column { width: 1%; white-space: nowrap; }

.container-fluid > .nav-tabs { border-bottom: none; }

table.model-list.users-grouped-table { width: auto; }

.users-grouped-table .list-buttons-column { width: auto; }

.users-grouped-table .col-is_active_user { text-align: center; }
.users-grouped-table .col-first_name,
.users-grouped-table .col-email {
  white-space: nowrap;

  padding-right: calc(0.75rem + 10px);
}

.users-grouped-table tbody + tbody { border-top: none; }

table.model-list tr.group-title-row,
table.model-list tr.group-title-row:hover,
table.model-list tr.group-spacer-row,
table.model-list tr.group-spacer-row:hover,
table.model-list tr.group-header-row,
table.model-list tr.group-header-row:hover {
  background-color: transparent;
}

table.model-list tr.group-header-row th {
  vertical-align: bottom;
  border-bottom-width: 2px;
}
table.model-list tr.group-title-row td {
  border: none;
  text-align: left;
  font-weight: 700;
}
table.model-list tr.group-spacer-row td {
  border: none;
  padding: 0.5rem 0;
}

.color-swatch {
  display: inline-block;
  width: 28px;
  height: 18px;
  border: 1px solid #ccc;
  border-radius: 3px;
  vertical-align: middle;
}

.status-card-danger { border-color: #c0392b; }

.danger-zone { margin-top: 2.5rem; }
.danger-zone h4 { color: #c0392b; }

dialog.purge-dialog { width: 30rem; }

.check-group { margin-bottom: 0.5rem; }
.check-group-items { margin-left: 1.6rem; }
.check-group label { font-weight: normal; margin-bottom: 0; }
.check-group p { margin-bottom: 0; }

.exclusive-check-list {
  max-width: 400px;
  max-height: 14rem;
  overflow-y: auto;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
}
.exclusive-check-list label { font-weight: normal; margin-bottom: 0; }
.exclusive-check-list p { margin-bottom: 0; }

.color-form-flex {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hex-input { width: 8rem; }

.season-switch-actions { margin-top: 5px; }

.line-meta {
  color: #6b7280;
  font-style: italic;
  font-size: 0.85em;
}

.linklike {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--color-header-bg);
  text-decoration: underline;
  cursor: pointer;
}

table.checklist {
  width: 100%;
  max-width: 100%;
}

table.checklist input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
}
