/*
 * Plant Monitor dashboard styles, on the Matrix tokens defined in matrix.css (--mx-*).
 * Component shapes follow Matrix: elevated cards on the page canvas (raised + elevation/1,
 * radius/container 20, padding 24), filled cards inside dense groups (sunken, no border),
 * dot-badge 8px for status, segmented control on a sunken track, pill badges.
 * Dark mode follows html.dark through the tokens.
 */

/* tokens for our pages and for the notes dialog (also used on the Unfold event list) */
.pm, .pm-dialog {
  --pm-surface: var(--mx-neutral-surface-raised);
  --pm-surface-2: var(--mx-neutral-surface-sunken);
  --pm-border: var(--mx-neutral-line-border);
  --pm-hairline: var(--mx-neutral-line-hairline);
  --pm-text: var(--mx-neutral-text-ink);
  --pm-secondary: var(--mx-neutral-text-secondary);
  --pm-muted: var(--mx-neutral-text-muted);
  --pm-ok: var(--mx-success-indicator);
  --pm-ok-bg: var(--mx-success-canvas);
  --pm-ok-text: var(--mx-success-text);
  --pm-warn: var(--mx-warning-indicator);
  --pm-warn-bg: var(--mx-warning-canvas);
  --pm-warn-text: var(--mx-warning-text);
  --pm-warn-border: var(--mx-warning-border);
  --pm-crit: var(--mx-danger-solid);
  --pm-crit-bg: var(--mx-danger-canvas);
  --pm-crit-text: var(--mx-danger-text);
  --pm-crit-border: var(--mx-danger-border);
  --pm-off: var(--mx-neutral-surface-indicator);
}
.pm {
  color: var(--pm-text);
  font-family: var(--mx-font-ui);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ------------------------------------------------------------ typography */
.pm-h1 { font-family: var(--mx-font-display); font-size: 28px; line-height: 36px; font-weight: 800; letter-spacing: 0; color: var(--pm-text); text-wrap: balance; }
.pm-h2 { font-size: 16px; line-height: 24px; font-weight: 700; display: flex; align-items: center; gap: 8px; color: var(--pm-text); }
.pm-h3 {
  font-size: 12px; line-height: 16px; font-weight: 700; color: var(--pm-secondary);
  display: flex; align-items: center; gap: 6px; margin-bottom: 12px;
}
.pm-h2 .material-symbols-outlined { font-size: 20px; color: var(--pm-secondary); }
.pm-h3 .material-symbols-outlined { font-size: 16px; }
.pm-eyebrow { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--pm-secondary); }
.pm-eyebrow::before { content: "»"; color: var(--mx-brand-solid); font-weight: 800; font-size: 16px; line-height: 1; }
.pm-muted { color: var(--pm-muted); }
.pm-secondary { color: var(--pm-secondary); }
.pm-small { font-size: 12px; line-height: 16px; }
.pm-nowrap { white-space: nowrap; }
.pm-grow { flex: 1 1 auto; min-width: 0; }
.pm-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-mt { margin-top: 0; }
.pm-link { color: var(--pm-text); font-weight: 500; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--mx-neutral-line-border-strong); }
.pm-link:hover { text-decoration-color: currentColor; }

/* ------------------------------------------------------------ layout */
.pm-pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pm-pagehead-title { display: flex; align-items: center; gap: 16px; min-width: 0; }
.pm-pagehead-title p { font-size: 14px; color: var(--pm-secondary); }
.pm-grid { display: grid; gap: 16px; }
.pm-grid-plants { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 24px; }
.pm-grid-tiles { grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 12px; }
.pm-grid-analog { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.pm-section { margin-top: 24px; }

/* card: Matrix "elevated" on the page canvas */
.pm-card {
  background: var(--pm-surface);
  border-radius: var(--mx-radius-container);
  padding: var(--mx-space-container);
  box-shadow: var(--mx-elevation-1);
}
.pm-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 16px;
}
.pm-card-head-wrap { flex-wrap: wrap; }
.pm-empty { padding: 32px; text-align: center; color: var(--pm-secondary); }

/* ------------------------------------------------------------ status */
/* dot-badge: size/dot/md 8px */
.pm-dot { width: 8px; height: 8px; border-radius: var(--mx-radius-pill); display: inline-block; background: currentColor; flex: none; }
.pm-dot-ok { color: var(--pm-ok); }
.pm-dot-warning { color: var(--pm-warn); }
.pm-dot-critical { color: var(--pm-crit); }
.pm-dot-info { color: var(--mx-info-solid); }
.pm-dot-offline { color: var(--pm-off); }
.pm-pulse { animation: pm-pulse 2s infinite; }
@keyframes pm-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pm-ok) 55%, transparent); }
  70% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--pm-ok) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .pm-pulse, .pm-tile-critical .pm-led { animation: none; } }

/* badge (pill): status canvas + status text, label/sm */
.pm-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--mx-radius-pill);
  font-size: 12px; line-height: 16px; font-weight: 500; white-space: nowrap;
}
.pm-pill-ok { background: var(--pm-ok-bg); color: var(--pm-ok-text); }
.pm-pill-warning { background: var(--pm-warn-bg); color: var(--pm-warn-text); }
.pm-pill-critical { background: var(--pm-crit-bg); color: var(--pm-crit-text); }
.pm-pill-offline { background: var(--pm-surface-2); color: var(--pm-secondary); }

.pm-badge { display: inline-block; padding: 0 6px; border-radius: var(--mx-radius-pill); font-size: 12px; line-height: 16px; font-weight: 500; }
.pm-badge-critical { background: var(--pm-crit-bg); color: var(--pm-crit-text); }
.pm-badge-warning { background: var(--pm-warn-bg); color: var(--pm-warn-text); }
.pm-badge-info { background: var(--mx-info-canvas); color: var(--mx-info-text); }

/* ------------------------------------------------------------ plant cards (overview) */
.pm-plantcard { display: flex; flex-direction: column; gap: 20px; transition: box-shadow .15s, transform .15s; position: relative; }
.pm-plantcard:hover { box-shadow: var(--mx-elevation-2); transform: translateY(-1px); }
.pm-plantcard-head { display: flex; align-items: center; gap: 12px; }
.pm-plant-name { font-weight: 700; font-size: 16px; line-height: 24px; color: var(--pm-text); }
.pm-plant-icon {
  width: 40px; height: 40px; border-radius: var(--mx-radius-control); display: grid; place-items: center; flex: none;
  background: var(--pm-surface-2); color: var(--pm-text);
}
.pm-plant-icon .material-symbols-outlined { font-size: 20px; }
.pm-plant-icon-lg { width: 56px; height: 56px; border-radius: 16px; }
.pm-plant-icon-lg .material-symbols-outlined { font-size: 28px; }
/* KPI items: Matrix "filled" card inside a dense group */
.pm-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.pm-kpi { background: var(--pm-surface-2); border-radius: var(--mx-radius-control); padding: 12px 16px; }
.pm-kpi-label { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--pm-secondary); min-height: 32px; }
.pm-kpi-value { font-family: var(--mx-font-display); font-size: 20px; line-height: 28px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 4px; color: var(--pm-text); }
.pm-unit { font-family: var(--mx-font-ui); font-size: 12px; font-weight: 400; color: var(--pm-secondary); margin-left: 4px; }
.pm-plantcard-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--pm-secondary); border-top: 1px solid var(--pm-hairline); padding-top: 16px; }

