/* ── VARIABLES & RESET ─────────────────────────────────────────────────────── */
:root {
  --bg: #09090f; --s1: #111118; --s2: #18181f; --s3: #22222c;
  --border: #2e2e3a; --hot: #ff3c3c; --hot2: #ff8c42;
  --trail: #7fff6e; --road: #3cb9ff; --drift: #ff8c42;
  --text: #f0f0f5; --muted: #6b6b80; --muted2: #9999b0;
  --yellow: #f0c040;
}
:root[data-theme="light"] {
  --bg: #f4f6fa; --s1: #ffffff; --s2: #f8fafc; --s3: #e9eef5;
  --border: #d8dee8; --text: #182033; --muted: #68738a; --muted2: #4d5970;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg); color: var(--text);
  height: 100vh; overflow: hidden;
  display: flex; flex-direction: column;
}

/* ── TOPBAR ─────────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center;
  background: var(--s1); border-bottom: 1px solid var(--border);
  min-height: 52px; flex-shrink: 0; z-index: 2000;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px; border-right: 1px solid var(--border);
  align-self: stretch; flex-shrink: 0;
}
.topbar-logo {
  width: 132px;
  height: 52px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  border-radius: 4px;
}
.logo-text {
  font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 1.12rem; letter-spacing: -0.5px;
}
.logo-text em { font-style: normal; color: var(--hot); }
.topbar-nav {
  display: flex; align-items: center; gap: 2px;
  padding: 0 8px; border-right: 1px solid var(--border); flex-shrink: 0;
}
.nav-btn {
  padding: 5px 12px; border-radius: 6px; border: none;
  background: none; color: var(--muted2); cursor: pointer;
  font-family: 'Inter', sans-serif; font-weight: 700;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.8px;
  transition: all 0.15s; display: flex; align-items: center; gap: 4px; white-space: nowrap;
}
.nav-btn:hover, .nav-btn.active { background: var(--s3); color: var(--text); }
.badge {
  background: var(--hot); color: #fff;
  border-radius: 10px; font-size: 0.6rem; padding: 1px 5px; font-weight: 900;
}
.badge-orange { background: var(--hot2); }
.badge-help { background: var(--road); }
.topbar-filters {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; flex: 1; min-width: 0;
}
.search-wrap {
  display: flex; align-items: center; gap: 6px;
  background: var(--s2); border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 10px; flex-shrink: 1;
  min-width: 140px; 
}
.search-wrap input {
  background: none; border: none; color: var(--text);
  font-family: 'Inter', sans-serif; font-size: 0.82rem;
  outline: none; width: 100%;
}
.search-wrap input::placeholder { color: var(--muted); }
.chip {
  padding: 4px 11px; border-radius: 20px; border: 1px solid var(--border);
  background: none; color: var(--muted2); font-size: 0.7rem; cursor: pointer;
  font-family: 'Inter', sans-serif; font-weight: 700; letter-spacing: 0.4px;
  text-transform: uppercase; transition: all 0.12s; white-space: nowrap; flex-shrink: 0;
}
.chip:hover { border-color: var(--text); color: var(--text); }
.chip.active-trail { border-color: var(--trail); color: var(--trail); background: rgba(127,255,110,0.07); }
.chip.active-road  { border-color: var(--road);  color: var(--road);  background: rgba(60,185,255,0.07); }
.chip.active-drift { border-color: var(--drift); color: var(--drift); background: rgba(255,140,66,0.07); }
.chip.active-radius{ border-color: var(--yellow); color: var(--yellow);background: rgba(240,192,64,0.07); }
.chip.active-heat  { border-color: var(--hot2);  color: var(--hot2);  background: rgba(255,140,66,0.07); }
.fsel {
  background: var(--s2); border: 1px solid var(--border); color: var(--text);
  font-family: 'Inter', sans-serif; font-size: 0.78rem;
  padding: 4px 8px; border-radius: 7px; cursor: pointer; outline: none; flex-shrink: 0;
}
.user-area {
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px; border-left: 1px solid var(--border); flex-shrink: 0;
}
.theme-btn {
  background: var(--s2); border: 1px solid var(--border); border-radius: 7px; padding: 5px 8px;
  color: var(--muted2); font-family: 'Inter', sans-serif; font-size: 0.66rem; font-weight: 700; cursor: pointer;
}
.theme-btn:hover { color: var(--text); border-color: var(--muted2); }
.suggest-btn {
  padding: 4px 11px; border-radius: 7px;
  border: 1px solid rgba(60,185,255,0.3); background: rgba(60,185,255,0.07);
  color: var(--road); font-family: 'Inter', sans-serif; font-weight: 700;
  font-size: 0.7rem; text-transform: uppercase; cursor: pointer;
  transition: all 0.13s; white-space: nowrap;
}
.suggest-btn:hover { background: var(--road); color: var(--bg); }
.user-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 7px; border: 1px solid var(--border);
  background: none; color: var(--muted2); cursor: pointer;
  font-family: 'Inter', sans-serif; font-weight: 700;
  font-size: 0.72rem; transition: all 0.13s; white-space: nowrap;
}
.user-btn:hover { border-color: var(--muted2); color: var(--text); }
.user-btn.logged { border-color: rgba(127,255,110,0.3); color: var(--trail); }
.user-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--trail); color: var(--bg);
  font-size: 0.65rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}

/* ── VIEWS ──────────────────────────────────────────────────────────────────── */
.view { display: none; flex: 1; overflow: hidden; min-height: 0; }
.view.active { display: flex; }

