:root {
  --color-bg: #e8eef2;
  --color-surface: #fff;
  --color-forest: #0f3d2e;
  --color-forest-light: #1a5c45;
  --color-border: #d8dee4;
  --color-text: #1a2330;
  --color-muted: #5c6b7a;
  --color-row-alt: #f4f7f9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(15, 61, 46, 0.06);
  --shadow-lg: 0 8px 30px rgba(15, 61, 46, 0.1);
  /* Use more of the viewport so wide tables are not squeezed next to empty margins */
  --layout-max: min(90rem, calc(100vw - 1.5rem));
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: min(90vw, 28rem);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  background: var(--color-forest);
  color: #fff;
  text-align: center;
}

.toast.error {
  background: #8b1538;
}

.toast.hidden {
  display: none;
}

.top {
  background: linear-gradient(135deg, var(--color-forest) 0%, var(--color-forest-light) 100%);
  color: #fff;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}

.top-inner {
  max-width: var(--layout-max);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  justify-content: space-between;
}

.top h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.main-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.nav-pill {
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  color: #fff;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
}

.nav-pill:hover {
  background: rgba(255, 255, 255, 0.14);
}

.nav-pill.active {
  background: #fff;
  color: var(--color-forest);
  border-color: #fff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  margin-left: auto;
}

.header-actions button {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

main {
  max-width: var(--layout-max);
  width: 100%;
  margin: 0 auto;
  padding: 1.35rem clamp(0.75rem, 2vw, 1.25rem) 2.5rem;
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 1.35rem clamp(1rem, 2.5vw, 1.75rem);
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(216, 222, 228, 0.7);
  min-width: 0; /* allow flex/grid children to shrink; table wrapper handles overflow */
}

.card-sessions {
  padding-bottom: 1.5rem;
}

.card-head h2 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 650;
  color: var(--color-forest);
  letter-spacing: -0.02em;
}

.card-head-hint {
  margin: 0 0 1.1rem;
}

.field-hike {
  margin-bottom: 1.35rem;
}

.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
}

.input-lg,
select.input-lg {
  font-size: 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #fafbfc;
}

.input-lg:focus,
select.input-lg:focus {
  outline: 2px solid rgba(15, 61, 46, 0.35);
  outline-offset: 1px;
  background: #fff;
}

/* Group sessions panel */
.sessions-panel {
  margin-top: 0.25rem;
  padding: 1.15rem 1.2rem;
  background: linear-gradient(180deg, #f6f9f7 0%, #eef3f0 100%);
  border-radius: var(--radius-sm);
  border: 1px solid #cdd9d3;
  min-width: 0;
  overflow-x: visible;
}

.sessions-panel-title {
  margin-bottom: 0.85rem;
}

.sessions-panel-title h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--color-forest);
}

.sessions-sub {
  display: block;
  font-size: 0.82rem;
  color: var(--color-muted);
  margin-top: 0.2rem;
}

.sessions-empty {
  margin: 1rem 0 0;
  padding: 1rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--color-border);
}

/* Log session card */
.card-log .log-title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--color-forest);
}

.log-hint {
  margin: 0 0 1.1rem;
}

.form-session-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1.1rem;
}

@media (max-width: 560px) {
  .form-session-grid {
    grid-template-columns: 1fr;
  }

  .field-span-2 {
    grid-column: span 1;
  }
}

.field-span-2 {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-actions .message {
  margin: 0;
}

/* Tables */
.table-wrap-elevated {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  margin-top: 0;
  max-height: min(55vh, 28rem);
  border-radius: var(--radius-sm);
  border: 1px solid #c5d0cc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.sessions-table {
  /* As wide as columns need; at least fill the wrapper. Scroll horizontally if needed. */
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
  table-layout: auto;
}

/* Keep text columns and Actions from collapsing when the viewport is narrow */
.sessions-table thead th:nth-child(6),
.sessions-table tbody td:nth-child(6) {
  min-width: 7.5rem;
}

.sessions-table thead th:nth-child(7),
.sessions-table tbody td:nth-child(7) {
  min-width: 7.5rem;
}

.sessions-table thead th:nth-child(8),
.sessions-table tbody td:nth-child(8) {
  min-width: 10.5rem;
}

.session-actions-btns {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  align-items: center;
}

.btn-danger {
  color: #7a1028;
  border-color: #c9a0a8;
  background: #fff8f8;
}

.btn-danger:hover {
  background: #fde8ec;
  border-color: #8b1538;
}

.sessions-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.7rem 0.75rem;
  text-align: left;
  font-weight: 650;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-forest);
  background: linear-gradient(180deg, #e4ece8 0%, #d8e5df 100%);
  border-bottom: 2px solid #b8c9c0;
  white-space: nowrap;
}

.sessions-table thead th.th-sortable {
  cursor: pointer;
  user-select: none;
  outline: none;
}