/* ------------------------------------------------------------ plant page */
.pm-statusbar {
  display: flex; align-items: center; gap: 32px; flex-wrap: wrap;
  background: var(--pm-surface); border-radius: var(--mx-radius-container); box-shadow: var(--mx-elevation-1);
  padding: 16px var(--mx-space-container);
}
.pm-statusbar-item { display: flex; flex-direction: column; gap: 2px; font-size: 12px; line-height: 16px; }
.pm-statusbar-item .pm-muted { color: var(--pm-secondary); font-weight: 500; }
.pm-statusbar-item strong { font-family: var(--mx-font-display); font-size: 20px; line-height: 28px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--pm-text); }

/* alert (Matrix "Alert"): status canvas, status border, icon in status color */
.pm-alarms { display: grid; gap: 8px; margin-top: 16px; }
.pm-alarm {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--mx-radius-control);
  border: 1px solid transparent; color: var(--pm-text);
}
.pm-alarm .material-symbols-outlined { font-size: 20px; }
.pm-alarm-critical { background: var(--pm-crit-bg); border-color: var(--pm-crit-border); }
.pm-alarm-critical .material-symbols-outlined, .pm-alarm-critical strong { color: var(--pm-crit-text); }
.pm-alarm-warning { background: var(--pm-warn-bg); border-color: var(--pm-warn-border); }
.pm-alarm-warning .material-symbols-outlined, .pm-alarm-warning strong { color: var(--pm-warn-text); }
.pm-alarm-info { background: var(--mx-info-canvas); }
.pm-alarm-info .material-symbols-outlined, .pm-alarm-info strong { color: var(--mx-info-text); }
.pm-alarm .pm-small { color: var(--pm-secondary); }

/* tiles: elevated items in a dense grid */
.pm-tile {
  background: var(--pm-surface); border-radius: var(--mx-radius-control); box-shadow: var(--mx-elevation-1);
  padding: 16px; border: 1px solid transparent; transition: border-color .2s, background-color .2s;
}
.pm-tile-label { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--pm-secondary); }
.pm-tile-value { font-family: var(--mx-font-display); font-size: 24px; line-height: 32px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 4px; color: var(--pm-text); }
.pm-tile-state { font-weight: 700; font-size: 14px; line-height: 20px; margin-top: 2px; color: var(--pm-text); }
.pm-tile-bool { display: flex; align-items: center; gap: 12px; }
.pm-led { width: 8px; height: 8px; border-radius: var(--mx-radius-pill); background: var(--pm-off); flex: none; }
.pm-tile-on .pm-led { background: var(--pm-ok); box-shadow: 0 0 0 4px var(--pm-ok-bg); }
.pm-tile-off .pm-led { background: var(--pm-off); }
.pm-tile-off .pm-tile-state { color: var(--pm-secondary); }
.pm-tile-warning { background: var(--pm-warn-bg); border-color: var(--pm-warn-border); box-shadow: none; }
.pm-tile-warning .pm-led { background: var(--pm-warn); box-shadow: 0 0 0 4px color-mix(in srgb, var(--pm-warn) 25%, transparent); }
.pm-tile-warning .pm-tile-state, .pm-tile-warning .pm-tile-value { color: var(--pm-warn-text); }
.pm-tile-critical { background: var(--pm-crit-bg); border-color: var(--pm-crit-border); box-shadow: none; }
.pm-tile-critical .pm-led { background: var(--pm-crit); box-shadow: 0 0 0 4px color-mix(in srgb, var(--pm-crit) 25%, transparent); animation: pm-blink 1.2s infinite; }
.pm-tile-critical .pm-tile-state, .pm-tile-critical .pm-tile-value { color: var(--pm-crit-text); }
/* Matrix "muted" state: the value is missing or stale */
.pm-tile-unknown { background: var(--pm-surface-2); box-shadow: none; }
.pm-tile-unknown .pm-tile-value, .pm-tile-unknown .pm-tile-state { color: var(--pm-muted); }
@keyframes pm-blink { 50% { opacity: 0.35; } }

