/* ══════════════════════════════════════════════════════════════════
   app.css — Happy Light Analytics.

   Same warm-ink token set as the rest of the suite (Maths, Sandbox,
   Journal), so theme.js's [data-theme] switch drives this page too.
   Dark is the bare :root; light overrides only what changes. theme.js
   stamps an explicit data-theme before first paint, so there is no
   prefers-color-scheme block.

   Chart colours are CSS on SVG classes: s0…s7 are the categorical
   series slots (fixed order, validated for colour-vision deficiency
   against the card surface in both themes), so is the neutral "Other",
   q0…q5 the sequential choropleth ramp (q0 = no data). The CSP is
   style-src 'self' with no 'unsafe-inline': nothing sets a style
   attribute in markup; the grid placement is written through the CSSOM.
   ══════════════════════════════════════════════════════════════════ */
:root{
  --bg:#0b0a0d; --bg-2:#16131a;
  --panel:rgba(29,25,34,.86); --panel-solid:#1d1922;
  --card:#1d1922;
  --line:rgba(184,175,164,.20); --line-hot:rgba(245,158,11,.45);
  --ink:#f5f1ea; --ink-dim:#b8afa4; --ink-faint:#6b635a;
  --brand:#f59e0b; --brand-2:#a78bfa;
  --ok:#4ee8a5; --warn:#fbbf24; --bad:#f87171;
  --good-text:#0ca30c; --bad-text:#e66767;
  --surf:rgba(43,37,51,.72);
  --field:#141117;
  --shadow:4px 4px 0 rgba(0,0,0,.45);
  --logo-glow:1; --logo-glow-color:#f59e0b; --logo-bulb:#d9a441;
  --logo-glass-hi:#fffdf6; --logo-glass-lo:#f8e3b6; --logo-face:#8a6a3b;
  --font:"Inter Variable","Inter",ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  --mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  --r:12px;

  /* chart chrome */
  --grid:rgba(184,175,164,.12);
  --axis:rgba(184,175,164,.32);
  --tick:#9a9186;
  --crosshair:rgba(245,241,234,.45);

  /* categorical series, dark steps */
  --s0:#3987e5; --s1:#d95926; --s2:#199e70; --s3:#c98500;
  --s4:#d55181; --s5:#008300; --s6:#9085e9; --s7:#e66767;
  --so:#6b635a;

  /* sequential (choropleth): low recedes into the dark surface */
  --q0:#2b2533; --q1:#123a6e; --q2:#1c5cab; --q3:#2a78d6; --q4:#5598e7; --q5:#9ec5f4;
}
:root[data-theme="light"]{
  --bg:#f6f2ea; --bg-2:#efe9de;
  --panel:rgba(255,253,247,.92); --panel-solid:#fffdf7;
  --card:#fffdf7;
  --line:rgba(90,74,54,.20); --line-hot:rgba(180,83,9,.42);
  --ink:#241f18; --ink-dim:#5b5145; --ink-faint:#7d7264;
  --brand:#b45309; --brand-2:#6d28d9;
  --ok:#047857; --warn:#8c6510; --bad:#b91c1c;
  --good-text:#006300; --bad-text:#b91c1c;
  --surf:rgba(241,236,226,.80);
  --field:#ffffff;
  --shadow:4px 4px 0 rgba(90,74,54,.18);
  --logo-glow:0; --logo-bulb:#a86f18;
  --logo-glass-hi:#fffaec; --logo-glass-lo:#f2d79c; --logo-face:#6b4d22;

  --grid:rgba(90,74,54,.12);
  --axis:rgba(90,74,54,.34);
  --tick:#7d7264;
  --crosshair:rgba(36,31,24,.40);

  --s0:#2a78d6; --s1:#eb6834; --s2:#1baf7a; --s3:#eda100;
  --s4:#e87ba4; --s5:#008300; --s6:#6250d6; --s7:#e34948;
  --so:#a39a8e;

  --q0:#ebe5da; --q1:#b7d3f6; --q2:#86b6ef; --q3:#5598e7; --q4:#256abf; --q5:#104281;
}