.sessions-table thead th.th-sortable:hover {
  background: linear-gradient(180deg, #dbe8e2 0%, #cddfd5 100%);
}

.sessions-table thead th.th-sortable:focus-visible {
  box-shadow: inset 0 0 0 2px var(--color-forest);
}

.sessions-table thead th.th-sort-num {
  text-align: right;
  vertical-align: middle;
}

.sessions-table thead th.th-sort-num .sort-indicator {
  display: inline-block;
  margin-left: 0.35rem;
}

.sort-indicator {
  display: inline-block;
  min-width: 0.65em;
  font-size: 0.85em;
  opacity: 0.45;
}

.th-sortable.sorted-asc .sort-indicator::after {
  content: '▲';
  opacity: 0.9;
}

.th-sortable.sorted-desc .sort-indicator::after {
  content: '▼';
  opacity: 0.9;
}

.th-sortable:not(.sorted-asc):not(.sorted-desc) .sort-indicator::after {
  content: '·';
  opacity: 0.25;
}

/* Filter row under sort headers */
.sessions-filter-row th {
  padding: 0.4rem 0.45rem 0.55rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  background: #e8f0eb;
  border-bottom: 1px solid #b8c9c0;
  vertical-align: middle;
}

.sessions-filter-row .th-filter-num {
  text-align: right;
}

.session-filter-input {
  width: 100%;
  min-width: 4.5rem;
  max-width: 100%;
  padding: 0.35rem 0.45rem;
  font-size: 0.78rem;
  border: 1px solid #b8c9c0;
  border-radius: 6px;
  background: #fff;
}

.session-filter-input::placeholder {
  color: #9aa8b0;
}

.session-filter-input:focus {
  outline: 2px solid rgba(15, 61, 46, 0.35);
  outline-offset: 1px;
  border-color: var(--color-forest);
}

.filter-empty-row .filter-empty-cell {
  text-align: center;
  padding: 1.25rem 1rem !important;
  color: var(--color-muted);
  font-size: 0.9rem;
  background: #fafbfb;
  border-bottom: none !important;
}

.sessions-table thead th.th-actions {
  text-align: center;
  white-space: nowrap;
}

.sessions-table tbody td.col-session-actions {
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.sessions-table .th-filter-actions {
  background: #e8f0eb;
}

.sessions-table tbody td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #e8ece9;
  vertical-align: top;
}

.sessions-table tbody tr:last-child td {
  border-bottom: none;
}

.sessions-table tbody tr {
  background: #fff;
}

.sessions-table tbody tr:nth-child(even) {
  background: var(--color-row-alt);
}

.sessions-table tbody tr:hover {
  background: #e8f2ec;
}

.col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sessions-table .col-date {
  white-space: nowrap;
  font-size: 0.78rem;
  color: var(--color-muted);
}

.member-cell {
  font-weight: 600;
  color: var(--color-text);
}

.data-table th.col-num,
.data-table td.col-num {
  text-align: right;
}

/* Admin hikes */
.admin-hikes-add {
  margin-bottom: 1.5rem;
  padding: 1.15rem;
  background: #f6f9f7;
  border-radius: var(--radius-sm);
  border: 1px solid #cdd9d3;
}

.admin-section-title {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--color-forest);
}

.admin-section-title-spaced {
  margin-top: 1.5rem;
}

.form-hike-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
  align-items: end;
}

@media (max-width: 640px) {
  .form-hike-grid {
    grid-template-columns: 1fr;
  }

  .form-hike-actions {
    grid-column: span 1;
  }
}

.field-checkbox .checkbox-row {
  margin-top: 0.25rem;
}

.checkbox-label {
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
}

.form-hike-actions {
  grid-column: 1 / -1;
}

.hikes-table-wrap {
  margin-top: 0.5rem;
  max-height: min(45vh, 22rem);
}

.hikes-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.hikes-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.65rem 0.85rem;
  text-align: left;
  font-weight: 650;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-forest);
  background: linear-gradient(180deg, #e4ece8 0%, #d8e5df 100%);
  border-bottom: 2px solid #b8c9c0;
}

.hikes-table tbody td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid #e8ece9;
  vertical-align: middle;
}

.hikes-table tbody tr:last-child td {
  border-bottom: none;
}

.hikes-table tbody tr:nth-child(even) {
  background: var(--color-row-alt);
}

.hikes-table tbody tr:hover {
  background: #e8f2ec;
}

.hikes-table tbody tr.row-active {
  background: #e3f0e8;
}

.hikes-table tbody tr.row-active:hover {
  background: #d4e8dc;
}

.col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill-active {
  background: var(--color-forest);
  color: #fff;
}

.pill-muted {
  background: #e2e8ec;
  color: var(--color-muted);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: #fff;
  cursor: pointer;
  font-weight: 500;
}

.btn-sm:hover {
  background: #f0f4f2;
  border-color: #b8c9c0;
}

.hidden {
  display: none !important;
}

.hint {
  color: var(--color-muted);
  font-size: 0.9rem;
  margin-top: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

button {
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #fff;
  cursor: pointer;
}

button.primary {
  background: var(--color-forest);
  color: #fff;
  border-color: var(--color-forest);
  font-weight: 600;
}

button.primary:hover {
  background: var(--color-forest-light);
  border-color: var(--color-forest-light);
}

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

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tab {
  border: none;
  background: #e4e9ed;
  font-weight: 500;
}

.tab.active {
  background: var(--color-forest);
  color: #fff;
}

.inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

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

.list li {
  padding: 0.65rem 0;
  border-bottom: 1px solid #eee;
  font-size: 0.95rem;
}

.list li:last-child {
  border-bottom: none;
}

.message {
  min-height: 1.25rem;
  font-size: 0.9rem;
  color: var(--color-forest);
}

.message.error {
  color: #b00020;
}

/* Legacy generic table (if any) */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