/* tiles are buttons: clicking opens the variable in the chart */
button.pm-tile { display: block; width: 100%; text-align: left; font: inherit; cursor: pointer; }
button.pm-tile.pm-tile-bool { display: flex; }
.pm-tile > span, .pm-tile .pm-grow > span { display: block; }
button.pm-tile:hover { box-shadow: var(--mx-elevation-2); }
button.pm-tile:focus-visible { outline: 2px solid var(--mx-system-focus-ring); outline-offset: 2px; }
.pm-tile-top { display: flex !important; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pm-tile-go { font-size: 18px; color: var(--pm-muted); opacity: 0; transition: opacity .15s; }
button.pm-tile:hover .pm-tile-go, button.pm-tile:focus-visible .pm-tile-go { opacity: 1; }
.pm-tile-foot { font-size: 12px; line-height: 16px; color: var(--pm-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.pm-tile-int .pm-tile-state { font-family: var(--mx-font-display); font-weight: 800; }

/* sparkline: last hour, Matrix info blue */
.pm-spark { display: block; width: 100%; height: 32px; margin-top: 8px; overflow: visible; }
.pm-spark-line { fill: none; stroke: var(--mx-info-solid); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.pm-spark-area { fill: var(--mx-info-solid); opacity: 0.10; }
.pm-spark.is-flat .pm-spark-line { stroke: var(--pm-muted); }
.pm-spark.is-flat .pm-spark-area { opacity: 0; }
.pm-tile-critical .pm-spark-line { stroke: var(--pm-crit); }
.pm-tile-critical .pm-spark-area { fill: var(--pm-crit); }

/* folded healthy groups: same heading as the other sections, with a summary pill and a show/hide toggle */
.pm-fold-summary { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; margin-bottom: 0; border-radius: var(--mx-radius-item); }
.pm-fold-summary::-webkit-details-marker { display: none; }
.pm-fold[open] > .pm-fold-summary { margin-bottom: 12px; }
.pm-fold-summary .pm-h3 { margin: 0; }
.pm-fold-status { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--mx-radius-pill); background: var(--pm-ok-bg); color: var(--pm-ok-text); font-size: 12px; line-height: 16px; font-weight: 500; }
.pm-fold-toggle { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; font-size: 12px; font-weight: 500; color: var(--pm-secondary); padding: 2px 4px 2px 8px; border-radius: var(--mx-radius-item); }
.pm-fold-summary:hover .pm-fold-toggle { color: var(--pm-text); background: var(--mx-system-state-hover); }
.pm-fold-summary:focus-visible { outline: 2px solid var(--mx-system-focus-ring); outline-offset: 2px; }
.pm-fold-toggle .material-symbols-outlined { font-size: 18px; transition: transform .15s; }
.pm-fold[open] .pm-fold-toggle .material-symbols-outlined { transform: rotate(180deg); }
.pm-fold .pm-when-open { display: none; }
.pm-fold[open] .pm-when-open { display: inline; }
.pm-fold[open] .pm-when-closed { display: none; }
.pm-h3 .pm-badge { margin-left: 4px; }

/* ------------------------------------------------------------ chart */
/* segmented control: sunken track, padding/track 2px, selected item raised */
.pm-segmented { display: inline-flex; background: var(--mx-neutral-surface-control); border-radius: var(--mx-radius-control); padding: 2px; flex-wrap: wrap; gap: 2px; }
.pm-segmented button { padding: 6px 12px; font-size: 12px; line-height: 16px; font-weight: 500; border-radius: 10px; color: var(--pm-secondary); }
.pm-segmented button:hover { color: var(--pm-text); background: var(--mx-system-state-hover); }
.pm-segmented button.is-active { background: var(--pm-surface); color: var(--pm-text); font-weight: 700; box-shadow: var(--mx-elevation-1); }
/* variables: every group in one flowing row, the group name as a small caption before its chips */
.pm-chart-toolbar { display: flex; align-items: flex-start; gap: 8px 24px; margin-bottom: 4px; }
.pm-chips { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.pm-chipgroup { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pm-chipgroup-label { font-size: 10px; line-height: 14px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--pm-muted); margin-right: 2px; }
/* select chip: outlined at rest, ink solid when selected */
.pm-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; line-height: 16px; font-weight: 500; padding: 6px 12px; border-radius: var(--mx-radius-pill);
  border: 1px solid var(--pm-border); color: var(--pm-secondary); background: transparent; transition: background-color .15s, color .15s, border-color .15s;
}
.pm-chip:hover { background: var(--mx-system-state-hover); color: var(--pm-text); }
.pm-chip.is-active { background: var(--mx-neutral-surface-solid); border-color: var(--mx-neutral-surface-solid); color: var(--mx-neutral-text-on-ink); }
.pm-chip-dot { width: 12px; height: 3px; border-radius: 2px; flex: none; opacity: 0.5; }
.pm-chip-dot.is-bool { width: 8px; height: 8px; border-radius: var(--mx-radius-pill); }
.pm-chip.is-active .pm-chip-dot { opacity: 1; }
.pm-chart { width: 100%; height: 420px; }

/* chart toolbar */
.pm-chart-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pm-segmented button { display: inline-flex; align-items: center; gap: 4px; }
.pm-segmented button .material-symbols-outlined { font-size: 16px; }
.pm-custom {
  display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 16px;
  padding: 12px 16px; background: var(--pm-surface-2); border-radius: var(--mx-radius-control);
}
.pm-custom[hidden] { display: none; }
.pm-custom label { font-size: 12px; font-weight: 500; color: var(--pm-secondary); }
.pm-custom input {
  height: 40px; padding: 0 12px; border-radius: var(--mx-radius-item); border: 1px solid var(--mx-neutral-line-border-strong);
  background: var(--pm-surface); color: var(--pm-text); font: inherit; font-size: 14px; color-scheme: light;
}
html.dark .pm-custom input { color-scheme: dark; }
.pm-chart-bar { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 8px; min-height: 32px; }
.pm-chart-hint { flex: 1 1 auto; }
.pm-focus-note { display: inline-flex; align-items: center; gap: 12px; padding: 6px 12px; border-radius: var(--mx-radius-pill); background: var(--mx-info-canvas); color: var(--mx-info-text); font-size: 12px; }
.pm-focus-note[hidden] { display: none; }
.pm-focus-note strong { font-weight: 700; }
.pm-focus-note .pm-link { font-size: 12px; color: inherit; text-decoration-color: currentColor; background: none; border: 0; padding: 0; cursor: pointer; }
.pm-focus-note:not([hidden]) + .pm-chart-hint { display: none; }
.pm-chart-actions { display: flex; flex: none; gap: 8px; margin-left: auto; }
.pm-btn-sm { min-height: 32px; padding: 0 12px; font-size: 12px; border-radius: 10px; }
.pm-btn-sm .material-symbols-outlined { font-size: 18px; }
.pm-btn[hidden] { display: none; }
.pm-btn.pm-btn-solid { background: var(--mx-neutral-surface-solid); color: var(--mx-neutral-text-on-ink); }
.pm-btn-solid:hover { opacity: 0.88; }
.pm-chip-remove { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-left: -4px; border-radius: var(--mx-radius-pill); color: var(--pm-muted); }
.pm-chip-remove:hover { background: var(--mx-system-state-hover); color: var(--pm-text); }
.pm-chip-remove .material-symbols-outlined { font-size: 16px; }

/* period statistics under the chart */
.pm-stats { margin-top: 24px; }
.pm-stats:empty { display: none; }
.pm-stats-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); overflow-x: auto; }
.pm-stats-table td:first-child { min-width: 220px; }
.pm-stats-table { background: var(--pm-surface-2); border-radius: var(--mx-radius-control); overflow: hidden; }
.pm-stats-table th, .pm-stats-table td { padding: 8px 16px; font-variant-numeric: tabular-nums; }
.pm-stats-table th:not(:first-child), .pm-stats-table td:not(:first-child) { text-align: right; white-space: nowrap; }
.pm-stats-table tbody tr:hover td { background: transparent; }
.pm-stats-swatch { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 8px; vertical-align: middle; }
.pm-stats-swatch.is-bool { width: 8px; height: 8px; border-radius: var(--mx-radius-pill); }
.pm-meter { display: inline-block; width: 64px; height: 4px; border-radius: var(--mx-radius-pill); background: var(--mx-neutral-surface-muted); margin-right: 8px; vertical-align: middle; overflow: hidden; }
.pm-meter > span { display: block; height: 100%; border-radius: inherit; }
.pm-chart-note { text-align: right; margin-top: 4px; color: var(--pm-muted); }

/* secondary button: outlined, size md 40px, radius/control */
.pm-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--mx-radius-control); font-size: 14px; font-weight: 500; color: var(--pm-text); }
.pm-btn .material-symbols-outlined { font-size: 20px; }
.pm-btn-ghost { border: 1px solid var(--mx-neutral-line-border-strong); background: var(--pm-surface); }
.pm-btn-ghost:hover { background: var(--mx-system-state-hover); }

/* ------------------------------------------------------------ table */
.pm-table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--mx-space-container)) calc(-1 * var(--mx-space-container)); }
.pm-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
.pm-table th { text-align: left; font-weight: 500; font-size: 12px; line-height: 16px; color: var(--pm-secondary); padding: 12px var(--mx-space-container); border-bottom: 1px solid var(--pm-border); }
.pm-table td { padding: 12px var(--mx-space-container); border-bottom: 1px solid var(--pm-hairline); color: var(--pm-text); }
.pm-table td.pm-muted { color: var(--pm-secondary); }
.pm-table tr:last-child td { border-bottom: 0; }
.pm-table tbody tr:hover td { background: var(--mx-system-state-hover); }
.pm-row-active td { background: var(--pm-crit-bg); }

