/* Nursing Homes USA v1.6.0 — calm, modern, readable */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #0f1b2d;
  --ink2: #334155;
  --muted: #64748b;
  --line: #e5e8ee;
  --line2: #eef1f5;
  --navy: #14243a;
  --accent: #2557a7;
  --accent-soft: #e9f0fb;
  --hot: #c9601f;
  --hot-soft: #fcefe6;
  --good: #1f7a4d;
  --bad: #b42318;
  --amber: #8a6d1f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 4px 14px rgba(15, 27, 45, .05);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
body { display: grid; grid-template-columns: 440px 1fr; }
.muted { color: var(--muted); }
.pad { padding: 16px 20px; }

/* ---------- panel ---------- */
#panel { height: 100vh; overflow-y: auto; background: var(--bg); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
#map { height: 100vh; }
#grab { display: none; }

.brand { position: relative; padding: 16px 20px 6px; background: var(--card); }
.brand-link { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none !important; }
.logo { width: 30px; height: 30px; flex: none; }
.wordmark { font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.ver { font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 0; margin-left: 2px; vertical-align: 2px; }
.tagline { margin: 2px 0 0 40px; color: var(--muted); font-size: 13px; }
#maptoggle { position: absolute; right: 16px; top: 18px; border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--accent); }
#maptoggle:hover { background: var(--accent-soft); }

.search { position: sticky; top: 0; z-index: 6; background: var(--card); padding: 10px 20px 10px; }
.sicon { position: absolute; left: 32px; top: 22px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
#q { width: 100%; padding: 11px 12px 11px 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 15px; }
#q:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
#results { position: absolute; left: 20px; right: 20px; top: 58px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 27, 45, .14); max-height: 62vh; overflow-y: auto; padding: 4px 0; }
#results .grp { padding: 8px 14px 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
#results button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 14px; }
#results button:hover, #results button.act { background: var(--accent-soft); }
#results small { color: var(--muted); }

#tabs { display: flex; gap: 2px; padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 64px; z-index: 5; }
#tabs button { flex: 1; border: 0; background: none; padding: 10px 6px 11px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
#tabs button:hover { color: var(--ink); }
#tabs button.on { color: var(--ink); border-color: var(--navy); }

#view { flex: 1; padding-bottom: 8px; }
.foot { padding: 14px 20px 22px; font-size: 12px; color: var(--muted); }
.foot p { margin: 0; }

/* ---------- building blocks ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin: 12px 16px; padding: 14px 16px; }
.card > h3:first-child, .card > .h:first-child { margin-top: 0; }
h2 { font-size: 20px; line-height: 1.25; font-weight: 750; letter-spacing: -.015em; margin: 0; }
h3, .h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 8px; }
.scope { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 12px 20px 0; font-size: 14px; color: var(--ink2); }
.scope b { color: var(--ink); font-weight: 700; }
.scope .where { color: var(--muted); }
#area { border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; background: #fff; color: var(--accent); font-weight: 600; }
.seg { display: inline-flex; background: var(--line2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(15, 27, 45, .12); }
.bar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 20px 6px; }
.bar-head h2 { font-size: 16px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 20px 4px; }
.controls select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; font-size: 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink2); cursor: pointer; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 20px 0; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.chips button.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 20px 12px; }
.note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.more { border: 0; background: none; color: var(--accent); padding: 8px 0 2px; font-weight: 600; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .02em; padding: 2px 7px; border-radius: 99px; background: var(--line2); color: var(--ink2); vertical-align: 1px; }
.badge.rep { background: var(--accent-soft); color: var(--accent); }
.badge.inf { background: #f7f0dc; color: var(--amber); }
.badge.warn { background: #fde8e7; color: var(--bad); }
.badge.cand { background: #fff4e5; color: #9a5b00; }
.pos { color: var(--good); } .neg { color: var(--bad); }
.stars { color: #d39b2a; letter-spacing: 1px; white-space: nowrap; }
.stars .off { color: #d8dde5; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; border: 0; background: none; text-align: left; padding: 9px 10px; border-radius: 9px; }
.row:hover { background: var(--accent-soft); }
.row.plain { cursor: default; } .row.plain:hover { background: none; }
.row small, .row .sub2 { color: var(--muted); font-size: 13px; }
.row .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .r b { font-weight: 650; }
.lc { margin: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px; }
.people .ico { display: inline-block; width: 22px; }
.people .pct { color: var(--muted); font-size: 13px; text-align: right; }
.rank .row { display: grid; grid-template-columns: 22px 1fr auto; }
.rank .n { color: var(--muted); font-size: 12px; font-weight: 600; text-align: right; }
.rank .who { min-width: 0; }
.rank .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.meter { height: 5px; background: var(--line2); border-radius: 3px; margin-top: 5px; overflow: hidden; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, #2557a7, #4f7fd0); border-radius: 3px; }
.rank .num small { display: block; }
.hrow .nm { font-weight: 600; }
.hrow .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* detail pages */
.back { border: 0; background: none; color: var(--accent); padding: 12px 20px 0; font-weight: 600; }
.head { padding: 6px 20px 2px; }
.head .sub { color: var(--muted); margin-top: 3px; }
.head .badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 16px 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; min-width: 0; }
.tile b { display: block; font-size: 20px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile span { font-size: 12px; color: var(--muted); }
.facts { display: grid; grid-template-columns: 112px 1fr; margin: 0; }
.facts dt, .facts dd { padding: 9px 0; border-bottom: 1px solid var(--line2); margin: 0; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { font-weight: 600; }
.facts dt:last-of-type, .facts dd:last-of-type { border-bottom: 0; }
.facts small { font-weight: 400; color: var(--muted); margin-left: 4px; }
.hot { color: var(--hot); }
.soft { opacity: .9; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 5px 12px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.srcs { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.src { color: var(--muted); font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; }
.src:hover { color: var(--accent); }
details > summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 6px 0; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸ "; } details[open] > summary::before { content: "▾ "; }

/* payer mix */
.mix { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--line2); margin: 6px 0 6px; }
.mix i { display: block; height: 100%; }
.mix .mcd { background: #2557a7; } .mix .mcr { background: #6ea3e8; } .mix .oth { background: #c9d4e4; }
.mixkey { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--ink2); }
.mixkey i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
table.money { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.money th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 0 6px; }
table.money th:first-child, table.money td:first-child { text-align: left; color: var(--ink2); }
table.money td { text-align: right; padding: 5px 0; border-top: 1px solid var(--line2); }

/* activity */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 92px; margin: 12px 20px 4px; padding-top: 14px; }
.chart .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.chart .b i { display: block; width: 100%; max-width: 26px; background: #9db8e3; border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .b.last i { background: var(--navy); }
.chart .b em { font-style: normal; font-size: 10.5px; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.chart .b span { font-size: 10.5px; color: var(--ink2); font-weight: 600; margin-bottom: 2px; }
.deal .when { font-size: 12.5px; font-weight: 700; color: var(--hot); }

/* map */
#legend { position: fixed; top: 12px; right: 12px; z-index: 3; background: rgba(255, 255, 255, .96); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; font-size: 13px; display: flex; gap: 14px; box-shadow: var(--shadow); }
#legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
#legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.maplibregl-popup-content { font: 14px/1.35 var(--font); padding: 8px 10px; border-radius: 8px; box-shadow: 0 6px 20px rgba(15, 27, 45, .15); }
.maplibregl-popup-content small { color: var(--muted); }
#sheetbtn { display: none; }

/* map hidden: the list fills the screen */
body.nomap { grid-template-columns: 1fr; }
body.nomap #map, body.nomap #legend { display: none; }
body.nomap #panel { width: 100%; max-width: 820px; margin: 0 auto; border-left: 1px solid var(--line); }

/* ---------- phones ---------- */
@media (max-width: 800px) {
  html, body { height: 100%; overflow: hidden; }
  body { display: block; }
  #map { position: fixed; inset: 0; height: auto; }
  #panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; height: 48vh; max-height: calc(100dvh - 56px); border-right: 0; border-radius: 18px 18px 0 0; box-shadow: 0 -8px 28px rgba(15, 27, 45, .2); transition: height .25s ease; overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom); }
  #panel.dragging { transition: none; }
  #grab { display: flex; align-items: center; justify-content: center; position: sticky; top: 0; z-index: 8; background: var(--card); padding: 9px 0 5px; touch-action: none; cursor: grab; border-radius: 18px 18px 0 0; padding: 12px 0 13px; }
  #grab i { display: block; width: 42px; height: 5px; border-radius: 3px; background: #cdd3dc; }
  #sheetbtn { display: block; position: absolute; right: 12px; top: 4px; border: 0; background: var(--line2); border-radius: 99px; padding: 3px 10px; font-size: 12px; font-weight: 600; color: var(--accent); }
  .brand { padding: 0 16px 4px; touch-action: none; }
  .tagline { display: none; }
  .wordmark { font-size: 17px; }
  .logo { width: 26px; height: 26px; }
  #maptoggle { right: 12px; top: 0; padding: 4px 10px; font-size: 12px; }
  .search { position: sticky; top: 30px; padding: 6px 16px 8px; }
  .sicon { left: 28px; top: 17px; }
  #q { font-size: 16px; }
  #results { left: 16px; right: 16px; top: 54px; max-height: 55vh; }
  #tabs { top: 86px; padding: 0 8px; }
  .scope, .controls, .chips, .bar-head, .hint, .chart { margin-left: 16px; margin-right: 16px; }
  .scope { padding-left: 16px; padding-right: 16px; margin: 0; }
  .card { margin: 10px 12px; }
  .lc { margin: 8px 8px; }
  .tiles { margin: 10px 12px 0; }
  .back { padding: 10px 16px 0; }
  .head { padding: 6px 16px 2px; }
  .row { padding: 11px 10px; }
  .kv { grid-template-columns: 120px 1fr; }
  #legend { top: 10px; left: 10px; right: auto; font-size: 12px; padding: 5px 9px; gap: 10px; }
  .maplibregl-ctrl-top-right { top: 44px; }
  body.nomap #panel { position: fixed; inset: 0; height: 100dvh !important; max-height: none; border-radius: 0; box-shadow: none; max-width: none; border-left: 0; }
  body.nomap #grab { display: none; }
  body.nomap .brand { padding-top: 12px; }
  body.nomap #maptoggle { top: 12px; }
  body.nomap .search { top: 0; }
  body.nomap #tabs { top: 56px; }
}

.people .pw { display: flex; align-items: flex-start; gap: 2px; min-width: 0; }
.people .pw b { font-weight: 600; }
.people .pw small { color: var(--muted); font-size: 12.5px; }
.people .ico { flex: none; width: 24px; padding-top: 1px; }

/* v1.7.0: bought vs sold mini chart */
.chart.duo { margin: 6px 0 0; height: 96px; }
.chart.duo .pair { display: flex; align-items: flex-end; gap: 2px; width: 100%; justify-content: center; }
.chart.duo .pair i { width: 45%; max-width: 12px; background: #2557a7; border-radius: 3px 3px 0 0; min-height: 0; }
.chart.duo .pair i.s { background: #d9733b; }

/* v1.12.0: owner HQ line + ranking filter */
.rank .who .base { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 1px; }
.controls .rfilter { flex: 1; min-width: 150px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #fff; font-size: 14px; }
.controls .rfilter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* latest-deals / new-providers ticker */
.ticker { display: flex; align-items: center; gap: 8px; margin: 8px 20px 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 13px; min-width: 0; }
.ticker b { white-space: nowrap; color: var(--ink); }
.tk-dot { width: 8px; height: 8px; border-radius: 50%; background: #d9733b; flex: none; animation: tk-pulse 1.6s ease-in-out infinite; }
@keyframes tk-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.tk-items { flex: 1; min-width: 0; position: relative; height: 18px; overflow: hidden; }
.tk-items a { position: absolute; inset: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--accent); visibility: hidden; }
.tk-items a.on { visibility: visible; animation: tk-in .35s ease-out; }
@keyframes tk-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.tk-all { border: 0; background: none; color: var(--accent); font: 600 13px inherit; cursor: pointer; white-space: nowrap; padding: 0; }
@media (max-width: 800px) { .ticker { margin: 8px 16px 4px; } }
