/* ════════════════════════════════════════════════════════════════════════════
   70-alerts.css  the ALERTS page, the rule builder and the ALRT pane
   (static/js/alerts.js, window.MPAlerts, 2026-10-09; board Option A "Rules",
   shots A-list, A-builder, A-pane).
   ----------------------------------------------------------------------------
   Owns the `.alr-*` namespace (no other file uses it). The page and the pane
   are drawn on the shared table layout (66-table.css, .mpt-*); this file
   keeps the stage layer, the state pills, the side panel's grouped lists
   and the builder dialog.

   House rules: tokens.css colours only (both themes follow), rings are
   inset box shadows (no 1px borders), no accent lines (active = filled
   background), no glow focus halos, no native number spinners, one font,
   12 / 14 px, grey sentence case. APPENDED LAST: owns only .alr-*.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Stage layer (research.js stamps data-rsx-mode on #research-view) ───── */
.alr-surface{
  position:absolute;inset:0;display:none;flex-direction:column;
  min-width:0;min-height:0;background:var(--bg-primary);
}
.alr-surface [hidden]{display:none!important;}
#research-view[data-rsx-mode="alerts"] .alr-surface{display:flex;}
#research-view[data-rsx-mode="alerts"] #research-iframe{display:none;}
#research-view[data-rsx-mode="alerts"] .research-panel{display:none!important;}

.alr-board .mpt-btn .mpt-i,.alr-dlg .mpt-btn .mpt-i{width:10px;height:10px;}
.alr-board .alr-new{gap:5px;}

/* ── State pill: a small dot + the state word on a quiet fill ────────── */
.alr-pill{
  display:inline-flex;align-items:center;gap:6px;max-width:100%;height:max(18px, 1.278rem);padding:0 7px;box-sizing:border-box;
  border-radius:var(--radius);background:var(--bg-elevated);color:var(--text-secondary);
  line-height:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;vertical-align:middle;
}
.alr-dot{flex:none;display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--text-muted);}
.alr-p-armed .alr-dot,.alr-d-ok{background:var(--green);}
.alr-p-fired{background:color-mix(in srgb, var(--amber) 18%, transparent);color:var(--text-primary);}
.alr-p-fired .alr-dot{background:var(--amber);}
.alr-d-no{background:var(--text-xmuted);}
.alr-d-unk{background:var(--text-xmuted);}
.mpt-t .alr-fired{color:var(--text-primary);}
/* Light: the quiet fill is the travertine tone, not the card white. */
:root[data-theme="light"] .alr-pill:not(.alr-p-fired){background:var(--bg-tertiary);}
:root[data-theme="light"] .mpt-t > tbody > tr.mpt-r:hover .alr-pill:not(.alr-p-fired),
:root[data-theme="light"] .mpt-t > tbody > tr.mpt-r.mpt-sel .alr-pill:not(.alr-p-fired){background:var(--bg-secondary);}
.mpt-t > tbody > tr.mpt-r:hover .alr-pill:not(.alr-p-fired),
.mpt-t > tbody > tr.mpt-r.mpt-sel .alr-pill:not(.alr-p-fired){background:var(--bg-tertiary);}

/* A narrow page with the side panel open: the Conditions column gives way
   (the side panel lists them), the Rule column takes its room. */
@container mptpage (max-width:1180px){
  .alr-board:has(> .mpt-body > .mpt-side:not([hidden])) .alr-table .alr-cc{display:none;}
  .alr-board:has(> .mpt-body > .mpt-side:not([hidden])) .alr-table col:nth-child(2){width:auto!important;}
}

