/**
 * Official floor plan: rendering, navigation, layers, legend, dashboard.
 * Status colours are supplied inline by MA_Plan::status_css().
 */

.ma-plan {
	--ma-plan-height: 80vh;
	--ma-ink: #1f2a24;
	--ma-ink-soft: #64726a;
	--ma-line: #dbe0d8;
	--ma-surface: #fff;
	--ma-surface-2: #f7f9f5;
	--ma-accent: #17251d;
	--ma-radius: 10px;
	font-family: inherit;
	color: var(--ma-ink);
}

/* --- Toolbar ----------------------------------------------------------- */

.ma-plan__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-bottom: 10px;
}

.ma-field {
	display: flex;
	align-items: center;
}

.ma-field--search {
	flex: 1 1 200px;
	min-width: 160px;
}

.ma-plan__toolbar input[type="search"],
.ma-plan__toolbar select {
	width: 100%;
	height: 34px;
	padding: 0 10px;
	font-size: 13px;
	color: var(--ma-ink);
	background: var(--ma-surface);
	border: 1px solid var(--ma-line);
	border-radius: 8px;
	box-shadow: none;
}

.ma-plan__toolbar select {
	width: auto;
	min-width: 140px;
}

.ma-plan .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.ma-plan__counter {
	margin-left: auto;
	font-size: 12px;
	color: var(--ma-ink-soft);
	font-variant-numeric: tabular-nums;
}

.ma-linkbtn {
	padding: 0;
	font-size: 12px;
	line-height: 1.4;
	color: #2b6b45;
	background: none;
	border: 0;
	border-bottom: 1px solid rgba(43, 107, 69, .35);
	cursor: pointer;
}

.ma-linkbtn:hover {
	color: #17251d;
	border-bottom-color: #17251d;
}

/* --- Layers ------------------------------------------------------------
   These rules are written with enough specificity to survive inside a
   dashboard panel: `.ma-panel label` would otherwise flatten the switch
   (this exact collision broke the toggles once). */

.ma-layers {
	margin-bottom: 10px;
	background: var(--ma-surface);
	border: 1px solid var(--ma-line);
	border-radius: var(--ma-radius);
	overflow: hidden;
}

.ma-layers__summary {
	display: flex;
	align-items: baseline;
	gap: 8px;
	padding: 10px 14px;
	cursor: pointer;
	list-style: none;
	background: var(--ma-surface-2);
	border-bottom: 1px solid transparent;
}

.ma-layers[open] .ma-layers__summary {
	border-bottom-color: var(--ma-line);
}

.ma-layers__summary::-webkit-details-marker {
	display: none;
}

.ma-layers__summary::before {
	content: "";
	width: 7px;
	height: 7px;
	border-right: 1.6px solid var(--ma-ink-soft);
	border-bottom: 1.6px solid var(--ma-ink-soft);
	transform: rotate(-45deg);
	transition: transform .15s ease;
	flex: none;
	align-self: center;
}

.ma-layers[open] .ma-layers__summary::before {
	transform: rotate(45deg);
}

.ma-layers__title {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .07em;
	color: var(--ma-ink);
}

.ma-layers__hint {
	font-size: 12px;
	color: var(--ma-ink-soft);
}

.ma-layers__body {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
	gap: 2px 14px;
	padding: 12px 14px;
}

.ma-layers .ma-switch {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 5px 0;
	font-size: 13px;
	cursor: pointer;
	user-select: none;
}

.ma-layers .ma-switch input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.ma-layers .ma-switch__box {
	display: block;
	position: relative;
	width: 32px;
	height: 18px;
	flex: none;
	background: #d3d9cf;
	border-radius: 999px;
	transition: background .15s ease;
}

.ma-layers .ma-switch__box::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 14px;
	height: 14px;
	background: #fff;
	border-radius: 50%;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
	transition: transform .15s ease;
}

.ma-layers .ma-switch input:checked + .ma-switch__box {
	background: #2b6b45;
}

.ma-layers .ma-switch input:checked + .ma-switch__box::after {
	transform: translateX(14px);
}

.ma-layers .ma-switch input:focus-visible + .ma-switch__box {
	outline: 2px solid #17251d;
	outline-offset: 2px;
}

.ma-layers .ma-switch__label {
	color: var(--ma-ink);
}

.ma-layers__actions {
	grid-column: 1 / -1;
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
	margin-top: 8px;
	padding-top: 10px;
	border-top: 1px dashed var(--ma-line);
}

/* --- Stage ------------------------------------------------------------- */

.ma-plan__stage {
	position: relative;
	background: var(--ma-surface-2);
	background-image:
		linear-gradient(rgba(31, 42, 36, .045) 1px, transparent 1px),
		linear-gradient(90deg, rgba(31, 42, 36, .045) 1px, transparent 1px);
	background-size: 26px 26px;
	border: 1px solid var(--ma-line);
	border-radius: var(--ma-radius);
	overflow: hidden;
}