@media (max-width: 640px) {
  .pm { gap: 16px; }
  .pm-stats-grid { grid-template-columns: 1fr; }
  .pm-chart-hint { display: none; }
  .pm-chart-actions { margin-left: 0; }
  .pm-h1 { font-size: 22px; line-height: 28px; }
  .pm-grid-plants { grid-template-columns: 1fr; }
  .pm-grid-tiles, .pm-grid-analog { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .pm-tile { padding: 12px; }
  .pm-tile-value { font-size: 20px; line-height: 28px; }
  .pm-tile-bool { gap: 10px; }
  .pm-card { padding: 16px; border-radius: 16px; }
  .pm-table-wrap { margin: 0 -16px -16px; }
  .pm-table th, .pm-table td { padding-left: 16px; padding-right: 16px; }
  .pm-statusbar { gap: 16px 24px; padding: 12px 16px; border-radius: 16px; }
}

/* ------------------------------------------------------------ synoptic (process schema) */
.pm-syn-card { margin-top: 24px; }
.pm-syn-legend { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; font-size: 12px; color: var(--pm-secondary); }
.pm-syn-key { display: inline-flex; align-items: center; gap: 6px; }
.pm-syn-key i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; border: 2px solid; }
.pm-syn-key i.is-run { border-color: var(--pm-ok); background: var(--pm-ok-bg); }
.pm-syn-key i.is-stop { border-color: var(--mx-neutral-line-border-strong); background: var(--pm-surface); }
.pm-syn-key i.is-alarm { border-color: var(--pm-crit); background: var(--pm-crit-bg); }
.pm-syn-key i.is-flow { width: 20px; height: 4px; border: 0; border-radius: 2px; background: repeating-linear-gradient(90deg, var(--mx-info-solid) 0 4px, transparent 4px 8px); }
.pm-syn-scroll { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
.pm-syn { display: block; width: 100%; min-width: 760px; height: auto; font-family: var(--mx-font-ui); }

.pm-syn-duct path { fill: none; stroke: var(--mx-neutral-surface-control); stroke-width: 12; stroke-linecap: round; stroke-linejoin: round; }
.pm-syn-duct path.pm-syn-flow { stroke: var(--mx-info-solid); stroke-width: 4; stroke-dasharray: 3 12; opacity: 0; }
.pm-syn-duct.is-active path.pm-syn-flow { opacity: 1; animation: pm-flow 0.9s linear infinite; }
.pm-syn-duct.is-air.is-active path.pm-syn-flow { stroke: var(--pm-muted); }
@keyframes pm-flow { to { stroke-dashoffset: -15; } }
.pm-syn-exhaust path { stroke: var(--mx-neutral-line-border-strong); stroke-width: 3; fill: none; }
.pm-syn-exhaust.is-active path { stroke: var(--pm-secondary); }
.pm-syn-arrowhead { fill: var(--pm-secondary); }
.pm-syn-note { font-size: 11px; fill: var(--pm-muted); font-style: italic; }

.pm-syn-node { cursor: pointer; }
.pm-syn-node:focus { outline: none; }
.pm-syn-node:focus-visible .pm-syn-shape { stroke: var(--mx-system-focus-ring); stroke-width: 3; }
.pm-syn-shape { fill: var(--pm-surface); stroke: var(--mx-neutral-line-border-strong); stroke-width: 2; transition: fill .2s, stroke .2s; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.08)); }
.pm-syn-node:hover .pm-syn-shape { filter: drop-shadow(0 4px 10px rgba(0,0,0,0.14)); }
.pm-syn-name { font-size: 13px; font-weight: 700; fill: var(--pm-text); }
.pm-syn-status { font-size: 12px; font-weight: 500; fill: var(--pm-secondary); }
.pm-syn-value { font-family: var(--mx-font-display); font-size: 14px; font-weight: 800; fill: var(--pm-text); }
.pm-syn-value .pm-syn-status { font-family: var(--mx-font-ui); }
.pm-syn-pleat { stroke: var(--mx-neutral-line-border); stroke-width: 2; fill: none; }
.pm-syn-led { fill: var(--pm-off); }
.pm-syn-blades { fill: var(--pm-muted); transform-box: fill-box; transform-origin: center; }

.pm-syn-node.state-run .pm-syn-shape { stroke: var(--pm-ok); fill: var(--pm-ok-bg); }
.pm-syn-node.state-run .pm-syn-status { fill: var(--pm-ok-text); }
.pm-syn-node.state-run .pm-syn-led { fill: var(--pm-ok); }
.pm-syn-node.state-run .pm-syn-blades { fill: var(--pm-ok); animation: pm-spin 1.2s linear infinite; }
.pm-syn-node.state-info .pm-syn-shape { stroke: var(--mx-info-solid); fill: var(--mx-info-canvas); }
.pm-syn-node.state-info .pm-syn-status { fill: var(--mx-info-text); }
.pm-syn-node.state-alarm .pm-syn-shape { stroke: var(--pm-crit); fill: var(--pm-crit-bg); }
.pm-syn-node.state-alarm .pm-syn-status { fill: var(--pm-crit-text); font-weight: 700; }
.pm-syn-node.state-alarm .pm-syn-led, .pm-syn-node.state-alarm .pm-syn-blades { fill: var(--pm-crit); }
.pm-syn-node.state-unknown .pm-syn-shape { stroke-dasharray: 5 4; }
.pm-syn-node.state-unknown text { fill: var(--pm-muted); }
@keyframes pm-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .pm-syn-node.state-run .pm-syn-blades, .pm-syn-duct.is-active path.pm-syn-flow { animation: none; }
}

/* ------------------------------------------------------------ compact plant page layout */
.pm { gap: 20px; }
.pm-pagehead .pm-h1 { font-size: 24px; line-height: 32px; }
.pm-pagehead .pm-plant-icon-lg { width: 48px; height: 48px; }
.pm-live-top { display: flex; flex-direction: column; gap: 16px; }
.pm-live-top .pm-alarms { margin-top: 0; }
.pm-statusbar { padding: 12px var(--mx-space-container); gap: 32px; }
.pm-statusbar-item strong { font-size: 18px; line-height: 24px; }
.pm-syn-card { margin-top: 0; padding-top: 16px; padding-bottom: 12px; }
.pm-syn-card .pm-card-head { margin-bottom: 4px; }
.pm-syn-card > p { margin-top: 4px; }
.pm-signals { display: flex; flex-direction: column; gap: 20px; }
.pm-signals .pm-h3 { margin-bottom: 10px; }
.pm-grid-analog { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.pm-tile-analog { padding: 14px 16px; }
.pm-tile-analog .pm-tile-value { font-size: 22px; line-height: 28px; }
.pm-tile-analog .pm-spark { height: 28px; margin-top: 6px; }

/* signal panels: dense lists side by side */
.pm-sig-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.pm-sig-card { padding: 16px 16px 12px; }
.pm-sig-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; padding: 0 8px; }
.pm-sig-head .pm-h3 { margin: 0; color: var(--pm-text); font-size: 13px; }
.pm-sig-sub { font-size: 11px; line-height: 16px; font-weight: 700; color: var(--pm-muted); padding: 10px 8px 2px; }
.pm-sig-list { list-style: none; margin: 0; padding: 0; }
.pm-sig-list li + li { border-top: 1px solid var(--pm-hairline); }
.pm-sig {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: var(--mx-radius-item);
  font: inherit; font-size: 13px; line-height: 18px; text-align: left; color: var(--pm-text); background: transparent;
}
button.pm-sig { cursor: pointer; }
button.pm-sig:hover { background: var(--mx-system-state-hover); }
button.pm-sig:focus-visible { outline: 2px solid var(--mx-system-focus-ring); outline-offset: 1px; }
.pm-sig-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-sig-val { flex: none; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pm-sig-on .pm-led { background: var(--pm-ok); box-shadow: 0 0 0 3px var(--pm-ok-bg); }
.pm-sig-off .pm-sig-val { color: var(--pm-secondary); font-weight: 500; }
.pm-sig-critical { background: var(--pm-crit-bg); }
.pm-sig-critical .pm-led { background: var(--pm-crit); animation: pm-blink 1.2s infinite; }
.pm-sig-critical .pm-sig-val { color: var(--pm-crit-text); }
.pm-sig-warning { background: var(--pm-warn-bg); }
.pm-sig-warning .pm-led { background: var(--pm-warn); }
.pm-sig-warning .pm-sig-val { color: var(--pm-warn-text); }
.pm-sig-unknown { color: var(--pm-muted); }
.pm-sig-ok .pm-sig-val { font-family: var(--mx-font-display); font-weight: 800; }
@media (prefers-reduced-motion: reduce) { .pm-sig-critical .pm-led { animation: none; } }
@media (max-width: 640px) {
  .pm-sig-grid { grid-template-columns: 1fr; }
  .pm-statusbar { gap: 12px 20px; }
}
/* keep the synoptic within one screen on wide monitors */
.pm-syn { max-height: 440px; }
.pm-stats { margin-top: 16px; }
.pm-stats .pm-h3 { margin-bottom: 8px; }
.pm-stats-table th, .pm-stats-table td { padding: 6px 16px; }

/* synoptic: converting machine outline (context only, not monitored), damper, spark sensor */
.pm-syn-machine rect { fill: var(--pm-surface-2); stroke: var(--mx-neutral-line-border); stroke-width: 1.5; }
.pm-syn-machine text { font-size: 12px; font-weight: 700; fill: var(--pm-secondary); }
.pm-syn-machine text.pm-syn-note { font-weight: 400; fill: var(--pm-muted); }
.pm-syn-reel { fill: none; stroke: var(--mx-neutral-line-border-strong); stroke-width: 2; }
.pm-syn-web { fill: none; stroke: var(--mx-neutral-line-border-strong); stroke-width: 2; }
.pm-syn-ground { fill: none; stroke: var(--mx-neutral-line-border-strong); stroke-width: 2; stroke-dasharray: 2 6; }
.pm-syn-duct.is-idle path { stroke-dasharray: none; opacity: 0.7; }
.pm-syn-blade { stroke: var(--pm-text); stroke-width: 4; stroke-linecap: round; }
.pm-syn-bolt { fill: var(--pm-muted); }
.pm-syn-node.state-alarm .pm-syn-blade { stroke: var(--pm-crit); }
.pm-syn-node.state-alarm .pm-syn-bolt { fill: var(--pm-crit); }
.pm-syn-node:not([data-pm-focus]) { cursor: default; }
.pm-syn-key i.is-unknown { border-color: var(--mx-neutral-line-border-strong); border-style: dashed; background: var(--pm-surface); }
.pm-syn-port { fill: var(--pm-surface); stroke: var(--mx-neutral-line-border-strong); stroke-width: 2; }
.pm-syn-hose { fill: none; stroke: var(--mx-neutral-line-border-strong); stroke-width: 5; stroke-linecap: round; }

/* overview: the plant schematics side by side on wide screens, stacked otherwise; each opens its plant page */
.pm-syn-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 860px), 1fr)); margin-top: 16px; }
.pm-syn-grid .pm-syn-card { margin: 0; }
.pm-syn-title { display: inline-flex; align-items: center; gap: 8px; color: var(--pm-text); text-decoration: none; }
.pm-syn-title:hover { color: var(--mx-info-text); }
.pm-syn-title .pm-pill { margin-left: 4px; }
.pm-syn-link { display: block; color: inherit; text-decoration: none; border-radius: var(--mx-radius-control); }
.pm-syn-link:hover .pm-syn-shape { filter: drop-shadow(0 3px 8px rgba(0,0,0,0.12)); }
.pm-syn-link:focus-visible { outline: 2px solid var(--mx-system-focus-ring); outline-offset: 4px; }
.pm-syn-link .pm-syn-node, .pm-syn-link .pm-synm-node { cursor: pointer; }