*{box-sizing:border-box}
[hidden]{display:none !important}
html{color-scheme:dark}
:root[data-theme="light"]{color-scheme:light}
body{
  margin:0;background:var(--bg);color:var(--ink);
  font-family:var(--font);font-size:15px;line-height:1.5;
  -webkit-font-smoothing:antialiased;min-height:100dvh;
}
body.is-dragging{cursor:grabbing;user-select:none;-webkit-user-select:none}
a{color:var(--brand)}
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,summary:focus-visible,[tabindex]:focus-visible{
  outline:2px solid var(--brand);outline-offset:2px;border-radius:4px;
}
.skip{position:absolute;left:-9999px;top:0;background:var(--panel-solid);
  color:var(--ink);padding:.6rem .9rem;z-index:80;border-radius:0 0 var(--r) 0}
.skip:focus{left:0}

/* ── header ── */
.top{position:sticky;top:0;z-index:40;display:flex;align-items:center;gap:.6rem;
  padding:.55rem 1rem;background:var(--panel);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line)}
.home{text-decoration:none;color:inherit;flex:none}
.wordmark{font-weight:700;letter-spacing:-.03em;line-height:1;
  display:inline-flex;flex-direction:column;align-items:center;gap:.3rem}
.wordmark.small{font-size:1rem}
.wordmark .hl-lockup{height:2em;width:auto;display:inline-block;color:var(--ink);flex:none}
.wm-b{color:var(--ink-dim);font-size:max(.62rem,.16em);font-weight:700;
  letter-spacing:.26em;text-indent:.26em;text-transform:uppercase;line-height:1}

.tabs{display:flex;gap:.25rem;overflow-x:auto;min-width:0;flex:0 1 auto;
  margin-left:.6rem;scrollbar-width:thin;padding:.15rem}
.tab{appearance:none;font:inherit;font-size:.85rem;white-space:nowrap;cursor:pointer;
  color:var(--ink-dim);background:none;border:1px solid transparent;border-radius:999px;
  padding:.3rem .85rem;max-width:16rem;overflow:hidden;text-overflow:ellipsis}
.tab:hover{color:var(--ink);border-color:var(--line)}
.tab[aria-selected="true"]{color:var(--ink);background:var(--surf);border-color:var(--line-hot);font-weight:600}
.top-act{margin-left:auto;display:flex;align-items:center;gap:.45rem;flex:none}

/* ── buttons ── */
.btn{appearance:none;font:inherit;font-size:.85rem;cursor:pointer;white-space:nowrap;
  display:inline-flex;align-items:center;gap:.4rem;
  color:var(--ink);background:var(--surf);border:1px solid var(--line);
  border-radius:999px;padding:.38rem .9rem}