/* ── MAP ────────────────────────────────────────────────────────────────────── */
.map-view { flex-direction: row; min-height: 0; height: 100%; overflow: hidden; }
#map { flex: 1; height: 100%; position: relative; min-width: 0; }
.leaflet-container { background: #09090f !important; }
.map-overlay {
  position: absolute; bottom: 12px; left: 12px;
  display: flex; gap: 6px; z-index: 800;
}
.mpill {
  background: rgba(9,9,15,0.85); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 4px 10px; font-family: 'Inter', sans-serif;
  color: #f0f0f5; font-size: 0.68rem; font-weight: 700;
  display: flex; align-items: center; gap: 4px;
}
:root[data-theme="light"] .mpill {
  background: rgba(255,255,255,0.92);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(24,32,51,0.18);
}
.dot { width: 5px; height: 5px; border-radius: 50%; }
.dot.t { background: var(--trail); }
.dot.r { background: var(--road); }
.dot.d { background: var(--drift); }
.dot.h { background: var(--hot); }
#heatCanvas {
  position: absolute; top: 0; left: 0;
  pointer-events: none; z-index: 600; display: none; opacity: 0.65;
}

/* ── SIDEBAR ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: 350px; background: var(--s1);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden; flex-shrink: 0;
  min-height: 0; height: 100%;
}
.race-list {
  flex: 1; overflow-y: scroll; padding: 7px;
  display: flex; flex-direction: column; gap: 5px;
  min-height: 0;
}
.race-list::-webkit-scrollbar { width: 4px; }
.race-list::-webkit-scrollbar-track { background: transparent; }
.race-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.hot-strip {
  background: linear-gradient(90deg, rgba(255,60,60,0.1), rgba(255,140,66,0.06));
  border-bottom: 1px solid var(--border); padding: 10px 12px; flex-shrink: 0;
}
.hot-label {
  display: flex; align-items: center; gap: 6px;
  font-family: 'Inter', sans-serif; font-weight: 800;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 1px;
  color: var(--hot); margin-bottom: 7px;
}
.hot-label::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--hot); animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1);} 50%{opacity:0.5;transform:scale(1.4);} }
.hot-nav { display: flex; justify-content: flex-end; gap: 4px; margin: -27px 0 7px; }
.hot-nav button {
  width: 23px; height: 20px; padding: 0;
  background: var(--s2); border: 1px solid var(--border); border-radius: 5px;
  color: var(--text); cursor: pointer; font-size: 1.15rem; line-height: 1;
}
.hot-nav button:hover { color: var(--hot); border-color: var(--hot); }
.hot-scroll { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; scroll-behavior: smooth; }
.hot-scroll::-webkit-scrollbar { display: none; }
.hot-card {
  min-width: 148px; background: var(--s2);
  border: 1px solid rgba(255,60,60,0.2); border-radius: 9px;
  padding: 9px; cursor: pointer; transition: all 0.14s; flex-shrink: 0;
}
.hot-card:hover { border-color: var(--hot); }
.hot-card.hc-today { border-color: var(--yellow) !important; background: rgba(240,192,64,0.07) !important; }
.hot-card-name {
  font-family: 'Inter', sans-serif; font-weight: 800;
  font-size: 0.78rem; line-height: 1.2; margin-bottom: 4px;
}
.hot-card-meta { font-size: 0.67rem; color: var(--muted2); display: flex; flex-direction: column; gap: 2px; }
.hot-days {
  display: inline-block; margin-top: 5px;
  background: var(--hot); color: #fff;
  font-family: 'Inter', sans-serif; font-weight: 800;
  font-size: 0.62rem; padding: 2px 6px; border-radius: 4px;
}
.hot-days.is-today { background: linear-gradient(90deg, var(--yellow), var(--hot2)); color: var(--bg); }
.sb-head {
  padding: 9px 12px 6px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sb-title {
  font-family: 'Inter', sans-serif; font-weight: 700;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
}
.cnt-badge {
  background: var(--s3); border: 1px solid var(--border); color: var(--text);
  font-family: 'Inter', sans-serif; font-weight: 800;
  font-size: 0.68rem; padding: 2px 7px; border-radius: 10px;
}
.cnt-badge.pending { background: rgba(255,140,66,0.15); color: var(--hot2); border-color: rgba(255,140,66,0.3); }
.month-row {
  display: flex; gap: 3px; padding: 7px 8px;
  overflow: hidden; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.mo {
  flex: 1 1 0; min-width: 0; padding: 2px 0; border-radius: 4px; border: 1px solid var(--border);
  background: none; color: var(--muted);
  font-family: 'Inter', sans-serif; font-weight: 700;
  font-size: 0.6rem; text-transform: uppercase; cursor: pointer;
  transition: all 0.12s; white-space: nowrap;
}
.mo:hover { border-color: var(--muted2); color: var(--text); }
.mo.active { background: var(--hot); color: #fff; border-color: var(--hot); }

/* ── RACE CARDS ─────────────────────────────────────────────────────────────── */
.rc {
  background: var(--s2); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 11px 9px;
  cursor: pointer; transition: all 0.14s; position: relative; overflow: hidden; flex-shrink: 0;
}
.rc::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 2px 2px 0;
}
.rc.trail::before { background: var(--trail); }
.rc.road::before  { background: var(--road); }
.rc.drift::before { background: var(--drift); }
.rc:hover, .rc.sel { border-color: var(--muted2); background: var(--s3); }
.rc.rc-today {
  border-color: var(--yellow);
  background: linear-gradient(135deg, rgba(240,192,64,0.06), rgba(255,140,66,0.03));
}
.today-banner {
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(90deg, var(--yellow), var(--hot2));
  color: var(--bg); font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 1.2px;
  padding: 4px 11px; margin: -11px -11px 9px -11px; border-radius: 10px 10px 0 0;
  animation: todayPulse 2s ease-in-out infinite;
}
@keyframes todayPulse { 0%,100%{opacity:1;} 50%{opacity:0.82;} }
.rc-name {
  font-family: 'Inter', sans-serif; font-weight: 800;
  font-size: 0.88rem; line-height: 1.2; margin-bottom: 6px; padding-left: 7px;
}
.rc-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 7px; padding-left: 7px; }
.tag {
  font-family: 'Inter', sans-serif; font-weight: 700;
  font-size: 0.62rem; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px;
}
.tag.ttrail { background: rgba(127,255,110,0.1); color: var(--trail); }
.tag.troad  { background: rgba(60,185,255,0.1);  color: var(--road); }
.tag.tdrift { background: rgba(255,140,66,0.1); color: var(--drift); }
.tag.tdist, .tag.tdate { background: rgba(255,255,255,0.05); color: var(--muted2); }
.tag.telev  { background: rgba(255,140,66,0.1);  color: var(--hot2); }
.tag.tprice { background: rgba(127,255,110,0.07); color: var(--trail); }
.tag.thot   { background: rgba(255,60,60,0.12);  color: var(--hot); animation: pulse 2s infinite; }
.tag.ttoday { background: rgba(240,192,64,0.15); color: var(--yellow); font-weight: 900; }
.rc-rating  { display: flex; align-items: center; gap: 5px; padding-left: 7px; margin-bottom: 6px; }
.rating-star { color: var(--border); font-size: 0.78rem; }
.rating-star.on { color: var(--yellow); }
.rating-avg  { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 0.75rem; color: var(--yellow); }
.rating-count { font-size: 0.65rem; color: var(--muted); }
.rc-actions { display: flex; gap: 4px; padding-left: 7px; flex-wrap: wrap; }
.abtn {
  padding: 4px 8px; border-radius: 5px; border: none;
  font-family: 'Inter', sans-serif; font-weight: 700;
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.3px;
  cursor: pointer; transition: all 0.13s; white-space: nowrap;
}
.abtn.elev  { background: rgba(255,140,66,0.1); color: var(--hot2);  border: 1px solid rgba(255,140,66,0.2); }
.abtn.elev:hover  { background: var(--hot2);  color: #fff; }
.abtn.nav   { background: rgba(60,185,255,0.08); color: var(--road); border: 1px solid rgba(60,185,255,0.2); }
.abtn.nav:hover   { background: var(--road);  color: var(--bg); }
.abtn.route { background: rgba(180,120,255,0.08); color: #c08cff; border: 1px solid rgba(180,120,255,0.2); }
.abtn.route:hover { background: #c08cff; color: var(--bg); }
.abtn.link  { background: rgba(127,255,110,0.07); color: var(--trail); border: 1px solid rgba(127,255,110,0.18); }
.abtn.link:hover  { background: var(--trail); color: var(--bg); }
.abtn.rev   { background: rgba(240,192,64,0.08); color: var(--yellow); border: 1px solid rgba(240,192,64,0.2); }
.abtn.rev:hover   { background: var(--yellow); color: var(--bg); }
.reviews-section { margin: 6px 0 0 7px; display: none; }
.review-item { border-top: 1px solid var(--border); padding: 6px 0; }
.review-header { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.review-user { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.65rem; color: var(--muted2); }
.review-date { font-size: 0.6rem; color: var(--muted); margin-left: auto; }
.review-body { font-size: 0.72rem; color: var(--muted2); line-height: 1.4; }
.no-res { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 0.8rem; }
.no-res div { font-size: 2rem; margin-bottom: 8px; }

/* ── ELEVATION PANEL ─────────────────────────────────────────────────────────── */
.elev-panel { border-top: 1px solid var(--border); padding: 12px; display: none; flex-direction: column; gap: 8px; flex-shrink: 0; }
.elev-panel.vis { display: flex; }
.ep-head { display: flex; align-items: center; justify-content: space-between; }
.ep-title { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--hot2); }
.ep-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; }
.ep-stats { display: flex; gap: 14px; }
.ep-s { display: flex; flex-direction: column; gap: 1px; }
.ep-sl { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); font-family: 'Inter', sans-serif; }
.ep-sv { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 0.95rem; color: var(--hot2); }
#elevChart { max-height: 110px; }

/* ── BACKOFFICE ──────────────────────────────────────────────────────────────── */
.bo-view { flex-direction: column; background: var(--bg); overflow-y: auto; padding: 28px 32px; }
.bo-header { margin-bottom: 22px; }
.bo-header h2 { font-family: 'Inter', sans-serif; font-weight: 900; font-size: 1.4rem; margin-bottom: 4px; }
.bo-header p { color: var(--muted2); font-size: 0.82rem; }
.bo-layout { display: flex; gap: 22px; align-items: flex-start; }
.bo-form-card { background: var(--s1); border: 1px solid var(--border); border-radius: 13px; padding: 22px; width: 400px; flex-shrink: 0; }
.bo-form-card h3 { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 0.88rem; margin-bottom: 16px; }
.form-grid { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.field label { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted2); }
.field input, .field select, .field textarea {
  background: var(--s2); border: 1px solid var(--border); color: var(--text);
  font-family: 'Inter', sans-serif; font-size: 0.82rem;
  padding: 7px 10px; border-radius: 7px; outline: none; width: 100%;
  transition: border-color 0.13s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--muted2); }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); }
