/**
 * Construction Company Management System — core UI.
 *
 * All rules are scoped under .mgscm-app so theme styles are not affected (and vice versa).
 * Components use the mg- prefix. Colors are tokens; dark mode redefines them.
 */

/* ------------------------------------------------------------------ *
 * Tokens
 * ------------------------------------------------------------------ */
.mgscm-app {
	--mg-font: Arial, Helvetica, sans-serif;
	--mg-bg: #f1f5f9;
	--mg-surface: #ffffff;
	--mg-surface-2: #f8fafc;
	--mg-surface-3: #eef2f7;
	--mg-border: #e2e8f0;
	--mg-border-strong: #cbd5e1;
	--mg-text: #1e293b;
	--mg-heading: #0f172a;
	--mg-muted: #64748b;
	--mg-faint: #94a3b8;
	--mg-input: #f1f5f9;
	--mg-input-border: #e2e8f0;

	--mg-accent: #f59e0b;
	--mg-accent-600: #d97706;
	--mg-accent-ink: #0b1220;
	--mg-accent-soft: rgba(245, 158, 11, 0.12);

	--mg-sidebar: #0f172a;
	--mg-sidebar-2: #020617;
	--mg-sidebar-text: #cbd5e1;
	--mg-sidebar-muted: #64748b;
	--mg-sidebar-hover: #1e293b;

	--mg-success: #059669;
	--mg-success-soft: rgba(16, 185, 129, 0.14);
	--mg-info: #2563eb;
	--mg-info-soft: rgba(59, 130, 246, 0.13);
	--mg-warning: #b45309;
	--mg-warning-soft: rgba(245, 158, 11, 0.16);
	--mg-danger: #dc2626;
	--mg-danger-soft: rgba(239, 68, 68, 0.12);
	--mg-purple: #7c3aed;
	--mg-purple-soft: rgba(139, 92, 246, 0.13);
	--mg-neutral: #475569;
	--mg-neutral-soft: rgba(100, 116, 139, 0.14);

	--mg-radius: 12px;
	--mg-radius-sm: 8px;
	--mg-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
	--mg-shadow-lg: 0 20px 45px rgba(2, 6, 23, 0.25);
	--mg-focus: 0 0 0 3px rgba(245, 158, 11, 0.45);
	--mg-sidebar-w: 260px;
	--mg-header-h: 64px;
	--mg-bottom-h: 64px;
}

.mgscm-app[data-theme="dark"] {
	--mg-bg: #020617;
	--mg-surface: #0f172a;
	--mg-surface-2: #0b1324;
	--mg-surface-3: #16213a;
	--mg-border: #1e293b;
	--mg-border-strong: #334155;
	--mg-text: #e2e8f0;
	--mg-heading: #ffffff;
	--mg-muted: #94a3b8;
	--mg-faint: #64748b;
	--mg-input: #1e293b;
	--mg-input-border: #273449;
	--mg-success: #34d399;
	--mg-info: #60a5fa;
	--mg-warning: #fbbf24;
	--mg-danger: #f87171;
	--mg-purple: #a78bfa;
	--mg-neutral: #cbd5e1;
	--mg-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ------------------------------------------------------------------ *
 * Base / reset (scoped)
 * ------------------------------------------------------------------ */
body.mgscm-fullscreen {
	margin: 0;
	padding: 0;
	background: #f1f5f9;
}

body.mgscm-fullscreen.mg-dark-body {
	background: #020617;
}

.mgscm-app,
.mgscm-app *,
.mgscm-app *::before,
.mgscm-app *::after {
	box-sizing: border-box;
}

.mgscm-app {
	font-family: var(--mg-font);
	font-size: 14px;
	line-height: 1.5;
	color: var(--mg-text);
	background: var(--mg-bg);
	-webkit-font-smoothing: antialiased;
	text-align: left;
}

.mgscm-app h1,
.mgscm-app h2,
.mgscm-app h3,
.mgscm-app h4,
.mgscm-app p,
.mgscm-app ul,
.mgscm-app ol,
.mgscm-app figure,
.mgscm-app fieldset,
.mgscm-app dl,
.mgscm-app dd {
	margin: 0;
	padding: 0;
	border: 0;
}

.mgscm-app ul,
.mgscm-app ol {
	list-style: none;
}

.mgscm-app a {
	color: inherit;
	text-decoration: none;
}

.mgscm-app img {
	max-width: 100%;
	height: auto;
	display: block;
}

.mgscm-app button,
.mgscm-app input,
.mgscm-app select,
.mgscm-app textarea {
	font: inherit;
	color: inherit;
	letter-spacing: normal;
	text-transform: none;
	margin: 0;
}

.mgscm-app button {
	cursor: pointer;
	background: none;
	border: 0;
	padding: 0;
	box-shadow: none;
}

.mgscm-app [hidden] {
	display: none !important;
}

.mgscm-app :focus-visible {
	outline: none;
	box-shadow: var(--mg-focus);
}

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

.mgscm-app .dashicons {
	width: 18px;
	height: 18px;
	font-size: 18px;
	line-height: 1;
	flex-shrink: 0;
	vertical-align: middle;
}

.mg-skip-link {
	position: absolute;
	left: -9999px;
	top: 8px;
	z-index: 100000;
	background: var(--mg-accent);
	color: var(--mg-accent-ink);
	padding: 8px 14px;
	border-radius: var(--mg-radius-sm);
	font-weight: 700;
}

.mg-skip-link:focus {
	left: 8px;
}

/* ------------------------------------------------------------------ *
 * Layout
 * ------------------------------------------------------------------ */
.mgscm-app#mgscm-app {
	display: flex;
	min-height: 100vh;
	min-height: 100dvh;
	position: relative;
}

.mg-sidebar {
	width: var(--mg-sidebar-w);
	background: var(--mg-sidebar);
	color: var(--mg-sidebar-text);
	display: flex;
	flex-direction: column;
	position: fixed;
	inset: 0 auto 0 0;
	z-index: 60;
	border-right: 1px solid #1e293b;
	transform: translateX(-100%);
	transition: transform 0.25s ease;
}

.mg-sidebar.is-open {
	transform: translateX(0);
	box-shadow: var(--mg-shadow-lg);
}

.mg-sidebar-overlay {
	position: fixed;
	inset: 0;
	background: rgba(2, 6, 23, 0.6);
	backdrop-filter: blur(2px);
	z-index: 55;
}

.mg-brand {
	height: var(--mg-header-h);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 0 16px 0 20px;
	background: var(--mg-sidebar-2);
	border-bottom: 1px solid #1e293b;
}

.mg-brand__link {
	display: flex;
	align-items: center;
	gap: 12px;
	min-width: 0;
}

.mg-brand__logo {
	width: 40px;
	height: 40px;
	border-radius: 10px;
	background: var(--mg-accent);
	color: var(--mg-accent-ink);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 6px 16px rgba(245, 158, 11, 0.25);
	flex-shrink: 0;
}

.mg-brand__logo--img {
	background: #fff;
	padding: 4px 8px;
	width: auto;
	height: auto;
	max-width: 100%;
	min-height: 40px;
}

.mg-brand__logo--img img {
	display: block;
	max-height: 40px;
	max-width: 190px;
	width: auto;
	height: auto;
	object-fit: contain;
}

