:root {
  --bg: #f3efe7;
  --paper: #fffcf8;
  --ink: #1f1b16;
  --muted: #5f5a52;
  --accent: #c3562d;
  --accent-soft: #f3d3c4;
  --line: #e3dacd;
  --shadow: 0 8px 28px rgba(64, 40, 17, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top right, #f9d6b9 0%, var(--bg) 45%, #ebe5db 100%);
  color: var(--ink);
  font-family: "Manrope", sans-serif;
  min-height: 100vh;
}

.bg-glow {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 10% 0%, rgba(195, 86, 45, 0.13), transparent 35%);
  pointer-events: none;
  z-index: -1;
}

.topbar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 18px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
}

.badge-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 7px rgba(195, 86, 45, 0.15);
}

.brand-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand h1 {
  margin: 0;
  font-family: "Source Serif 4", serif;
  font-size: 26px;
  line-height: 1;
}

nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 100%;
}

nav a {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.65);
  font-weight: 600;
}

nav a:hover {
  border-color: var(--accent);
}

.nav-inline-form {
  margin: 0;
}

.nav-inline-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.nav-inline-btn:hover {
  border-color: var(--accent);
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #f0ceb8;
  background: linear-gradient(135deg, #d96d42 0%, #c3562d 100%);
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(195, 86, 45, 0.4);
}

.inline-form {
  margin: 0;
}

.strava-login-form {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.strava-login-form input[type="email"] {
  flex: 0 1 320px;
  font-size: 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.95);
  color: #2f2116;
}

.strava-connect-btn {
  appearance: none;
  border: none !important;
  padding: 0;
  background: transparent !important;
  box-shadow: none !important;
  cursor: pointer;
  flex: 0 0 auto;
  width: 237px;
  max-width: 100%;
}

.strava-connect-btn img {
  display: block;
  width: 100%;
  height: auto;
}

.strava-connect-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  border-radius: 6px;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 18px 30px;
  display: grid;
  gap: 16px;
}

.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 18px 18px;
  display: grid;
  justify-items: center;
  gap: 8px;
}

.powered-by-strava {
  display: block;
  width: min(180px, 60vw);
  height: auto;
}

.site-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.hero {
  background: linear-gradient(135deg, #2a2118 0%, #403126 55%, #594534 100%);
  color: #fff7ef;
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.hero.compact {
  padding: 18px 24px;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  opacity: 0.82;
}

.hero h2 {
  margin: 10px 0 8px;
  font-family: "Source Serif 4", serif;
  font-size: 34px;
  line-height: 1.05;
}

.hero .sub {
  margin: 0;
  max-width: 650px;
  opacity: 0.85;
}

.login-hero {
  max-width: 760px;
  margin: 10px auto 0;
  padding: 28px;
}

.login-hero h2 {
  font-size: 52px;
}

.login-hero .sub {
  max-width: 560px;
}

.hero-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.force-refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #f0ceb8;
  background: linear-gradient(135deg, #d96d42 0%, #c3562d 100%);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 4px 18px rgba(195, 86, 45, 0.4);
}

.force-refresh:disabled {
  opacity: 0.85;
  cursor: not-allowed;
}

.btn-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.force-refresh.is-loading .btn-spinner {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.refresh-note {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.refresh-note.success {
  color: #d8ffd7;
}

.refresh-note.warning {
  color: #ffefb4;
}

.refresh-note.error {
  color: #ffd0d0;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stats-group {
  display: grid;
  gap: 10px;
}

.stats-row-head h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.card h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.card p {
  margin: 10px 0 2px;
  font-size: 30px;
  font-weight: 800;
}

.card span {
  color: var(--muted);
  font-size: 12px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.panel-head h3 {
  margin: 0;
  font-size: 18px;
}

.link-action {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  text-align: left;
  padding: 11px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

td a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.gear-cell-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.gear-name-link {
  display: block;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gear-id-muted {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.gear-state {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.state-active {
  background: #d7f4dd;
  color: #185824;
}

.state-retired {
  background: #efe5dc;
  color: #6f5238;
}

tr.gear-retired td {
  background: rgba(120, 90, 60, 0.08);
}

tr.gear-retired td a {
  color: #5d4532;
}

.activity-name-link {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.activity-name-link:hover {
  color: var(--accent);
}

.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}

input,
select,
button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: #fff;
}

button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.meta {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.pager {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.pager a {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  font-weight: 700;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 14px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 15, 11, 0.6);
}

.modal-card {
  position: relative;
  width: min(940px, 100%);
  max-height: 85vh;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 14px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.modal-head h3 {
  margin: 0;
}

.modal-close {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  width: 32px;
  height: 32px;
  line-height: 30px;
  padding: 0;
}

.activity-detail h4 {
  margin: 0 0 4px;
  font-size: 22px;
}

.activity-detail-header {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, #fff 0%, #fff8f2 100%);
  padding: 14px;
  margin-bottom: 12px;
}

.activity-detail-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 800;
}

.activity-detail-sub {
  margin: 0 0 12px;
  color: var(--muted);
}

.activity-detail-link-wrap {
  margin: 0 0 12px;
}

.activity-detail-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 800;
}

.activity-detail-link:hover {
  text-decoration: underline;
}

.detail-section {
  margin-bottom: 12px;
}

.detail-section h5 {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.detail-grid-overview {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.detail-grid strong {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-grid span {
  font-weight: 700;
}

@media (max-width: 900px) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero h2 {
    font-size: 28px;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-grid-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .page {
    padding: 10px 12px 24px;
    gap: 12px;
  }

  .login-hero {
    margin-top: 0;
    padding: 20px;
  }

  .login-hero h2 {
    font-size: 38px;
  }

  .site-footer {
    padding: 0 12px 16px;
  }

  .hero {
    padding: 18px;
    border-radius: 14px;
  }

  .hero h2 {
    font-size: 24px;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .force-refresh {
    width: 100%;
    justify-content: center;
  }

  .panel {
    padding: 10px;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }

  .responsive-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 4px 8px;
    margin-bottom: 10px;
  }

  .responsive-table tr.gear-retired {
    background: rgba(120, 90, 60, 0.08);
  }

  .responsive-table td {
    border-bottom: 1px dashed var(--line);
    padding: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
  }

  .responsive-table td:last-child {
    border-bottom: 0;
  }

  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    flex-shrink: 0;
  }

  .responsive-table td > * {
    margin-left: auto;
    text-align: right;
    max-width: 64%;
    overflow-wrap: anywhere;
  }

  .responsive-table td .gear-cell-main {
    width: 100%;
    align-items: flex-end;
  }

  .responsive-table td .gear-name-link {
    max-width: 100%;
  }

  .responsive-table td .gear-id-muted {
    display: none;
  }

  .responsive-table .activity-name-link {
    text-align: right;
  }

  .responsive-table td small {
    margin-top: 4px;
  }

  .pager {
    justify-content: space-between;
  }
}

@media (max-width: 560px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  nav {
    width: 100%;
    justify-content: flex-start;
  }

  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .strava-login-form {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
  }

  .strava-login-form input[type="email"] {
    flex: none;
    width: 100%;
    max-width: 320px;
  }

  .strava-connect-btn {
    width: min(237px, 100%);
  }

  .login-hero h2 {
    font-size: 32px;
  }

  .card p {
    font-size: 26px;
  }

  .responsive-table td > * {
    max-width: 58%;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid-overview {
    grid-template-columns: 1fr;
  }
}