.field textarea { resize: vertical; min-height: 55px; }
.date-picker { display: flex; gap: 5px; }
.date-picker select {
  flex: 1; padding: 7px 4px; background: var(--s2); border: 1px solid var(--border);
  color: var(--text); font-family: 'Inter', sans-serif; font-size: 0.78rem;
  border-radius: 7px; cursor: pointer; outline: none;
  text-align: center; appearance: none;
}
.date-picker select:focus { border-color: var(--muted2); }
.bo-submit {
  width: 100%; padding: 10px; border-radius: 7px; border: none;
  background: linear-gradient(135deg, var(--hot), var(--hot2));
  color: #fff; font-family: 'Inter', sans-serif; font-weight: 900;
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px;
  cursor: pointer; transition: opacity 0.14s; margin-top: 2px;
}
.bo-submit:hover { opacity: 0.88; }
.cancel-edit-btn {
  display: none; width: 100%; padding: 7px; border-radius: 7px;
  border: 1px solid var(--border); background: none; color: var(--muted2);
  font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.72rem;
  text-transform: uppercase; cursor: pointer; margin-top: 6px;
}
.bo-table-wrap { flex: 1; min-width: 0; }
.bo-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.bo-tab { display: flex; align-items: center; gap: 7px; padding: 9px 13px; border: none; border-bottom: 2px solid transparent; background: none; color: var(--muted2); font-family: 'Inter', sans-serif; font-size: .78rem; font-weight: 800; cursor: pointer; }
.bo-tab:hover { color: var(--text); }
.bo-tab.active { color: var(--text); border-bottom-color: var(--road); }
.bo-panel { display: none; }
.bo-panel.active { display: block; }
.bo-table-wrap h3 { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 0.88rem; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.bo-table { background: var(--s1); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 22px; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--s2); }
th { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); }
td { padding: 9px 12px; font-size: 0.8rem; border-bottom: 1px solid rgba(46,46,58,0.5); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.015); }
.td-name { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.82rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-type { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.62rem; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; }
.td-type.trail { background: rgba(127,255,110,0.1); color: var(--trail); }
.td-type.road  { background: rgba(60,185,255,0.1);  color: var(--road); }
.td-type.drift { background: rgba(255,140,66,0.1); color: var(--drift); }
.edit-btn { padding: 3px 9px; border-radius: 5px; border: 1px solid rgba(60,185,255,0.25); background: rgba(60,185,255,0.07); color: var(--road); font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.62rem; text-transform: uppercase; cursor: pointer; transition: all 0.12s; margin-right: 3px; }
.edit-btn:hover { background: var(--road); color: var(--bg); }
.edit-btn.approve { border-color: rgba(127,255,110,0.25); background: rgba(127,255,110,0.07); color: var(--trail); }
.edit-btn.approve:hover { background: var(--trail); color: var(--bg); }
.del-btn { padding: 3px 9px; border-radius: 5px; border: 1px solid rgba(255,60,60,0.25); background: rgba(255,60,60,0.07); color: var(--hot); font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.62rem; text-transform: uppercase; cursor: pointer; transition: all 0.12s; }
.del-btn:hover { background: var(--hot); color: #fff; }

/* ── MODALS ──────────────────────────────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 9000; background: rgba(9,9,15,0.88); backdrop-filter: blur(12px); align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal-card { background: var(--s1); border: 1px solid var(--border); border-radius: 16px; padding: 28px 26px 22px; width: 340px; display: flex; flex-direction: column; align-items: center; box-shadow: 0 24px 80px rgba(0,0,0,0.6); animation: modalIn 0.22s cubic-bezier(0.34,1.56,0.64,1); }
.modal-card.wide { width: 420px; max-height: 88vh; overflow-y: auto; align-items: flex-start; }
.help-modal-card { width: 390px; }
.help-form { width: 100%; display: flex; flex-direction: column; gap: 11px; }
.help-form .field textarea { min-height: 120px; }
.help-problem { min-width: 180px; max-width: 280px; white-space: pre-wrap; }
.help-unanswered td { background: rgba(255,140,66,0.07); }
.help-unanswered td:first-child { border-left: 3px solid var(--hot2); }
.help-status { display: inline-block; margin-bottom: 5px; padding: 2px 6px; border-radius: 4px; background: rgba(255,140,66,0.14); color: var(--hot2); font-size: .62rem; font-weight: 800; text-transform: uppercase; }
.help-response { display: block; width: 220px; min-height: 58px; margin-bottom: 5px; background: var(--s2); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font: 0.72rem 'Inter', sans-serif; padding: 6px; resize: vertical; }
.help-reply-btn { margin: 0; }
.help-history { width: 100%; margin-top: 4px; }
.help-history-item { border-top: 1px solid var(--border); padding: 9px 0; font-size: 0.72rem; line-height: 1.4; }
.help-history-date { color: var(--muted); font-size: 0.65rem; margin-bottom: 3px; }
.help-history-problem { color: var(--text); }
.help-history-response { color: var(--muted2); margin-top: 4px; }
.help-history-empty { color: var(--muted); font-size: 0.72rem; }
.month-filter-card { width: 310px; align-items: stretch; }
.month-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 14px 0 4px; }
.month-option {
  padding: 8px 4px; border: 1px solid var(--border); border-radius: 7px; background: var(--s2);
  color: var(--muted2); font-family: 'Inter', sans-serif; font-size: 0.72rem; font-weight: 700; cursor: pointer;
}
.month-option:hover { border-color: var(--muted2); color: var(--text); }
.month-option.selected { background: rgba(255,60,60,0.12); border-color: var(--hot); color: var(--hot); }
.month-filter-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.month-filter-actions .modal-btn, .month-filter-actions .modal-cancel { margin-top: 0; }
.filter-field-label { font-size: 0.67rem; color: var(--muted2); font-weight: 700; margin: 12px 0 5px; text-transform: uppercase; letter-spacing: 0.6px; }
.filter-modal-select { width: 100%; padding: 8px 10px; background: var(--s2); border: 1px solid var(--border); border-radius: 7px; color: var(--text); font-family: 'Inter', sans-serif; font-size: 0.78rem; outline: none; }
@keyframes modalIn { from{opacity:0;transform:scale(0.93) translateY(10px);} to{opacity:1;transform:scale(1) translateY(0);} }
.modal-logo { display: flex; align-items: center; gap: 7px; margin-bottom: 18px; }
.modal-logo-text { font-family: 'Inter', sans-serif; font-weight: 900; font-size: 1.1rem; letter-spacing: -0.5px; }
.modal-logo-text em { font-style: normal; color: var(--hot); }
.modal-title { font-family: 'Inter', sans-serif; font-weight: 900; font-size: 1rem; margin-bottom: 3px; }
.modal-sub { font-size: 0.76rem; color: var(--muted); margin-bottom: 20px; text-align: center; }
.modal-label { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted2); align-self: flex-start; margin-bottom: 5px; }
.modal-field { width: 100%; margin-bottom: 4px; }
.modal-input-wrap { display: flex; align-items: center; gap: 7px; background: var(--s2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; transition: border-color 0.14s; }
.modal-input-wrap:focus-within { border-color: var(--hot); }
.modal-input-wrap.shake { animation: shake 0.4s ease; border-color: var(--hot) !important; }
@keyframes shake { 0%,100%{transform:translateX(0);} 20%{transform:translateX(-6px);} 40%{transform:translateX(6px);} 60%{transform:translateX(-4px);} 80%{transform:translateX(4px);} }
.modal-input-wrap input { background: none; border: none; color: var(--text); font-family: 'Inter', sans-serif; font-size: 0.88rem; outline: none; flex: 1; }
.modal-input-wrap input::placeholder { color: var(--muted); }
.pw-toggle { background: none; border: none; cursor: pointer; font-size: 0.85rem; color: var(--muted); padding: 0; }
.modal-error { min-height: 16px; font-size: 0.7rem; color: var(--hot); padding-left: 2px; font-family: 'Inter', sans-serif; font-weight: 700; margin-top: 5px; }
.modal-btn { width: 100%; margin-top: 14px; padding: 10px; background: linear-gradient(135deg, var(--hot), var(--hot2)); border: none; border-radius: 9px; color: #fff; font-family: 'Inter', sans-serif; font-weight: 900; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 1px; cursor: pointer; transition: opacity 0.14s; }
.modal-btn:hover { opacity: 0.88; }
.modal-cancel { background: none; border: none; color: var(--muted); font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.72rem; cursor: pointer; margin-top: 10px; padding: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.modal-cancel:hover { color: var(--text); }
.auth-tabs { display: flex; gap: 0; width: 100%; background: var(--s2); border-radius: 8px; padding: 3px; margin-bottom: 18px; }
.auth-tab { flex: 1; padding: 6px; border: none; border-radius: 6px; background: none; color: var(--muted2); font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; cursor: pointer; transition: all 0.13s; }
.auth-tab.active { background: var(--s1); color: var(--text); }

/* ── STARS ───────────────────────────────────────────────────────────────────── */
.star-row { display: flex; gap: 4px; margin-bottom: 5px; }
.star { font-size: 1.5rem; color: var(--border); cursor: pointer; transition: color 0.1s; line-height: 1; }
.star.active { color: var(--yellow); }
.star-label { font-size: 0.72rem; color: var(--muted2); font-family: 'Inter', sans-serif; font-weight: 600; margin-bottom: 12px; min-height: 16px; align-self: flex-start; }
.review-textarea { width: 100%; background: var(--s2); border: 1px solid var(--border); color: var(--text); font-family: 'Inter', sans-serif; font-size: 0.82rem; padding: 8px 10px; border-radius: 8px; outline: none; resize: vertical; min-height: 70px; transition: border-color 0.13s; }
.review-textarea:focus { border-color: var(--muted2); }
.review-textarea::placeholder { color: var(--muted); }

/* ── TOAST ───────────────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--s3); border: 1px solid var(--border); border-radius: 9px; padding: 10px 16px; font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.8rem; z-index: 9999; transform: translateY(60px); opacity: 0; transition: all 0.3s; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.ok  { border-color: rgba(127,255,110,0.4); color: var(--trail); }
.toast.err { border-color: rgba(255,60,60,0.4);   color: var(--hot); }

/* ── WATCHLIST & CHECK-IN ────────────────────────────────────────────────────── */
.rc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.rc-top .rc-name { flex: 1; }
.watch-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 0 2px;
  color: var(--muted); transition: transform 0.15s;
  flex-shrink: 0; margin-top: 1px;
}
.watch-btn:hover { transform: scale(1.2); }
.watch-btn.watched { color: var(--yellow); }

.rc-social {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding-left: 7px; margin-bottom: 5px;
}
.social-pill {
  font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.6rem;
  padding: 2px 7px; border-radius: 10px;
  background: rgba(255,255,255,0.05); color: var(--muted2);
  border: 1px solid var(--border);
}
.social-pill.checkin-pill { background: rgba(127,255,110,0.07); color: var(--trail); border-color: rgba(127,255,110,0.2); }
.social-pill.my-checkin   { background: rgba(127,255,110,0.13); color: var(--trail); border-color: rgba(127,255,110,0.3); font-weight: 800; }

.abtn.checkin      { background: rgba(127,255,110,0.07); color: var(--trail); border: 1px solid rgba(127,255,110,0.2); }
.abtn.checkin:hover{ background: var(--trail); color: var(--bg); }
.abtn.checkin-done { background: rgba(127,255,110,0.15); color: var(--trail); border: 1px solid rgba(127,255,110,0.35); font-weight: 900; }
.abtn.checkin-done:hover { background: rgba(255,60,60,0.1); color: var(--hot); border-color: rgba(255,60,60,0.2); }

.watch-tab-btn {
  display: flex; align-items: center; gap: 4px;
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 3px 8px; cursor: pointer; color: var(--muted2);
  font-size: 0.78rem; transition: all 0.13s;
}
.watch-tab-btn:hover { border-color: var(--yellow); color: var(--yellow); }
.watch-tab-btn.active { background: rgba(240,192,64,0.1); border-color: var(--yellow); color: var(--yellow); }
.month-filter-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px; padding: 3px 7px;
  color: var(--muted2); font-family: 'Inter', sans-serif; font-size: 0.66rem; font-weight: 700;
  cursor: pointer; transition: all 0.13s;
}
.month-filter-btn:hover, .month-filter-btn.active { color: var(--hot); border-color: var(--hot); background: rgba(255,60,60,0.08); }