/* ------------------------------------------------------------ synoptic time travel (history.js) */
.pm-syn-card.is-history { box-shadow: 0 0 0 2px var(--mx-info-solid), var(--mx-elevation-1); }
.pm-pill-history { background: var(--mx-info-canvas); color: var(--mx-info-text); font-weight: 700; }
.pm-pill-history .material-symbols-outlined { font-size: 16px; }
.pm-syn-time { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; padding: 4px 8px 6px; border-radius: var(--mx-radius-control); background: var(--pm-surface-2); }
/* --pm-track-l / --pm-track-r: set by history.js so the track runs exactly under the chart time axis */
.pm-syn-track { position: relative; height: 28px; display: flex; align-items: center; padding: 0 var(--pm-track-r, 0px) 0 var(--pm-track-l, 0px); }
.pm-syn-track input[type=range] { position: relative; z-index: 1; width: 100%; margin: 0; accent-color: var(--mx-info-solid); background: transparent; cursor: pointer; }
.pm-syn-ticks { position: absolute; top: 0; bottom: 0; left: calc(var(--pm-track-l, 0px) + 9px); right: calc(var(--pm-track-r, 0px) + 9px); pointer-events: none; }
.pm-syn-ticks i { position: absolute; top: 3px; min-width: 3px; height: 6px; border-radius: 3px; background: var(--pm-warn); }
.pm-syn-ticks i.is-critical { background: var(--pm-crit); }
.pm-syn-controls { display: flex; align-items: center; gap: 4px; min-height: 40px; }
.pm-syn-step { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--mx-radius-item); color: var(--pm-secondary); flex: none; }
.pm-syn-step:hover { background: var(--mx-system-state-hover); color: var(--pm-text); }
.pm-syn-step:focus-visible, .pm-syn-speed:focus-visible { outline: 2px solid var(--mx-system-focus-ring); }
.pm-syn-play { width: 36px; height: 36px; border-radius: 50%; background: var(--mx-info-solid); color: #fff; }
.pm-syn-play:hover { background: #2f80b3; color: #fff; }
.pm-syn-play .material-symbols-outlined { font-size: 22px; }
.pm-syn-speed { flex: none; height: 28px; padding: 0 10px; margin: 0 4px; border-radius: 14px; border: 1px solid var(--mx-neutral-line-border-strong); font-size: 12px; font-weight: 700; color: var(--pm-secondary); font-variant-numeric: tabular-nums; }
.pm-syn-speed:hover { color: var(--pm-text); background: var(--mx-system-state-hover); }
.pm-syn-when { flex: none; margin-left: 4px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--pm-text); }
.pm-syn-when.is-flash { font-weight: 500; color: var(--pm-secondary); }
.pm-syn-card:not(.is-history) .pm-syn-when { color: var(--pm-ok-text); }
.pm-syn-golive { flex: none; margin-left: auto; }

/* marker of the instant pinned on the synoptic */
.pm-chart-pin { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid var(--mx-info-solid); pointer-events: none; z-index: 2; }
.pm-chart-pin::before { content: ""; position: absolute; top: 2px; left: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--mx-info-solid); }

/* floating copy of the synoptic while the chart is browsed below it */
/* top right, clicks pass through to the chart below (the events lane at the bottom stays clickable) */
.pm-syn-float {
  position: fixed; right: 24px; top: 80px; z-index: 40; width: min(440px, 40vw); padding: 8px 10px 10px; pointer-events: none;
  border-radius: var(--mx-radius-container, 12px); background: var(--pm-surface); cursor: pointer;
  box-shadow: 0 0 0 2px var(--mx-info-solid), 0 12px 32px rgba(0,0,0,0.22);
}
.pm-syn-float-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--mx-info-text); margin-bottom: 4px; }
.pm-syn-float-head .material-symbols-outlined { font-size: 16px; }
.pm-syn-float-when { flex: 1; }
.pm-syn-float-live { pointer-events: auto; display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; border-radius: 50%; color: var(--pm-secondary); }
.pm-syn-float-live:hover { background: var(--mx-system-state-hover); }
.pm-syn-float .pm-syn { min-width: 0; max-height: none; pointer-events: none; }
@media (max-width: 640px) {
  .pm-syn-controls { flex-wrap: wrap; }
  .pm-syn-step { width: 40px; height: 40px; }
  .pm-syn-play { width: 44px; height: 44px; }
  .pm-syn-golive { flex-basis: 100%; justify-content: center; min-height: 40px; }
}
/* time bar: thin track, brand-blue thumb */
.pm-syn-track input[type=range] { -webkit-appearance: none; appearance: none; height: 24px; }
.pm-syn-track input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--mx-neutral-surface-control); }
.pm-syn-track input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--mx-neutral-surface-control); }
.pm-syn-track input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: var(--mx-info-solid); border: 3px solid var(--pm-surface); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.pm-syn-track input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--mx-info-solid); border: 3px solid var(--pm-surface); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.pm-syn-track input[type=range]:focus-visible { outline: 2px solid var(--mx-system-focus-ring); outline-offset: 2px; border-radius: 4px; }
.pm-syn-card:not(.is-history) .pm-syn-track input[type=range]::-webkit-slider-thumb { background: var(--pm-ok); }
.pm-syn-card:not(.is-history) .pm-syn-track input[type=range]::-moz-range-thumb { background: var(--pm-ok); }


