/* Plant hover cards and side sheet (plant-sheet.js), shared by the World, US and My Grid maps.
   Own tokens, so it looks the same on pages with different stylesheets; follows the page's
   data-theme when it has one, else the system setting. */
.ps-sheet, .ps-hover {
  --ps-card: #ffffff; --ps-text: #1b1f24; --ps-muted: #5d6670; --ps-line: #dde1e6; --ps-track: #e3e6ea;
  --ps-seg: #dbe6fb; --ps-seg-text: #123a8a; --ps-accent: #2563eb;
  --ps-ok-bg: #dcf3e8; --ps-ok: #0d5c3c; --ps-plan-bg: #fbefd0; --ps-plan: #6b4700;
  --ps-warn-bg: #fde3dc; --ps-warn: #8a2a12; --ps-idle-bg: #e9ecef; --ps-idle: #3f4650;
  --ps-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ps-sheet, :root:not([data-theme="light"]) .ps-hover {
    --ps-card: #1f242b; --ps-text: #e8ebef; --ps-muted: #a3acb6; --ps-line: #333a44; --ps-track: #2c333c;
    --ps-seg: #33435a; --ps-seg-text: #ffffff; --ps-accent: #6ea8ff;
    --ps-ok-bg: #16382b; --ps-ok: #7ad7ae; --ps-plan-bg: #3a2f12; --ps-plan: #f0c766;
    --ps-warn-bg: #44221a; --ps-warn: #f4a48c; --ps-idle-bg: #2c333c; --ps-idle: #c3cad2;
    --ps-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] .ps-sheet, :root[data-theme="dark"] .ps-hover {
  --ps-card: #1f242b; --ps-text: #e8ebef; --ps-muted: #a3acb6; --ps-line: #333a44; --ps-track: #2c333c;
  --ps-seg: #33435a; --ps-seg-text: #ffffff; --ps-accent: #6ea8ff;
  --ps-ok-bg: #16382b; --ps-ok: #7ad7ae; --ps-plan-bg: #3a2f12; --ps-plan: #f0c766;
  --ps-warn-bg: #44221a; --ps-warn: #f4a48c; --ps-idle-bg: #2c333c; --ps-idle: #c3cad2;
  --ps-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* ---- hover card: lives in a MapLibre popup with className "ps-hover" */
.ps-hover .maplibregl-popup-content { padding: 0; background: none; box-shadow: none; border: 0; }
.ps-hover .maplibregl-popup-tip { display: none; }
.ps-hover-card {
  width: 240px; box-sizing: border-box; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px;
  background: var(--ps-card); color: var(--ps-text); border: 1px solid var(--ps-line); border-radius: 8px;
  box-shadow: var(--ps-shadow); font: 12px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.ps-hname { font-size: 14px; }
.ps-hrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ps-hval { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- shared bits */
.ps-sheet, .ps-hover-card { font-variant-numeric: tabular-nums; }
.ps-muted { color: var(--ps-muted); }
.ps-kicker { display: inline-flex; align-items: center; gap: 6px; color: var(--ps-muted); font-size: 12px; }
.ps-sw { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; box-sizing: border-box; }
.ps-sw.hollow { border: 2.5px solid; background: transparent; }
.ps-gauge { height: 6px; border-radius: 3px; background: var(--ps-track); overflow: hidden; }
.ps-gauge div { height: 100%; border-radius: 3px; }
.ps-pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.ps-pill.ok { background: var(--ps-ok-bg); color: var(--ps-ok); }
.ps-pill.plan { background: var(--ps-plan-bg); color: var(--ps-plan); }
.ps-pill.warn { background: var(--ps-warn-bg); color: var(--ps-warn); }
.ps-pill.idle, .ps-pill.gone { background: var(--ps-idle-bg); color: var(--ps-idle); }

/* ---- side sheet (desktop): docked on the right, over the map */
.ps-sheet {
  position: fixed; z-index: 20; top: var(--ps-top, 12px); right: 12px; bottom: calc(12px + var(--nav-h, 0px)); width: 384px; max-width: calc(100vw - 24px);
  display: flex; flex-direction: column; box-sizing: border-box;
  background: var(--ps-card); color: var(--ps-text); border: 1px solid var(--ps-line); border-radius: 12px;
  box-shadow: var(--ps-shadow); font: 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.ps-sheet[hidden] { display: none; }
.ps-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--ps-line); display: flex; flex-direction: column; gap: 4px; }
.ps-toprow { display: flex; align-items: center; gap: 8px; }
.ps-close {
  margin-left: auto; width: 36px; height: 36px; margin-right: -8px; border: 0; border-radius: 6px;
  background: none; color: var(--ps-muted); font-size: 22px; line-height: 1; cursor: pointer;
}
.ps-close:hover { background: var(--ps-track); color: var(--ps-text); }
.ps-name { margin: 0; font-size: 19px; line-height: 1.25; }
.ps-meta { color: var(--ps-muted); font-size: 12px; }
.ps-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ps-btn {
  font: inherit; font-size: 12px; padding: 6px 10px; border: 1px solid var(--ps-line); border-radius: 6px;
  background: none; color: var(--ps-text); cursor: pointer; text-decoration: none;
}
.ps-btn:hover { border-color: var(--ps-accent); color: var(--ps-accent); }
.ps-body { flex: 1; overflow-y: auto; padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.ps-more { display: flex; flex-direction: column; gap: 14px; }
.ps-now { display: flex; flex-direction: column; gap: 6px; }
.ps-nowrow { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ps-big { font-size: 26px; font-weight: 650; }
.ps-pct { margin-left: auto; font-weight: 600; }
.ps-now .ps-gauge { height: 8px; }
.ps-note { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--ps-muted); font-size: 12px; }
.ps-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; border: 1px dashed var(--ps-muted); }
.ps-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ps-tile { border: 1px solid var(--ps-line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.ps-tl, .ps-ts { font-size: 11px; color: var(--ps-muted); }
.ps-tv { font-size: 17px; font-weight: 600; }
.ps-text p { margin: 0 0 8px; }
.ps-text p:last-child { margin: 0; }
.ps-h { font-weight: 600; }
.ps-chart, .ps-section { display: flex; flex-direction: column; gap: 6px; }
.ps-seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); border: 1px solid var(--ps-line); border-radius: 8px; overflow: hidden; }
.ps-seg button { font: inherit; font-size: 12px; padding: 7px 6px; border: 0; background: none; color: var(--ps-muted); cursor: pointer; }
.ps-seg button[aria-pressed="true"] { background: var(--ps-seg); color: var(--ps-seg-text); }
.ps-bars { display: flex; align-items: flex-end; gap: 3px; height: 104px; border-bottom: 1px solid var(--ps-line); }
.ps-bar { flex: 1; min-width: 0; padding: 0; border: 0; border-radius: 3px 3px 0 0; opacity: 0.5; cursor: pointer; }
.ps-bar.on, .ps-bar:hover, .ps-bar:focus-visible { opacity: 1; }
.ps-line { display: block; width: 100%; height: 104px; }
.ps-cap { stroke: var(--ps-muted); stroke-dasharray: 4 4; }
.ps-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--ps-muted); }
.ps-readout { font-size: 12px; }
.ps-stack { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; }
.ps-caprow { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.ps-caprow .ps-sw { margin-right: 6px; vertical-align: -1px; }
.ps-about { border-top: 1px solid var(--ps-line); padding-top: 10px; font-size: 12px; color: var(--ps-muted); }
.ps-about summary { cursor: pointer; color: var(--ps-text); font-weight: 600; }
.ps-about p { margin: 8px 0 0; }
.ps-about strong { color: var(--ps-text); }

/* ---- phone: a bottom drawer that peeks (name + output now), then expands */
.ps-sheet.drawer {
  top: auto; left: 0; right: 0; bottom: var(--nav-h, 0px); width: auto; max-width: none; max-height: calc(85vh - var(--nav-h, 0px));
  border-radius: 16px 16px 0 0; border-bottom: 0;
}
.ps-sheet.drawer .ps-head { border-bottom: 0; padding-top: 4px; padding-bottom: 0; }
.ps-sheet.drawer .ps-body { padding-top: 8px; }
.ps-sheet.drawer:not(.expanded) .ps-more { display: none; }
.ps-sheet.drawer:not(.expanded) .ps-body { flex: none; overflow: visible; }
.ps-handle { flex: none; display: flex; align-items: center; justify-content: center; height: 24px; touch-action: none; }
.ps-handle::before { content: ""; width: 40px; height: 5px; border-radius: 3px; background: var(--ps-line); }
.ps-foot { padding: 0 16px 16px; }
.ps-expand {
  width: 100%; min-height: 44px; font: inherit; font-size: 14px; font-weight: 600; border: 0; border-radius: 8px;
  background: var(--ps-seg); color: var(--ps-seg-text); cursor: pointer;
}
.ps-sheet.drawer .ps-btn { min-height: 44px; font-size: 14px; flex: 1 1 40%; }
.ps-sheet.drawer .ps-close { width: 44px; height: 44px; }
.ps-sheet.drawer .ps-seg button { min-height: 44px; }
.ps-sheet.drawer .ps-about summary { padding: 12px 0; }
.ps-sheet .pulse { flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .ps-sheet:not([hidden]) { animation: ps-in 0.16s ease-out; }
  @keyframes ps-in { from { opacity: 0; transform: translateX(12px); } }
  .ps-sheet.drawer:not([hidden]) { animation-name: ps-up; }
  @keyframes ps-up { from { opacity: 0; transform: translateY(24px); } }
}
/* Loading dot, for pages whose stylesheet has none */
.ps-sheet .pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ps-accent); animation: ps-pulse 1.2s ease-in-out infinite; }
@keyframes ps-pulse { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .ps-sheet .pulse { animation: none; } }
.ps-units { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 4px; }
.ps-units td { padding: 3px 0; border-top: 1px solid var(--ps-line); }
.ps-units td:last-child { text-align: right; color: var(--ps-muted); }
/* While the sheet is open on a wide screen, the map's own top-right controls move left of it. */
#map .maplibregl-ctrl-top-right { transition: right 0.16s ease-out; }
body:has(.ps-sheet:not([hidden]):not(.drawer)) #map .maplibregl-ctrl-top-right { right: 396px; } /* full-window maps */
/* Phone: the map's zoom buttons are big enough for a finger. */
@media (max-width: 760px) { .maplibregl-ctrl-group button { width: 44px; height: 44px; } }