/* With a logo: logo on top, company name below (wraps instead of truncating). */
.mg-brand:has(.mg-brand__logo--img) {
	height: auto;
	min-height: var(--mg-header-h);
	padding-top: 12px;
	padding-bottom: 12px;
	align-items: flex-start;
}

.mg-brand__link:has(.mg-brand__logo--img) {
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
}

.mg-brand__link:has(.mg-brand__logo--img) .mg-brand__name {
	white-space: normal;
}

.mg-brand--center:has(.mg-brand__logo--img) {
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 8px;
}

.mg-brand--center:has(.mg-brand__logo--img) .mg-brand__text {
	align-items: center;
}

.mg-brand--center .mg-brand__logo--img img {
	max-height: 56px;
	max-width: 240px;
}

.mg-brand__logo .dashicons {
	width: 22px;
	height: 22px;
	font-size: 22px;
}

.mg-brand__text {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.mg-brand__name {
	color: #fff;
	font-weight: 800;
	font-size: 15px;
	letter-spacing: 0.02em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mg-brand__tag {
	color: #94a3b8;
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.mg-sidebar__close {
	color: #94a3b8;
}

.mg-nav {
	flex: 1;
	overflow-y: auto;
	padding: 16px 12px;
}

.mg-nav__group + .mg-nav__group {
	margin-top: 18px;
}

.mg-nav__heading {
	padding: 0 12px 8px;
	font-size: 11px;
	font-weight: 700;
	color: var(--mg-sidebar-muted);
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

.mg-nav__list li + li {
	margin-top: 2px;
}

.mg-nav__link {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	border-radius: var(--mg-radius-sm);
	font-weight: 500;
	color: var(--mg-sidebar-text);
	transition: background 0.15s, color 0.15s;
}

.mg-nav__link:hover {
	background: var(--mg-sidebar-hover);
	color: #fff;
}

.mg-nav__link.is-active {
	background: var(--mg-accent);
	color: var(--mg-accent-ink);
	font-weight: 700;
	box-shadow: 0 6px 14px rgba(245, 158, 11, 0.18);
}

.mg-user {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	border-top: 1px solid #1e293b;
	background: rgba(2, 6, 23, 0.7);
}

.mg-user__avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: 2px solid var(--mg-accent);
}

.mg-user__info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
}

.mg-user__name {
	color: #fff;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mg-user__role {
	font-size: 12px;
	color: #94a3b8;
}

.mg-user__logout {
	color: #94a3b8;
}

.mg-main {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
}

.mg-header {
	height: var(--mg-header-h);
	position: sticky;
	top: 0;
	z-index: 40;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 0 16px;
	background: var(--mg-surface);
	border-bottom: 1px solid var(--mg-border);
	box-shadow: var(--mg-shadow);
}

.mg-header__title {
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 1;
}

.mg-header__company {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--mg-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mg-header__view {
	font-weight: 700;
	color: var(--mg-heading);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mg-header__actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.mg-clock {
	display: none;
	flex-direction: column;
	text-align: right;
	padding-right: 12px;
	margin-right: 4px;
	border-right: 1px solid var(--mg-border);
}

.mg-clock__time {
	font-size: 12px;
	font-weight: 700;
	color: var(--mg-heading);
}

.mg-clock__date {
	font-size: 11px;
	color: var(--mg-muted);
}

.mg-content {
	flex: 1;
	padding: 16px 16px calc(var(--mg-bottom-h) + 24px);
	outline: none;
}

.mg-page {
	max-width: 1400px;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* Bottom nav (mobile) */
.mg-bottom-nav {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 45;
	height: calc(var(--mg-bottom-h) + env(safe-area-inset-bottom, 0px));
	padding-bottom: env(safe-area-inset-bottom, 0px);
	display: flex;
	background: var(--mg-surface);
	border-top: 1px solid var(--mg-border);
	box-shadow: 0 -4px 14px rgba(15, 23, 42, 0.06);
}

.mg-bottom-nav__item {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 3px;
	font-size: 11px;
	font-weight: 600;
	color: var(--mg-muted);
	min-width: 0;
}

.mg-bottom-nav__item span:last-child {
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	padding: 0 4px;
}

.mg-bottom-nav__item.is-active {
	color: var(--mg-accent-600);
}

.mgscm-app[data-theme="dark"] .mg-bottom-nav__item.is-active {
	color: var(--mg-accent);
}

/* Desktop layout */
@media (min-width: 1024px) {
	.mg-sidebar {
		position: sticky;
		top: 0;
		height: 100vh;
		height: 100dvh;
		transform: none;
		flex-shrink: 0;
	}

	.mg-sidebar__close,
	.mg-header__menu,
	.mg-sidebar-overlay,
	.mg-bottom-nav {
		display: none !important;
	}

	.mg-header {
		padding: 0 24px;
	}

	.mg-content {
		padding: 24px;
	}

	.mg-page {
		gap: 20px;
	}
}

@media (min-width: 1200px) {
	.mg-clock {
		display: flex;
	}
}

/* Embedded mode (inside a theme page) */
.mgscm-app:not(.mg-auth) .mg-embedded-note {
	display: none;
}

/* ------------------------------------------------------------------ *
 * Page header
 * ------------------------------------------------------------------ */
.mg-page-header {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 12px;
}

.mg-page-header__text {
	min-width: 0;
}

.mg-page-title {
	font-size: 22px;
	line-height: 1.25;
	font-weight: 800;
	color: var(--mg-heading);
	word-break: break-word;
}

.mg-page-subtitle {
	color: var(--mg-muted);
	margin-top: 2px;
}

.mg-page-header__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.mg-back {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	font-size: 13px;
	font-weight: 600;
	color: var(--mg-muted);
	margin-bottom: 4px;
}

.mg-back:hover {
	color: var(--mg-accent-600);
}

/* ------------------------------------------------------------------ *
 * Buttons
 * ------------------------------------------------------------------ */
.mgscm-app .mg-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-height: 40px;
	padding: 8px 16px;
	border-radius: var(--mg-radius-sm);
	border: 1px solid transparent;
	font-size: 13px;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
	transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
	position: relative;
	text-decoration: none;
}

.mgscm-app .mg-btn--sm {
	min-height: 34px;
	padding: 6px 12px;
	font-size: 12px;
}

.mgscm-app .mg-btn--primary {
	background: var(--mg-accent);
	color: var(--mg-accent-ink);
}

.mgscm-app .mg-btn--primary:hover {
	background: var(--mg-accent-600);
}

.mgscm-app .mg-btn--secondary {
	background: var(--mg-surface);
	color: var(--mg-text);
	border-color: var(--mg-border-strong);
}

.mgscm-app .mg-btn--secondary:hover {
	background: var(--mg-surface-3);
}

.mgscm-app .mg-btn--ghost {
	background: transparent;
	color: var(--mg-muted);
}

.mgscm-app .mg-btn--ghost:hover {
	background: var(--mg-surface-3);
	color: var(--mg-text);
}

.mgscm-app .mg-btn--danger {
	background: var(--mg-danger);
	color: #fff;
}

.mgscm-app[data-theme="dark"] .mg-btn--danger {
	background: #dc2626;
}

.mgscm-app .mg-btn--danger:hover {
	filter: brightness(0.92);
}

.mgscm-app .mg-btn--danger-ghost {
	background: transparent;
	color: var(--mg-danger);
	border-color: var(--mg-danger-soft);
}

.mgscm-app .mg-btn--danger-ghost:hover {
	background: var(--mg-danger-soft);
}

.mgscm-app .mg-btn--success {
	background: var(--mg-success-soft);
	color: var(--mg-success);
}

.mgscm-app .mg-btn--success:hover {
	filter: brightness(0.95);
}

.mgscm-app .mg-btn[disabled],
.mgscm-app .mg-btn.is-loading {
	opacity: 0.7;
	cursor: not-allowed;
	pointer-events: none;
}

.mgscm-app .mg-btn .mg-spinner {
	display: none;
}

.mgscm-app .mg-btn.is-loading .mg-spinner {
	display: inline-block;
}

.mgscm-app .mg-btn.is-loading .dashicons {
	display: none;
}

.mgscm-app .mg-icon-btn {
	width: 38px;
	height: 38px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--mg-radius-sm);
	color: var(--mg-muted);
	transition: background 0.15s, color 0.15s;
	flex-shrink: 0;
}

.mgscm-app .mg-icon-btn:hover {
	background: var(--mg-surface-3);
	color: var(--mg-text);
}

.mg-sidebar .mg-icon-btn:hover {
	background: var(--mg-sidebar-hover);
	color: #fff;
}

.mg-row-actions {
	display: inline-flex;
	gap: 2px;
	justify-content: flex-end;
}

.mg-row-actions .mg-icon-btn {
	width: 34px;
	height: 34px;
}

.mg-row-actions .mg-icon-btn--danger:hover {
	color: var(--mg-danger);
	background: var(--mg-danger-soft);
}

.mg-row-actions .mg-icon-btn--success:hover {
	color: var(--mg-success);
	background: var(--mg-success-soft);
}

.mg-link {
	color: var(--mg-accent-600);
	font-weight: 600;
	font-size: 13px;
	white-space: nowrap;
}

.mgscm-app[data-theme="dark"] .mg-link {
	color: var(--mg-accent);
}

.mg-link:hover {
	text-decoration: underline;
}

.mg-strong-link {
	font-weight: 700;
	color: var(--mg-heading);
}

.mg-strong-link:hover {
	color: var(--mg-accent-600);
}

/* ------------------------------------------------------------------ *
 * Cards, grids
 * ------------------------------------------------------------------ */
.mg-card {
	background: var(--mg-surface);
	border: 1px solid var(--mg-border);
	border-radius: var(--mg-radius);
	box-shadow: var(--mg-shadow);
	padding: 16px;
	min-width: 0;
}

.mg-card--flush {
	padding: 0;
	overflow: hidden;
}

.mg-card__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding-bottom: 14px;
	margin-bottom: 14px;
	border-bottom: 1px solid var(--mg-border);
	flex-wrap: wrap;
}

.mg-card__header--padded {
	padding: 16px;
	margin: 0;
}

.mg-card__title {
	font-size: 15px;
	font-weight: 700;
	color: var(--mg-heading);
}

.mg-card > .mg-card__title {
	margin-bottom: 12px;
}

.mg-card__subtitle {
	font-size: 12px;
	color: var(--mg-muted);
	margin-top: 2px;
}

.mg-grid-2 {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 16px;
}

@media (min-width: 1024px) {
	.mg-grid-2 {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 20px;
	}

	.mg-card {
		padding: 20px;
	}

	.mg-card--flush {
		padding: 0;
	}

	.mg-card__header--padded {
		padding: 18px 20px;
	}
}

/* KPIs */
.mg-kpis {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
}

@media (min-width: 1024px) {
	.mg-kpis {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: 20px;
	}
}

.mg-kpi {
	background: var(--mg-surface);
	border: 1px solid var(--mg-border);
	border-radius: var(--mg-radius);
	box-shadow: var(--mg-shadow);
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
	transition: border-color 0.15s, transform 0.15s;
}

a.mg-kpi:hover {
	border-color: var(--mg-accent);
	transform: translateY(-1px);
}

.mg-kpi__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.mg-kpi__label {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--mg-muted);
}

.mg-kpi__icon {
	width: 38px;
	height: 38px;
	border-radius: 10px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.mg-kpi__value {
	font-size: 24px;
	font-weight: 800;
	color: var(--mg-heading);
	line-height: 1.1;
}

.mg-kpi__hint {
	font-size: 12px;
	color: var(--mg-muted);
}

.mg-tone-warning { background: var(--mg-warning-soft); color: var(--mg-warning); }
.mg-tone-info { background: var(--mg-info-soft); color: var(--mg-info); }
.mg-tone-success { background: var(--mg-success-soft); color: var(--mg-success); }
.mg-tone-danger { background: var(--mg-danger-soft); color: var(--mg-danger); }
.mg-tone-purple { background: var(--mg-purple-soft); color: var(--mg-purple); }
.mg-tone-neutral { background: var(--mg-neutral-soft); color: var(--mg-neutral); }

/* Stat tiles (details pages) */
.mg-stats {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
}

@media (min-width: 768px) {
	.mg-stats {
		grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
	}
}

@media (min-width: 768px) {
	.mg-stats--4 {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

.mg-stat {
	background: var(--mg-surface);
	border: 1px solid var(--mg-border);
	border-radius: var(--mg-radius);
	padding: 14px;
	min-width: 0;
}

.mg-stat__label {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--mg-muted);
}

.mg-stat__value {
	font-size: 19px;
	font-weight: 800;
	color: var(--mg-heading);
	margin-top: 4px;
	word-break: break-word;
}

/* Links inside stat cards (e.g. a long project name) must wrap instead of overflowing the card. */
.mg-stat__value .mg-link {
	display: inline-block;
	max-width: 100%;
	white-space: normal;
	overflow-wrap: anywhere;
	line-height: 1.35;
}

.mg-stat__hint {
	font-size: 12px;
	color: var(--mg-muted);
}

/* Quick actions */
.mg-quick-actions__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
	gap: 10px;
}

.mg-quick-action {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 14px 10px;
	border-radius: var(--mg-radius-sm);
	border: 1px dashed var(--mg-border-strong);
	font-weight: 600;
	font-size: 13px;
	text-align: center;
	color: var(--mg-text);
	transition: border-color 0.15s, background 0.15s;
}

.mg-quick-action .dashicons {
	color: var(--mg-accent-600);
	width: 24px;
	height: 24px;
	font-size: 24px;
}

.mg-quick-action:hover {
	border-color: var(--mg-accent);
	background: var(--mg-accent-soft);
}

/* Definition list */
.mg-dl {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 14px 24px;
}

@media (min-width: 640px) {
	.mg-dl {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 1200px) {
	.mg-dl--3 {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

.mg-dl__item dt {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--mg-muted);
}

.mg-dl__item dd {
	margin-top: 2px;
	color: var(--mg-heading);
	font-weight: 500;
	word-break: break-word;
}

.mg-dl__item--full {
	grid-column: 1 / -1;
}

.mg-prose {
	white-space: pre-line;
	color: var(--mg-text);
}

.mg-muted {
	color: var(--mg-muted);
}

.mg-small {
	font-size: 12px;
}

.mg-dash {
	color: var(--mg-faint);
}

.mg-stack {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* ------------------------------------------------------------------ *
 * Badges, progress
 * ------------------------------------------------------------------ */
.mg-badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 3px 9px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 700;
	white-space: nowrap;
	line-height: 1.4;
}

.mg-badge::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
}

.mg-badge--warning { background: var(--mg-warning-soft); color: var(--mg-warning); }
.mg-badge--info { background: var(--mg-info-soft); color: var(--mg-info); }
.mg-badge--success { background: var(--mg-success-soft); color: var(--mg-success); }
.mg-badge--danger { background: var(--mg-danger-soft); color: var(--mg-danger); }
.mg-badge--purple { background: var(--mg-purple-soft); color: var(--mg-purple); }
.mg-badge--neutral { background: var(--mg-neutral-soft); color: var(--mg-neutral); }

.mg-badge--plain::before {
	display: none;
}

.mg-progress {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 110px;
}

.mg-progress__bar {
	flex: 1;
	height: 6px;
	border-radius: 999px;
	background: var(--mg-surface-3);
	overflow: hidden;
}

.mg-progress__fill {
	height: 100%;
	border-radius: 999px;
	background: var(--mg-accent);
	transition: width 0.4s ease;
}

.mg-progress__fill--done {
	background: var(--mg-success);
}

.mg-progress__value {
	font-size: 12px;
	font-weight: 700;
	color: var(--mg-heading);
	min-width: 34px;
	text-align: right;
}

.mg-progress--lg .mg-progress__bar {
	height: 10px;
}

/* ------------------------------------------------------------------ *
 * Forms
 * ------------------------------------------------------------------ */
.mg-grid {
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	gap: 14px 16px;
}

.mg-col-full,
.mg-col-half,
.mg-col-third,
.mg-col-two-thirds,
.mg-col-quarter {
	grid-column: span 12;
	min-width: 0;
}

@media (min-width: 640px) {
	.mg-col-half { grid-column: span 6; }
	.mg-col-third { grid-column: span 6; }
	.mg-col-quarter { grid-column: span 6; }
	.mg-col-two-thirds { grid-column: span 12; }
}

@media (min-width: 900px) {
	.mg-col-third { grid-column: span 4; }
	.mg-col-two-thirds { grid-column: span 8; }
	.mg-col-quarter { grid-column: span 3; }
}

.mg-field {
	display: flex;
	flex-direction: column;
	gap: 5px;
}

.mgscm-app .mg-label {
	display: block;
	font-size: 12px;
	font-weight: 700;
	color: var(--mg-text);
	letter-spacing: 0.01em;
}

.mg-req {
	color: var(--mg-danger);
	font-weight: 800;
}

.mgscm-app .mg-input {
	width: 100%;
	min-height: 40px;
	padding: 8px 12px;
	border-radius: var(--mg-radius-sm);
	border: 1px solid var(--mg-input-border);
	background: var(--mg-input);
	color: var(--mg-text);
	font-size: 14px;
	line-height: 1.4;
	box-shadow: none;
	transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
	-webkit-appearance: none;
	appearance: none;
}

.mgscm-app select.mg-input {
	padding-right: 34px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
}

.mgscm-app textarea.mg-input {
	min-height: 84px;
	resize: vertical;
}

.mgscm-app input[type="file"].mg-input {
	padding: 7px;
	background: var(--mg-surface-2);
	border-style: dashed;
}

.mgscm-app .mg-input:focus {
	outline: none;
	border-color: var(--mg-accent);
	box-shadow: var(--mg-focus);
	background: var(--mg-surface);
}

.mgscm-app .mg-input::placeholder {
	color: var(--mg-faint);
}

.mgscm-app .mg-input--sm {
	min-height: 34px;
	padding: 6px 10px;
	font-size: 13px;
}

.mgscm-app .mg-input[aria-invalid="true"] {
	border-color: var(--mg-danger);
	background: var(--mg-danger-soft);
}

.mg-help {
	font-size: 12px;
	color: var(--mg-muted);
}

.mg-error {
	font-size: 12px;
	font-weight: 600;
	color: var(--mg-danger);
	min-height: 0;
}

.mg-error:empty {
	display: none;
}

.mg-form-note {
	font-size: 12px;
	color: var(--mg-muted);
	margin-bottom: 12px;
}

.mg-form-section {
	font-size: 12px;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--mg-muted);
	padding-top: 6px;
	border-top: 1px solid var(--mg-border);
	margin-top: 4px;
}

.mg-form-section:first-of-type {
	border-top: 0;
	padding-top: 0;
	margin-top: 0;
}

.mg-form-alert {
	padding: 10px 12px;
	border-radius: var(--mg-radius-sm);
	background: var(--mg-danger-soft);
	color: var(--mg-danger);
	font-weight: 600;
	margin-bottom: 14px;
}

.mg-check {
	display: inline-flex;
	align-items: flex-start;
	gap: 8px;
	cursor: pointer;
	font-weight: 500;
}

.mgscm-app .mg-check input {
	width: 18px;
	height: 18px;
	margin-top: 1px;
	accent-color: var(--mg-accent-600);
	flex-shrink: 0;
}

.mg-check-row {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 20px;
	padding-top: 4px;
}

.mg-output {
	display: flex;
	align-items: center;
	min-height: 40px;
	padding: 8px 12px;
	border-radius: var(--mg-radius-sm);
	background: var(--mg-accent-soft);
	font-weight: 800;
	color: var(--mg-heading);
}

.mg-hours-preview {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 10px 12px;
	border-radius: var(--mg-radius-sm);
	background: var(--mg-accent-soft);
	color: var(--mg-heading);
}

.mg-field--actions {
	flex-direction: row;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 8px;
}

.mg-sticky-actions {
	position: sticky;
	bottom: calc(var(--mg-bottom-h) + 8px);
	z-index: 20;
	display: flex;
	justify-content: flex-end;
	padding: 12px;
	background: var(--mg-surface);
	border: 1px solid var(--mg-border);
	border-radius: var(--mg-radius);
	box-shadow: 0 -4px 14px rgba(15, 23, 42, 0.08);
}

@media (min-width: 1024px) {
	.mg-sticky-actions {
		bottom: 12px;
	}
}

.mg-settings {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* Equipment picker */
.mg-eq-picker {
	border: 1px solid var(--mg-input-border);
	border-radius: var(--mg-radius-sm);
	padding: 10px;
	background: var(--mg-surface-2);
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.mg-eq-picker__selected {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	min-height: 28px;
	align-items: center;
}

.mg-sel-chip {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 3px 4px 3px 10px;
	border-radius: 999px;
	background: var(--mg-accent);
	color: var(--mg-accent-ink);
	font-size: 12px;
	font-weight: 700;
	max-width: 100%;
}

.mgscm-app .mg-sel-chip__x {
	width: 20px;
	height: 20px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	color: inherit;
}

.mgscm-app .mg-sel-chip__x:hover {
	background: rgba(0, 0, 0, 0.12);
}

.mg-eq-picker__list {
	max-height: 280px;
	overflow-y: auto;
	border: 1px solid var(--mg-border);
	border-radius: var(--mg-radius-sm);
	background: var(--mg-surface);
	overscroll-behavior: contain;
}

.mg-eq-row {
	display: grid;
	grid-template-columns: auto minmax(0, 1.4fr) minmax(0, 1.2fr) auto;
	align-items: center;
	gap: 10px;
	padding: 9px 12px;
	border-bottom: 1px solid var(--mg-border);
	cursor: pointer;
}

.mg-eq-row:last-child {
	border-bottom: 0;
}

.mg-eq-row:hover:not(.is-disabled) {
	background: var(--mg-accent-soft);
}

.mg-eq-row.is-selected {
	background: var(--mg-accent-soft);
}

.mg-eq-row.is-disabled {
	cursor: not-allowed;
	opacity: 0.6;
}

.mgscm-app .mg-eq-row input {
	width: 18px;
	height: 18px;
	accent-color: var(--mg-accent-600);
}

.mg-eq-row__main,
.mg-eq-row__meta {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.mg-eq-row__name {
	font-weight: 700;
	color: var(--mg-heading);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mg-eq-row__sub,
.mg-eq-row__meta {
	font-size: 12px;
	color: var(--mg-muted);
}

.mg-eq-row__sub {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mg-eq-row__meta strong {
	color: var(--mg-text);
	font-weight: 600;
}

.mg-eq-loading,
.mg-eq-error {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 12px;
	color: var(--mg-muted);
	font-size: 12px;
	font-weight: 600;
}

@media (max-width: 640px) {
	.mg-eq-row {
		grid-template-columns: auto minmax(0, 1fr) auto;
	}

	.mg-eq-row__meta {
		grid-column: 2 / 4;
		flex-direction: row;
		flex-wrap: wrap;
		gap: 2px 12px;
	}
}

/* User picker */
.mg-user-picker {
	position: relative;
}

.mg-user-picker__results {
	position: absolute;
	left: 0;
	right: 0;
	top: calc(100% + 4px);
	z-index: 5;
	background: var(--mg-surface);
	border: 1px solid var(--mg-border);
	border-radius: var(--mg-radius-sm);
	box-shadow: var(--mg-shadow-lg);
	max-height: 220px;
	overflow-y: auto;
}

.mg-user-picker__results li {
	padding: 9px 12px;
	cursor: pointer;
	font-size: 13px;
}

.mg-user-picker__results li:hover,
.mg-user-picker__results li[aria-selected="true"] {
	background: var(--mg-accent-soft);
}

.mg-user-picker__results li.is-disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

.mg-user-picker__selected {
	margin-top: 8px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 8px 10px;
	border-radius: var(--mg-radius-sm);
	background: var(--mg-success-soft);
	font-weight: 600;
}

/* Upload preview */
.mg-upload-preview {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
	gap: 8px;
}

.mg-upload-preview img {
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
	border-radius: var(--mg-radius-sm);
	border: 1px solid var(--mg-border);
}

/* Deductions editor */
.mg-deductions {
	margin-top: 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.mg-deductions__rows {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.mg-deductions__row {
	display: grid;
	grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
	gap: 8px;
	align-items: center;
}

/* Activity expenses editor (reuses the deductions row layout) */
.mgscm-app .mg-expenses {
	margin: 30px 0;
	padding: 16px;
	border: 1px solid var(--mg-border-strong, var(--mg-border));
	border-radius: var(--mg-radius-sm);
	min-width: 0;
}

.mg-expenses__foot {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
}

.mg-expenses__total {
	font-size: 13px;
	color: var(--mg-muted);
}

.mg-expenses__total strong {
	color: var(--mg-heading);
}

/* ------------------------------------------------------------------ *
 * Toolbar, lists, tables
 * ------------------------------------------------------------------ */
.mg-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 12px 16px;
	border-bottom: 1px solid var(--mg-border);
	align-items: center;
}

.mg-search {
	position: relative;
	flex: 1 1 220px;
	min-width: 0;
	display: block;
}

.mg-search .dashicons {
	position: absolute;
	left: 10px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--mg-faint);
	pointer-events: none;
	width: 16px;
	height: 16px;
	font-size: 16px;
}

.mgscm-app .mg-search .mg-input {
	padding-left: 34px;
	min-height: 36px;
}

.mg-filter {
	flex: 1 1 150px;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 6px;
}

.mgscm-app .mg-filter .mg-input {
	min-height: 36px;
	font-size: 13px;
	padding-top: 6px;
	padding-bottom: 6px;
}

.mg-filter__label {
	font-size: 12px;
	font-weight: 600;
	color: var(--mg-muted);
	white-space: nowrap;
}

@media (min-width: 1024px) {
	.mg-search {
		flex: 1 1 260px;
	}

	.mg-filter {
		flex: 0 1 190px;
	}

	.mg-filter--date {
		flex: 0 1 200px;
	}
}

.mg-filter-dates {
	display: flex;
	flex: 1 1 280px;
	flex-wrap: nowrap;
	gap: 8px;
	min-width: 0;
}

.mg-filter-break {
	flex-basis: 100%;
	height: 0;
}

.mg-filter-dates .mg-filter--date {
	flex: 1 1 0;
}

@media (max-width: 767px) {
	.mg-filter-dates .mg-filter--date {
		flex-direction: column;
		align-items: stretch;
		gap: 2px;
	}

	.mg-filter-dates .mg-filter--date .mg-input {
		width: 100%;
	}
}

@media (min-width: 768px) {
	.mg-filter-dates {
		flex: 0 1 420px;
	}
}

.mg-bulkbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	padding: 10px 16px;
	background: var(--mg-accent-soft);
	border-bottom: 1px solid var(--mg-border);
	font-weight: 600;
}

.mgscm-app .mg-list-totals {
	margin: 0;
	padding: 20px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.01em;
	color: var(--mg-heading);
	background: var(--mg-neutral-soft);
	border-bottom: 1px solid var(--mg-border);
}

.mgscm-app .mg-list-totals:empty {
	display: none;
}

.mg-table-wrap {
	width: 100%;
	overflow-x: auto;
	position: relative;
}

.mgscm-app .mg-table {
	width: 100%;
	border-collapse: collapse;
	border-spacing: 0;
	margin: 0;
	border: 0;
	font-size: 13px;
}

.mgscm-app .mg-table th {
	background: var(--mg-surface-2);
	color: var(--mg-muted);
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	text-align: left;
	padding: 11px 14px;
	border: 0;
	border-bottom: 1px solid var(--mg-border);
	white-space: nowrap;
}

.mgscm-app .mg-table td {
	padding: 12px 14px;
	border: 0;
	border-bottom: 1px solid var(--mg-border);
	vertical-align: middle;
	background: transparent;
}

.mgscm-app .mg-table tbody tr {
	transition: background 0.12s;
}

.mgscm-app .mg-table tbody tr:hover {
	background: var(--mg-surface-2);
}

.mgscm-app .mg-table tbody tr.is-muted {
	opacity: 0.7;
}

.mg-table .mg-num {
	text-align: right;
	white-space: nowrap;
}

.mg-table .mg-actions-col {
	text-align: right;
	width: 1%;
	white-space: nowrap;
}

.mg-table .mg-check-col {
	width: 1%;
}

.mg-sort {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font: inherit;
	color: inherit;
	text-transform: inherit;
	letter-spacing: inherit;
}

.mg-sort:hover {
	color: var(--mg-heading);
}

.mg-sort__icon::after {
	content: "↕";
	font-size: 11px;
	opacity: 0.45;
}

th[aria-sort="ascending"] .mg-sort__icon::after {
	content: "↑";
	opacity: 1;
	color: var(--mg-accent-600);
}

th[aria-sort="descending"] .mg-sort__icon::after {
	content: "↓";
	opacity: 1;
	color: var(--mg-accent-600);
}

.mg-cell-title {
	font-weight: 700;
	color: var(--mg-heading);
	display: block;
}

.mg-cell-sub {
	display: block;
	font-size: 12px;
	color: var(--mg-muted);
	margin-top: 1px;
}

.mg-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: var(--mg-accent-soft);
	color: var(--mg-accent-600);
	font-weight: 800;
	font-size: 13px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.mg-avatar--lg {
	width: 64px;
	height: 64px;
	font-size: 22px;
}

.mg-person {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.mg-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-top: 6px;
}

.mg-tag {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	padding: 2px 8px;
	border-radius: 6px;
	background: var(--mg-surface-3);
	color: var(--mg-text);
	font-size: 11px;
	font-weight: 600;
}

.mg-tag .dashicons {
	width: 12px;
	height: 12px;
	font-size: 12px;
}

/* Table states */
.mg-table-state td {
	padding: 0 !important;
}

.mg-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 8px;
	padding: 40px 20px;
}

.mg-state--subtle {
	padding: 32px 20px;
	border: 1px dashed var(--mg-border-strong);
	border-radius: var(--mg-radius);
	background: var(--mg-surface);
}

.mg-state__icon {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--mg-surface-3);
	color: var(--mg-muted);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 4px;
}

.mg-state__icon .dashicons {
	width: 26px;
	height: 26px;
	font-size: 26px;
}

.mg-state--error .mg-state__icon {
	background: var(--mg-danger-soft);
	color: var(--mg-danger);
}

.mg-state__title {
	font-size: 15px;
	font-weight: 700;
	color: var(--mg-heading);
}

.mg-state__text {
	color: var(--mg-muted);
	max-width: 420px;
}

.mg-state .mg-btn {
	margin-top: 8px;
}

.mg-inline-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 32px 16px;
	color: var(--mg-muted);
	font-weight: 600;
}

.mg-skeleton-row td {
	padding: 14px !important;
}

.mg-skeleton {
	display: block;
	height: 12px;
	border-radius: 6px;
	background: linear-gradient(90deg, var(--mg-surface-3) 25%, var(--mg-border) 37%, var(--mg-surface-3) 63%);
	background-size: 400% 100%;
	animation: mg-shimmer 1.3s ease infinite;
	width: 80%;
}

.mg-skeleton--sm { width: 45%; height: 10px; }
.mg-skeleton--lg { width: 60%; height: 22px; }

@keyframes mg-shimmer {
	0% { background-position: 100% 50%; }
	100% { background-position: 0 50%; }
}

/* Pagination */
.mg-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 12px 16px;
}

.mg-pagination:empty {
	display: none;
}

.mg-pagination__info {
	font-size: 12px;
	color: var(--mg-muted);
}

.mg-pagination__pages {
	display: flex;
	gap: 4px;
	flex-wrap: wrap;
}

.mg-page-btn {
	min-width: 34px;
	height: 34px;
	padding: 0 10px;
	border-radius: var(--mg-radius-sm);
	border: 1px solid var(--mg-border);
	background: var(--mg-surface);
	font-size: 13px;
	font-weight: 600;
	color: var(--mg-text);
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.mg-page-btn:hover:not([disabled]) {
	border-color: var(--mg-accent);
}

.mg-page-btn.is-current {
	background: var(--mg-accent);
	border-color: var(--mg-accent);
	color: var(--mg-accent-ink);
}

.mg-page-btn[disabled] {
	opacity: 0.45;
	cursor: not-allowed;
}

.mg-page-gap {
	padding: 0 4px;
	color: var(--mg-faint);
	align-self: center;
}

/* Mobile card layout for tables */
@media (max-width: 767px) {
	.mgscm-app .mg-table thead {
		display: none;
	}

	.mgscm-app .mg-table,
	.mgscm-app .mg-table tbody,
	.mgscm-app .mg-table tr,
	.mgscm-app .mg-table td {
		display: block;
		width: 100%;
	}

	.mgscm-app .mg-table tbody tr {
		margin: 12px;
		width: auto;
		border: 1px solid var(--mg-border);
		border-radius: var(--mg-radius);
		background: var(--mg-surface);
		box-shadow: var(--mg-shadow);
		padding: 6px 0;
	}

	.mgscm-app .mg-table tbody tr.mg-table-state,
	.mgscm-app .mg-table tbody tr.mg-skeleton-row {
		border: 0;
		box-shadow: none;
		background: transparent;
	}

	.mgscm-app .mg-table td {
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		gap: 12px;
		padding: 8px 14px;
		border-bottom: 1px dashed var(--mg-border);
		text-align: right;
	}

	.mgscm-app .mg-table td:last-child {
		border-bottom: 0;
	}

	.mgscm-app .mg-table td > * {
		min-width: 0;
	}

	.mgscm-app .mg-table td[data-label]::before {
		content: attr(data-label);
		font-size: 11px;
		font-weight: 700;
		text-transform: uppercase;
		letter-spacing: 0.04em;
		color: var(--mg-muted);
		text-align: left;
		flex-shrink: 0;
		max-width: 42%;
	}

	.mgscm-app .mg-table td.mg-td-primary {
		display: block;
		text-align: left;
		border-bottom: 1px solid var(--mg-border);
		padding-bottom: 10px;
	}

	.mgscm-app .mg-table td.mg-td-primary::before {
		display: none;
	}

	.mgscm-app .mg-table td.mg-actions-col {
		justify-content: flex-end;
		width: 100%;
	}

	.mgscm-app .mg-table td.mg-actions-col::before {
		display: none;
	}

	.mgscm-app .mg-table .mg-num {
		text-align: right;
	}

	.mg-table .mg-progress {
		min-width: 140px;
	}

	.mg-pagination {
		justify-content: center;
	}
}

/* Floating add button on mobile */
@media (max-width: 1023px) {
	.mgscm-app .mg-fab-mobile {
		position: fixed;
		right: 16px;
		bottom: calc(var(--mg-bottom-h) + 16px + env(safe-area-inset-bottom, 0px));
		z-index: 44;
		border-radius: 999px;
		min-height: 52px;
		padding: 0 20px;
		box-shadow: 0 10px 24px rgba(217, 119, 6, 0.35);
	}

	.mg-hide-sm {
		display: none;
	}
}

/* ------------------------------------------------------------------ *
 * Tabs
 * ------------------------------------------------------------------ */
.mg-tabs {
	display: flex;
	gap: 4px;
	overflow-x: auto;
	border-bottom: 1px solid var(--mg-border);
	scrollbar-width: none;
}

.mg-tabs::-webkit-scrollbar {
	display: none;
}

.mgscm-app .mg-tab {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 10px 14px;
	font-weight: 600;
	color: var(--mg-muted);
	border-bottom: 2px solid transparent;
	margin-bottom: -1px;
	white-space: nowrap;
}

.mgscm-app .mg-tab:hover {
	color: var(--mg-heading);
}

.mgscm-app .mg-tab.is-active {
	color: var(--mg-heading);
	border-bottom-color: var(--mg-accent);
}

.mg-tab-panel {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* ------------------------------------------------------------------ *
 * Feed / timeline / gallery
 * ------------------------------------------------------------------ */
.mg-feed {
	display: flex;
	flex-direction: column;
}

.mg-feed__item {
	display: flex;
	gap: 12px;
	padding: 12px 0;
	border-bottom: 1px solid var(--mg-border);
	min-width: 0;
}

.mg-feed__item:first-child {
	padding-top: 0;
}

.mg-feed__item:last-child {
	border-bottom: 0;
	padding-bottom: 0;
}

.mg-feed__body {
	flex: 1;
	min-width: 0;
}

.mg-feed__title {
	font-weight: 700;
	color: var(--mg-heading);
	display: block;
}

a.mg-feed__title:hover {
	color: var(--mg-accent-600);
}

.mg-feed__meta {
	font-size: 12px;
	color: var(--mg-muted);
	margin-top: 2px;
	display: flex;
	flex-wrap: wrap;
	gap: 4px 10px;
	align-items: center;
}

.mg-feed__text {
	margin-top: 4px;
	color: var(--mg-text);
	font-size: 13px;
}

.mg-feed__aside {
	flex-shrink: 0;
	text-align: right;
}

.mg-status-bars {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.mg-status-bar__row {
	display: flex;
	justify-content: space-between;
	font-size: 13px;
	font-weight: 600;
	margin-bottom: 4px;
}

.mg-stacked-bar {
	display: flex;
	height: 12px;
	border-radius: 999px;
	overflow: hidden;
	background: var(--mg-surface-3);
	margin-bottom: 14px;
}

.mg-stacked-bar span {
	height: 100%;
}

.mg-fill-success { background: var(--mg-success); }
.mg-fill-warning { background: var(--mg-accent); }
.mg-fill-danger { background: var(--mg-danger); }
.mg-fill-neutral { background: var(--mg-faint); }
.mg-fill-info { background: var(--mg-info); }
.mg-fill-purple { background: var(--mg-purple); }

.mg-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 16px;
}

.mg-legend__item {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
}

.mg-legend__dot {
	width: 10px;
	height: 10px;
	border-radius: 3px;
}

.mg-subheading {
	font-size: 12px;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--mg-muted);
	margin: 16px 0 8px;
}

.mg-timeline {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 16px;
	padding-left: 22px;
}

.mg-timeline::before {
	content: "";
	position: absolute;
	left: 7px;
	top: 6px;
	bottom: 6px;
	width: 2px;
	background: var(--mg-border);
}

.mg-timeline__item {
	position: relative;
	background: var(--mg-surface-2);
	border: 1px solid var(--mg-border);
	border-radius: var(--mg-radius);
	padding: 14px;
}

.mg-timeline__item::before {
	content: "";
	position: absolute;
	left: -21px;
	top: 18px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--mg-accent);
	border: 3px solid var(--mg-surface);
	box-shadow: 0 0 0 1px var(--mg-border);
}

.mg-timeline__head {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: flex-start;
	gap: 8px;
}

.mg-timeline__title {
	font-size: 15px;
	font-weight: 700;
	color: var(--mg-heading);
}

.mg-timeline__meta {
	font-size: 12px;
	color: var(--mg-muted);
}

.mg-timeline__text {
	margin-top: 8px;
	white-space: pre-line;
}

.mg-timeline .mg-progress {
	margin-top: 10px;
	max-width: 320px;
}

.mg-gallery {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
	gap: 8px;
	margin-top: 12px;
}

.mg-gallery--lg {
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.mg-gallery__item {
	display: block;
	border-radius: var(--mg-radius-sm);
	overflow: hidden;
	border: 1px solid var(--mg-border);
	aspect-ratio: 4 / 3;
	background: var(--mg-surface-3);
}

.mg-gallery__item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.25s;
}

.mg-gallery__item:hover img {
	transform: scale(1.04);
}

/* ------------------------------------------------------------------ *
 * Alerts
 * ------------------------------------------------------------------ */
.mg-alert {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 14px;
	border-radius: var(--mg-radius);
	font-weight: 600;
}

.mg-alert--warning { background: var(--mg-warning-soft); color: var(--mg-warning); }
.mg-alert--info { background: var(--mg-info-soft); color: var(--mg-info); }
.mg-alert--danger { background: var(--mg-danger-soft); color: var(--mg-danger); }

.mg-alert__cta {
	margin-left: auto;
	white-space: nowrap;
}

.mg-alert--link:hover {
	filter: brightness(0.97);
}

/* ------------------------------------------------------------------ *
 * Modal
 * ------------------------------------------------------------------ */
.mg-modal {
	position: fixed;
	inset: 0;
	z-index: 100;
	display: flex;
	align-items: flex-end;
	justify-content: center;
}

.mg-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(2, 6, 23, 0.65);
	backdrop-filter: blur(3px);
	animation: mg-fade 0.15s ease;
}

.mg-modal__dialog {
	position: relative;
	width: 100%;
	max-height: 92vh;
	max-height: 92dvh;
	display: flex;
	flex-direction: column;
	background: var(--mg-surface);
	border: 1px solid var(--mg-border);
	border-radius: 16px 16px 0 0;
	box-shadow: var(--mg-shadow-lg);
	animation: mg-slide-up 0.2s ease;
	overflow: hidden;
}

.mg-modal__dialog > form {
	display: flex;
	flex-direction: column;
	min-height: 0;
	flex: 1;
}

.mg-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 18px;
	background: var(--mg-surface-2);
	border-bottom: 1px solid var(--mg-border);
	flex-shrink: 0;
}