/* overview: active alarms of all plants above the plant cards, each row opens its plant */
.pm-alarms-overview { margin: 0 0 16px; }
a.pm-alarm-link { color: inherit; text-decoration: none; }
a.pm-alarm-link:hover { filter: brightness(0.97); box-shadow: var(--mx-elevation-1); }
a.pm-alarm-link:focus-visible { outline: 2px solid var(--mx-system-focus-ring); outline-offset: 2px; }
.pm-alarm-go { margin-left: auto; color: var(--pm-secondary); }
/* overview card of an offline plant: the numbers are the last values received, not the current ones */
.pm-plantcard.pm-state-offline .pm-kpi-value { color: var(--pm-muted); }

/* log saw (troncatore): log on the conveyor, cut rolls, disc blade on an orbiting arm */
.pm-syn-log { fill: var(--pm-surface-2); stroke: var(--mx-neutral-line-border-strong); stroke-width: 1.5; }
.pm-syn-conveyor { fill: none; stroke: var(--mx-neutral-line-border-strong); stroke-width: 2; stroke-dasharray: 2 4; stroke-linecap: round; }
.pm-syn-orbit { fill: none; stroke: var(--mx-neutral-line-border); stroke-width: 1.5; stroke-dasharray: 3 3; }
.pm-syn-arm { fill: none; stroke: var(--pm-muted); stroke-width: 4; stroke-linecap: round; }
.pm-syn-sawblade { fill: var(--pm-muted); transform-box: fill-box; transform-origin: center; }
.pm-syn-sawhub { fill: var(--pm-surface); stroke: var(--pm-muted); stroke-width: 1.5; }
.pm-syn-orbiter { transform-box: view-box; }
.pm-syn-node.state-run .pm-syn-sawblade { fill: var(--pm-ok); animation: pm-spin 0.5s linear infinite; }
.pm-syn-node.state-run .pm-syn-arm { stroke: var(--pm-ok); }
.pm-syn-node.state-run .pm-syn-orbiter { animation: pm-spin 2.4s linear infinite; }
.pm-syn-node.state-alarm .pm-syn-sawblade { fill: var(--pm-crit); }
.pm-syn-node.state-alarm .pm-syn-arm { stroke: var(--pm-crit); }
.pm-syn-logsaw .pm-syn-log { filter: none; }
@media (prefers-reduced-motion: reduce) {
  .pm-syn-node.state-run .pm-syn-sawblade, .pm-syn-node.state-run .pm-syn-orbiter { animation: none; }
}

/* ------------------------------------------------------------ wide screens
 * Our pages run without Unfold's "container" cap (is_fullwidth). Up to 1900 px one column in the
 * agreed order (schema, chart, measures, alarms, connections, events); wider: two columns, the
 * schema/chart/events on the left and the measures + signal panels on the right. */
.pm { max-width: 2600px; margin-inline: auto; width: 100%; }
.pm-layout { display: flex; flex-direction: column; gap: 20px; }
.pm-main, .pm-side { display: contents; }
.pm-side > * { order: 2; }
#pm-events-card { order: 3; }
@media (min-width: 1900px) {
  .pm-layout { display: grid; grid-template-columns: minmax(0, 1fr) clamp(440px, 24vw, 600px); gap: 20px; align-items: start; }
  .pm-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
  .pm-side { display: block; min-width: 0; }
  .pm-side .pm-grid-analog { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .pm-side .pm-sig-grid { grid-template-columns: 1fr; }
  .pm-main .pm-syn { max-height: 520px; }
}
@media (min-width: 2400px) {
  .pm-main .pm-syn { max-height: 600px; }
}

/* ------------------------------------------------------------ notes on events */
.pm-note-btn {
  display: inline-flex; align-items: center; gap: 4px; flex: none; height: 32px; min-width: 32px; padding: 0 8px; justify-content: center;
  border-radius: 999px; color: var(--pm-muted); background: transparent; font-size: 12px; font-weight: 700; cursor: pointer;
  font-family: var(--mx-font-ui, inherit);
}
.pm-note-btn .material-symbols-outlined { font-size: 18px; }
.pm-note-btn:hover { background: var(--mx-system-state-hover); color: var(--pm-text, inherit); }
.pm-note-btn:focus-visible { outline: 2px solid var(--mx-system-focus-ring); outline-offset: 1px; }
.pm-note-btn.has-notes { color: var(--mx-info-text); background: var(--mx-info-canvas); }
.pm-note-btn.with-label { border: 1px solid var(--mx-neutral-line-border-strong); background: var(--pm-surface, transparent); color: var(--pm-secondary, inherit); padding: 0 12px; }
.pm-note-btn.with-label.has-notes { border-color: transparent; background: var(--mx-info-canvas); color: var(--mx-info-text); }
.pm-note-label { font-weight: 600; }
.pm-note-count:empty { display: none; }

/* alarm row: body (link on the overview), notes button, chevron */
.pm-alarm-body { color: inherit; text-decoration: none; min-width: 0; }
a.pm-alarm-go { display: inline-flex; color: var(--pm-secondary); text-decoration: none; }

/* dialog */
.pm-dialog {
  width: min(560px, calc(100vw - 32px)); max-height: min(80vh, 720px); padding: 24px; border: 0; border-radius: 20px;
  background: var(--pm-surface); color: var(--pm-text); font-family: var(--mx-font-ui); box-shadow: 0 24px 60px rgba(0,0,0,0.25);
}
.pm-dialog::backdrop { background: rgba(20,20,18,0.45); }
.pm-dialog-close { position: absolute; top: 12px; right: 12px; display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; border-radius: 50%; color: var(--pm-secondary); }
.pm-dialog-close:hover { background: var(--mx-system-state-hover); }
.pm-notes-loading { padding: 24px 0; color: var(--pm-muted); }
.pm-notes-head { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-right: 40px; margin-bottom: 16px; }
.pm-notes-title { font-size: 18px; line-height: 24px; font-weight: 800; margin: 0; }
.pm-notes-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.pm-note { padding: 12px 14px; border-radius: 12px; background: var(--pm-surface-2); }
.pm-note-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 12px; margin-bottom: 6px; }
.pm-note-avatar { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; border-radius: 50%; background: var(--ti-gradient, var(--mx-info-solid)); color: #fff; font-size: 11px; font-weight: 800; }
.pm-note-actions { margin-left: auto; display: inline-flex; gap: 12px; }
.pm-note-actions .pm-link { font-size: 12px; background: none; border: 0; padding: 0; cursor: pointer; }
.pm-link-danger { color: var(--pm-crit-text); text-decoration-color: currentColor; }
.pm-note-text { font-size: 14px; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
.pm-notes-empty { padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--mx-neutral-line-border-strong); color: var(--pm-secondary); font-size: 13px; }
.pm-notes-error { color: var(--pm-crit-text); font-size: 13px; margin: 0 0 8px; }
.pm-notes-form { display: flex; flex-direction: column; gap: 8px; }
.pm-notes-label { font-size: 12px; font-weight: 700; color: var(--pm-secondary); }
.pm-notes-form textarea {
  width: 100%; min-height: 84px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--mx-neutral-line-border-strong);
  background: var(--pm-surface); color: var(--pm-text); font: inherit; font-size: 14px; line-height: 1.5; resize: vertical;
}
.pm-notes-form textarea:focus { outline: 2px solid var(--mx-system-focus-ring); outline-offset: 0; border-color: transparent; }
.pm-notes-form-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px 12px; flex-wrap: wrap; }
.pm-notes-form-foot .pm-small { margin-right: auto; }
@media (max-width: 640px) {
  .pm-dialog { padding: 20px 16px; max-height: 88vh; }
  .pm-alarm .pm-note-label { display: none; }
}
.pm-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.pm-table .pm-cell-notes { width: 1%; text-align: right; padding-top: 4px; padding-bottom: 4px; }