.btn:hover{border-color:var(--line-hot)}
.btn:disabled{opacity:.45;cursor:default}
.btn.primary{background:var(--brand);border-color:transparent;color:#1a1206;font-weight:600}
:root[data-theme="light"] .btn.primary{color:#fff}
.btn.danger{color:var(--bad);border-color:color-mix(in srgb,var(--bad) 45%,transparent)}
#da-ok.danger{background:var(--bad);color:#fff;border-color:transparent}
.btn.small{font-size:.78rem;padding:.25rem .7rem}
.btn svg,.icon-btn svg{width:1rem;height:1rem;fill:none;stroke:currentColor;stroke-width:1.6;
  stroke-linecap:round;stroke-linejoin:round;flex:none}
.icon-btn{appearance:none;flex:none;display:grid;place-items:center;
  width:1.9rem;height:1.9rem;padding:0;border-radius:.45rem;cursor:pointer;font:inherit;
  background:none;border:1px solid transparent;color:var(--ink-dim)}
.icon-btn:hover{color:var(--ink);border-color:var(--line)}
.icon-btn[aria-pressed="true"]{color:var(--brand);border-color:var(--line-hot)}

.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;
  overflow:hidden;background:var(--surf)}
.seg button{appearance:none;background:none;border:0;color:var(--ink-dim);
  font:inherit;font-size:.8rem;padding:.32rem .8rem;cursor:pointer;white-space:nowrap}
.seg button.on{background:var(--brand);color:#1a1206;font-weight:700}
:root[data-theme="light"] .seg button.on{color:#fff}

.notice{position:fixed;left:50%;top:4.2rem;transform:translateX(-50%);z-index:90;
  margin:0;max-width:min(36rem,calc(100vw - 2rem));padding:.55rem .9rem;
  background:var(--panel-solid);border:1px solid var(--line);border-radius:.6rem;
  box-shadow:var(--shadow);font-size:.88rem}
.notice.bad{border-color:color-mix(in srgb,var(--bad) 55%,transparent)}
.notice.ok{border-color:color-mix(in srgb,var(--ok) 55%,transparent)}

/* ── board ── */
.board{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));grid-auto-rows:64px;
  gap:12px;padding:16px;max-width:1600px;margin:0 auto;outline:none}
.board-empty{text-align:center;padding:4rem 1rem;color:var(--ink-dim)}

.widget{position:relative;display:flex;flex-direction:column;min-width:0;min-height:0;
  background:var(--card);border:1px solid var(--line);border-radius:var(--r);
  transition:box-shadow .15s}
.board .widget{transition:box-shadow .15s}
.widget.dragging,.widget.resizing{z-index:10;box-shadow:0 0 0 2px var(--brand),var(--shadow)}
.w-head{display:flex;align-items:center;gap:.3rem;padding:.4rem .4rem .2rem .7rem;flex:none;
  cursor:grab;touch-action:none;min-width:0}
.dragging .w-head{cursor:grabbing}
.w-grip{display:grid;place-items:center;width:.8rem;margin-left:-.35rem;color:var(--ink-faint);flex:none}
.w-grip svg{width:1rem;height:1rem;stroke:currentColor;stroke-width:2.4;stroke-linecap:round}
.w-title{margin:0;font-size:.9rem;font-weight:600;flex:1;min-width:0;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.w-head .icon-btn{width:1.7rem;height:1.7rem;opacity:.55}
.widget:hover .w-head .icon-btn,.widget:focus-within .w-head .icon-btn,.w-head .icon-btn[aria-pressed="true"]{opacity:1}
.w-del:hover{color:var(--bad)}
.w-status{font-size:.7rem;color:var(--ink-faint);white-space:nowrap;display:inline-flex;align-items:center;gap:.3rem}
.w-status:empty{display:none}
.w-status::before{content:"";width:.45rem;height:.45rem;border-radius:50%;background:currentColor}
.w-status.live{color:var(--ink-dim)}
.w-status.live::before{background:var(--ok)}
.w-status.loading::before{background:var(--brand);animation:pulse 1s ease-in-out infinite}
.w-status.bad{color:var(--bad)}
@keyframes pulse{50%{opacity:.25}}
.w-body{position:relative;flex:1;min-height:0;display:flex;flex-direction:column;padding:0 .7rem .6rem}
.w-resize{position:absolute;right:0;bottom:0;width:18px;height:18px;cursor:nwse-resize;touch-action:none;
  border-radius:0 0 var(--r) 0}
.w-resize::after{content:"";position:absolute;right:5px;bottom:5px;width:7px;height:7px;
  border-right:2px solid var(--ink-faint);border-bottom:2px solid var(--ink-faint);opacity:.6}
.widget:hover .w-resize::after{opacity:1}

.empty{margin:auto;padding:1rem;text-align:center;font-size:.85rem;color:var(--ink-dim);max-width:30rem}
.empty.bad{color:var(--bad)}
.note{margin:.2rem 0 0;font-size:.72rem;color:var(--ink-faint)}
.hint{margin:.2rem 0;font-size:.78rem;color:var(--ink-faint)}

/* ── charts ── */
.plot{position:relative;flex:1;min-height:0;min-width:0}
.plot>svg{position:absolute;inset:0;display:block;overflow:visible}
.chart text{font:11px var(--font);fill:var(--tick)}
.ticks text{font-variant-numeric:tabular-nums}
.grid line{stroke:var(--grid);stroke-width:1;shape-rendering:crispEdges}
.grid line.baseline{stroke:var(--axis)}
.direct text,text.direct{fill:var(--ink-dim);font-size:10.5px;font-weight:600;
  paint-order:stroke;stroke:var(--card);stroke-width:3px;stroke-linejoin:round}

.s0{--c:var(--s0)} .s1{--c:var(--s1)} .s2{--c:var(--s2)} .s3{--c:var(--s3)}
.s4{--c:var(--s4)} .s5{--c:var(--s5)} .s6{--c:var(--s6)} .s7{--c:var(--s7)} .so{--c:var(--so)}
.q0{--c:var(--q0)} .q1{--c:var(--q1)} .q2{--c:var(--q2)} .q3{--c:var(--q3)} .q4{--c:var(--q4)} .q5{--c:var(--q5)}
.fillonly{fill:var(--c);stroke:none}
.strokeonly{stroke:var(--c);fill:none;stroke-width:2.5;stroke-linecap:round}

.line{fill:none;stroke:var(--c);stroke-width:2;stroke-linejoin:round;stroke-linecap:round}
.area{fill:var(--c);fill-opacity:.14;stroke:none}
.dot{fill:var(--c);stroke:var(--card);stroke-width:2}
.dot.lift{stroke:var(--ink);stroke-width:2}
.bar{fill:var(--c);stroke:none;transition:filter .1s}
.bar.lift,.slice.lift,.region.lift{filter:brightness(1.18)}
:root[data-theme="light"] .bar.lift,:root[data-theme="light"] .slice.lift{filter:brightness(.88)}
.slice{fill:var(--c);stroke:var(--card);stroke-width:2;stroke-linejoin:round}
.crosshair{stroke:var(--crosshair);stroke-width:1;shape-rendering:crispEdges}
.hit{fill:transparent;cursor:crosshair}
.hit:focus-visible{outline:none;stroke:var(--brand);stroke-width:1}
.donut-total{font-size:20px !important;font-weight:600;fill:var(--ink) !important}
.donut-sub{font-size:11px;fill:var(--ink-faint) !important}

.legend{display:flex;flex-wrap:wrap;gap:.15rem .8rem;font-size:.75rem;color:var(--ink-dim);
  padding:.1rem 0 .35rem;flex:none}
.legend-item{display:inline-flex;align-items:center;gap:.35rem;min-width:0}
.legend-item span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:12rem}
.legend-key{width:14px;height:10px;flex:none}

.pie-wrap{flex:1;min-height:0;display:flex;gap:.8rem;align-items:center}
.pie-plot{flex:1 1 55%;align-self:stretch}
.pie-plot>svg{position:absolute;inset:0;margin:auto}
.pie-legend{flex:1 1 45%;list-style:none;margin:0;padding:0;font-size:.78rem;
  display:flex;flex-direction:column;gap:.2rem;min-width:0;max-height:100%;overflow:auto}
.pie-legend li{display:flex;align-items:center;gap:.4rem;min-width:0;cursor:default}
.pl-name{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ink-dim)}
.pl-val{font-variant-numeric:tabular-nums;color:var(--ink);font-weight:600}