/* Row delete (Price, Events, Commodities): an x, then "Confirm" in place. */
.mpt-t td.alr-dc{padding-top:0;padding-bottom:0;overflow:visible;}
.alr-x{
  display:inline-flex;align-items:center;justify-content:center;min-width:22px;height:20px;padding:0 4px;box-sizing:border-box;
  border:0;border-radius:var(--radius-sm);background:transparent;color:var(--text-xmuted);cursor:pointer;
  font:inherit;line-height:1;vertical-align:middle;
}
.mpt-t tr.mpt-r:hover .alr-x{color:var(--text-secondary);}
.alr-x:hover{background:var(--bg-hover);color:var(--text-primary)!important;}
.alr-x.alr-armed{padding:0 8px;background:color-mix(in srgb, var(--red) 16%, transparent);color:var(--red)!important;}
.alr-x:focus-visible{outline:none;box-shadow:inset 0 0 0 1px var(--border-strong);}

/* ── Side panel: name, subtitle, grouped lists, actions ──────────────── */
.alr-board .mpt-side{display:flex;flex-direction:column;gap:max(8px, 0.5683rem);}
.alr-board .mpt-side[hidden]{display:none!important;}
.alr-board .alr-sh{line-height:1.3;word-break:break-word;}
.alr-board .alr-ss{margin:0 0 4px;color:var(--text-secondary);}
.alr-board .alr-sh + .alr-ss{margin-top:-4px;}
.alr-grp{
  margin:0;padding:2px max(10px, 0.71rem);border-radius:var(--radius-lg);
  background:var(--bg-tertiary);
}
.alr-gh{margin:0;padding:6px 0 2px;font-size:inherit;font-weight:400;color:var(--text-muted);}
.alr-it,.alr-kv{
  display:flex;align-items:center;gap:8px;min-height:max(28px, 1.989rem);box-sizing:border-box;
  box-shadow:inset 0 -1px 0 var(--border-subtle);
}
.alr-it:last-child,.alr-kv:last-child{box-shadow:none;}
.alr-il{flex:1 1 auto;min-width:0;color:var(--text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.alr-ir{flex:none;margin-left:auto;padding-left:8px;color:var(--text-muted);white-space:nowrap;}
.alr-k{flex:none;width:max(100px, 7.1rem);color:var(--text-muted);}
.alr-v{flex:1 1 auto;min-width:0;color:var(--text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.alr-acts{display:flex;align-items:center;gap:4px;flex-wrap:nowrap;padding-top:2px;min-width:0;}
.alr-acts .mpt-btn{flex:none;padding:0 7px;}
.alr-acts .alr-del.alr-armed{background:color-mix(in srgb, var(--red) 16%, transparent);box-shadow:none;color:var(--red);}
.alr-err{margin:0;color:var(--red);}
/* Screen universe (2026-10-10): the side panel's Screen group wraps its
   filters instead of cutting them; a note says when the list is stale. */
.alr-kv.alr-wrap{align-items:flex-start;padding-top:6px;padding-bottom:6px;}
.alr-kv.alr-wrap .alr-v{white-space:normal;overflow:visible;overflow-wrap:anywhere;}
.alr-note{margin:4px 0 2px;color:var(--text-muted);}

/* ── Pane (ALRT): the shared pane mode; pills a size down ────────────── */
.alr-pane .alr-pill{height:16px;padding:0 6px;gap:5px;}
.alr-pane .alr-dot{width:5px;height:5px;}

/* ── The builder dialog ──────────────────────────────────────────────── */
.alr-scrim{
  position:fixed;inset:0;z-index:9400;display:flex;align-items:center;justify-content:center;
  padding:16px;box-sizing:border-box;background:var(--scrim-sheet);
}
.mpt.alr-dlg{
  position:relative;flex:none;width:min(760px, 100%);max-height:calc(100vh - 32px);
  display:flex;flex-direction:column;overflow:visible;
  background:var(--bg-secondary);border-radius:var(--radius-lg);
  box-shadow:inset 0 0 0 1px var(--border-default), var(--shadow-modal);
  container-type:normal;
}
.alr-dh{
  flex:none;display:flex;align-items:center;height:max(40px, 2.84rem);padding:0 8px 0 max(14px, 0.994rem);
  box-shadow:inset 0 -1px 0 var(--border-default);
}
.alr-dt{margin:0;flex:1 1 auto;font-size:var(--mpt-title);font-weight:600;color:var(--text-primary);}
.alr-close,.alr-rm{
  flex:none;display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;
  border:0;border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer;
}
.alr-close:hover,.alr-rm:hover{background:var(--bg-hover);color:var(--text-primary);}
.alr-close:focus-visible,.alr-rm:focus-visible{outline:none;box-shadow:inset 0 0 0 1px var(--border-strong);}
.alr-db{
  flex:1 1 auto;min-height:0;display:flex;flex-direction:column;gap:6px;
  padding:max(12px, 0.8525rem) max(14px, 0.994rem) max(10px, 0.71rem);
}
.alr-r1,.alr-lv,.alr-cond,.alr-cf,.alr-rp,.alr-ch{display:flex;align-items:center;gap:6px;min-width:0;flex-wrap:wrap;}
.alr-r1{margin-bottom:6px;}
.alr-lh{margin-top:4px;color:var(--text-muted);}
.alr-conds{display:flex;flex-direction:column;gap:4px;}
.alr-cond{flex-wrap:nowrap;}
.alr-cn{flex:none;width:14px;text-align:right;color:var(--text-muted);}
.alr-cond .alr-rm{margin-left:auto;}
.alr-now{flex:none;color:var(--text-muted);white-space:nowrap;}
.alr-unit{flex:none;color:var(--text-muted);margin-left:-2px;}
.alr-cf{padding-left:20px;}
/* A condition group: one filled block (no stripe, no accent line), its
   All / Any control on top, its conditions inside. */
.alr-gbox{
  display:flex;flex-direction:column;gap:4px;padding:6px 6px 6px 0;
  border-radius:var(--radius-lg);background:var(--bg-tertiary);
}
.alr-ghd{display:flex;align-items:center;gap:6px;min-width:0;padding-left:4px;}
.alr-gk{flex:none;color:var(--text-muted);white-space:nowrap;}
.alr-ghd .mpt-btn{flex:none;padding:0 7px;}
.alr-cf .alr-ck0{margin-left:6px;}
/* Side panel: a group's items under one quiet heading. */
.alr-igb{padding:0 0 0 10px;}
.alr-igh{padding:6px 0 0;color:var(--text-muted);}
.alr-rp{margin-top:6px;gap:10px;}
.alr-ch{gap:10px;}
.alr-dlg .mpt-dd-v{max-width:16rem;}

/* Text inputs: the control's height and ring, an inset ring on focus. */
.alr-in{
  height:var(--mpt-ctl);padding:0 8px;box-sizing:border-box;min-width:0;
  border:0;border-radius:var(--radius);outline:none;background:var(--bg-primary);color:var(--text-primary);
  box-shadow:inset 0 0 0 1px var(--border-default);font:inherit;
}
.alr-in::placeholder{color:var(--text-muted);opacity:1;}
.alr-in:focus{box-shadow:inset 0 0 0 1px var(--border-strong);}
.alr-in.alr-bad{box-shadow:inset 0 0 0 1px var(--red);}
.alr-name{flex:1 1 220px;min-width:140px;}
.alr-num{width:max(84px, 5.97rem);font-variant-numeric:tabular-nums;}

/* Checkboxes: a drawn box (inset ring), filled when on; no native look. */
.alr-ck{position:relative;display:inline-flex;align-items:center;gap:6px;height:var(--mpt-ctl);color:var(--text-secondary);cursor:pointer;white-space:nowrap;user-select:none;}
.alr-ck:hover{color:var(--text-primary);}
.alr-ck input{position:absolute;opacity:0;width:1px;height:1px;margin:0;pointer-events:none;}
.alr-box{
  flex:none;display:inline-flex;align-items:center;justify-content:center;width:13px;height:13px;box-sizing:border-box;
  border-radius:var(--radius-sm);background:var(--bg-primary);box-shadow:inset 0 0 0 1px var(--border-strong);
}
.alr-box svg{width:9px;height:9px;fill:none;stroke:var(--on-accent);stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;opacity:0;}
.alr-ck input:checked + .alr-box{background:var(--accent);box-shadow:none;}
.alr-ck input:checked + .alr-box svg{opacity:1;}
.alr-ck input:focus-visible + .alr-box{box-shadow:inset 0 0 0 1px var(--text-primary);}

/* Footer: the cap, Cancel, Create. One grey line above it on errors. */
.alr-berr{margin:0;padding:0 max(14px, 0.994rem) 8px;color:var(--red);}
.alr-df{
  flex:none;display:flex;align-items:center;gap:8px;height:max(40px, 2.84rem);padding:0 max(14px, 0.994rem);
  box-shadow:inset 0 1px 0 var(--border-default);
}
.alr-cap{color:var(--text-muted);white-space:nowrap;}
.alr-df .alr-save{padding:0 12px;}

/* The window popover: two HH:MM fields over the presets. */
.mpt-pop.alr-pop-win{min-width:max(220px, 15.6rem);}
.alr-win{display:flex;align-items:center;gap:8px;padding:4px 4px 6px;}
.alr-wl{display:inline-flex;align-items:center;gap:6px;color:var(--text-muted);}
.alr-hhmm{width:58px;text-align:center;font-variant-numeric:tabular-nums;}
.alr-wz{color:var(--text-muted);}
.mpt-pop.alr-pop-sym{max-height:min(18rem, 60vh);}

@media (max-width:640px){
  .alr-cond{flex-wrap:wrap;}
  .alr-cf{padding-left:0;}
}

/* Delivery channels (2026-10-12, alerts.js channelPicker): a ready channel
   is the drawn checkbox; one that needs a step shows its name and one quiet
   action (Connect, Turn on, Set up). Shared by the builder and the chat
   card, so sizes fall back when --mpt-ctl is not set. */
.alr-chp{display:flex;align-items:center;flex-wrap:wrap;gap:4px 12px;min-width:0;}
.alr-chp .alr-ck{height:var(--mpt-ctl, 24px);}
.alr-chl{flex:none;color:var(--text-muted);margin-right:-2px;}
.alr-cx{display:inline-flex;align-items:center;gap:6px;height:var(--mpt-ctl, 24px);white-space:nowrap;color:var(--text-secondary);}
.alr-cx-want .alr-cxn{color:var(--text-primary);}
.alr-cxw{color:var(--text-muted);}
.alr-cxb{
  flex:none;display:inline-flex;align-items:center;height:20px;padding:0 7px;border:0;border-radius:var(--radius);
  background:var(--bg-tertiary);color:var(--text-primary);font:inherit;cursor:pointer;white-space:nowrap;
}
.alr-cxb:hover{background:var(--bg-hover);}
.alr-cxb:focus-visible{outline:none;box-shadow:inset 0 0 0 1px var(--border-strong);}
.alr-cxb:disabled{cursor:default;color:var(--text-muted);}
.alr-chi{flex:none;display:inline-flex;align-items:center;color:var(--text-muted);cursor:help;}
.alr-chi svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.1;stroke-linecap:round;}
.alr-chi svg circle:last-child{fill:currentColor;stroke:none;}
/* The read only parts of a rule the builder cannot show as controls: the
   stored words in place of the controls, no ring, nothing to click. */
.alr-ro{display:inline-flex;align-items:center;gap:6px;min-width:0;height:var(--mpt-ctl, 24px);padding:0 2px;
  color:var(--text-primary);}
.alr-rok{flex:none;color:var(--text-muted);}
.alr-rov{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.alr-lhi{display:flex;align-items:center;gap:6px;}
.alr-ros{padding:2px 0;}
.alr-rotag{color:var(--text-muted);}
.alr-cro{min-height:22px;color:var(--text-primary);}
.alr-croh .alr-rot{color:var(--text-muted);}
.alr-cros .alr-rot{padding-left:12px;}
.alr-rot{min-width:0;overflow-wrap:anywhere;}
.alr-df .alr-ck{margin-right:4px;}