/* time-bar ticks of events with notes */
.pm-syn-ticks i.has-notes::before { content: ""; position: absolute; left: -2px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--mx-info-solid); box-shadow: 0 0 0 2px var(--pm-surface-2); }
/* Unfold styles <dialog> as absolute + translate: when the page is scrolled down (e.g. at the chart) the
   notes dialog opened out of view. Keep it fixed and centred in the visible area. */
dialog.pm-dialog[open] { position: fixed; inset: 0; margin: auto; transform: none; translate: none; height: fit-content; }
.pm-syn-float { max-height: calc(100vh - 48px); overflow: auto; }

/* schema header: same height in live (colour key) and history (alarm + note button): no shift below */
.pm-syn-card > .pm-card-head { height: 52px; align-items: center; flex-wrap: nowrap; margin-bottom: 4px; }

/* history with an alarm open at that instant: red frame and the header as an alarm banner */
.pm-syn-card.is-history.has-alarm { box-shadow: 0 0 0 3px var(--pm-crit), var(--mx-elevation-1); }
.pm-syn-alert {
  flex: 1 1 auto; min-width: 0; height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 8px 0 14px;
  border-radius: var(--mx-radius-control); background: var(--pm-crit-bg); border: 1px solid var(--pm-crit-border); color: var(--pm-crit-text);
}
.pm-syn-alert-warning { background: var(--pm-warn-bg); border-color: var(--pm-warn-border); color: var(--pm-warn-text); }
.pm-syn-alert-info { background: var(--mx-info-canvas); border-color: transparent; color: var(--mx-info-text); }
.pm-syn-alert-icon { font-size: 26px; flex: none; animation: pm-blink 1.2s infinite; }
.pm-syn-alert-text { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 4px 14px; white-space: nowrap; overflow: hidden; }
.pm-syn-alert-text strong { font-size: 16px; font-weight: 800; flex: none; }
.pm-syn-alert-more { font-size: 12px; font-weight: 700; opacity: 0.8; }
.pm-syn-alert-when { font-size: 13px; font-weight: 600; flex: none; font-variant-numeric: tabular-nums; }
.pm-syn-alert-note { min-width: 0; display: inline-flex; align-items: baseline; gap: 4px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; color: var(--pm-text); }
.pm-syn-alert-note .material-symbols-outlined { font-size: 16px; align-self: center; color: var(--mx-info-text); }
.pm-syn-alert-note b { flex: none; }
.pm-syn-alert .pm-note-btn, .pm-syn-alert .pm-pill { flex: none; }
.pm-syn-alert .pm-note-btn.with-label { background: var(--pm-surface); }
@media (prefers-reduced-motion: reduce) { .pm-syn-alert-icon { animation: none; } }
@media (max-width: 900px) {
  .pm-syn-alert-note, .pm-syn-alert .pm-pill-history { display: none; }
}
@media (max-width: 640px) {
  .pm-syn-card > .pm-card-head { height: auto; flex-wrap: wrap; }
  .pm-syn-alert { height: auto; padding: 10px 12px; flex-wrap: wrap; }
  .pm-syn-alert-text { white-space: normal; flex-wrap: wrap; }
  .pm-syn-alert-note { display: inline-flex; flex-basis: 100%; white-space: normal; }
}
/* floating copy: the alarm under the small schema */
.pm-syn-float .pm-syn-alert { height: auto; margin-top: 6px; padding: 8px 10px; flex-wrap: wrap; }
.pm-syn-float .pm-syn-alert-text { white-space: normal; flex-wrap: wrap; }
.pm-syn-float .pm-syn-alert-note { display: inline-flex; white-space: normal; flex-basis: 100%; }
.pm-syn-float .pm-syn-alert .pm-pill { display: none; }
.pm-syn-float .pm-syn-alert-icon { animation: none; }

/* ------------------------------------------------------------ event page: notes history (timeline) */
.pm-event-notes { margin-top: 24px; gap: 0; }
.pm-event-notes-card {
  background: var(--pm-surface); border: 1px solid var(--pm-border); border-radius: 8px; padding: 20px 24px 24px;
}
.pm-event-notes-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 20px; }
.pm-event-notes .pm-notes-head { display: none; } /* the event fields are already shown above */
.pm-event-notes .pm-notes-list { position: relative; gap: 14px; margin: 0 0 20px; padding-left: 40px; }
.pm-event-notes .pm-notes-list::before { content: ""; position: absolute; left: 13px; top: 14px; bottom: 14px; width: 2px; border-radius: 1px; background: var(--pm-border); }
.pm-event-notes .pm-notes-list:has(.pm-notes-empty) { padding-left: 0; }
.pm-event-notes .pm-notes-list:has(.pm-notes-empty)::before { display: none; }
.pm-event-notes .pm-note { position: relative; padding: 12px 16px; border-radius: 10px; background: var(--pm-surface-2); }
.pm-event-notes .pm-note-avatar { position: absolute; left: -40px; top: 10px; width: 28px; height: 28px; font-size: 12px; box-shadow: 0 0 0 4px var(--pm-surface); }
.pm-event-notes .pm-note-meta { margin-bottom: 4px; }
.pm-event-notes .pm-note-meta strong { font-size: 13px; }
.pm-event-notes .pm-note-text { font-size: 14px; }
.pm-event-notes .pm-notes > .pm-notes-form { border-top: 1px solid var(--pm-hairline); padding-top: 16px; }
.pm-event-notes .pm-notes-form textarea { min-height: 96px; }
@media (max-width: 640px) {
  .pm-event-notes-card { padding: 16px; }
  .pm-event-notes .pm-notes-list { padding-left: 34px; }
  .pm-event-notes .pm-notes-list::before { left: 11px; }
  .pm-event-notes .pm-note-avatar { left: -34px; width: 24px; height: 24px; }
}
/* room under the notes card: Unfold's sticky action bar (Close / Delete) must not cover "Save note" */
.pm-event-notes { margin-bottom: 96px; }

/* ------------------------------------------------------------ alarm colours by severity (critical red / warning amber / info blue) */
.pm-syn-node.state-warning .pm-syn-shape { stroke: var(--pm-warn); fill: var(--pm-warn-bg); }
.pm-syn-node.state-warning .pm-syn-status { fill: var(--pm-warn-text); font-weight: 700; }
.pm-syn-node.state-warning .pm-syn-led, .pm-syn-node.state-warning .pm-syn-blades, .pm-syn-node.state-warning .pm-syn-sawblade, .pm-syn-node.state-warning .pm-syn-bolt { fill: var(--pm-warn); }
.pm-syn-node.state-warning .pm-syn-arm, .pm-syn-node.state-warning .pm-syn-blade { stroke: var(--pm-warn); }
.pm-syn-node.state-info .pm-syn-led, .pm-syn-node.state-info .pm-syn-blades, .pm-syn-node.state-info .pm-syn-sawblade, .pm-syn-node.state-info .pm-syn-bolt { fill: var(--mx-info-solid); }
.pm-syn-node.state-info .pm-syn-arm, .pm-syn-node.state-info .pm-syn-blade { stroke: var(--mx-info-solid); }
.pm-syn-node.state-info .pm-syn-status { font-weight: 700; }
.pm-syn-key i.is-warning { border-color: var(--pm-warn); background: var(--pm-warn-bg); }
.pm-syn-key i.is-info { border-color: var(--mx-info-solid); background: var(--mx-info-canvas); }
.pm-syn-ticks i.is-info { background: var(--mx-info-solid); }
.pm-tile-info { background: var(--mx-info-canvas); border-color: transparent; box-shadow: none; }
.pm-tile-info .pm-led { background: var(--mx-info-solid); box-shadow: 0 0 0 4px color-mix(in srgb, var(--mx-info-solid) 25%, transparent); }
.pm-tile-info .pm-tile-state, .pm-tile-info .pm-tile-value { color: var(--mx-info-text); }
.pm-sig-info { background: var(--mx-info-canvas); }
.pm-sig-info .pm-led { background: var(--mx-info-solid); }
.pm-sig-info .pm-sig-val { color: var(--mx-info-text); }