/* ── KPI ── */
.kpi{flex:1;display:flex;flex-direction:column;justify-content:center;min-height:0;gap:.1rem;position:relative}
.kpi-label{font-size:.72rem;color:var(--ink-faint);text-transform:none}
.kpi-value{font-size:clamp(1.6rem,3.2vw,2.4rem);font-weight:650;letter-spacing:-.02em;line-height:1.1;color:var(--ink)}
.kpi-delta,.kpi-sub{font-size:.75rem;color:var(--ink-dim)}
.kpi-delta.good .kpi-arrow{color:var(--good-text)}
.kpi-delta.bad .kpi-arrow{color:var(--bad-text)}
.kpi-spark{position:absolute;right:0;bottom:0;width:42%;height:42%;opacity:.95}
.kpi-spark svg{display:block;width:100%;height:100%}
.spark{fill:none;stroke:var(--so);stroke-width:1.5;stroke-linejoin:round}
.widget.is-kpi .w-head{padding-bottom:0}

/* ── maps ── */
.map .region{fill:var(--q0);stroke:var(--card);stroke-width:.6;stroke-linejoin:round}
.map .region.q1,.map .region.q2,.map .region.q3,.map .region.q4,.map .region.q5{fill:var(--c)}
.map .region.lift{stroke:var(--ink);stroke-width:1.2}
.regions{cursor:default}
.bubble{fill:var(--c);fill-opacity:.62;stroke:var(--card);stroke-width:1.5}
.bubble.lift{fill-opacity:1;stroke:var(--ink)}
.map-legend{padding-right:14px;display:flex;flex-wrap:wrap;gap:.2rem .7rem;align-items:center;font-size:.72rem;color:var(--ink-dim);padding-top:.3rem;flex:none}
.ml-item{display:inline-flex;align-items:center;gap:.3rem;font-variant-numeric:tabular-nums}
.ml-note{color:var(--ink-faint);text-decoration:underline dotted;cursor:help}

/* ── tables ── */
.tbl-bar{display:flex;align-items:center;gap:.6rem;padding-bottom:.35rem;flex:none}
.tbl-search{flex:1;min-width:0;max-width:18rem;font:inherit;font-size:.8rem;color:var(--ink);
  background:var(--field);border:1px solid var(--line);border-radius:999px;padding:.25rem .7rem}