.ma-plan__canvas {
	height: var(--ma-plan-height);
	touch-action: pan-y;
	cursor: grab;
}

.ma-plan__canvas.is-panning {
	cursor: grabbing;
}

.ma-plan__canvas > svg {
	display: block;
	width: 100%;
	height: 100%;
}

.ma-plan__nav {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

/* A theme can force padding on <button>; neutralised (root cause of the
   icon shift fixed back in v0.18.0). */
.ma-plan__btn {
	padding: 0;
	width: 34px;
	height: 34px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 17px;
	line-height: 1;
	color: var(--ma-ink);
	background: #fff;
	border: 1px solid var(--ma-line);
	border-radius: 8px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .07);
	cursor: pointer;
}

.ma-plan__btn:hover {
	background: var(--ma-surface-2);
}

/* --- Units ------------------------------------------------------------- */

.ma-unit {
	cursor: pointer;
}

.ma-plan[data-mode="admin"] .ma-unit:hover > path:first-of-type,
.ma-plan[data-mode="admin"] .ma-unit:hover > rect:first-of-type {
	stroke: #17251d;
	stroke-width: 1.4px;
}

.ma-unit[data-highlight="1"] > path:first-of-type,
.ma-unit[data-highlight="1"] > rect:first-of-type,
.ma-unit.is-found > path:first-of-type,
.ma-unit.is-found > rect:first-of-type {
	stroke: #873e2b;
	stroke-width: 2px;
}

.ma-unit.is-selected > path:first-of-type,
.ma-unit.is-selected > rect:first-of-type {
	stroke: #17251d;
	stroke-width: 2.2px;
}

/* Filtering dims, never hides: the plan must stay readable as a plan. */
.ma-unit.is-dimmed {
	opacity: .15;
}

.ma-unit-label {
	font-family: Arial, Helvetica, sans-serif;
	fill: #1f2a24;
	pointer-events: none;
	user-select: none;
}

/* --- Legend ------------------------------------------------------------ */

.ma-legend {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 12px;
	margin-top: 10px;
}

.ma-legend__title {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .07em;
	color: var(--ma-ink-soft);
}

.ma-legend__list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ma-chip {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 5px 11px;
	font-size: 12px;
	line-height: 1.5;
	color: var(--ma-ink);
	background: #fff;
	border: 1px solid var(--ma-line);
	border-radius: 999px;
	cursor: pointer;
}

.ma-chip:hover {
	border-color: #b9c2b4;
}

.ma-chip[aria-pressed="true"] {
	border-color: var(--ma-accent);
	box-shadow: inset 0 0 0 1px var(--ma-accent);
}

.ma-chip__dot {
	width: 12px;
	height: 12px;
	border-radius: 3px;
	border: 1px solid rgba(0, 0, 0, .2);
	flex: none;
}

.ma-chip__count {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.ma-plan-missing {
	padding: 16px;
	color: var(--ma-ink-soft);
	border: 1px dashed var(--ma-line);
	border-radius: var(--ma-radius);
}

/* =======================================================================
   Market status dashboard
   ======================================================================= */

.ma-status__h1 {
	margin-bottom: 6px;
}

.ma-status__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 370px;
	gap: 18px;
	align-items: start;
}

.ma-kpis {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
	gap: 12px;
	margin: 14px 0 18px;
}

.ma-kpi {
	display: flex;
	flex-direction: column;
	gap: 3px;
	padding: 14px 16px;
	background: #fff;
	border: 1px solid #dbe0d8;
	border-radius: 10px;
}

.ma-kpi--hero {
	color: #f3f6f0;
	background: #17251d;
	border-color: #17251d;
}

.ma-kpi__label {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: #6b7a70;
}

.ma-kpi--hero .ma-kpi__label,
.ma-kpi--hero .ma-kpi__sub {
	color: #9db3a5;
}

.ma-kpi__value {
	font-size: 30px;
	font-weight: 700;
	line-height: 1.1;
	font-variant-numeric: tabular-nums;
}

.ma-kpi__value small {
	font-size: 15px;
	font-weight: 600;
	opacity: .7;
}

.ma-kpi__sub {
	font-size: 12px;
	color: #6b7a70;
}

.ma-panel {
	padding: 14px 16px;
	margin-bottom: 16px;
	background: #fff;
	border: 1px solid #dbe0d8;
	border-radius: 10px;
}

.ma-panel--flush {
	padding: 0;
	overflow: hidden;
}

.ma-panel--flush .ma-panel__head {
	padding: 14px 16px 0;
}

.ma-panel--flush .ma-plan {
	padding: 0 16px 16px;
}

.ma-panel__head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
}

.ma-panel h2 {
	margin: 0 0 10px;
	font-size: 13px;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: #5d6b62;
}

.ma-panel__meta {
	margin: -4px 0 10px;
	font-size: 12px;
	color: #6b7a70;
}

.ma-panel__empty,
.ma-panel__hint {
	margin: 6px 0 0;
	font-size: 12px;
	color: #6b7a70;
}