.mg-modal__title {
	font-size: 16px;
	font-weight: 800;
	color: var(--mg-heading);
}

.mg-modal__body {
	padding: 18px;
	overflow-y: auto;
	flex: 1;
	min-height: 0;
}

.mg-modal__footer {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--mg-border);
	background: var(--mg-surface);
	flex-shrink: 0;
}

.mg-modal__footer .mg-btn {
	flex: 1;
}

@media (min-width: 640px) {
	.mg-modal {
		align-items: center;
		padding: 24px;
	}

	.mg-modal__dialog {
		border-radius: 16px;
		max-width: 560px;
		animation: mg-pop 0.18s ease;
	}

	.mg-modal--sm { max-width: 420px; }
	.mg-modal--lg { max-width: 820px; }

	.mg-modal__footer .mg-btn {
		flex: 0 0 auto;
	}
}

.mg-confirm {
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding-top: 24px;
}

.mg-confirm__icon {
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: var(--mg-danger-soft);
	color: var(--mg-danger);
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.mg-confirm__icon .dashicons {
	width: 26px;
	height: 26px;
	font-size: 26px;
}

.mg-confirm__message {
	color: var(--mg-muted);
}

@keyframes mg-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mg-slide-up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes mg-pop { from { transform: scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }

body.mg-modal-open {
	overflow: hidden;
}

/* Lightbox */
.mg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 120;
	background: rgba(2, 6, 23, 0.92);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.mg-lightbox__figure {
	max-width: 100%;
	max-height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
}

.mg-lightbox__figure img {
	max-height: 80vh;
	max-width: 100%;
	border-radius: var(--mg-radius-sm);
	object-fit: contain;
}

.mg-lightbox__figure figcaption {
	color: #e2e8f0;
	font-size: 13px;
	text-align: center;
}

.mgscm-app .mg-lightbox__close {
	position: absolute;
	top: 16px;
	right: 16px;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

/* ------------------------------------------------------------------ *
 * Loading: spinner, overlay, top bar
 * ------------------------------------------------------------------ */
.mg-spinner {
	display: inline-block;
	width: 20px;
	height: 20px;
	border: 2.5px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: mg-spin 0.7s linear infinite;
	opacity: 0.8;
	flex-shrink: 0;
}

.mg-spinner--sm {
	width: 14px;
	height: 14px;
	border-width: 2px;
}

.mg-spinner--lg {
	width: 36px;
	height: 36px;
	border-width: 3.5px;
	color: var(--mg-accent);
}

@keyframes mg-spin {
	to { transform: rotate(360deg); }
}

.mg-loading-overlay {
	position: fixed;
	inset: 0;
	z-index: 150;
	background: rgba(2, 6, 23, 0.35);
	display: flex;
	align-items: center;
	justify-content: center;
	animation: mg-fade 0.15s ease;
}

.mg-loading-overlay__box {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 16px 22px;
	border-radius: var(--mg-radius);
	background: var(--mg-surface);
	box-shadow: var(--mg-shadow-lg);
	font-weight: 700;
	color: var(--mg-heading);
}

.mg-topbar-loader {
	position: fixed;
	top: 0;
	left: 0;
	height: 3px;
	width: 0;
	z-index: 200;
	background: linear-gradient(90deg, var(--mg-accent), #fbbf24);
	box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
	opacity: 0;
	transition: width 0.4s ease, opacity 0.3s ease;
}

.mgscm-app.is-busy .mg-topbar-loader {
	width: 75%;
	opacity: 1;
	transition: width 8s cubic-bezier(0.1, 0.7, 0.2, 1), opacity 0.1s;
}

.mg-list.is-loading .mg-table tbody {
	opacity: 0.55;
	pointer-events: none;
}

/* ------------------------------------------------------------------ *
 * Toasts
 * ------------------------------------------------------------------ */
.mg-toasts {
	position: fixed;
	z-index: 210;
	left: 12px;
	right: 12px;
	top: 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	pointer-events: none;
}

@media (min-width: 640px) {
	.mg-toasts {
		left: auto;
		right: 20px;
		top: 20px;
		width: 380px;
	}
}

.mg-toast {
	pointer-events: auto;
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 12px 14px;
	border-radius: var(--mg-radius);
	background: var(--mg-surface);
	border: 1px solid var(--mg-border);
	border-left: 4px solid var(--mg-info);
	box-shadow: var(--mg-shadow-lg);
	color: var(--mg-text);
	animation: mg-toast-in 0.25s ease;
}

.mg-toast.is-leaving {
	animation: mg-toast-out 0.2s ease forwards;
}

.mg-toast--success { border-left-color: var(--mg-success); }
.mg-toast--error { border-left-color: var(--mg-danger); }
.mg-toast--warning { border-left-color: var(--mg-accent); }

.mg-toast__icon {
	flex-shrink: 0;
	margin-top: 1px;
}

.mg-toast--success .mg-toast__icon { color: var(--mg-success); }
.mg-toast--error .mg-toast__icon { color: var(--mg-danger); }
.mg-toast--warning .mg-toast__icon { color: var(--mg-accent-600); }
.mg-toast--info .mg-toast__icon { color: var(--mg-info); }

.mg-toast__msg {
	flex: 1;
	font-weight: 600;
	font-size: 13px;
}

.mgscm-app .mg-toast__close {
	color: var(--mg-faint);
	width: 22px;
	height: 22px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

@keyframes mg-toast-in {
	from { transform: translateX(30px); opacity: 0; }
	to { transform: none; opacity: 1; }
}

@keyframes mg-toast-out {
	to { transform: translateX(30px); opacity: 0; }
}

/* ------------------------------------------------------------------ *
 * Auth screens
 * ------------------------------------------------------------------ */
.mgscm-app.mg-auth {
	min-height: 70vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px 16px;
	background: linear-gradient(160deg, #0f172a 0%, #020617 100%);
}

body.mgscm-fullscreen .mgscm-app.mg-auth {
	min-height: 100vh;
}

.mg-auth__card {
	width: 100%;
	max-width: 420px;
	background: var(--mg-surface);
	border-radius: 16px;
	padding: 28px 24px;
	box-shadow: var(--mg-shadow-lg);
}

.mg-brand--center {
	justify-content: center;
	background: none;
	border: 0;
	height: auto;
	padding: 0 0 16px;
	display: flex;
	align-items: center;
	gap: 12px;
}

.mg-brand--center .mg-brand__name {
	color: var(--mg-heading);
}

.mg-auth__title {
	font-size: 18px;
	font-weight: 800;
	text-align: center;
	color: var(--mg-heading);
	margin-bottom: 18px !important;
}

.mg-auth #mg-login-form p {
	margin-bottom: 14px;
}

.mg-auth #mg-login-form label {
	display: block;
	font-size: 12px;
	font-weight: 700;
	margin-bottom: 5px;
}

.mg-auth #mg-login-form input[type="text"],
.mg-auth #mg-login-form input[type="password"] {
	width: 100%;
	min-height: 42px;
	padding: 8px 12px;
	border-radius: var(--mg-radius-sm);
	border: 1px solid var(--mg-input-border);
	background: var(--mg-input);
}

.mg-auth #mg-login-form input:focus {
	outline: none;
	border-color: var(--mg-accent);
	box-shadow: var(--mg-focus);
}

.mg-auth #mg-login-form .login-remember label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 500;
}

.mg-auth #mg-login-form .button-primary {
	width: 100%;
	min-height: 44px;
	border-radius: var(--mg-radius-sm);
	background: var(--mg-accent);
	color: var(--mg-accent-ink);
	font-weight: 800;
	border: 0;
	cursor: pointer;
}