/* ── CHAT ────────────────────────────────────────────────────────────────────── */
.abtn.chat { background: rgba(60,185,255,0.07); color: var(--road); border: 1px solid rgba(60,185,255,0.2); }
.abtn.chat:hover { background: var(--road); color: var(--bg); }

.chat-modal-card {
  width: 480px !important;
  height: 560px !important;
  max-height: 88vh !important;
  padding: 0 !important;
  overflow: hidden !important;
  border-radius: 16px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
}

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 14px; border-bottom: 1px solid var(--border);
  background: var(--s2); flex-shrink: 0;
}
.chat-header-title { font-family: 'Inter', sans-serif; font-weight: 900; font-size: 0.92rem; line-height: 1.2; }
.chat-header-sub   { font-size: 0.7rem; color: var(--muted2); margin-top: 2px; }
.chat-close {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 1rem; padding: 4px; border-radius: 4px; transition: color 0.12s; flex-shrink: 0;
}
.chat-close:hover { color: var(--text); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
  min-height: 0; /* critical — allows flex child to shrink below content size */
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); }

.chat-empty {
  text-align: center; color: var(--muted); font-size: 0.8rem;
  padding: 40px 20px; flex: 1;
}
.chat-msg { display: flex; }
.chat-msg.mine   { justify-content: flex-end; }
.chat-msg.theirs { justify-content: flex-start; }
.chat-bubble {
  max-width: 75%; padding: 8px 12px; border-radius: 12px;
  background: var(--s2); border: 1px solid var(--border);
}
.chat-msg.mine .chat-bubble {
  background: rgba(60,185,255,0.12); border-color: rgba(60,185,255,0.25);
  border-radius: 12px 12px 2px 12px;
}
.chat-msg.theirs .chat-bubble { border-radius: 12px 12px 12px 2px; }
.chat-user { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.62rem; color: var(--road); margin-bottom: 3px; text-transform: lowercase; }
.chat-user-mine { color: var(--trail); text-align: right; }
.chat-text { font-size: 0.82rem; line-height: 1.45; color: var(--text); word-break: break-word; }
.chat-ts   { font-size: 0.6rem; color: var(--muted); margin-top: 4px; text-align: right; }

