/*
** Copyright (C) 2021-2026 initMAX s.r.o.
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/

/* ---- Inline Tabler icons ---------------------------------------------- */

/* Inline Tabler SVGs stroking in currentColor; the little buttons that hold them centre the icon, not a text glyph. */
.navigatormax-icon {
	display: inline-block;
	vertical-align: middle;
	flex: 0 0 auto;
}

.navigatormax-ac-select,
.navigatormax-rule-remove:not(.btn-link),
.navigatormax-crow-remove:not(.btn-link),
.js-tag-remove:not(.btn-link) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.navigatormax-ac-select svg,
.navigatormax-rule-remove:not(.btn-link) svg,
.navigatormax-crow-remove:not(.btn-link) svg,
.js-tag-remove:not(.btn-link) svg {
	width: 15px;
	height: 15px;
}

/* ---- Rules editor ------------------------------------------------------ */

.navigatormax-rules {
	display: flex;
	flex-direction: column;
	/* Clear separation between rules (A, B, C ...); the two lines of one Host rule sit tighter (below). */
	gap: 12px;
}

/* Every target uses the same two-row grid: selectors above, criteria below. */
.navigatormax-rule {
 display: grid;
 grid-template-columns: 16px repeat(6, minmax(0, 1fr)) 26px;
 gap: 6px;
 align-items: center;
 border-bottom: 1px solid rgba(127, 127, 127, .25);
 padding-bottom: 10px;
}
.navigatormax-rule > * { min-width: 0; }
.navigatormax-rule-letter { grid-column: 1; grid-row: 1; text-align: center; font-weight: 600; }
.navigatormax-rule-type { grid-column: 2 / 5; grid-row: 1; }
.navigatormax-rule .js-host-mode { grid-column: 5 / 8; grid-row: 1; }
.navigatormax-rule > .navigatormax-rule-remove { grid-column: 8; grid-row: 1; }
.navigatormax-rule-break { display: none; }
.navigatormax-rule :is(.js-host, .js-group, .js-template) { grid-column: 2 / 5; grid-row: 2; }
.navigatormax-rule .js-dashboard { grid-column: 5 / 8; grid-row: 2; }
.navigatormax-rule[data-type="0"] .js-dashboard,
.navigatormax-rule[data-type="5"] .js-group,
.navigatormax-rule .js-url { grid-column: 2 / 8; grid-row: 2; }
.navigatormax-rule .js-tag { grid-column: 2 / 4; grid-row: 2; }
.navigatormax-rule .js-tag-op { grid-column: 4 / 6; grid-row: 2; }
.navigatormax-rule .js-tag-value { grid-column: 6 / 8; grid-row: 2; }
.navigatormax-rule[data-host-mode="1"] .js-dashboard { grid-column: 2 / 8; grid-row: 3; }
.navigatormax-rule z-select { width: 100% !important; min-width: 0; }
.navigatormax-rule .navigatormax-rule-op { display: flex; min-width: 0; }

.navigatormax-ac {
	position: relative;
	display: inline-flex;
	align-items: stretch;
	flex: 1 1 160px;
	min-width: 120px;
}

/* Plain input cell, no suggestions (Custom URL); the link gets the most space as the longest thing on the row. */
.navigatormax-text {
	display: inline-flex;
	flex: 1 1 160px;
	min-width: 120px;
}

.navigatormax-rule .js-url {
	flex: 2 1 240px;
}

.navigatormax-ac-input {
	flex: 1 1 auto;
	min-width: 0;
}

.navigatormax-ac-select,
.navigatormax-rule-remove:not(.btn-link) {
	flex: 0 0 auto;
	margin-left: 2px;
	padding: 0 6px;
	line-height: 1.6;
	cursor: pointer;
	border: 1px solid rgba(127, 127, 127, 0.4);
	border-radius: 2px;
	background: rgba(127, 127, 127, 0.08);
	color: inherit;
}

.navigatormax-ac-select:hover,
.navigatormax-rule-remove:not(.btn-link):hover {
	background: rgba(127, 127, 127, 0.18);
}

/* Fixed (coords set by JS), NOT absolute: the .overlay-dialogue-body is overflow:auto and would clip an absolute list. */
.navigatormax-ac-list {
	position: fixed;
	z-index: 10000;
	max-height: 180px;
	overflow-y: auto;
	border: 1px solid rgba(127, 127, 127, 0.4);
	border-radius: 3px;
	/* A light popover, readable over either theme. */
	background: #fff;
	color: #2c2c2c;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.navigatormax-ac-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 4px 8px;
	cursor: pointer;
}

.navigatormax-ac-item:hover {
	background: rgba(127, 127, 127, 0.18);
}

.navigatormax-ac-name {
	/* Shrinkable so it ellipsis-clips only at the screen edge; full name stays in the hover tooltip. */
	flex: 0 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Host-count badge on template suggestions. */
.navigatormax-ac-count {
	flex: 0 0 auto;
	min-width: 18px;
	padding: 0 5px;
	border-radius: 8px;
	background: rgba(127, 127, 127, 0.18);
	color: inherit;
	font-size: 11px;
	text-align: center;
}

.navigatormax-ac-empty {
	padding: 4px 8px;
	color: inherit;
	font-style: italic;
}

.navigatormax-rules-add {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 12px;
	min-width: 0;
	margin-top: 6px;
}
.navigatormax-form .navigatormax-rules-add > button {
	margin: 0;
	max-width: 100%;
	white-space: normal;
}

/* ---- Buttons icon / colour list --------------------------------------- */

/* Primary action directly beneath the source selection's Add link. */
.navigatormax-tiles-head {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 8px;
}
.navigatormax-form .navigatormax-rules-field > .navigatormax-tiles-head { margin-top: 0; padding-top: 16px; }
.navigatormax-form #navigatormax_load {
	max-width: 100%;
	min-width: 0;
	min-height: 26px;
	height: auto;
	margin: 0;
	padding: 4px 12px;
	line-height: 1.4;
	white-space: normal;
	box-sizing: border-box;
}

/* Vertical list; each row is a real flex box (NOT display:contents) so jQuery UI sortable can drag it. */
.navigatormax-tiles {
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-height: 240px;
	overflow-y: auto;
}

.navigatormax-crow {
	display: flex;
	align-items: center;
	gap: 10px;
}

/* The drag grip: a Tabler grip-vertical icon. */
.navigatormax-crow-handle {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	cursor: grab;
	opacity: 0.55;
}

.navigatormax-crow-handle svg {
	width: 16px;
	height: 16px;
}

.navigatormax-crow-handle:active {
	cursor: grabbing;
}

/* The row being dragged (jQuery UI sortable helper / placeholder). */
.navigatormax-crow.ui-sortable-helper {
	opacity: 0.9;
}

/* Name column: the tile's display name, plus the original dashboard name underneath when a label
   overrides it, so you can still tell which dashboard the tile opens. */
.navigatormax-crow-names {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 0;
	line-height: 1.15;
}