/* ------------------------------------------------------------ "Le mie preferenze" */
.pm-notif-form { display: flex; flex-direction: column; gap: 20px; }
.pm-notif-general { display: flex; flex-direction: column; gap: 16px; }
.pm-notif-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.pm-notif-row .pm-h2 { margin-bottom: 2px; }
.pm-notif-row + .pm-notif-row { padding-top: 16px; border-top: 1px solid var(--pm-hairline); }
.pm-notif-lang label { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; font-size: 13px; border-radius: 10px; color: var(--pm-secondary); cursor: pointer; }
.pm-notif-lang label.is-active { background: var(--pm-surface); color: var(--pm-text); font-weight: 700; box-shadow: var(--mx-elevation-1); }
.pm-notif-lang input { position: absolute; opacity: 0; pointer-events: none; }
.pm-notif-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); align-items: start; }
.pm-notif-card { transition: box-shadow .2s; }
.pm-notif-card.is-on { box-shadow: 0 0 0 2px var(--pm-ok), var(--mx-elevation-1); }
.pm-notif-head { display: flex; align-items: center; gap: 12px; }
.pm-notif-head .pm-h2 { margin: 0; }
.pm-notif-body { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--pm-hairline); }
.pm-notif-card:not(.is-on) .pm-notif-body { opacity: 0.45; }
.pm-notif-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; color: var(--pm-secondary); }
.pm-notif-field select {
  height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--mx-neutral-line-border-strong);
  background: var(--pm-surface); color: var(--pm-text); font: inherit; font-size: 14px; font-weight: 500;
}
.pm-notif-scope { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.pm-notif-scope legend { font-size: 12px; font-weight: 700; color: var(--pm-secondary); margin-bottom: 6px; padding: 0; }
.pm-notif-scope > label, .pm-notif-check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; cursor: pointer; }
.pm-notif-scope input, .pm-notif-check input, .pm-notif-alarms input { accent-color: var(--mx-info-solid); width: 16px; height: 16px; margin-top: 2px; flex: none; }
.pm-notif-alarms { list-style: none; margin: 4px 0 0 24px; padding: 0; display: flex; flex-direction: column; border-radius: 10px; background: var(--pm-surface-2); }
.pm-notif-alarms li + li { border-top: 1px solid var(--pm-hairline); }
.pm-notif-alarms label { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: 13px; cursor: pointer; }
.pm-notif-alarms .pm-badge { flex: none; }
.pm-notif-scope:has(input[value="all"]:checked) .pm-notif-alarms { opacity: 0.5; }
/* save: a floating button at the bottom right, no band across the page */
.pm-notif-actions { position: sticky; bottom: 16px; z-index: 5; display: flex; justify-content: flex-end; pointer-events: none; }
.pm-notif-actions .pm-btn { pointer-events: auto; box-shadow: 0 6px 18px rgba(0,0,0,0.18); }
/* on/off switch */
.pm-switch { position: relative; display: inline-flex; cursor: pointer; flex: none; }
.pm-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pm-switch-track { width: 44px; height: 26px; border-radius: 13px; background: var(--mx-neutral-surface-control); transition: background .2s; position: relative; }
.pm-switch-thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform .2s; }
.pm-switch input:checked + .pm-switch-track { background: var(--pm-ok); }
.pm-switch input:checked + .pm-switch-track .pm-switch-thumb { transform: translateX(18px); }
.pm-switch input:focus-visible + .pm-switch-track { outline: 2px solid var(--mx-system-focus-ring); outline-offset: 2px; }
@media (max-width: 640px) {
  .pm-notif-actions .pm-btn { width: 100%; justify-content: center; min-height: 44px; }
  .pm-notif-alarms { margin-left: 0; }
}
.pm-pagehead-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pm-btn-notif-on { background: var(--pm-ok-bg); color: var(--pm-ok-text); border: 1px solid transparent; }
@media (max-width: 640px) { .pm-pagehead-actions { width: 100%; } .pm-pagehead-actions .pm-btn { flex: 1 1 auto; justify-content: center; } }
.pm-notif-section { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 -4px; }
.pm-notif-lang svg { width: 21px; height: 14px; border-radius: 2px; overflow: hidden; box-shadow: 0 0 0 1px rgba(0,0,0,0.12); flex: none; }

/* sent notification: preview of the e-mail */
.pm-mail-preview { margin-top: 24px; margin-bottom: 96px; gap: 0; }
.pm-mail-meta { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; }
.pm-mail-meta div { display: flex; gap: 12px; }
.pm-mail-meta span { width: 70px; flex: none; color: var(--pm-muted); }
.pm-mail-tabs { display: inline-flex; gap: 2px; padding: 2px; margin-bottom: 12px; border-radius: 10px; background: var(--mx-neutral-surface-control); }
.pm-mail-tabs button { padding: 6px 14px; font-size: 12px; font-weight: 600; border-radius: 8px; color: var(--pm-secondary); }
.pm-mail-tabs button.is-active { background: var(--pm-surface); color: var(--pm-text); box-shadow: var(--mx-elevation-1); }
.pm-mail-frame { display: block; width: 100%; height: 860px; border: 1px solid var(--pm-border); border-radius: 12px; background: #f1f1ef; }
.pm-mail-frame[hidden], .pm-mail-text[hidden] { display: none; }
.pm-mail-text { margin: 0; padding: 16px; border-radius: 12px; background: var(--pm-surface-2); font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 860px; overflow: auto; }
/* playback: no soft shadows on the schema shapes (each redraw would repaint them) */
#pm-syn-slot.is-playing .pm-syn-shape { filter: none; transition: none; }
/* playback: the colours show running/stopped; spinning fans and moving flows would only add repaint work
   at several frames per second. The schema is also isolated so its repaints do not involve the page. */
#pm-syn-slot.is-playing .pm-syn-blades, #pm-syn-slot.is-playing .pm-syn-flow, #pm-syn-slot.is-playing .pm-syn-orbiter,
#pm-syn-slot.is-playing .pm-syn-sawblade, #pm-syn-slot.is-playing .pm-syn-alert-icon { animation: none !important; }
.pm-syn-scroll { contain: layout paint; }

/* chopper: fixed teeth of the stator (the rotor uses the fan blade colours and spin) */
.pm-syn-teeth { fill: var(--mx-neutral-line-border-strong); }
.pm-syn-node.state-run .pm-syn-teeth { fill: var(--pm-ok); opacity: 0.55; }
.pm-syn-node.state-alarm .pm-syn-teeth { fill: var(--pm-crit); opacity: 0.55; }
.pm-syn-node.state-warning .pm-syn-teeth { fill: var(--pm-warn); opacity: 0.7; }
.pm-syn-node.state-info .pm-syn-teeth { fill: var(--mx-info-solid); opacity: 0.55; }
