/* report.css — main dashboard styles (moved out of main.ts). Shared tokens live in shared.css */
/* Dashboard-specific overrides — shared tokens live in shared.css */
:root {
  --primary: #15150F;
  --primary-dark: #2b2c26;
  --accent: #F0761E;
  --bg-body: #E9E9E6;
  --bg-card: #ffffff;
  --text-main: #15150F;
  --text-muted: #726f68;
  --border: #e3e2dc;
  --display-font: 'Poppins', sans-serif;
  --nav-height: 60px;
}

* { box-sizing: border-box; }
/* Reserve the scrollbar gutter so switching between short and long tabs doesn't shift the layout sideways */
html { overflow-y: scroll; scrollbar-gutter: stable; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  font-size: 14px;
}

.dashboard-wrapper {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  background: var(--primary);
  padding: 16px 24px;
  border-radius: 6px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { height: 40px; border-radius: 6px; }
.brand h1 { margin: 0; font-family: var(--display-font); font-size: 1.3em; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; color: #ffffff; }
.meta { display: flex; align-items: center; flex-shrink: 0; }
.status-indicator[hidden] { display:none; }
.status-indicator { display:flex; align-items:center; gap:8px; }
.status-pill { display:inline-flex; align-items:center; padding:3px 8px; border-radius:4px; font-size:0.78em; font-weight:700; text-transform:uppercase; letter-spacing:0.03em; border-left: 3px solid transparent; }
.status-pill.in-progress { background:#fdead9; color:#b1530f; border-left-color:var(--accent); animation: pulse-pill 2s ease-in-out infinite; }
@keyframes pulse-pill {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.status-pill.updated { background:#e9e8e4; color:var(--primary); border-left-color:var(--primary); }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.kpi-card { background: var(--bg-card); padding: 14px 16px; border-radius: 6px; border: 1px solid var(--border); border-left: 3px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.kpi-card:first-child { border-left-color: var(--primary); }
.kpi-card:nth-child(3) { border-left-color: var(--accent); }
.kpi-val { font-size: 2em; font-weight: 800; color: var(--primary); font-family: var(--display-font); line-height: 1; }
.kpi-card:nth-child(3) .kpi-val { color: var(--accent); }
.kpi-lbl { font-size: .72em; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; order: -1; }

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0; overflow-x: auto; }
.tab-btn {
  background: transparent; border: none; border-bottom: 3px solid transparent; padding: 10px 16px;
  font-weight: 600; color: var(--text-muted); cursor: pointer; white-space: nowrap;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--accent); }
.tab-icon { display: none; }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.search-wrapper {
  position: sticky;
  top: 0;
  z-index: 50;
  margin-bottom: 16px;
  background: var(--bg-body);
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--border);
}
.search-input {
  width: 100%; padding: 12px 16px; font-size: 1em; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-card); outline: none; transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--accent); }