.tbl-count{font-size:.72rem;color:var(--ink-faint)}
.tbl-wrap{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;border:1px solid var(--line);border-radius:.5rem}
.tbl{width:100%;border-collapse:collapse;font-size:.8rem}
.tbl th{position:sticky;top:0;background:var(--card);text-align:left;font-weight:600;color:var(--ink-dim);
  padding:.35rem .55rem;border-bottom:1px solid var(--line);white-space:nowrap;z-index:1}
.tbl td{padding:.3rem .55rem;border-bottom:1px solid var(--line);white-space:nowrap;max-width:22rem;overflow:hidden;text-overflow:ellipsis}
.tbl tr:last-child td{border-bottom:0}
.tbl .num{text-align:right;font-variant-numeric:tabular-nums}
.tbl tbody tr:hover td{background:var(--surf)}
.tbl-sort{appearance:none;background:none;border:0;padding:0;font:inherit;color:inherit;cursor:pointer}
.tbl-sort:hover{color:var(--ink)}
.tbl th.num .tbl-sort{text-align:right}
.tbl-arrow{font-size:.65rem;color:var(--brand)}
.tbl-pager{display:flex;align-items:center;justify-content:flex-end;gap:.6rem;padding-top:.35rem;font-size:.75rem;color:var(--ink-dim);flex:none}

/* ── tooltip ── */
.tip{position:fixed;left:0;top:0;z-index:100;pointer-events:none;min-width:8rem;max-width:20rem;
  padding:.45rem .6rem;border-radius:.5rem;border:1px solid var(--line);
  background:var(--panel-solid);box-shadow:var(--shadow);font-size:.78rem}
.tip-title{color:var(--ink-dim);font-size:.72rem;margin-bottom:.2rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tip-row{display:flex;align-items:center;gap:.45rem;line-height:1.5}
.tip-key{width:14px;height:8px;flex:none}
.tip-val{font-weight:650;color:var(--ink);font-variant-numeric:tabular-nums}
.tip-lab{color:var(--ink-dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}

/* ── dialogs ── */
.dlg{border:1px solid var(--line);border-radius:var(--r);padding:0;color:var(--ink);
  background:var(--panel-solid);box-shadow:var(--shadow);max-height:calc(100dvh - 2rem);
  width:min(30rem,calc(100vw - 2rem))}
.dlg[open]{display:flex;flex-direction:column}
.dlg::backdrop{background:rgba(8,7,10,.6)}
:root[data-theme="light"] .dlg::backdrop{background:rgba(60,50,35,.35)}
.dlg-wide{width:min(64rem,calc(100vw - 2rem))}
.dlg-small{width:min(26rem,calc(100vw - 2rem))}
.dlg-head{display:flex;align-items:center;justify-content:space-between;gap:.5rem;
  padding:.7rem .8rem .6rem 1.1rem;border-bottom:1px solid var(--line);flex:none}
.dlg-head h2{margin:0;font-size:1.05rem}
.dlg-foot{display:flex;align-items:center;justify-content:flex-end;gap:.5rem;
  padding:.7rem 1.1rem;border-top:1px solid var(--line);flex:none}
.dlg-foot .grow{flex:1}
.da-text{margin:.9rem 1.1rem 0;color:var(--ink-dim);font-size:.9rem}
.da-input{margin:.9rem 1.1rem 0;font:inherit;color:var(--ink);background:var(--field);
  border:1px solid var(--line);border-radius:.45rem;padding:.45rem .6rem}
.dlg-small .dlg-foot{border-top:0}

.fld{display:flex;flex-direction:column;gap:.25rem;min-width:0;flex:1;margin:0;border:0;padding:0}
.fld>span,.fld>legend{font-size:.75rem;font-weight:600;color:var(--ink-dim);padding:0}
.fld small{font-weight:400;color:var(--ink-faint)}
.fld input,.fld select,.fld textarea,.filter-row select,.filter-row input{
  font:inherit;font-size:.88rem;color:var(--ink);background:var(--field);min-width:0;width:100%;
  border:1px solid var(--line);border-radius:.45rem;padding:.4rem .55rem}
.fld textarea{font-family:var(--mono);font-size:.8rem;resize:vertical;min-height:8rem}
.fld-row{display:flex;gap:.7rem;align-items:flex-end}
.fld-checks{display:flex;flex-wrap:wrap;gap:.4rem 1.1rem;font-size:.85rem}
.fld-checks label{display:inline-flex;align-items:center;gap:.4rem;cursor:pointer}
input[type=checkbox],input[type=radio]{accent-color:var(--brand)}
.checks{display:flex;flex-wrap:wrap;gap:.25rem .9rem;font-size:.85rem;max-height:8.5rem;overflow:auto;
  padding:.35rem .5rem;border:1px solid var(--line);border-radius:.45rem;background:var(--field)}
.checks label{display:inline-flex;align-items:center;gap:.3rem;cursor:pointer;white-space:nowrap}
.checks.muted{opacity:.5}
.filters{display:flex;flex-direction:column;gap:.35rem;margin-bottom:.35rem}
.filter-row{display:grid;grid-template-columns:minmax(0,1.3fr) 5.5rem minmax(0,1fr) auto;gap:.35rem;align-items:center}

.dw-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.1fr);min-height:0;overflow:auto}
.dw-form{display:flex;flex-direction:column;gap:.75rem;padding:1rem 1.1rem;min-width:0}
.dw-preview{padding:1rem 1.1rem;border-left:1px solid var(--line);background:var(--bg-2);min-width:0}
.dw-preview-label{margin:0 0 .4rem;font-size:.7rem;letter-spacing:.08em;text-transform:uppercase;color:var(--ink-faint)}
.widget.preview{height:min(22rem,52dvh);position:sticky;top:0}
.widget.preview .w-head{cursor:default}