.chat-footer {
  border-top: 1px solid var(--border); background: var(--s1);
  padding: 10px 14px 12px; flex-shrink: 0;
}
.chat-input-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--s2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px;
  transition: border-color 0.13s;
}
.chat-input-wrap:focus-within { border-color: var(--road); }
.chat-input {
  flex: 1; background: none; border: none; color: var(--text);
  font-family: 'Inter', sans-serif; font-size: 0.85rem; outline: none;
}
.chat-input::placeholder { color: var(--muted); }
.chat-send {
  background: var(--road); border: none; border-radius: 7px;
  color: var(--bg); width: 30px; height: 30px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity 0.13s;
}
.chat-send:hover { opacity: 0.85; }

/* ── CHECK-IN CALENDAR ───────────────────────────────────────────────────────── */
.cal-nav {
  background: var(--s2); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; width: 28px; height: 28px;
  cursor: pointer; font-size: 1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.13s;
}
.cal-nav:hover { border-color: var(--muted2); background: var(--s3); }

.cal-dow-row {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px; margin-bottom: 4px; width: 100%;
}
.cal-dow {
  text-align: center; font-family: 'Inter', sans-serif;
  font-weight: 700; font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted); padding: 4px 0;
}
.cal-days-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 3px; width: 100%;
}
.cal-day {
  aspect-ratio: 1; border-radius: 8px; border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; cursor: default;
  transition: all 0.12s; position: relative;
  background: var(--s2);
}
.cal-day:not(.empty):hover { border-color: var(--border); cursor: pointer; background: var(--s3); }
.cal-day.empty { background: transparent; border-color: transparent; }
.cal-day.is-today { border-color: var(--muted); background: var(--s3); }
.cal-day.has-checkin {
  background: rgba(127,255,110,0.1);
  border-color: rgba(127,255,110,0.35);
}
.cal-day.has-checkin:hover { background: rgba(127,255,110,0.18); }
.cal-day-num {
  font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.78rem;
  color: var(--muted2); line-height: 1;
}
.cal-day.is-today .cal-day-num { color: var(--text); }
.cal-day.has-checkin .cal-day-num { color: var(--trail); }
.cal-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--trail); margin-top: 2px;
}