.navigatormax-crow-label {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.navigatormax-crow-sub {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 11px;
	opacity: 0.6;
}

.navigatormax-crow-preview {
	flex: 0 0 auto;
	width: 24px;
	height: 24px;
	object-fit: contain;
}

/* Hidden rather than removed, so the icon column keeps its width and the rows stay aligned. */
.navigatormax-crow-preview.is-empty {
	visibility: hidden;
}

/* One chip per colour rule; the tooltip names the trigger that switches it on. */
.navigatormax-crow-colors {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 3px;
}

.navigatormax-crow-edit,
.navigatormax-crow-remove:not(.btn-link) {
	flex: 0 0 auto;
}

.navigatormax-swatch {
	width: 14px;
	height: 14px;
	border: 1px solid rgba(127, 127, 127, 0.4);
	border-radius: 3px;
	cursor: help;
}

.navigatormax-crow-remove:not(.btn-link) {
	padding: 0 6px;
	line-height: 1.6;
	cursor: pointer;
	border: 1px solid rgba(127, 127, 127, 0.4);
	border-radius: 2px;
	background: rgba(127, 127, 127, 0.08);
	color: inherit;
}

.navigatormax-crow-remove:not(.btn-link):hover {
	background: rgba(127, 127, 127, 0.18);
}

/* ---- Edit overlay: icon + colour rules --------------------------------- */
/* Rendered in a Zabbix overlay outside the widget form, so unscoped; base modal-popup sizes to content (capped 1024px). */

.navigatormax-edit {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* A native-looking form row: label column + control column. */
.navigatormax-edit-field {
	display: grid;
	grid-template-columns: 110px minmax(0, 1fr);
	gap: 10px;
	align-items: start;
}

.navigatormax-edit-label {
	display: flex;
	justify-content: flex-end;
	text-align: right;
	align-items: center;
	gap: 4px;
	/* Nudged down so it lines up with the first control, not the top of a tall rule table. */
	padding-top: 4px;
}


.navigatormax-edit-help {
	display: inline-flex;
	align-items: center;
}

input.navigatormax-edit-desc {
	width: 100%;
	max-width: 420px;
	box-sizing: border-box;
}

/* The per-tile font-size override: a small number box; empty inherits the widget's global size. */
input.navigatormax-edit-font {
	width: 90px;
}

.navigatormax-edit-checkbox {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	min-height: 24px;
	margin: 0;
}

/* Checkbox rows have no input-field top padding: centre both labels and help icons. */
.navigatormax-edit-field--checkbox { align-items: center; }
.navigatormax-edit-field--checkbox > .navigatormax-edit-label { padding-top: 0; }

/* Native options have a fixed max-width even when their menu is stretched.
   Let the option background cover the complete menu in this widget only. */
:is(.navigatormax-form, .navigatormax-edit) z-select .list li {
	width: 100%;
	max-width: none;
}

.navigatormax-erules-wrap {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
	min-width: 0;
}

/* Rule table; rows are display:contents so their cells align to this grid regardless of content length. */
.navigatormax-erules {
	display: grid;
	grid-template-columns: minmax(110px, 1fr) minmax(110px, 1fr) minmax(150px, 1.5fr) auto auto;
	gap: 6px 8px;
	align-items: center;
	width: 100%;
}

.navigatormax-erules-head,
.navigatormax-erow {
	display: contents;
}

/* Cells are grid items here; the link editor's flex-basis/min-width would push the table wider than the dialogue. */
.navigatormax-erow > .navigatormax-ac {
	flex: none;
	min-width: 0;
}

.navigatormax-erules-head > span {
	color: inherit;
	font-size: 11px;
	font-weight: 600;
}

.navigatormax-erow-color {
	display: flex;
	align-items: center;
	gap: 6px;
}

input.navigatormax-erow-swatch {
	flex: 0 0 auto;
	width: 28px;
	height: 22px;
	padding: 0;
	border: 1px solid rgba(127, 127, 127, 0.4);
	border-radius: 3px;
	background: none;
	cursor: pointer;
}

.navigatormax-erow-actions {
	display: flex;
	gap: 4px;
}

.navigatormax-erow-actions button {
	padding: 0 6px;
	line-height: 1.6;
	cursor: pointer;
	border: 1px solid rgba(127, 127, 127, 0.4);
	border-radius: 2px;
	background: rgba(127, 127, 127, 0.08);
	color: inherit;
}

.navigatormax-erow-actions button:hover {
	background: rgba(127, 127, 127, 0.18);
}

/* The empty / loading / error note lives in the tiles grid, so it has to span every column. */
.navigatormax-tiles-empty {
	color: inherit;
	font-style: italic;
}

/* "Expression" group: the calculation select and its Custom formula input stacked under one label;
   extra .fields-group qualifier beats the theme's .form-grid .fields-group frame (padding + border). */
.form-grid .fields-group.navigatormax-expression-group {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 6px;
	padding: 0;
	border: 0;
}

.navigatormax-expression-group > .form-field {
	margin: 0;
}

/* Show toggles inline on one "Show" row (Severities-filter style); extra .fields-group qualifier beats the theme's .form-grid .fields-group frame (5px padding + border). */
.form-grid .fields-group.navigatormax-show-group {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 18px;
	padding: 0;
	border: 0;
}

.navigatormax-show-group > .form-field {
	margin: 0;
}

/* ---- Edit overlay: None / Static / Dynamic colour --------------------- */

.navigatormax-color-static {
	display: flex;
	align-items: center;
	gap: 12px;
}

.navigatormax-color-dynamic {
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-width: 0;
}

/* Group/host/trigger filter, one criterion per row; keeps .navigatormax-erow for the typeahead but overrides its display:contents back to stacked rows. */
.navigatormax-color-filter {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* Paint: the segmented control sits next to the colour picker / severity gradient. */
.navigatormax-color-paint {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

/* Problem-tag rows: tag / operator / value / remove. */
.navigatormax-tags-wrap {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
	width: 100%;
	min-width: 0;
}

.navigatormax-tags {
	display: flex;
	flex-direction: column;
	gap: 6px;
	width: 100%;
}

.navigatormax-tag {
	display: flex;
	align-items: center;
	gap: 6px;
}

.navigatormax-tag-key,
.navigatormax-tag-value {
	flex: 1 1 120px;
	min-width: 0;
}

.navigatormax-tag-op {
	flex: 0 0 auto;
}

.js-tag-remove:not(.btn-link) {
	flex: 0 0 auto;
	padding: 0 6px;
	line-height: 1.6;
	cursor: pointer;
	border: 1px solid rgba(127, 127, 127, 0.4);
	border-radius: 2px;
	background: rgba(127, 127, 127, 0.08);
	color: inherit;
}

.js-tag-remove:not(.btn-link):hover {
	background: rgba(127, 127, 127, 0.18);
}

/* A dynamic tile whose paint colour is not yet known (severity / unset): a neutral hatched marker. */
.navigatormax-swatch--dynamic {
	background: repeating-linear-gradient(45deg, #8a97a0 0, #8a97a0 3px, #c9d1d6 3px, #c9d1d6 6px);
}

/* ---- Presets ---------------------------------------------------------- */

/* The preset row is not one of the settings, it is what fills them in, so it stands apart from the
   rows around it, by the same amount above as below. Both halves of the row carry the spacing,
   because the label and the field are separate cells of the form grid. */
.navigatormax-preset-label,
.navigatormax-preset-field {
	margin-top: 12px;
	margin-bottom: 12px;
}

.navigatormax-preset-label {
	font-weight: bold;
}

/* The list of presets, the button that writes the chosen one into the fields, and, for whoever may
   write the shared list, the button that saves this form as another one. */
.navigatormax-presets {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

/* The native select fills the space left by Load and Save as preset. */
.navigatormax-preset-select-wrap {
	flex: 1 1 0;
	min-width: 0;
	max-width: none;
}

.navigatormax-preset-select {
	min-width: 0;
	max-width: 100%;
}

/* A saved preset carries the control that drops it, so its row is a line with the name at one end
   and that control at the other. Group headings are left as the frontend draws them. */
#navigatormax_presets .list li:not([optgroup]) {
	display: flex;
	align-items: center;
	gap: 8px;
}

.navigatormax-preset-title {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Nothing but the icon, no bigger than the row; its colour is the frontend's warning colour, carried
   in by the class beside this one and followed through currentColor. */
.navigatormax-preset-remove {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: none;
	background: none;
	cursor: pointer;
	opacity: .75;
}

.navigatormax-preset-remove:hover,
.navigatormax-preset-remove:focus-visible {
	opacity: 1;
}

.navigatormax-preset-remove svg {
	width: 20px;
	height: 20px;
}

/* Where a preset is named before it is saved, and where saving over an existing name is asked about.
   A line of its own under the buttons, the whole width of the row so a question fits. */
.navigatormax-preset-panel {
	display: flex;
	flex: 1 0 100%;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin-top: 4px;
}

.navigatormax-preset-name {
	/* Same basis and cap as the preset list above, so the name box lines up under it. */
	flex: 1 1 220px;
	/* A text input carries the frontend's own fixed width, and the configuration dialog sizes itself
	   to its content, so that width widened the whole dialog. Zero takes the input out of that
	   measurement; the flex basis and the cap size it instead. */
	width: 0;
	min-width: 0;
	max-width: 360px;
}

.navigatormax-preset-question,
.navigatormax-preset-error {
	flex: 1 1 100%;
}

.dashboard-widget-form.dashboard-widget-navigatormax .initmax-free::before,
.dashboard-grid-widget-navigatormax .initmax-free::before {
    content: '';

    background-image: url('../../img/initmax-free.svg');
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
    background-clip: padding-box;

    display: block;
    height: 4rem;
    margin: 2rem 0;
}

.dashboard-widget-form.dashboard-widget-navigatormax .initmax-pro::before,
.dashboard-grid-widget-navigatormax .initmax-pro::before {
    content: '';

    background-image: url('../../img/initmax-pro.svg');
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
    background-clip: padding-box;

    display: block;
    height: 4rem;
    margin: 2rem 0;
}

/* The warning beside Load dashboards on 6.0-6.4, which have no zi- icon font; the colour is the one
   the 7.x warning glyph uses, so both lines read the same. */
.navigatormax-tiles-warning-icon {
	color: #e99003;
	vertical-align: middle;
	flex: 0 0 auto;
}

/* Section title row of the Zabbix 6.4 form, which has no collapsible fieldsets. */
.form-grid > .navigatormax-section-title {
	grid-column: 1 / -1;
	margin-top: 10px;
	padding-bottom: 4px;
	border-bottom: 1px solid rgba(128, 128, 128, 0.35);
	font-weight: bold;
}

/* The theme styles every dialogue <button> as a filled button; the section toggle reads as its title. */
.form-grid > .navigatormax-section-toggle > .navigatormax-section-toggle-button,
.form-grid > .navigatormax-section-toggle > .navigatormax-section-toggle-button:hover,
.form-grid > .navigatormax-section-toggle > .navigatormax-section-toggle-button:focus,
.form-grid > .navigatormax-section-toggle > .navigatormax-section-toggle-button:active {
	height: auto;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	line-height: inherit;
	cursor: pointer;
}

.navigatormax-section-toggle-button::before {
	content: '';
	display: inline-block;
	margin: 0 6px 2px 0;
	border: 4px solid transparent;
	border-top-color: currentColor;
	vertical-align: middle;
}

.navigatormax-section-toggle.collapsed .navigatormax-section-toggle-button::before {
	margin-bottom: 0;
	border-top-color: transparent;
	border-left-color: currentColor;
}

.form-grid > .navigatormax-section-toggle:is([data-nmax-section="targets"], [data-nmax-section="advanced"]).collapsed ~ .navigatormax-advanced-row,
.form-grid > .navigatormax-section-toggle[data-nmax-section="display_defaults"].collapsed ~ .navigatormax-defaults-row,
.form-grid > .navigatormax-section-toggle[data-nmax-section="problems"].collapsed ~ .navigatormax-problems-row {
	display: none;
}

/* Compact native form controls; never force a second line for preset actions. */
.navigatormax-preset-label, .navigatormax-preset-field { margin-block: 4px; }
.navigatormax-preset-select-wrap { flex: 1 1 0; max-width: none; }
.navigatormax-form .navigatormax-presets > button { flex: 0 0 auto; margin: 0; }
.navigatormax-rule .navigatormax-ac-input,
.navigatormax-rule .navigatormax-text input { width: 100%; min-width: 0; }
.navigatormax-field-note { font-size: 12px; line-height: 1.5; margin-top: 5px; color: inherit; opacity: .85; }
.navigatormax-field-note a { white-space: nowrap; }
.navigatormax-crow-icon { padding: 2px; width: 32px; height: 32px; flex-shrink: 0; }
.navigatormax-crow-preview.is-empty { visibility: visible; }
.navigatormax-crow-preview { width: 26px; height: 26px; object-fit: contain; }
.navigatormax-tile-dialog { width: 700px !important; max-width: calc(100vw - 32px) !important; box-sizing: border-box; }

.navigatormax-edit, .navigatormax-edit-field > * { min-width: 0; max-width: 100%; }
.navigatormax-edit-desc { width: 100% !important; min-width: 0; box-sizing: border-box; }
.navigatormax-color-filter, .navigatormax-color-dynamic { min-width: 0; }
.navigatormax-edit-preview { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; border: 1px solid rgba(127,127,127,.3); }
.navigatormax-preview-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; width: 160px; max-width: 100%; min-height: 100px; padding: 12px; box-sizing: border-box; text-align: center; overflow-wrap: anywhere; }
.navigatormax-preview-tile img { width: 40px; height: 40px; object-fit: contain; }
.navigatormax-preview-counts:empty { display: none; }
.navigatormax-preview-counts .navigatormax-btn-badges { margin-top: 0; }
.navigatormax-mode-previews { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.navigatormax-mode-previews[hidden] { display: none !important; }
.navigatormax-mode-icon, .navigatormax-mode-icon svg { display: block; flex: 0 0 14px; width: 14px; height: 14px; }
.navigatormax-mode-preview { display: inline-flex; flex: 0 0 156px; align-items: center; justify-content: space-between; gap: 6px; width: 156px; height: 24px; min-width: 0; max-width: 100%; padding: 2px 6px; border: 1px solid #dfe3e8; box-sizing: border-box; font-size: 11px; line-height: 18px; }
.navigatormax-mode-preview--light { background: #fff; color: #1f2c33; }
.navigatormax-mode-preview--dark { background: #1f1f1f; color: #dfe3e8; border-color: #4f4f4f; }
.navigatormax-mode-sample { padding: 0 7px; font-weight: 600; }
.navigatormax-mode-ratio { font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#color_picker.navigatormax-colour-dialog { width: 382px; max-width: calc(100vw - 20px); max-height: calc(100vh - 20px); overflow: auto; box-sizing: border-box; }
#color_picker.navigatormax-colour-dialog .navigatormax-mode-previews { margin-top: 8px; }
#color_picker.navigatormax-colour-dialog .color-picker-controls { flex-wrap: wrap; }
#color_picker .navigatormax-colour-apply { margin-left: 6px; }
.navigatormax-help-examples { display: flex; flex-wrap: wrap; gap: 20px; padding-top: 12px; }
.navigatormax-help-tile { margin-top: 5px; padding: 12px; background: #1f65f4; color: #fff; border-radius: 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 110px; }
.navigatormax-help-description { font-size: 11px; }
.navigatormax-help-counts { border: 1px solid currentColor; padding: 1px 5px; }
.navigatormax-help-list { margin-top: 5px; display: flex; gap: 8px; align-items: center; border-left: 4px solid #1f65f4; padding: 6px; }
@media (max-width: 600px) {
 .navigatormax-edit-field { grid-template-columns: 1fr; gap: 4px; }
 .navigatormax-preset-select-wrap { max-width: none; }
}

/* The core form uses a content-sized second track: long custom fields must not widen it. */
.navigatormax-form .form-grid { --label-width: 180px !important; grid-template-columns: 180px minmax(0, 1fr); }
.navigatormax-form .form-grid > .form-field,
.navigatormax-form .form-grid .fields-group,
.navigatormax-form .form-grid fieldset,
.navigatormax-form .navigatormax-rules-field,
.navigatormax-form .navigatormax-tiles-field { min-width: 0; max-width: 100%; }
.navigatormax-form .form-grid > label { white-space: normal; overflow-wrap: anywhere; }
.navigatormax-form .navigatormax-default-icon { max-width: 100%; }
.navigatormax-rule :is(.navigatormax-ac, .navigatormax-text) { min-width: 0; }
.navigatormax-field-note, .navigatormax-tiles-warning,
.navigatormax-preview-tile, .navigatormax-preview-tile strong,
.navigatormax-preview-tile small { white-space: normal; overflow-wrap: anywhere; }
.navigatormax-tiles-head { flex-wrap: wrap; }
.navigatormax-tiles-head > .navigatormax-tiles-warning { flex: 1 1 230px; min-width: 0; }
.navigatormax-section-help { display: inline-block; margin-left: 6px; }
/* Legacy help anchors otherwise sit on the text baseline, above the label's
   centre. Align the entire native circle, not just its question-mark glyph. */
.navigatormax-form label:has(> .icon-help-hint),
.navigatormax-form .navigatormax-section-title:has(> .icon-help-hint) {
 display: flex;
 align-items: center;
 gap: 6px;
}
.navigatormax-form label:has(> .icon-help-hint) {
 align-self: start;
 justify-content: flex-end;
}
.navigatormax-form :is(label, .navigatormax-section-title) > .icon-help-hint {
 flex: 0 0 14px;
 margin: 0;
 top: 0;
}
:is(.navigatormax-form, .navigatormax-edit) .icon-help-hint { vertical-align: middle; }
/* Older Zabbix help glyphs assume a right-aligned label. Dynamic section and
   picker hints also need the question mark centred inside its native circle. */
:is(.navigatormax-form, .navigatormax-edit) .icon-help-hint::after {
 position: absolute;
 inset: 0;
 display: flex;
 align-items: center;
 justify-content: center;
 line-height: 1;
}
.overlay-dialogue.navigatormax-hint {
 min-width: 0;
 margin: 0;
 transform: none;
 overflow: auto;
 overscroll-behavior: contain;
 white-space: normal;
 overflow-wrap: anywhere;
}
.navigatormax-edit-field > .navigatormax-field-note { margin-top: 0; }
.navigatormax-tile-dialog .navigatormax-ac-input { width: 100%; }
.navigatormax-tile-dialog .navigatormax-tags { max-width: 100%; }

.navigatormax-ac-list { box-sizing: border-box; max-width: calc(100vw - 24px); }

/* Width constraints belong to the controls, not a clipped dialogue body. */
.navigatormax-form .form-grid input:not([type=checkbox]):not([type=radio]),
.navigatormax-form .form-grid z-select,
.navigatormax-edit input:not([type=checkbox]):not([type=radio]),
.navigatormax-edit select { max-width: 100%; box-sizing: border-box; }
.navigatormax-edit-field > .navigatormax-field-note { grid-column: 2 / -1; }
.navigatormax-tag { flex-wrap: wrap; }
.navigatormax-tag-key, .navigatormax-tag-value { width: 0; }
.navigatormax-section-title > button { margin-left: 6px; }
.navigatormax-help-tile--default { background: #e9edf0; color: #1f2c33; }
.navigatormax-help-tile--static { background: #4caf50; color: #1f2c33; }
.navigatormax-help-tile--dynamic { background: #ffaa55; color: #1f2c33; }
@media (max-width: 600px) {
 .navigatormax-edit-field > .navigatormax-field-note { grid-column: 1; }
 .navigatormax-form .form-grid .radio-list-control { display: flex; flex-wrap: wrap; }
 .navigatormax-preview-tile { max-width: 100%; box-sizing: border-box; }
 .navigatormax-field-note a { white-space: normal; }
}

/* Zabbix's default 650px minimum must not push this widget's dialogue beyond a narrow viewport. */
.overlay-dialogue:has(.navigatormax-form),
.overlay-dialogue.modal-popup.modal-popup-generic:has(.navigatormax-form),
.overlay-dialogue.modal-popup.modal-popup-generic:is(.navigatormax-tile-dialog, .navigatormax-choice-dialog, .navigatormax-native-dialog) {
 min-width: 0;
 max-width: calc(100vw - 24px);
 box-sizing: border-box;
}
/* Native widget dialogs use auto width. Removing a selected name must not resize
   this form and switch its responsive layout while the user is editing it. */
.overlay-dialogue:has(.navigatormax-form),
.overlay-dialogue.modal.modal-widget-configuration:has(.navigatormax-form),
.overlay-dialogue.modal-popup.modal-popup-generic:has(.navigatormax-form) {
 --modal-width: min(1100px, calc(100vw - 24px));
 --modal-min-width: 0px;
 width: min(1100px, calc(100vw - 24px));
 min-width: 0;
 max-width: calc(100vw - 24px);
}
.navigatormax-form .form-grid fieldset > label { white-space: normal; overflow-wrap: anywhere; }
.navigatormax-form .checkbox-list.vertical {
 width: 100%;
 max-width: 100%;
 grid-auto-flow: row;
 grid-template-rows: none;
 grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr));
}
.navigatormax-form .checkbox-list.vertical > li { min-width: 0; }

/* Keep all adjacent controls on the native 24px baseline, in either theme. */
.navigatormax-ac-select, .navigatormax-rule-remove:not(.btn-link), .navigatormax-crow-remove:not(.btn-link), .js-tag-remove:not(.btn-link) {
 height: 24px;
 width: 26px;
 padding: 0;
 margin-left: 0;
 box-sizing: border-box;
}
.navigatormax-ac { gap: 4px; }
.navigatormax-edit-label > label { margin: 0; white-space: normal; }
.navigatormax-edit-help { flex: 0 0 auto; }
.navigatormax-edit-preview { justify-content: center; }
.navigatormax-crow { min-height: 36px; padding-block: 4px; border-bottom: 1px solid rgba(127,127,127,.2); gap: 6px; }
.navigatormax-tiles { gap: 0; }
.navigatormax-crow-colors { width: 16px; justify-content: center; }
.navigatormax-tiles-head { align-items: center; }
.navigatormax-tiles-head > .navigatormax-tiles-warning { flex-basis: 100%; line-height: 1.5; }
.navigatormax-tag { display: grid; grid-template-columns: minmax(0,1fr) minmax(125px,1fr) minmax(0,1fr) auto; }
.navigatormax-tag :is(input, z-select) { width: 100% !important; min-width: 0; }
@media (max-width: 600px) {
 .navigatormax-edit-label { justify-content: flex-start; text-align: left; }
 .navigatormax-rule > :is(.navigatormax-ac, .navigatormax-text, .navigatormax-rule-op) { grid-column: 2 / 8; grid-row: auto; }
 .navigatormax-rule .js-host-mode { grid-column: 2 / 8; grid-row: 2; }
 .navigatormax-rule-type { grid-column: 2 / 8; }
 .navigatormax-rule[data-type="0"] .js-dashboard,
.navigatormax-rule[data-type="5"] .js-group,
 .navigatormax-rule[data-host-mode="1"] .js-dashboard { grid-column: 2 / 8; grid-row: auto; }
 .navigatormax-tag { grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; }
 .navigatormax-tag-value { grid-column: 1 / 3; grid-row: 2; }
 .navigatormax-tag > .js-tag-remove { grid-column: 3; grid-row: 1; }
}

@media (max-width: 600px) {
 .navigatormax-form .form-grid > .form-field-show-header {
  position: static;
  grid-column: 2;
  text-align: left;
 }
}

/* On a phone-sized viewport labels belong above controls, never squeezed beside them. */
@media (max-width: 600px) {
 .navigatormax-form .form-grid {
  --label-width: 0px !important;
  grid-template-columns: minmax(0, 1fr);
  row-gap: 6px;
 }
 .navigatormax-form .form-grid > label,
 .navigatormax-form .form-grid fieldset > label {
  grid-column: 1;
  text-align: left;
  justify-self: start;
  padding-top: 6px;
 }
 .navigatormax-form .form-grid .form-field,
 .navigatormax-form .form-grid .fields-group,
 .navigatormax-form .form-grid > .form-field-show-header { grid-column: 1; }
 .navigatormax-form .navigatormax-presets { flex-wrap: nowrap; }
 .navigatormax-form .navigatormax-preset-select-wrap { flex-basis: 0; }
 .navigatormax-form .navigatormax-preset-panel { flex-basis: 100%; }
 .navigatormax-form .navigatormax-presets:has(.navigatormax-preset-panel:not([hidden])) { flex-wrap: wrap; }
}

/* Keep the PRO lettering dark on its yellow badge; the wordmark turns white. */
html:is([theme="dark-theme"], [theme="hc-dark"], [theme="dark-blue-theme"], [theme="dark-classic-theme"]) .overlay-dialogue:has(.navigatormax-form) .initmax-pro::before {
 background-image: url('../../img/initmax-pro-dark.svg?contrast=1') !important;
}

/* Core button:hover changes text to white. Our neutral controls retain the dialog text
   in every interactive state, instead of leaving white text on a pale background. */
:is(.navigatormax-form, .navigatormax-edit) :is(
 .navigatormax-ac-select, .navigatormax-rule-remove:not(.btn-link),
 .navigatormax-crow-remove:not(.btn-link), .js-tag-remove:not(.btn-link)
):is(:hover, :focus, :active) {
 color: inherit;
 background: rgba(127, 127, 127, .16);
}
:is(.navigatormax-form, .navigatormax-edit) :is(
 .navigatormax-ac-select, .navigatormax-rule-remove:not(.btn-link),
 .navigatormax-crow-remove:not(.btn-link), .js-tag-remove:not(.btn-link)
):focus-visible {
 outline: 2px solid currentColor;
 outline-offset: 1px;
}

/* Match the native Graph pattern selector rather than skinning a parallel input. */
.navigatormax-native-picker { flex: 1 1 0; min-width: 0; width: 100%; }
.navigatormax-native-picker .multiselect { min-width: 0; width: auto; flex: 1 1 0; }
.navigatormax-native-picker .selected { min-width: 0; }
.navigatormax-native-picker .multiselect-list { min-width: 0; max-width: 100%; }
.navigatormax-ac:has(.navigatormax-native-picker), .navigatormax-text { align-items: center; gap: 4px; }
.navigatormax-target-help { flex: 0 0 auto; display: inline-flex; align-items: center; }
.navigatormax-rule { grid-template-columns: 16px repeat(6, minmax(0, 1fr)) auto; }
.navigatormax-rule-remove.btn-link, .navigatormax-crow-remove.btn-link, .js-tag-remove.btn-link {
 width: auto; min-width: 0; height: auto; padding: 0; border: 0; border-radius: 0;
 background: none; line-height: inherit;
}
:is(.navigatormax-form,.navigatormax-edit) :is(.navigatormax-rule-remove,.navigatormax-crow-remove,.js-tag-remove).btn-link:is(:hover,:focus,:active) {
 background: none; text-decoration: underline;
}
.navigatormax-colour-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.navigatormax-colour-line .color-picker { margin: 0; flex: 0 0 auto; }
.navigatormax-crow-colors { flex: 0 0 32px; width: 32px; }
.navigatormax-swatch { display: inline-block; width: 32px; height: 32px; box-sizing: border-box; cursor: default; border-radius: 0; }
.navigatormax-swatch--empty { background: linear-gradient(135deg, transparent 47%, #768d99 48%, #768d99 52%, transparent 53%); }
.navigatormax-form .form-grid fieldset > label { overflow-wrap: normal; }
@media (min-width: 601px) {
 .navigatormax-form label[for="host_problems"], .navigatormax-form label[for="show_suppressed"] { white-space: nowrap; }
}
.navigatormax-ac > .multiselect-control { display: flex; flex: 1 1 0; min-width: 0; width: 100%; gap: 4px; }
.navigatormax-ac .navigatormax-native-picker { width: 0; min-width: 0; flex: 1 1 0; }
.navigatormax-ac > .multiselect-control .btn-split { flex: 0 0 auto; }

@media (max-width: 600px) {
 .navigatormax-form .form-grid fieldset > .form-field { margin-left: 24px; min-width: 0; }
}

/* Native controls retain core theme/hover styles; only constrain their layout. */
.navigatormax-image-control { display: flex; align-items: center; gap: 6px; min-width: 0; }
.navigatormax-image-control > img { flex: 0 0 24px; object-fit: contain; }
.navigatormax-image-control > .multiselect-control { min-width: 0; flex: 1 1 0; }
.navigatormax-image-control .navigatormax-icon-picker { min-width: 0; width: 0 !important; flex: 1 1 0; }
.navigatormax-image-control .multiselect-list { max-width: 100%; }
.navigatormax-image-control > button { flex: 0 0 auto; }
.navigatormax-page-select { width: 100% !important; min-width: 0; }
.overlay-dialogue.navigatormax-choice-dialog, .overlay-dialogue.navigatormax-native-dialog { box-sizing: border-box; width: min(760px, calc(100vw - 24px)); min-width: 0; max-width: calc(100vw - 24px); }
.navigatormax-choice-dialog input[type="search"] { width: 100%; margin-bottom: 10px; box-sizing: border-box; }
.navigatormax-choice-dialog .list-table { width: 100%; table-layout: fixed; }
.navigatormax-choice-dialog .list-table td:has(img) { width: 44px; }
.navigatormax-choice-dialog .list-table .btn-link { white-space: normal; overflow-wrap: anywhere; text-align: left; }
.navigatormax-choice-dialog .list-table .navigatormax-choice-check { width: 24px; }
.navigatormax-choice-dialog .list-table .navigatormax-choice-pages { width: 92px; text-align: right; white-space: nowrap; }
.navigatormax-choice-dialog .list-table td > label { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 600px) {
 .navigatormax-native-dialog .table-forms { display: block; width: 100%; min-width: 0; }
 .navigatormax-native-dialog .table-forms > li { display: block; width: 100%; }
 .navigatormax-native-dialog .table-forms > li > label { display: block; margin-bottom: 4px; }
 .navigatormax-native-dialog .multiselect-control { display: flex; width: 100%; min-width: 0; gap: 4px; }
 .navigatormax-native-dialog .multiselect { width: 0 !important; min-width: 0; flex: 1 1 0; }
 .navigatormax-native-dialog .btn-split { flex: 0 0 auto; }
}

/* A dynamic mode is a setting, not an actual problem colour. Use native secondary text. */
.navigatormax-crow-colors { flex-basis: 32px; width: 32px; }
.navigatormax-color-mode { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; min-width: 0; max-width: 100%; font-size: 12px; white-space: normal; overflow-wrap: anywhere; text-align: center; cursor: default; }


/* A tile is edited in one place. Core buttons and theme colours stay untouched;
   this layer only aligns the source, preview and actions. */
.navigatormax-tile-tools {
 display: flex;
 flex-wrap: wrap;
 align-items: center;
 gap: 8px;
 margin-bottom: 8px;
 min-width: 0;
}
.navigatormax-tile-tools > button { flex: 0 0 auto; }
.navigatormax-tile-tools input[type="search"],
.navigatormax-tile-tools .navigatormax-tile-search {
 flex: 1 1 180px;
 width: 0;
 min-width: min(180px, 100%);
 max-width: 100%;
 box-sizing: border-box;
}
.navigatormax-tiles {
 max-height: 420px;
 min-width: 0;
}
.navigatormax-add-custom-field {
 display: inline-flex;
 align-items: center;
 max-width: 100%;
 margin-top: 12px;
}
.navigatormax-add-custom-field > button { min-width: 0; white-space: normal; }
/* Native source menus keep FREE choices usable. Mark only their unavailable
   PRO options, using the same padlock path as the shared upgrade teaser. */
:is(.navigatormax-rule-type, .navigatormax-rule-host-mode) li[disabled],
.navigatormax-destination-type li[value="paid"][disabled] {
 padding-right: 44px;
 position: relative;
}
:is(.navigatormax-rule-type, .navigatormax-rule-host-mode) li[disabled]::after,
.navigatormax-destination-type li[value="paid"][disabled]::after {
 content: "";
 position: absolute;
 right: 12px;
 top: 50%;
 transform: translateY(-50%);
 width: 13px;
 height: 13px;
 background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23888888' d='M12 2a5 5 0 0 0-5 5v3H6a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7a2 2 0 0 0-2-2h-1V7a5 5 0 0 0-5-5zm-3 5a3 3 0 0 1 6 0v3H9V7zm3 6.5a1.5 1.5 0 0 1 .75 2.8V18a.75.75 0 0 1-1.5 0v-1.7a1.5 1.5 0 0 1 .75-2.8z'/%3E%3C/svg%3E") center / contain no-repeat;
}
/* The shared teaser aligns block labels to their top. A checkbox is centred in
   its native row instead, including the taller checkbox labels in Zabbix 7. */
:is(.navigatormax-form, .navigatormax-edit) :is(.form-field, .table-forms-td-right):has(> .initmax-pro-lock):is(:has(> input[type="checkbox"]), :has(> label > input[type="checkbox"])) {
 display: flex;
 align-items: center;
 flex-wrap: wrap;
}
:is(.navigatormax-form, .navigatormax-edit) .initmax-pro-lock {
 flex: 0 0 auto;
 vertical-align: middle !important;
 margin-top: 0 !important;
}
.navigatormax-edit-field > div:has(> .initmax-pro-lock) {
 display: flex;
 align-items: center;
 min-width: 0;
}
.navigatormax-edit-field > div:has(> .initmax-pro-lock) > input {
 flex: 1 1 0;
 min-width: 0;
 width: 0;
}
.navigatormax-crow {
 display: grid;
 grid-template-columns: 28px minmax(0, 1fr) 32px 32px auto;
 align-items: center;
 flex-shrink: 0;
 gap: 6px;
 padding-block: 6px;
 min-width: 0;
}
.navigatormax-crow-handle { grid-column: 1; grid-row: 1; flex-direction: column; gap: 2px; }
.navigatormax-crow-position { font-size: 11px; font-variant-numeric: tabular-nums; cursor: default; }
.navigatormax-crow-names { grid-column: 2; grid-row: 1; min-width: 0; gap: 3px; }
.navigatormax-crow-icon { grid-column: 3; grid-row: 1; margin: 0; box-sizing: border-box; }
.navigatormax-crow-colors { grid-column: 4; grid-row: 1; margin: 0; }
.navigatormax-crow-actions {
 grid-column: 5;
 grid-row: 1;
 display: flex;
 flex-wrap: wrap;
 align-items: center;
 justify-content: flex-end;
 gap: 4px;
 min-width: 0;
}
.navigatormax-form .navigatormax-crow-actions > button { flex: 0 0 auto; min-width: 0; max-width: 100%; margin: 0; }
.navigatormax-form .navigatormax-crow-actions > button:not(:first-child) { margin: 0; }
.navigatormax-form .navigatormax-crow-actions > .btn-link {
 height: auto;
 min-height: 24px;
 line-height: 24px;
 white-space: normal;
 overflow-wrap: anywhere;
}
.navigatormax-crow-actions > :is(.navigatormax-crow-move-up, .navigatormax-crow-move-down):is(.btn-icon, .navigatormax-btn-icon) {
 width: 24px;
 height: 24px;
 box-sizing: border-box;
}
.navigatormax-form .navigatormax-crow-actions > .navigatormax-crow-move-up + .navigatormax-crow-move-down {
 margin-inline-start: -2px;
}
.navigatormax-form .navigatormax-crow-actions > .navigatormax-btn-icon {
 /* Match the native Zabbix icon buttons on frontends without the icon font. */
 --navigatormax-arrow: #b0bec5;
 --navigatormax-arrow-hover: #768d99;
 --navigatormax-arrow-focus: #768d99;
 --navigatormax-arrow-disabled: #ced6da;
 display: inline-flex;
 align-items: center;
 justify-content: center;
 padding: 0;
 border: 0;
 border-radius: 2px;
 background: transparent;
 color: var(--navigatormax-arrow);
 line-height: 1;
}
html:is([theme="dark-theme"], :not([theme]):has(head > link[rel="stylesheet"][href*="/dark-theme.css"])) .navigatormax-form .navigatormax-crow-actions > .navigatormax-btn-icon {
 --navigatormax-arrow: #69808d;
 --navigatormax-arrow-hover: #a2b1ba;
 --navigatormax-arrow-focus: #69808d;
 --navigatormax-arrow-disabled: #3d4b53;
}
html:is([theme="hc-light"], :not([theme]):has(head > link[rel="stylesheet"][href*="/hc-light.css"])) .navigatormax-form .navigatormax-crow-actions > .navigatormax-btn-icon {
 --navigatormax-arrow: #555;
 --navigatormax-arrow-hover: #000;
 --navigatormax-arrow-focus: #555;
 --navigatormax-arrow-disabled: #ccc;
}
html:is([theme="hc-dark"], :not([theme]):has(head > link[rel="stylesheet"][href*="/hc-dark.css"])) .navigatormax-form .navigatormax-crow-actions > .navigatormax-btn-icon {
 --navigatormax-arrow: #7d7d7d;
 --navigatormax-arrow-hover: #fff;
 --navigatormax-arrow-focus: #ddd;
 --navigatormax-arrow-disabled: #555;
}
.navigatormax-form .navigatormax-crow-actions > .navigatormax-btn-icon:not(:disabled):hover {
 color: var(--navigatormax-arrow-hover);
 background: transparent;
}
.navigatormax-form .navigatormax-crow-actions > .navigatormax-btn-icon:not(:disabled):is(:focus, :active) {
 color: var(--navigatormax-arrow-focus);
 background: transparent;
}
.navigatormax-form .navigatormax-crow-actions > .navigatormax-btn-icon:focus-visible {
 outline: 2px solid currentColor;
 outline-offset: 1px;
}
.navigatormax-form .navigatormax-crow-actions > .navigatormax-btn-icon:disabled {
 /* Legacy core forces its text-button disabled colour with !important. */
 color: var(--navigatormax-arrow-disabled) !important;
 background: transparent;
 opacity: 1;
 cursor: default;
}
.navigatormax-form .navigatormax-crow-actions > .navigatormax-btn-icon > svg { flex: 0 0 auto; }
.navigatormax-crow-source {
 display: block;
 min-width: 0;
 max-width: 100%;
 font-size: 11px;
 line-height: 1.4;
 white-space: normal;
 overflow-wrap: anywhere;
}
.navigatormax-page-divider {
 display: flex;
 flex-shrink: 0;
 flex-wrap: wrap;
 align-items: center;
 gap: 4px 8px;
 padding: 10px 0 5px;
 border-bottom: 1px solid currentColor;
 font-size: 12px;
 font-weight: bold;
 line-height: 1.4;
 overflow-wrap: anywhere;
}
/* The hidden state must win over grid/flex display rules, including source selectors,
   filtered tiles, preview details and native controls inside the modal. */
.navigatormax-form [hidden], .navigatormax-edit [hidden] { display: none !important; }
.navigatormax-source-control {
 display: flex;
 flex-direction: column;
 gap: 6px;
 min-width: 0;
 max-width: 100%;
}
.navigatormax-source-control > :is(input, select, z-select, .multiselect-control, .navigatormax-ac) {
 width: 100%;
 min-width: 0;
 max-width: 100%;
 box-sizing: border-box;
}
.navigatormax-source-selection {
 display: flex;
 align-items: center;
 gap: 6px;
 min-width: 0;
 max-width: 100%;
}
.navigatormax-source-selection-field {
 display: flex;
 flex-direction: column;
 gap: 4px;
 min-width: 0;
 max-width: 100%;
}
.navigatormax-source-selection-field > label { white-space: normal; overflow-wrap: anywhere; }
.navigatormax-source-selection > input {
 flex: 1 1 0;
 width: 0;
 min-width: 0;
 box-sizing: border-box;
}
.navigatormax-source-selection > button { flex: 0 0 auto; margin: 0; }
.navigatormax-url-window-field {
 display: flex;
 flex-wrap: wrap;
 align-items: center;
 gap: 4px 8px;
 min-width: 0;
 max-width: 100%;
}
.navigatormax-url-window-field > label { white-space: normal; }
.navigatormax-url-window-field > z-select {
 flex: 1 1 150px;
 min-width: 0;
 max-width: 100%;
 width: 100%;
}
.navigatormax-source-note:empty { display: none; }
.navigatormax-source-note, .navigatormax-preview-note {
 font-size: 12px;
 line-height: 1.5;
 white-space: normal;
 overflow-wrap: anywhere;
 min-width: 0;
 max-width: 100%;
}
.navigatormax-preview-note { width: 100%; text-align: center; }
.navigatormax-live-preview {
 display: flex;
 flex-direction: column;
 align-items: center;
 gap: 6px;
 min-width: 0;
 max-width: 100%;
}
.navigatormax-rule > .navigatormax-rule-remove {
 grid-row: 1 / -1;
 align-self: center;
}
.navigatormax-rule > :is(.navigatormax-target-help, .navigatormax-rule-help) {
 grid-column: 1;
 grid-row: 2;
 align-self: start;
 display: flex;
 flex-direction: column;
 gap: 4px;
}
@media (max-width: 1100px) {
 .navigatormax-crow { grid-template-columns: 28px minmax(0, 1fr) fit-content(160px) 32px; }
 .navigatormax-crow-handle { grid-row: 1 / 3; }
 .navigatormax-crow-names { grid-row: 1 / 3; }
 .navigatormax-crow-icon { justify-self: end; }
 .navigatormax-crow-actions { grid-column: 3 / -1; grid-row: 2; }
}
@media (max-width: 600px) {
 .navigatormax-crow { grid-template-columns: 20px 32px minmax(32px, 1fr); gap: 6px; }
 .navigatormax-crow-handle { grid-column: 1; grid-row: 1 / 4; }
 .navigatormax-crow-names { grid-column: 2 / -1; grid-row: 1; }
 .navigatormax-crow-icon { grid-column: 2; grid-row: 2; justify-self: start; }
 .navigatormax-crow-colors { grid-column: 3; grid-row: 2; justify-content: flex-start; }
 .navigatormax-crow-actions { grid-column: 2 / -1; grid-row: 3; justify-content: flex-start; gap: 4px; }
 .navigatormax-crow-label { white-space: normal; overflow-wrap: anywhere; }
 .navigatormax-source-control .multiselect-control { min-width: 0; max-width: 100%; }
 .navigatormax-edit .radio-list-control { display: flex; flex-wrap: wrap; max-width: 100%; }
 .navigatormax-edit .radio-list-control > li { min-width: 0; max-width: 100%; }
 .navigatormax-edit .radio-list-control label { white-space: normal; overflow-wrap: anywhere; }
}

/* Native integer fields share a single layout row; only the capacity note wraps
   when the dialog is too narrow for the complete calculation. */
.form-grid .fields-group.navigatormax-grid-size {
 display: flex;
 flex-wrap: wrap;
 align-items: center;
 gap: 6px 10px;
 min-width: 0;
 max-width: 100%;
 padding: 0;
 border: 0;
}
.form-grid .fields-group.navigatormax-grid-size > label {
 display: inline-flex;
 align-items: center;
 align-self: center;
 min-height: 24px;
 line-height: 24px;
 flex: 0 0 auto;
 width: auto;
 max-width: 100%;
 margin: 0;
 padding: 0;
 white-space: nowrap;
 text-align: left;
}
.form-grid .fields-group.navigatormax-grid-size > .form-field {
 display: flex;
 align-items: center;
 align-self: center;
 min-height: 24px;
 line-height: 24px;
 flex: 0 0 auto;
 width: auto;
 min-width: 0;
 margin: 0;
}
.form-grid .fields-group.navigatormax-grid-size input {
 width: 64px !important;
 max-width: 100%;
 box-sizing: border-box;
}
.navigatormax-form .form-grid label.fields-group-label:has(+ .navigatormax-grid-size) {
 align-self: start;
 margin-top: 0;
 line-height: 24px;
}
.navigatormax-capacity {
 display: inline-block;
 align-self: center;
 flex: 0 1 auto;
 min-width: 0;
 max-width: 100%;
 margin: 0;
 padding: 0;
 border: 0;
 background: none;
 font-variant-numeric: tabular-nums;
 white-space: normal;
 overflow-wrap: anywhere;
 line-height: 24px;
}
@media (max-width: 600px) {
 .navigatormax-capacity { flex-basis: 100%; }
}

/* The 6.0 modal is display:table, whose intrinsic width can exceed max-width
   even with min-width removed. Only this legacy widget form needs block sizing. */
.overlay-dialogue.modal-popup.modal-popup-generic:has(#widget-dialogue-form.navigatormax-form) {
 display: block;
}
.overlay-dialogue.modal-popup.modal-popup-generic:has(#widget-dialogue-form.navigatormax-form) > .overlay-dialogue-body {
 box-sizing: border-box;
 min-width: 0;
 max-width: 100%;
}

/* Zabbix 6.0 renders Type/Name/Refresh as a table above the custom grid.
   Stack those native cells on a narrow screen as well as the widget fields. */
@media (max-width: 600px) {
 .navigatormax-form > .table-forms,
 .navigatormax-form > .table-forms > li {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
 }
 .navigatormax-form > .table-forms > li > :is(.table-forms-td-left, .table-forms-td-right) {
  display: block;
  width: auto;
  min-width: 0;
  max-width: 100%;
  text-align: left;
  box-sizing: border-box;
 }
 .navigatormax-form > .table-forms :is(input:not([type="checkbox"]):not([type="radio"]), select, z-select) {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
 }
 .overlay-dialogue.modal .navigatormax-form > .table-forms .table-forms-row-with-second-field .table-forms-second-column {
  position: static;
  margin-top: 6px;
 }
}

/* Saved calculation controls remain in the form for compatibility. The loader
   reveals a saved advanced filter explicitly; matching syntax belongs to each value. */
.navigatormax-form .js-nmax-pattern-mode { display: none !important; }
.navigatormax-form .navigatormax-step-note {
 font-size: 12px;
 line-height: 1.5;
 min-width: 0;
 max-width: 100%;
 white-space: normal;
 overflow-wrap: anywhere;
}

/* Native dialogue bodies inherit nowrap. Instructional text must wrap inside
   its own field instead of increasing the dialog's scroll width. */
:is(.navigatormax-form, .navigatormax-edit) :is(
 .navigatormax-pattern-hint, .navigatormax-step-note, .navigatormax-tiles-warning,
 .navigatormax-tiles-empty, .navigatormax-layout-caption, .navigatormax-pattern-kind,
 .navigatormax-page-divider, .navigatormax-source-note, .navigatormax-preview-note,
 .navigatormax-field-note, .navigatormax-edit-checkbox
) {
 min-width: 0;
 max-width: 100%;
 box-sizing: border-box;
 white-space: normal;
 overflow-wrap: anywhere;
}
.navigatormax-form .navigatormax-pattern-hint {
 margin: 6px 0 0;
 font-size: 12px;
 line-height: 1.5;
}

/* Include / Exclude uses the native select at the start of each selection row. */
.navigatormax-rule > .navigatormax-rule-include {
 grid-column: 2 / 3;
 grid-row: 1;
 width: 100%;
 min-width: 0;
 max-width: 100%;
}
.navigatormax-rule:has(> .navigatormax-rule-include) > .navigatormax-rule-type {
 grid-column: 3 / 5;
}
.navigatormax-rule:has(> .navigatormax-rule-include) > .js-host-mode {
 grid-column: 5 / 8;
}
.navigatormax-rule:is([data-type="4"], [data-type="5"]):has(> .navigatormax-rule-include) > .navigatormax-rule-type {
 grid-column-end: 8;
}

/* A small neutral schematic of one page. It uses the current Zabbix theme and
   does not imply severity colours or another live data preview. */
.navigatormax-layout-preview {
 display: flex;
 flex-direction: column;
 gap: 6px;
 min-width: 0;
 max-width: 100%;
}
.navigatormax-layout-grid {
 display: grid;
 grid-template-columns: repeat(4, minmax(0, 1fr));
 gap: 4px;
 width: min(360px, 100%);
 max-width: 100%;
 min-width: 0;
}
.navigatormax-layout-cell {
 display: flex;
 align-items: center;
 justify-content: center;
 min-width: 0;
 min-height: 20px;
 box-sizing: border-box;
 padding: 2px;
 border: 1px solid rgba(127, 127, 127, .45);
 background: rgba(127, 127, 127, .08);
 color: inherit;
 font-size: 10px;
 line-height: 14px;
 font-variant-numeric: tabular-nums;
 overflow-wrap: anywhere;
}
.navigatormax-layout-caption {
 font-size: 12px;
 line-height: 1.5;
 min-width: 0;
 max-width: 100%;
 white-space: normal;
 overflow-wrap: anywhere;
}
@media (max-width: 600px) {
 .navigatormax-rule > .navigatormax-rule-include { grid-column: 2 / 5; grid-row: 1; }
 .navigatormax-rule:has(> .navigatormax-rule-include) > .navigatormax-rule-type { grid-column: 5 / 8; grid-row: 1; }
 .navigatormax-rule:has(> .navigatormax-rule-include) > :is(.navigatormax-ac, .navigatormax-text, .navigatormax-rule-op) { grid-column: 2 / 8; grid-row: auto; }
 .navigatormax-rule:has(> .navigatormax-rule-include) > .js-host-mode { grid-column: 2 / 8; grid-row: 2; }
 .navigatormax-layout-grid { gap: 3px; }
}

/* React to the width left after the native form label, not just the browser width.
   Rules use observed width classes: inline-size containment in the native
   display:contents fieldset can omit their initial server-rendered children. */
.navigatormax-tiles-field { container: navigatormax-tiles / inline-size; }
.navigatormax-rule:has(> .navigatormax-rule-include) {
 grid-template-columns: 16px minmax(88px, 1fr) repeat(5, minmax(0, 1fr)) auto;
}
.navigatormax-rule .multiselect-control,
.navigatormax-image-control .multiselect-control {
 max-width: 100%;
 box-sizing: border-box;
}
.navigatormax-ac:has(> .navigatormax-pattern-kind) { flex-wrap: wrap; }
/* Two adjacent selectors keep their input baselines when one has no pattern hint.
   Reserve the ordinary single-line hint space and grow downwards for longer text. */
.navigatormax-rule > .navigatormax-ac:has(.navigatormax-native-picker) {
 align-self: start;
 align-content: flex-start;
 min-height: 44px;
}
.navigatormax-pattern-kind {
 display: flex;
 flex: 1 0 100%;
 flex-wrap: wrap;
 align-items: center;
 gap: 4px 8px;
 min-width: 0;
 max-width: 100%;
 box-sizing: border-box;
 font-size: 11px;
 line-height: 1.4;
 white-space: normal;
 overflow-wrap: anywhere;
}
.navigatormax-pattern-kind > .btn-link {
 flex: 0 1 auto;
 min-width: 0;
 max-width: 100%;
 height: auto;
 margin: 0;
 font-size: inherit;
 line-height: inherit;
 white-space: normal;
 text-align: left;
}
.navigatormax-pattern-kind[hidden] { display: none !important; }
.navigatormax-color-filter .navigatormax-ac { flex-wrap: wrap; min-width: 0; max-width: 100%; }
.navigatormax-pattern-error { flex: 1 0 100%; white-space: normal; overflow-wrap: anywhere; }
/* Native pickers and their hint are appended during initialization; the optional
   group scope always remains on the next line below both. */
.navigatormax-ac.js-group { flex-wrap: wrap; }
.navigatormax-ac.js-group > .navigatormax-pattern-kind { order: 1; }
.navigatormax-subgroups {
 order: 2;
 flex: 1 0 100%;
 min-width: 0;
 max-width: 100%;
 box-sizing: border-box;
 white-space: normal;
 overflow-wrap: anywhere;
}
.navigatormax-subgroups > label { max-width: 100%; white-space: normal; }

.navigatormax-rules-narrow .navigatormax-rule:has(> .navigatormax-rule-include) {
  grid-template-columns: 16px repeat(6, minmax(0, 1fr)) auto;
}
.navigatormax-rules-narrow .navigatormax-rule > .navigatormax-rule-include { grid-column: 2 / 4; grid-row: 1; }
.navigatormax-rules-narrow .navigatormax-rule:has(> .navigatormax-rule-include) > .navigatormax-rule-type { grid-column: 4 / 8; grid-row: 1; }
.navigatormax-rules-narrow .navigatormax-rule:has(> .navigatormax-rule-include) > :is(.navigatormax-ac, .navigatormax-text, .navigatormax-rule-op) {
  grid-column: 2 / 8;
  grid-row: auto;
}
.navigatormax-rules-narrow .navigatormax-rule:has(> .navigatormax-rule-include) > .js-host-mode { grid-column: 2 / 8; grid-row: 2; }
.navigatormax-rules-compact .navigatormax-rule > .navigatormax-rule-include { grid-column: 2 / 8; grid-row: 1; }
.navigatormax-rules-compact .navigatormax-rule:has(> .navigatormax-rule-include) > .navigatormax-rule-type { grid-column: 2 / 8; grid-row: 2; }
.navigatormax-rules-compact .navigatormax-rule:has(> .navigatormax-rule-include) > .js-host-mode { grid-row: 3; }
/* Keep the text centered beside both control rows. Very narrow viewports
   retain the stacked layout even when their tile container is wider than 400px. */
@media (min-width: 601px) {
 @container navigatormax-tiles (max-width: 680px) {
  .navigatormax-crow { grid-template-columns: 28px minmax(0, 1fr) fit-content(160px) 32px; }
  .navigatormax-crow-handle { grid-row: 1 / 3; }
  .navigatormax-crow-names { grid-row: 1 / 3; }
  .navigatormax-crow-icon { justify-self: end; }
  .navigatormax-crow-actions { grid-column: 3 / -1; grid-row: 2; }
 }
}
@container navigatormax-tiles (max-width: 400px) {
 .navigatormax-crow { grid-template-columns: 20px 32px minmax(32px, 1fr); gap: 6px; }
 .navigatormax-crow-handle { grid-column: 1; grid-row: 1 / 4; }
 .navigatormax-crow-names { grid-column: 2 / -1; grid-row: 1; }
 .navigatormax-crow-icon { grid-column: 2; grid-row: 2; justify-self: start; }
 .navigatormax-crow-colors { grid-column: 3; grid-row: 2; justify-content: flex-start; }
 .navigatormax-crow-actions { grid-column: 2 / -1; grid-row: 3; justify-content: flex-start; gap: 4px; }
 .navigatormax-crow-label { white-space: normal; overflow-wrap: anywhere; }
}

/* Legacy modals use table sizing, which otherwise ignores a responsive maximum. */
.overlay-dialogue.modal-popup.modal-popup-generic:is(.navigatormax-tile-dialog, .navigatormax-choice-dialog, .navigatormax-native-dialog) {
 display: block;
}
.overlay-dialogue:is(.navigatormax-tile-dialog, .navigatormax-choice-dialog, .navigatormax-native-dialog) > .overlay-dialogue-body {
 min-width: 0;
 max-width: 100%;
 box-sizing: border-box;
}

/* Only saved advanced expressions need a letter gutter beside the first selector.
   Preserve the responsive end line and the help icon's separate second-row column. */
.navigatormax-rule > .navigatormax-rule-letter:empty { display: none; }
.navigatormax-rule:has(> .navigatormax-rule-letter:empty) > .navigatormax-rule-include {
 grid-column-start: 1;
}

/* Keep the reason for a pending loader visible beside Apply, in every scroll position. */
.overlay-dialogue-footer.navigatormax-form-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.navigatormax-save-note { display: flex; align-items: flex-start; gap: 6px; flex: 1 1 240px; min-width: 0; max-width: 100%; text-align: left; white-space: normal; overflow-wrap: anywhere; font-size: 12px; line-height: 1.5; }
.navigatormax-save-note[hidden] { display: none; }
.navigatormax-save-note-text { min-width: 0; }
.navigatormax-save-warning { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 16px; width: 16px; height: 16px; margin-top: 1px; color: #e99003; font-size: 16px; line-height: 1; }
.navigatormax-save-warning[hidden] { display: none; }
.navigatormax-field-error { display: block; color: #e33734; font-size: 11px; line-height: 1.4; white-space: normal; overflow-wrap: anywhere; }
.navigatormax-form input.has-error, .navigatormax-edit input.has-error { border-color: #e33734; }
.navigatormax-validation-message { max-width: 100%; box-sizing: border-box; }
.navigatormax-form .multiselect.has-error { border-color: #e33734; }
.navigatormax-rule-error { flex-basis: 100%; }