.ma-panel__body label,
.ma-form label,
.ma-radio label {
	display: block;
	margin-bottom: 9px;
	font-size: 12px;
	font-weight: 600;
	color: #5d6b62;
}

.ma-panel__body select,
.ma-panel__body input[type="text"],
.ma-panel__body input[type="date"],
.ma-form select,
.ma-form input[type="text"] {
	display: block;
	width: 100%;
	margin-top: 3px;
	font-weight: 400;
}

.ma-grid2 {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0 10px;
}

.ma-panel__title {
	margin: 0 0 10px;
	font-size: 16px;
	font-weight: 700;
}

.ma-panel__actions {
	display: flex;
	align-items: center;
	gap: 12px;
}

.ma-panel__feedback {
	min-height: 1em;
	margin: 6px 0 0;
	font-size: 12px;
	color: #2b6b45;
}

.ma-panel__feedback.is-error {
	color: #8c1212;
}

.ma-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 12px;
}

.ma-table th {
	text-align: left;
	font-weight: 600;
	color: #6b7a70;
	border-bottom: 1px solid #e6eae2;
	padding: 5px 6px 5px 0;
}

.ma-table td {
	padding: 6px 6px 6px 0;
	border-bottom: 1px solid #f1f4ee;
	vertical-align: top;
}

.ma-muted {
	color: #a3ada6;
}

.ma-warn {
	color: #8a5a00;
}

.ma-sep {
	margin: 14px 0;
	border: 0;
	border-top: 1px solid #e6eae2;
}

.ma-form button {
	margin-top: 4px;
}

.ma-danger > summary {
	font-size: 12px;
	font-weight: 600;
	color: #8c1212;
	cursor: pointer;
}

.ma-radio label {
	display: flex;
	gap: 8px;
	font-weight: 400;
	line-height: 1.45;
}

.ma-btn-danger {
	color: #fff !important;
	background: #8c1212 !important;
	border-color: #6f0e0e !important;
}

.ma-bars__title {
	margin: 12px 0 6px;
	font-size: 12px;
	color: #5d6b62;
}

.ma-bars {
	margin: 0;
	padding: 0;
	list-style: none;
}

.ma-bars__row {
	display: grid;
	grid-template-columns: 90px minmax(0, 1fr) 38px;
	align-items: center;
	gap: 8px;
	margin-bottom: 5px;
	font-size: 12px;
}

.ma-bars__key {
	overflow: hidden;
	color: #5d6b62;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ma-bars__track {
	height: 9px;
	overflow: hidden;
	background: #eef1ea;
	border-radius: 3px;
}

.ma-bars__fill {
	display: block;
	height: 100%;
	background: #2b6b45;
	border-radius: 0 3px 3px 0;
}

.ma-bars__val {
	text-align: right;
	color: #1f2a24;
	font-variant-numeric: tabular-nums;
}

.ma-status-chip {
	display: inline-block;
	padding: 2px 9px;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.7;
	border-radius: 999px;
}

.ma-pill {
	display: inline-block;
	padding: 1px 7px;
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .04em;
	border-radius: 999px;
}

.ma-pill--warn {
	color: #4a3a05;
	background: #fbd45e;
}

.ma-pill--est {
	color: #5d6b62;
	background: #eef1ea;
}

.ma-stall-history {
	margin: 0;
	padding-left: 18px;
	font-size: 12px;
	color: #5d6b62;
}

.ma-stall-ident {
	font-size: 13px;
	color: #5d6b62;
}

/* --- Tablet & mobile ---------------------------------------------------
   The plan is the tool: on a phone it must behave exactly as on desktop,
   only stacked. Nothing is hidden away. */

@media (max-width: 1200px) {
	.ma-status__grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media (max-width: 782px) {
	.ma-plan {
		--ma-plan-height: 66vh;
	}

	.ma-kpis {
		grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
		gap: 8px;
	}

	.ma-kpi {
		padding: 11px 12px;
	}

	.ma-kpi__value {
		font-size: 24px;
	}

	.ma-layers__body {
		grid-template-columns: 1fr 1fr;
	}

	.ma-plan__toolbar {
		gap: 6px;
	}

	.ma-plan__toolbar select {
		flex: 1 1 auto;
		min-width: 0;
	}

	.ma-plan__counter {
		flex: 1 0 100%;
		margin-left: 0;
	}

	/* Bigger hit targets for fingers. */
	.ma-plan__btn {
		width: 42px;
		height: 42px;
		font-size: 19px;
	}

	.ma-chip {
		padding: 7px 12px;
	}

	.ma-switch {
		padding: 8px 0;
	}

	.ma-panel--flush .ma-plan {
		padding: 0 10px 12px;
	}

	.ma-bars__row {
		grid-template-columns: 74px minmax(0, 1fr) 34px;
	}
}

@media (max-width: 480px) {
	.ma-layers__body {
		grid-template-columns: 1fr;
	}

	.ma-grid2 {
		grid-template-columns: 1fr;
	}
}