.cal-list { width: 100%; }
.cal-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 8px; background: var(--s2);
  border: 1px solid var(--border); margin-bottom: 5px;
  cursor: pointer; transition: all 0.13s;
}
.cal-item:hover { border-color: var(--muted2); background: var(--s3); }
.cal-item-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.cal-item-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cal-item-dot.trail { background: var(--trail); }
.cal-item-dot.road  { background: var(--road); }
.cal-item-name {
  font-family: 'Inter', sans-serif; font-weight: 800; font-size: 0.82rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-item-meta { font-size: 0.68rem; color: var(--muted2); margin-top: 2px; }
.cal-item-right { flex-shrink: 0; margin-left: 8px; }
.cal-item-badge {
  font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.65rem;
  text-transform: uppercase; letter-spacing: 0.4px;
  padding: 3px 8px; border-radius: 6px;
}
.cal-item-badge.past     { background: rgba(127,255,110,0.12); color: var(--trail); }
.cal-item-badge.upcoming { background: rgba(255,140,66,0.12);  color: var(--hot2); }

/* ── LEAFLET POPUP ───────────────────────────────────────────────────────────── */
.ngpop .leaflet-popup-content-wrapper { background: var(--s2); color: var(--text); border: 1px solid var(--border); border-radius: 11px; }
.ngpop .leaflet-popup-tip { background: var(--s2); }
.ngpop .leaflet-popup-content { margin: 13px; }

.compact-tooltip {
  position: absolute;
  background: var(--s3);
  color: var(--text);
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  z-index: 5000;
  pointer-events: none;
}

/* ── RESPONSIVE ──────────────────────────────────────────────────────────────── */

/* ── TABLET (≤ 1024px) ── */
@media (max-width: 1024px) {
  .sidebar { width: 300px; }
  
  /* Esconder texto de botões secundários para poupar espaço */
  .suggest-btn span, 
  #calBtn span, 

  .nav-btn span:not(.badge),
  #heatBtn span { 
    display: none; 
  }
  

  .suggest-btn, #calBtn, .nav-btn, #heatBtn, .user-btn {
    padding: 6px 10px;
    min-width: 40px;
    justify-content: center;
    position: relative;
  }

  .search-wrap { min-width: 120px; }
  .bo-form-card { width: 340px; }
}

