/* Rank map, map settings and heatmap styles from the previous KnownBiz app (src/styles.css), unchanged. */
.rankmap, .mapsettings, .heatmap-wrap, .rm-detail, .rm-popup {
  /* brand */
  --plum: #582b43;        /* plum-700: primary actions, active tab */
  --deep: #3b1830;        /* plum-900: app shell */
  --gold: #d9a34a;        /* gold-400: badges, decoration */
  --gold-text: #8a5d0b;   /* gold on white, 5.5:1 */

  /* text */
  --ink: #2b1b25;
  --ink-soft: #3d2a35;
  --muted: #5e4655;       /* secondary text, 8:1 */
  --subtle: #6f5a66;      /* meta lines */

  /* surfaces and lines */
  --cream: #faf7f2;       /* canvas */
  --surface: #ffffff;
  --sand: #f6f1ea;        /* insets, chips */
  --inset: #fbf8f3;
  --line: #e9dfd2;
  --line-soft: #f0e8dd;
  --line-faint: #f4ede4;
  --field: #d9ccbd;       /* input and secondary-button borders */

  /* states: tint + text, always shown with a label */
  --plum-tint: #f3ecf0;
  --review-bg: #fbf0d9;  --review-fg: #7a520a;  --review-wash: #fffaf0;  --review-line: #f3e6cb;
  --blocked-bg: #fbe9df; --blocked-fg: #8f2f0e; --blocked-wash: #fdf6f2; --blocked-line: #f0d2c2;
  --failed-bg: #f9e1e1;  --failed-fg: #9b1f1f;
  --done-bg: #e5f1e9;    --done-fg: #1d6539;    --done-wash: #f1f8f3;    --done-line: #d6eadc;
  --info-bg: #e6eff6;    --info-fg: #24506e;

  --err: var(--failed-fg);
  --ok: var(--done-fg);

  --radius-card: 14px;
  --radius-ctl: 10px;
  --radius-badge: 6px;
  --sidebar: 232px;
}
.linkbtn { background: none; border: 0; padding: 0; color: var(--plum); text-decoration: underline; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.linkbtn:hover { color: var(--deep); }
.playbook-list .linkbtn { text-align: left; text-decoration: none; font-weight: 600; padding: 4px 0; }
.playbook-list .linkbtn:hover { text-decoration: underline; }
.playbook-list .linkbtn.on { font-weight: 800; color: var(--deep); }
.heatmap-wrap { margin: 12px 0; }
.heatmap {
  display: grid; gap: 3px; max-width: 420px;
}
.heatmap-wrap.small .heatmap { max-width: 260px; gap: 2px; }
.hm-cell {
  aspect-ratio: 1; display: grid; place-items: center;
  border-radius: 4px; font-size: 0.8rem; font-weight: 700;
  color: #10231a; font-variant-numeric: tabular-nums;
}
.heatmap-wrap.small .hm-cell { font-size: 0.68rem; }
.hm-top3 { background: #35b67a; color: #06281a; }
.hm-top10 { background: #9ed47f; color: #1d2e12; }
.hm-top20 { background: #f0c44c; color: #3a2d05; }
.hm-low { background: #e8865a; color: #3a1708; }
.hm-none { background: #d7dbe0; color: #5d6670; }
.hm-skip { background: transparent; border: 1px dashed #c3c9d0; }
.hm-err { background: repeating-linear-gradient(45deg, #d7dbe0, #d7dbe0 4px, #c3c9d0 4px, #c3c9d0 8px); color: #5d6670; }
.hm-legend {
  list-style: none; padding: 0; margin: 10px 0 0;
  display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted);
}
.hm-legend li { display: flex; align-items: center; gap: 6px; }
.hm-swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.hm-scale { margin-top: 8px; }
.scanfigures dl {
  display: flex; flex-wrap: wrap; gap: 18px; margin: 10px 0 0;
}
.scanfigures dt { font-size: 12px; font-weight: 600; color: var(--subtle); }
.scanfigures dd { margin: 2px 0 0; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rankmap h3 { margin: 0 0 8px; font-size: 15px; }
.rm-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 10px 0 12px; }
.rm-bar label { gap: 3px; min-width: 0; }
.rm-bar label > span { font-size: 12px; font-weight: 600; color: var(--subtle); }
.rm-bar select { max-width: 22rem; }
.rm-stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
.rm-stage.with-detail { grid-template-columns: minmax(0, 1fr) 300px; }
@media (max-width: 900px) {
  .rm-stage.with-detail { grid-template-columns: minmax(0, 1fr); }
}
.rm-mapwrap { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; isolation: isolate; }
.rm-map { width: 100%; background: #e8e4dc; font-family: inherit; }
.rm-map .leaflet-control-attribution { font-size: 10px; }
.rm-icon { background: none; border: 0; }
.rm-marker {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 2px solid #fff; box-sizing: border-box;
  font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: pointer;
  transition: transform .12s ease;
}
.rm-icon:hover .rm-marker { transform: scale(1.12); }
.rm-icon:focus-visible { outline: none; }
.rm-icon:focus-visible .rm-marker { outline: 3px solid var(--deep); outline-offset: 2px; }
.rm-marker.rm-selected { transform: scale(1.22); outline: 3px solid var(--deep); outline-offset: 2px; }
.rm-badge {
  position: absolute; top: -9px; right: -12px; min-width: 18px; padding: 0 4px;
  height: 14px; border-radius: 7px; font-size: 10px; font-weight: 800; line-height: 14px;
  text-align: center; color: #fff; pointer-events: none; white-space: nowrap;
}
.rm-badge.rm-up { background: var(--done-fg); }
.rm-badge.rm-down { background: var(--failed-fg); }
.rm-home { pointer-events: none; }
.rm-drag { cursor: grab; }
.rm-drag svg { display: block; filter: drop-shadow(0 3px 4px rgba(0,0,0,.5)); }
.rm-plan {
  display: block; box-sizing: border-box; border-radius: 50%; border: 3px solid; background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35); cursor: pointer; position: relative;
}
.rm-plan::after { content: ''; position: absolute; inset: 22%; border-radius: 50%; background: currentColor; }
.rm-plan.home { cursor: default; }
.rm-plan.off { border-style: dashed; border-color: #8a8a8a !important; background: rgba(255,255,255,.55); box-shadow: none; opacity: .75; }
.rm-plan.off::after {
  inset: 0; border-radius: 0; background:
    linear-gradient(45deg, transparent 44%, #8a8a8a 44%, #8a8a8a 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, #8a8a8a 44%, #8a8a8a 56%, transparent 56%);
  transform: scale(.5);
}
.rm-icon:focus-visible .rm-plan { outline: 3px solid var(--deep); outline-offset: 2px; }
.rm-editbar { margin: 0 0 12px; padding: 12px 14px; border: 1px solid var(--review-line); border-radius: 12px; background: var(--review-wash); }
.rm-editbar p { margin: 0 0 10px; }
.rm-editbar .rm-bar { margin: 0 0 10px; }
.rm-editbar .row { flex-wrap: wrap; }
.rm-centre { margin: 0 0 14px; padding: 10px 14px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--inset); }
.rm-centre p { margin: 0 0 8px; }
.rm-centre .row { flex-wrap: wrap; }
.rm-halo { position: absolute; inset: 0; border-radius: 50%; border: 3px solid; box-shadow: 0 0 0 2px #fff; box-sizing: border-box; }
.rm-pin { position: absolute; display: block; filter: drop-shadow(0 2px 3px rgba(0,0,0,.45)); }
.rm-pinname {
  position: absolute; bottom: calc(100% + 26px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 12px; font-weight: 800;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
}
.rm-tools { position: absolute; top: 10px; right: 10px; z-index: 500; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.rm-seg { display: inline-flex; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.rm-seg button, .rm-tool {
  min-height: 34px; padding: 0 12px; border: 0; background: #fff; color: var(--deep);
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.rm-seg button + button { border-left: 1px solid var(--line); }
.rm-seg button[aria-pressed="true"] { background: var(--plum); color: #fff; }
.rm-tool { border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.rm-tool:hover:not(:disabled), .rm-seg button:hover:not([aria-pressed="true"]) { background: var(--sand); }
.rm-tool:disabled { opacity: .6; cursor: wait; }
.rm-date {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 500;
  padding: 6px 14px; border-radius: 999px; background: rgba(43,27,37,.88); color: #fff;
  font-size: 14px; font-weight: 800; pointer-events: none;
}
.rm-detail { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--inset); font-size: 13px; }
.rm-popup .rm-detail { border: 0; padding: 0; background: none; }
.rm-popup .rm-close { display: none; }
.rm-map .leaflet-popup-scrolled { border: 0; }
.rm-map .leaflet-popup-content { margin: 14px; font-family: inherit; font-size: 13px; line-height: 1.45; }
.rm-detailhead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.rm-detailhead > div { flex: 1 1 auto; min-width: 0; }
.rm-chip {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.rm-close { flex: 0 0 auto; width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; font-size: 20px; line-height: 1; color: var(--subtle); cursor: pointer; }
.rm-close:hover { background: var(--sand); color: var(--deep); }
.rm-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0 0 10px; }
.rm-facts dt { font-size: 12px; font-weight: 600; color: var(--subtle); max-width: 7.5rem; }
.rm-facts dd { margin: 0; overflow-wrap: anywhere; }
.rm-change.up, .rm-change.appeared { color: var(--done-fg); font-weight: 700; }
.rm-change.down, .rm-change.lost { color: var(--failed-fg); font-weight: 700; }
.rm-change .muted { font-weight: 500; }
.rm-detail h4 { margin: 10px 0 6px; font-size: 13px; }
.rm-rivals { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rm-rivals li { display: flex; align-items: baseline; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.rm-rivals li.mine { background: var(--plum-tint); font-weight: 700; }
.rm-rank { flex: 0 0 1.4em; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--subtle); }
.rm-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.rm-rating { flex: 0 0 auto; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--gold-text); font-weight: 700; }
.rm-replay { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 12px 0 0; }
.rm-replay input[type="range"] { flex: 1 1 180px; max-width: 360px; min-height: 0; padding: 0; accent-color: var(--plum); }
.rm-legend { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; }
.rm-legend li { display: flex; align-items: center; gap: 7px; }
.rm-swatch { width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.15); }
.rm-swatch.outlined { border-color: #6b6b6b; }
.rm-swatch.small { width: 9px; height: 9px; margin: 0 3.500px; background: #fff; border-color: #8a8a8a; }
.rm-overlaynote { margin: 0 0 10px; padding: 8px 12px; border-radius: 10px; background: var(--info-bg); color: var(--info-fg); }
.rm-ringkey { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #fff; margin: 0 5px 0 4px; vertical-align: middle; }
.rm-newscan { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.rm-newscan .rm-bar { margin: 0 0 8px; }
.mapsettings fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.mapsettings legend { padding: 0; margin-bottom: 8px; font-size: 13px; font-weight: 800; color: var(--ink); }
.ms-grid { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; }
.ms-grid label { gap: 4px; }
.ms-grid label > span { font-size: 12px; font-weight: 600; color: var(--subtle); }
.ms-checks { display: flex; flex-direction: column; gap: 8px; }
.ms-checks.inline { flex-direction: row; flex-wrap: wrap; gap: 8px 20px; }
.ms-bands { width: 100%; max-width: 640px; border-collapse: collapse; font-size: 13px; }
.ms-bands th, .ms-bands td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line-faint); vertical-align: middle; }
.ms-bands th { font-size: 12px; font-weight: 600; color: var(--subtle); }
.ms-bands input[type="number"] { width: 72px; }
.ms-color { display: flex; align-items: center; gap: 8px; }
.ms-color input[type="color"] { width: 44px; min-height: 36px; height: 36px; padding: 2px; }
.ms-color input[type="text"] { width: 104px; font-variant-numeric: tabular-nums; }
.ms-preview {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; padding: 26px 18px 16px;
  border: 1px solid var(--line); border-radius: 12px; background: #e8e4dc;
}
.ms-preview .rm-marker { cursor: default; }
.ms-preview .ms-pin svg { display: block; filter: drop-shadow(0 2px 3px rgba(0,0,0,.4)); }
.ms-preview .ms-divider { align-self: stretch; width: 1px; background: rgba(0,0,0,.14); margin: 0 4px; }
.ms-preview .ms-pv { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-soft); }
.ms-savebar {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 12px 0; background: linear-gradient(to top, var(--cream) 70%, transparent);
}
/* new-app glue */
.rm-bar label, .ms-grid label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.rm-bar select, .rm-bar input, .ms-grid select, .ms-grid input[type=number], .ms-grid input[type=text] { font: inherit; padding: 8px 10px; border: 1px solid var(--field, #d9ccbd); border-radius: 10px; background: #fff; color: var(--ink); min-height: 40px; }
.rankmap .warn, .mapsettings .warn { color: var(--review-fg, #7a520a); background: var(--review-wash, #fffaf0); padding: 8px 12px; border-radius: 10px; }
.rankmap .error, .mapsettings .error { color: var(--failed-fg, #9b1f1f); }
.rankmap .row.between { display: flex; justify-content: space-between; align-items: baseline; }
.small-text { font-size: .85rem; }