.dd-grid{display:grid;grid-template-columns:14rem minmax(0,1fr);min-height:0;overflow:hidden;flex:1}
.dd-list{border-right:1px solid var(--line);padding:.8rem;overflow:auto;display:flex;flex-direction:column;gap:.6rem}
.dd-list ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:.15rem}
.dd-item{appearance:none;width:100%;text-align:left;font:inherit;cursor:pointer;color:var(--ink);
  background:none;border:1px solid transparent;border-radius:.45rem;padding:.4rem .55rem;
  display:flex;flex-direction:column}
.dd-item:hover{background:var(--surf)}
.dd-item[aria-current="true"]{background:var(--surf);border-color:var(--line-hot)}
.dd-name{font-size:.85rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.dd-meta{font-size:.7rem;color:var(--ink-faint)}
.dd-meta.bad{color:var(--bad)}
.dd-edit{padding:1rem 1.1rem;display:flex;flex-direction:column;gap:.8rem;overflow:auto;min-width:0}
.dd-src{align-self:flex-start;flex-wrap:wrap}
.dd-pane{display:flex;flex-direction:column;gap:.6rem}
.drop{display:flex;flex-direction:column;align-items:center;gap:.3rem;text-align:center;cursor:pointer;
  padding:2rem 1rem;border:2px dashed var(--line);border-radius:var(--r);color:var(--ink-dim);font-size:.9rem}
.drop strong{color:var(--brand)}
.drop small{color:var(--ink-faint)}
.drop.over,.drop:hover{border-color:var(--line-hot);background:var(--surf)}
.drop input{position:absolute;width:1px;height:1px;opacity:0}
.drop:focus-within{outline:2px solid var(--brand);outline-offset:2px}
.grid-edit{width:auto}
.grid-edit td,.grid-edit th{padding:0;border:1px solid var(--line)}
.grid-edit input{font:inherit;font-size:.82rem;color:var(--ink);background:transparent;border:0;padding:.3rem .45rem;width:8.5rem}
.grid-edit th input{font-weight:600}
.grid-edit .grid-x{border:0;padding:0 .2rem}
.grid-edit .icon-btn{width:1.5rem;height:1.5rem}
.row-gap{display:flex;gap:.4rem}
.d-status{margin:0;font-size:.82rem;color:var(--ink-dim)}
.d-status.ok{color:var(--ok)}
.d-status.bad{color:var(--bad)}
.d-preview{display:flex;flex-direction:column;gap:.5rem;min-height:0}
.d-preview .tbl-wrap{max-height:16rem}
.col-chips{display:flex;flex-wrap:wrap;gap:.3rem}
.chip{font-size:.72rem;color:var(--ink-faint);border:1px solid var(--line);border-radius:999px;padding:.05rem .5rem}
.chip b{color:var(--ink);font-weight:600}
.chip.t-number{border-color:color-mix(in srgb,var(--s0) 50%,var(--line))}
.chip.t-date{border-color:color-mix(in srgb,var(--s2) 50%,var(--line))}

/* ── bar menu ── same <details>/<summary> pattern as the siblings ── */
.hl-menu{position:relative}
.hl-menu-summary{display:flex;align-items:center;gap:.45rem;cursor:pointer;list-style:none;
  padding:.4rem .8rem;border:1px solid var(--line);border-radius:999px;background:var(--panel);
  color:var(--ink-dim);font-size:.8rem;user-select:none}
.hl-menu-summary::-webkit-details-marker{display:none}
.hl-menu-summary:hover{border-color:var(--line-hot);color:var(--ink)}
.hl-menu-bars{width:.85rem;height:.7rem;flex:none;
  border-top:2px solid currentColor;border-bottom:2px solid currentColor;position:relative}
.hl-menu-bars::after{content:"";position:absolute;left:0;right:0;top:calc(50% - 1px);
  border-top:2px solid currentColor}
.hl-menu-panel{position:absolute;right:0;top:calc(100% + .35rem);z-index:60;
  min-width:15rem;display:flex;flex-direction:column;padding:.3rem;
  border:1px solid var(--line);border-radius:.6rem;
  background:var(--panel-solid);box-shadow:var(--shadow);max-height:calc(100dvh - 5rem);overflow:auto}
.hl-menu-head{margin:.45rem .55rem .2rem;font-size:.62rem;letter-spacing:.08em;
  text-transform:uppercase;color:var(--ink-faint)}
.hl-menu-head:first-child{margin-top:.2rem}
.hl-menu-item{appearance:none;background:none;border:0;cursor:pointer;font:inherit;
  font-size:.85rem;color:var(--ink);text-align:left;text-decoration:none;
  padding:.45rem .55rem;border-radius:.4rem}
.hl-menu-item:hover{background:var(--line)}
.hl-menu-item:focus-visible{outline:2px solid var(--brand);outline-offset:-2px}
.hl-menu-seg{margin:.15rem .55rem .3rem;align-self:flex-start}

/* ── signed-in chip ── same markup and rules in every Happy Light app. ── */
.hl-me{display:inline-flex;align-items:center;gap:.4rem;flex:none;max-width:13rem;
  padding:.15rem .7rem .15rem .15rem;border-radius:999px;
  border:1px solid color-mix(in srgb,var(--ok) 40%,var(--line));
  background:color-mix(in srgb,var(--ok) 9%,var(--surf,transparent));
  color:var(--ink);font-size:.78rem;font-weight:600;line-height:1.2;
  text-decoration:none;white-space:nowrap}
.hl-me:hover{border-color:color-mix(in srgb,var(--ok) 65%,transparent);
  background:color-mix(in srgb,var(--ok) 16%,var(--surf,transparent))}
.hl-me-avatar{position:relative;display:grid;place-items:center;flex:none;
  width:1.45rem;height:1.45rem;border-radius:50%;
  background:color-mix(in srgb,var(--ink) 10%,transparent)}
.hl-me-ghost{width:.8rem;height:.8rem;fill:currentColor;animation:hl-me-bob 2.4s steps(4) infinite}
.hl-me-dot{position:absolute;right:-1px;bottom:-1px;width:.5rem;height:.5rem;
  border-radius:50%;background:var(--ok);box-shadow:0 0 0 2px var(--bg)}
.hl-me-dot::after{content:"";position:absolute;inset:0;border-radius:inherit;
  background:var(--ok);animation:hl-me-ping 2.4s cubic-bezier(.22,.61,.36,1) infinite}
.hl-me-name{min-width:0;overflow:hidden;text-overflow:ellipsis}
@keyframes hl-me-bob{0%,100%{transform:translateY(0)}50%{transform:translateY(-1px)}}
@keyframes hl-me-ping{0%{transform:scale(1);opacity:.6}70%,100%{transform:scale(2.4);opacity:0}}
@media (max-width:560px){.hl-me{padding:.15rem}.hl-me-name{display:none}}
@media (prefers-reduced-motion:reduce){.hl-me-ghost,.hl-me-dot::after,.w-status.loading::before{animation:none}}

/* ── narrower screens ── */
@media (max-width:1000px){
  .top{flex-wrap:wrap}
  .tabs{order:5;flex:1 1 100%;margin-left:0}
}
/* Phones: widgets stack in reading order; dragging is off, heights follow
   the desktop row span so a tall widget stays tall. */
@media (max-width:720px){
  .top{padding:.45rem 16px;gap:.4rem}
  .wordmark.small{font-size:.85rem}
  .btn span{display:none}
  .btn{padding:.38rem .6rem}
  .hl-menu-word{display:none}
  .board{display:flex;flex-direction:column;padding:12px 16px;gap:12px}
  .board .widget{height:calc(min(var(--h),7) * 56px + 24px);min-height:150px}
  .board .widget.is-kpi{height:130px;min-height:0}
  .w-head{cursor:default}
  .w-grip,.w-resize{display:none}
  .w-head .icon-btn{opacity:1}
  .dlg{width:100vw;max-width:100vw;max-height:100dvh;height:100dvh;border-radius:0;margin:0}
  .dlg-small{height:auto;margin:auto;width:calc(100vw - 2rem);border-radius:var(--r)}
  .dw-grid{grid-template-columns:1fr}
  .dw-preview{border-left:0;border-top:1px solid var(--line);order:-1}
  .widget.preview{height:15rem;position:static}
  .dd-grid{grid-template-columns:1fr;overflow:auto}
  .dd-list{border-right:0;border-bottom:1px solid var(--line);max-height:11rem}
  .fld-row{flex-wrap:wrap}
  .fld-row>.fld{flex:1 1 9rem}
  .filter-row{grid-template-columns:minmax(0,1fr) 4.5rem minmax(0,1fr) auto}
  .pie-wrap{gap:.4rem}
}

/* ── modes: share-link viewer, server, local ── */
.remote-only{display:none}
body.remote-mode .remote-only{display:revert}
body.read-only .edit-only,body.read-only .w-edit,body.read-only .w-del,
body.read-only .w-grip,body.read-only .w-resize{display:none !important}
body.read-only .w-head{cursor:default}
.viewer-bar{margin:0;display:flex;flex-wrap:wrap;gap:.3rem 1rem;justify-content:center;align-items:center;
  padding:.45rem 16px;font-size:.82rem;color:var(--ink-dim);background:var(--surf);border-bottom:1px solid var(--line)}

.gate{position:fixed;inset:0;z-index:95;display:grid;place-items:center;padding:16px;
  background:color-mix(in srgb,var(--bg) 88%,transparent);backdrop-filter:blur(6px)}
.gate-card{width:min(26rem,100%);padding:1.4rem 1.3rem;text-align:center;
  background:var(--panel-solid);border:1px solid var(--line);border-radius:var(--r);box-shadow:var(--shadow)}
.gate-msg{margin:0 0 1rem;font-size:.95rem}
.gate-act{display:flex;flex-wrap:wrap;gap:.5rem;justify-content:center}
.gate-act:empty{display:none}
.gate-act a.btn{text-decoration:none}

.check-line{display:flex;align-items:flex-start;gap:.5rem;font-size:.86rem;cursor:pointer}
.check-line input{margin-top:.25rem}
.check-line small{color:var(--ink-faint)}
.share-body{display:flex;flex-direction:column;gap:.75rem;padding:1rem 1.1rem 1.1rem}
.share-body>.btn{align-self:flex-start}
.share-link{display:flex;gap:.4rem}
.share-link input{flex:1;min-width:0;font:inherit;font-size:.82rem;font-family:var(--mono);color:var(--ink);
  background:var(--field);border:1px solid var(--line);border-radius:.45rem;padding:.35rem .5rem}

/* ── tile maps (Leaflet) ── */
.tilemap{position:relative;flex:1;min-height:0;border-radius:.5rem;overflow:hidden;background:var(--q0);z-index:0}
.tilemap .leaflet-container{font:inherit}
.leaflet-container{background:var(--q0);font-family:var(--font)}
.leaflet-interactive.bubble{fill:var(--c);fill-opacity:.62;stroke:var(--card);stroke-width:1.5}
.leaflet-interactive.bubble:hover{fill-opacity:1;stroke:var(--ink)}
.leaflet-interactive.region.tiled{fill:var(--c);fill-opacity:.62;stroke:var(--card);stroke-width:.8}
.leaflet-interactive.region.tiled.q0{fill-opacity:0}
.leaflet-interactive.region.tiled:hover{stroke:var(--ink);stroke-width:1.5}
.leaflet-control-attribution{font-size:10px}
.leaflet-control-zoom a{color:#241f18}
.ml-swatch{display:inline-block;width:14px;height:8px;border-radius:2px;background:var(--c)}
/* Light tiles, tone-inverted for dark mode when no dark tile set is configured. */
:root:not([data-theme="light"]) .invert-dark .leaflet-tile-pane{filter:invert(1) hue-rotate(180deg) brightness(.9) contrast(.9)}
:root:not([data-theme="light"]) .leaflet-control-attribution{background:rgba(29,25,34,.8);color:var(--ink-dim)}
:root:not([data-theme="light"]) .leaflet-control-attribution a{color:var(--ink)}