/* ── TABLET PORTRAIT / LARGE MOBILE (≤ 900px) ── */
@media (max-width: 900px) {
  /* Body can scroll on these views */
  body { overflow: auto; }

  /* Topbar: layout flexível */
  .topbar {
    flex-wrap: wrap; height: auto;
    padding: 4px 0; gap: 0; position: sticky; top: 0; z-index: 2000;
  }
  .logo { 
    border-right: none; padding: 0 12px; 
    height: 48px;
  }
  .topbar-nav { border: none; padding: 0 8px; }
  .user-area {
    border: none; padding: 0 12px;
    margin-left: auto; gap: 6px;
    height: 48px;
  }
  /* Filters row abaixo */
  .topbar-filters {
    order: 3; width: 100%;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    overflow: visible; gap: 8px;
    background: var(--s2);
    height: 48px; /* Altura fixa para manter alinhado */
    flex: none;
  }
  .topbar-filters::-webkit-scrollbar { display: none; }

  /* Map + sidebar stack vertically */
  .view.active.map-view { flex-direction: column; overflow: visible; }
  #map { height: 55vw; min-height: 260px; max-height: 420px; flex: none; }
  .sidebar {
    width: 100%; height: auto; max-height: none;
    border-left: none; border-top: 1px solid var(--border);
    overflow: visible;
  }
  .hot-strip { padding: 8px 10px; }
  .race-list { max-height: 420px; overflow-y: auto; }
  .elev-panel { position: sticky; bottom: 0; background: var(--s1); z-index: 10; }

  /* Backoffice */
  .bo-view { padding: 16px; overflow-y: auto; }
  .bo-layout { flex-direction: column; gap: 16px; }
  .bo-form-card { width: 100%; }
  .bo-table { overflow-x: auto; }

  /* Modals full-width */
  .modal-card { width: 92vw !important; max-width: 420px; }
  .modal-card.wide { width: 92vw !important; max-width: 480px; }
}