.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 16px; overflow: hidden; }
.card-header { padding: 12px 16px; background: #f2f1ec; border-bottom: 1px solid var(--border); font-weight: 700; font-family: var(--display-font); text-transform: uppercase; letter-spacing: 0.02em; font-size: 0.9em; display: flex; justify-content: space-between; align-items: center; color: var(--primary); }

/* Internal pill tabs for All-Time tab */
.pill-tabs { display:flex; gap:8px; margin-bottom:16px; }
.pill-tab {
  padding:6px 16px; border-radius:20px; border:1px solid var(--border);
  background:transparent; font-size:0.82em; font-weight:600; cursor:pointer;
  color:var(--text-muted); transition:all 0.15s;
}
.pill-tab.active { background:var(--primary); color:#fff; border-color:var(--primary); }
.pill-pane { display:none; }
.pill-pane.active { display:block; }
@media (max-width: 600px) { .at-records-grid { grid-template-columns: 1fr !important; } }

.graph-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
}

.masonry-grid {
  column-count: 3;
  column-gap: 16px;
}
.masonry-grid .card {
  break-inside: avoid;
  margin-bottom: 16px;
}
@media (max-width: 1100px) { .masonry-grid { column-count: 2; } }
@media (max-width: 768px)  { .masonry-grid { column-count: 1; } }

table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th {
  text-align: left; padding: 10px 16px; font-size: 0.75em; text-transform: uppercase;
  color: var(--text-muted); border-bottom: 1px solid var(--border); background: #f2f1ec;
  cursor: pointer; user-select: none;
}
th:hover { background: #e8e7e1; color: var(--primary); }
td { padding: 10px 16px; border-bottom: 1px solid #e8e7e1; color: var(--text-main); }
tr:hover td { background: #f4f3ef; }
.td-right { text-align: right; }

/* Pack the event cards into as many columns as fit (desktop), single column on mobile */
.results-grid { column-width: 420px; column-gap: 16px; }
.results-grid .event-card { break-inside: avoid; display: inline-block; width: 100%; margin-bottom: 16px; }
.sortable-table th:nth-child(1) { width: 15%; }
.sortable-table th:nth-child(2) { width: 45%; }
.sortable-table th:nth-child(3) { width: 20%; text-align: right; }
.sortable-table th:nth-child(4) { width: 20%; text-align: right; }

.scrollable-list {
  max-height: 500px;
  overflow-y: auto;
}

.badge { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 0.8em; font-weight: 700; }
.badge-purple { background: #fdead9; color: #b1530f; }
.badge-green { background: var(--accent); color: #ffffff; }
.badge-blue { background: #e9e8e4; color: var(--primary); }
.chip { display:inline-block; padding:1px 6px; border-radius:10px; font-size:0.72em; font-weight:700; font-variant-numeric:tabular-nums; line-height:1.5; vertical-align:middle; }
.chip-good { background:#e1f0e5; color:#1d6b3a; }
.chip-flat { background:#eeede9; color:#6b6a63; }
.spark { display:inline-block; flex-shrink:0; line-height:0; }
.spark svg { display:block; overflow:visible; }
.spark-line { fill:none; stroke:var(--primary); stroke-width:1.6; stroke-linejoin:round; stroke-linecap:round; }
.spark-best { fill:#fff; stroke:var(--primary); stroke-width:1.4; }
.spark-last { fill:var(--accent); }
.kpi-val { font-variant-numeric: tabular-nums; }
.heat-months { display:flex; gap:6px; align-items:flex-start; }
.heat-mcol { flex:1; min-width:0; display:flex; flex-direction:column; gap:3px; }
.heat-mlbl { font-size:0.66em; color:var(--text-muted); font-weight:600; text-align:center; line-height:1.2; margin-bottom:2px; }
.heat-mlbl small { display:block; font-size:0.9em; font-weight:500; opacity:.75; }
.heat-cell { cursor:pointer; }
.heat-cell { aspect-ratio:1; border-radius:3px; background:#e9e8e4; min-width:0; padding:0; border:0; }
.heat-cell.h1 { background:var(--primary); }
.heat-cell.h2 { background:#2f8f4e; }
.heat-club { cursor:pointer; }
.heat-club.l1 { background:#cfcec8; } .heat-club.l2 { background:#a3a299; } .heat-club.l3 { background:#64645b; } .heat-club.l4 { background:var(--primary); }
.heat-cell.sel { outline:2px solid var(--accent); outline-offset:1px; }
.m-details { border-bottom:1px solid #e8e7e1; }
.m-details > summary { list-style:none; cursor:pointer; display:flex; justify-content:space-between; align-items:center; gap:8px; padding:9px 0; font-size:0.72em; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--text-muted); }
.m-details > summary::-webkit-details-marker { display:none; }
.m-details > summary::after { content:'▸'; transition:transform .15s; margin-left:auto; padding-left:6px; }
.m-details[open] > summary::after { transform:rotate(90deg); }
.m-details > summary .m-sum { text-transform:none; letter-spacing:0; font-weight:600; color:var(--primary); margin-left:auto; }
.m-details[open] { padding-bottom:8px; }
.m-details .modal-row:last-child { border-bottom:none; }
.heat-head { display:flex; flex-wrap:wrap; align-items:center; gap:6px 8px; font-size:0.85em; }
.club-kpis { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px; margin-bottom:12px; }
.club-kpi { background:var(--bg-card); border:1px solid var(--border); border-left:3px solid var(--primary); border-radius:6px; padding:12px 14px; display:flex; flex-direction:column; gap:2px; }
.club-kpi-lbl { font-size:.72em; color:var(--text-muted); font-weight:600; text-transform:uppercase; letter-spacing:.05em; }
.club-kpi-val { font-size:1.7em; font-weight:800; color:var(--primary); font-family:var(--display-font); line-height:1.1; font-variant-numeric:tabular-nums; }
@media (max-width: 600px) { .club-kpi:last-child:nth-child(odd) { grid-column: 1 / -1; } }
.club-kpi-sub { font-size:.75em; color:var(--text-muted); }
.club-progress { background:var(--bg-card); border:1px solid var(--border); border-radius:6px; padding:10px 14px; }
.club-progress-head { display:flex; justify-content:space-between; gap:8px; flex-wrap:wrap; font-size:.8em; color:var(--text-muted); margin-bottom:6px; }
.club-progress-head strong { color:var(--text-main); }
.club-progress-track { height:8px; background:#e9e8e4; border-radius:4px; overflow:hidden; }
.club-progress-fill { height:100%; background:var(--primary); border-radius:4px; }
.club-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(320px,1fr)); gap:16px; align-items:start; }
.club-grid .card { margin-bottom:0; }
.club-sublabel { font-size:.72em; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--text-muted); padding:12px 0 4px; }
.club-listrow { display:flex; gap:10px; padding:5px 0; border-bottom:1px solid #e8e7e1; font-size:.9em; }
.club-listrow:last-child { border-bottom:none; }
.club-rank { width:16px; font-weight:800; color:var(--text-muted); }
.ev-row { padding:5px 0; }
.ev-head { display:flex; justify-content:space-between; gap:8px; font-size:.88em; }
.ev-meta { color:var(--text-muted); font-size:.85em; white-space:nowrap; }
.ev-track { height:6px; background:#e9e8e4; border-radius:3px; margin-top:3px; overflow:hidden; }
.ev-fill { height:100%; background:var(--primary); border-radius:3px; }
.heat-legend { display:flex; gap:12px; flex-wrap:wrap; font-size:0.72em; color:var(--text-muted); margin-top:8px; }
.heat-legend i { display:inline-block; width:10px; height:10px; border-radius:2px; margin-right:4px; vertical-align:-1px; }
@media (prefers-reduced-motion: no-preference) { .heat-cell { animation: heat-in .35s ease both; animation-delay: calc(var(--i, 0) * 8ms); } }
@keyframes heat-in { from { opacity:0; transform:scale(.6); } to { opacity:1; transform:none; } }
.badge-gray { background: #e9e8e4; color: var(--text-muted); }

/* === MODAL STYLES === */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(20,21,15,0.5); z-index: 1000; align-items: center; justify-content: center;
}
.modal {
  background: var(--bg-card); width: 90%; max-width: 400px; border-radius: 8px;
  overflow: hidden; animation: slideUp 0.2s ease-out;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { padding: 16px; background: #f2f1ec; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-weight: 800; font-family: var(--display-font); text-transform: uppercase; font-size: 1em; color: var(--primary); }
.close-btn { background: none; border: none; font-size: 1.5em; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-body { padding: 20px; }
.modal-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #e8e7e1; font-size: 0.95em; }
.modal-row:last-child { border-bottom: none; }
.modal-label { color: var(--text-muted); font-weight: 500; }
.modal-value { color: var(--text-main); font-weight: 600; }
.profile-link { display: block; text-align: center; margin-top: 15px; padding: 10px; background: var(--primary); color: white; text-decoration: none; border-radius: 6px; font-weight: 600; }
.profile-link:hover { background: var(--primary-dark); }

/* === CLICKABLE RUNNERS === */
.runner-link { cursor: pointer; color: #111; transition: color 0.1s; font-size: 0.875rem; }
.runner-link:hover { color: var(--accent); text-decoration: underline; }

/* Overview Grid - Masonry-style layout with better card packing */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.overview-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.overview-grid .card {
  margin-bottom: 0;
  font-size: 0.93em;
}
.overview-grid .card-header {
  font-size: 0.82em;
  padding: 10px 14px;
}

@media (max-width: 1200px) {
  .overview-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .overview-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body { font-size: 13px; padding-bottom: var(--nav-height); }
  .dashboard-wrapper { padding: 12px; }
  .top-nav { flex-direction: row; align-items: center; border-radius: 6px; padding: 10px 12px; }
  .brand img { height: 32px; }
  .brand h1 { font-size: 1em; }
  .graph-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
  .kpi-card { padding: 10px 12px; }
  .kpi-val { font-size: 1.5em; }
  .kpi-lbl { font-size: .68em; }
  .tabs {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 900;
    background: var(--bg-card); border-top: 1px solid var(--border); border-bottom: none;
    margin-bottom: 0; padding: 4px 2px; overflow-x: auto; justify-content: space-around; gap: 0;
    height: var(--nav-height);
  }
  .tab-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 6px 2px; font-size: 0.68em; border-bottom: none; border-top: 3px solid transparent;
    color: var(--text-muted);
  }
  .tab-btn.active { border-top-color: var(--accent); color: var(--text-main); font-weight: 700; }
  .tab-icon { display: block; width: 20px; height: 20px; }
  .tab-icon svg { display: block; width: 100%; height: 100%; }
  th, td { padding: 8px 6px; font-size: 0.85em; }
  .modal-overlay { align-items: flex-end; }
  .modal { width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; }
}