.mg-auth #mg-login-form .button-primary:hover {
	background: var(--mg-accent-600);
}

.mg-auth__panel[hidden] {
	display: none;
}

.mg-auth__lead {
	color: var(--mg-muted);
	margin-bottom: 16px;
	text-align: center;
}

.mg-auth__lead--strong {
	color: var(--mg-heading);
	font-weight: 600;
}

.mg-auth-form {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.mgscm-app .mg-btn--block {
	display: flex;
	width: 100%;
	min-height: 44px;
}

.mg-pw {
	position: relative;
}

.mgscm-app .mg-pw .mg-input {
	padding-right: 44px;
}

.mgscm-app .mg-pw__toggle {
	position: absolute;
	top: 0;
	right: 0;
	width: 42px;
	height: 100%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--mg-muted);
}

.mgscm-app .mg-pw__toggle:hover,
.mgscm-app .mg-pw__toggle[aria-pressed="true"] {
	color: var(--mg-accent-600);
}

.mg-auth__success {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 6px;
}

.mg-auth__success .mg-auth__title {
	margin-bottom: 4px !important;
}

.mg-auth__success-icon {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--mg-success-soft);
	color: var(--mg-success);
	margin-bottom: 6px;
}

.mg-auth__success--error .mg-auth__success-icon {
	background: var(--mg-danger-soft);
	color: var(--mg-danger);
}

.mg-auth__success-icon .dashicons {
	width: 28px;
	height: 28px;
	font-size: 28px;
}

.mg-auth__links {
	text-align: center;
	font-size: 13px;
	margin-top: 16px;
}

.mg-auth__links a {
	color: var(--mg-accent-600);
	font-weight: 600;
}

/* ------------------------------------------------------------------ *
 * Misc
 * ------------------------------------------------------------------ */
.mg-current-assignment:empty {
	display: none;
}

.mg-profile-head {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
}

.mg-profile-head__name {
	font-size: 18px;
	font-weight: 800;
	color: var(--mg-heading);
}

.mg-report-filters__actions {
	display: flex;
	justify-content: flex-end;
	margin-top: 14px;
}

@media (prefers-reduced-motion: reduce) {
	.mgscm-app *,
	.mgscm-app *::before,
	.mgscm-app *::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}