/* ── MOBILE (≤ 600px) ── */
@media (max-width: 600px) {
  .topbar { padding: 0; }
  .topbar-logo { width: 90px; height: 36px; }
  
  /* Esconder texto em mobile para caber tudo na mesma linha */
  .suggest-btn span, 
  #calBtn span, 
  .nav-btn span:not(.badge),

  .user-btn #userLabel,
  #heatBtn span { 
    display: none; 
  }

  .user-btn { padding: 0 8px; border: none; background: var(--s3); min-width: 40px; justify-content: center; }
  .user-avatar { width: 24px; height: 24px; }
  

  .suggest-btn, #calBtn, .nav-btn, #heatBtn {
    padding: 0 10px;
    min-width: 40px;
    height: 36px;
    justify-content: center;
    display: flex;
    align-items: center;
  }

  .theme-btn { padding: 6px; height: 36px; width: 36px; }
  .user-area { gap: 4px; padding: 0 8px; }
  
  .topbar-filters {
    padding: 4px 12px;
    gap: 6px;
    height: 44px;
  }
  .search-wrap { min-width: 130px; height: 34px; }
  .chip, .fsel { height: 32px; font-size: 0.65rem; }

  /* Map taller on mobile */
  #map { height: 45vh; min-height: 220px; max-height: none; }

  /* Sidebar: full list */
  .sidebar { border-top: 1px solid var(--border); }
  .hot-card { min-width: 130px; }
  .hot-card-name { font-size: 0.72rem; }
  .month-row { gap: 3px; padding: 6px 8px; }
  .mo { font-size: 0.6rem; padding: 2px 5px; }

  /* Race cards */
  .rc { padding: 9px 9px 7px; }
  .rc-name { font-size: 0.82rem; }
  .tag { font-size: 0.58rem; padding: 1px 5px; }
  .abtn { font-size: 0.6rem; padding: 3px 6px; }

  /* Elevation panel */
  .ep-sv { font-size: 0.85rem; }
  #elevChart { max-height: 90px; }

  /* Backoffice */
  .bo-header h2 { font-size: 1.1rem; }
  .form-row { flex-direction: column; gap: 10px; }
  th { font-size: 0.58rem; padding: 7px 8px; }
  td { font-size: 0.72rem; padding: 7px 8px; }
  .edit-btn, .del-btn { font-size: 0.58rem; padding: 2px 6px; }

  /* Modals */
  .modal-card { padding: 20px 16px 16px; border-radius: 14px; }
  .modal-btn { font-size: 0.75rem; padding: 9px; }
  .star { font-size: 1.25rem; }

  /* Map overlay pills */
  .mpill { font-size: 0.6rem; padding: 3px 8px; }
}

/* ── VERY SMALL (≤ 380px) ── */
@media (max-width: 380px) {
  .topbar-logo { width: 80px; }
  .search-wrap { min-width: 90px; }
  #map { height: 40vh; }
}

/* ── TOUCH: remove hover effects that feel odd on mobile ── */
@media (hover: none) {
  .rc:hover { background: var(--s2); border-color: var(--border); }
  .chip:hover { border-color: var(--border); color: var(--muted2); }
  .abtn:hover { background: inherit; color: inherit; }
  .hot-card:hover { border-color: rgba(255,60,60,0.2); }
}
