/* ============================================================================
   MINI TASK — UNIFIED THEME (single source of truth)
   ----------------------------------------------------------------------------
   This file is loaded LAST in App.razor, so its :root token declarations win
   over the legacy variable systems scattered across app.css / dark-mode.css.

   Contents
     1. Design tokens (light)            --mt-*
     2. Design tokens (dark)             html.dark-mode overrides
     3. Compatibility bridge             legacy vars (--kiro/--color/--comp/
                                         --app/--ui/--dm/--proj) -> --mt-*
     4. Base reset                       replaces Bootstrap Reboot
     5. Base typography & elements
     6. Scrollbars, selection, focus     one canonical definition
     7. MudBlazor harmonization          gentle, token-driven
     8. Canonical components             .mt-page-header / .mt-card /
                                         .mt-metric / .mt-dialog-* / .mt-empty
     9. Module: AG Motors shared styles  (extracted from 8 duplicated dialogs)
    10. Safety nets                      temporary, documented, minimal

   Rules for new code:
     - Never hardcode a hex color: use var(--mt-*).
     - Never add !important here except in section 10 (and document why).
     - Dark mode = token overrides only. No component should need its own
       ".dark-mode" rules once it consumes tokens.
   ========================================================================== */


/* ============================================================
   1. DESIGN TOKENS — LIGHT (default)
   ============================================================ */
:root {
    /* Brand */
    --mt-primary: #4F46E5;
    --mt-primary-strong: #4338CA;
    --mt-primary-deep: #3730A3;
    --mt-primary-soft: #EEF2FF;
    --mt-primary-soft-2: #E0E7FF;
    --mt-on-primary: #FFFFFF;
    --mt-accent: #16AFC4;
    --mt-accent-strong: #0E8CA0;
    --mt-accent-soft: #E8FAFD;
    --mt-gradient-brand: linear-gradient(135deg, #4F46E5 0%, #16AFC4 100%);
    --mt-gradient-brand-soft: linear-gradient(135deg, rgba(79, 70, 229, 0.12) 0%, rgba(22, 175, 196, 0.12) 100%);

    /* Status */
    --mt-success: #10B981;
    --mt-success-strong: #059669;
    --mt-success-soft: #E7F8F1;
    --mt-warning: #F59E0B;
    --mt-warning-strong: #B45309;
    --mt-warning-soft: #FFF7E6;
    --mt-danger: #EF4444;
    --mt-danger-strong: #DC2626;
    --mt-danger-soft: #FEF1F2;
    --mt-info: #3B82F6;
    --mt-info-strong: #2563EB;
    --mt-info-soft: #EFF6FF;

    /* Category accents (kept distinct on purpose for status boards/charts) */
    --mt-cat-purple: #8B5CF6;
    --mt-cat-orange: #FDAB3D;
    --mt-cat-yellow: #FFCB00;

    /* Surfaces & text */
    --mt-bg: #F7F8FB;
    --mt-bg-muted: #F1F4F9;
    --mt-surface: #FFFFFF;
    --mt-surface-hover: #FAFBFF;
    --mt-surface-raised: #FFFFFF;
    --mt-field-bg: #F6F8FB;
    --mt-ink: #1B1F31;
    --mt-text: #1B1F31;
    --mt-text-muted: #667085;
    --mt-text-soft: #98A2B3;
    --mt-text-invert: #FFFFFF;
    --mt-line: #E2E8F0;
    --mt-line-soft: #EEF2F7;
    --mt-line-strong: #CBD5E1;

    /* Navigation drawer (stays dark in both modes — brand decision) */
    --mt-nav-bg: #17172B;
    --mt-nav-bg-2: #201B45;
    --mt-nav-text: #F8FAFC;
    --mt-nav-muted: rgba(255, 255, 255, 0.68);
    --mt-nav-line: rgba(255, 255, 255, 0.12);
    --mt-nav-active: rgba(255, 255, 255, 0.10);

    /* Radii — matches the app's dominant 8/12/16 cluster */
    --mt-radius-xs: 4px;
    --mt-radius-sm: 8px;
    --mt-radius-md: 12px;
    --mt-radius-lg: 16px;
    --mt-radius-xl: 20px;
    --mt-radius-pill: 999px;

    /* Shadows */
    --mt-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --mt-shadow-md: 0 8px 20px rgba(15, 23, 42, 0.07);
    --mt-shadow-lg: 0 20px 44px rgba(15, 23, 42, 0.12);
    --mt-shadow-focus: 0 0 0 3px rgba(79, 70, 229, 0.16);

    /* Typography */
    --mt-font: 'Inter', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    --mt-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    --mt-text-xs: 0.75rem;    /* 12px */
    --mt-text-sm: 0.8125rem;  /* 13px */
    --mt-text-md: 0.875rem;   /* 14px */
    --mt-text-base: 1rem;     /* 16px */
    --mt-text-lg: 1.125rem;   /* 18px */
    --mt-text-xl: 1.25rem;    /* 20px */
    --mt-text-2xl: 1.5rem;    /* 24px */
    --mt-text-3xl: 1.875rem;  /* 30px */

    /* Motion */
    --mt-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --mt-fast: 150ms;
    --mt-normal: 200ms;
    --mt-slow: 300ms;

    /* Layout & stacking (MudBlazor: drawer 1300 / appbar 1400 / dialog 1500 /
       popover 1600 / snackbar 1700 / tooltip 1800) */
    --mt-appbar-height: 60px;
    --mt-z-toast: 1750;

    color-scheme: light;
}


/* ============================================================
   2. DESIGN TOKENS — DARK
   ============================================================ */
html.dark-mode {
    /* Brand (lightened for contrast on dark surfaces) */
    --mt-primary: #A5B4FC;
    --mt-primary-strong: #C7D2FE;
    --mt-primary-deep: #818CF8;
    --mt-primary-soft: rgba(129, 140, 248, 0.16);
    --mt-primary-soft-2: rgba(129, 140, 248, 0.24);
    --mt-on-primary: #101322;
    --mt-accent: #67E8F9;
    --mt-accent-strong: #22D3EE;
    --mt-accent-soft: rgba(103, 232, 249, 0.14);
    --mt-gradient-brand: linear-gradient(135deg, #6366F1 0%, #0EA5BF 100%);
    --mt-gradient-brand-soft: linear-gradient(135deg, rgba(129, 140, 248, 0.18) 0%, rgba(103, 232, 249, 0.14) 100%);

    /* Status */
    --mt-success: #34D399;
    --mt-success-strong: #6EE7B7;
    --mt-success-soft: rgba(52, 211, 153, 0.14);
    --mt-warning: #FBBF24;
    --mt-warning-strong: #FCD34D;
    --mt-warning-soft: rgba(251, 191, 36, 0.14);
    --mt-danger: #F87171;
    --mt-danger-strong: #FCA5A5;
    --mt-danger-soft: rgba(248, 113, 113, 0.14);
    --mt-info: #7DD3FC;
    --mt-info-strong: #BAE6FD;
    --mt-info-soft: rgba(125, 211, 252, 0.14);

    --mt-cat-purple: #C4B5FD;
    --mt-cat-orange: #FDBA74;
    --mt-cat-yellow: #FDE047;

    /* Surfaces & text */
    --mt-bg: #0B1120;
    --mt-bg-muted: #111827;
    --mt-surface: #172033;
    --mt-surface-hover: #1C2942;
    --mt-surface-raised: #1D283B;
    --mt-field-bg: #111A2B;
    --mt-ink: #F1F5F9;
    --mt-text: #EDF2F9;
    --mt-text-muted: #A7B2C5;
    --mt-text-soft: #7E8BA3;
    --mt-text-invert: #0B1120;
    --mt-line: #334155;
    --mt-line-soft: #1E293B;
    --mt-line-strong: #475569;

    /* Navigation drawer (slightly deeper in dark mode) */
    --mt-nav-bg: #131322;
    --mt-nav-bg-2: #1B1638;
    --mt-nav-text: #E5E7EB;

    /* Shadows */
    --mt-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --mt-shadow-md: 0 10px 24px rgba(0, 0, 0, 0.30);
    --mt-shadow-lg: 0 24px 52px rgba(0, 0, 0, 0.42);
    --mt-shadow-focus: 0 0 0 3px rgba(165, 180, 252, 0.22);

    color-scheme: dark;
}


/* ============================================================
   3. COMPATIBILITY BRIDGE — legacy variable systems
   ------------------------------------------------------------
   app.css / dark-mode.css / component styles still read these.
   Re-pointing them at --mt-* unifies the whole app immediately.
   Delete each block as its consumers are migrated (Fase 4).
   ============================================================ */
:root,
html.dark-mode {
    /* -- System 1: --kiro-* (app.css:11) -- */
    --kiro-primary: var(--mt-primary);
    --kiro-primary-hover: var(--mt-primary-strong);
    --kiro-primary-light: var(--mt-primary-deep);
    --kiro-secondary: var(--mt-accent);
    --kiro-success: var(--mt-success);
    --kiro-warning: var(--mt-warning);
    --kiro-error: var(--mt-danger);
    --kiro-info: var(--mt-info);
    --kiro-dark: var(--mt-ink);
    --kiro-gray: var(--mt-text-muted);
    --kiro-light-gray: var(--mt-bg-muted);
    --kiro-border: var(--mt-line);

    /* -- System 2: --color-* / --spacing-* / --radius-* / --shadow-* (app.css:613) -- */
    --color-primary: var(--mt-primary);
    --color-secondary: var(--mt-accent);
    --color-text-primary: var(--mt-text);
    --color-text-secondary: var(--mt-text-muted);
    --color-border: var(--mt-line);
    --color-background: var(--mt-bg);
    --radius-sm: var(--mt-radius-xs);
    --radius-md: var(--mt-radius-sm);
    --radius-lg: var(--mt-radius-md);
    --radius-xl: var(--mt-radius-lg);
    --shadow-sm: var(--mt-shadow-sm);
    --shadow-md: var(--mt-shadow-md);
    --shadow-lg: var(--mt-shadow-lg);
    --shadow-hover: var(--mt-shadow-md);
    --transition-fast: var(--mt-fast) ease;
    --transition-normal: var(--mt-normal) ease;
    --transition-slow: var(--mt-slow) ease;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* -- System 4: --app-* "Airflow-inspired" (app.css:3406) -- */
    --app-primary: var(--mt-primary);
    --app-primary-strong: var(--mt-primary-strong);
    --app-primary-soft: var(--mt-primary-soft);
    --app-cyan: var(--mt-accent);
    --app-cyan-soft: var(--mt-accent-soft);
    --app-green: var(--mt-success);
    --app-green-soft: var(--mt-success-soft);
    --app-amber: var(--mt-warning);
    --app-amber-soft: var(--mt-warning-soft);
    --app-red: var(--mt-danger);
    --app-red-soft: var(--mt-danger-soft);
    --app-purple: var(--mt-cat-purple);
    --app-ink: var(--mt-ink);
    --app-muted: var(--mt-text-muted);
    --app-line: var(--mt-line);
    --app-bg: var(--mt-bg);
    --app-surface: var(--mt-surface);
    --app-radius: var(--mt-radius-sm);
    --app-shell-radius: var(--mt-radius-xl);
    --app-shadow: var(--mt-shadow-md);
    --app-bg-soft: var(--mt-bg-muted);
    --app-surface-soft: var(--mt-surface-hover);
    --app-line-soft: var(--mt-line-soft);
    --app-shadow-soft: var(--mt-shadow-sm);

    /* -- System 5: --ui-* "Calm modern" (app.css:4358) -- */
    --ui-bg: var(--mt-bg);
    --ui-bg-elevated: var(--mt-surface);
    --ui-bg-muted: var(--mt-bg-muted);
    --ui-surface: var(--mt-surface);
    --ui-surface-hover: var(--mt-surface-hover);
    --ui-ink: var(--mt-ink);
    --ui-muted: var(--mt-text-muted);
    --ui-muted-soft: var(--mt-text-soft);
    --ui-line: var(--mt-line);
    --ui-line-soft: var(--mt-line-soft);
    --ui-primary: var(--mt-primary);
    --ui-primary-strong: var(--mt-primary-deep);
    --ui-primary-soft: var(--mt-primary-soft);
    --ui-accent: var(--mt-accent);
    --ui-accent-soft: var(--mt-accent-soft);
    --ui-success: var(--mt-success);
    --ui-success-soft: var(--mt-success-soft);
    --ui-warning: var(--mt-warning-strong);
    --ui-warning-soft: var(--mt-warning-soft);
    --ui-danger: var(--mt-danger-strong);
    --ui-danger-soft: var(--mt-danger-soft);
    --ui-nav: var(--mt-nav-bg);
    --ui-nav-raised: var(--mt-nav-bg-2);
    --ui-radius: var(--mt-radius-sm);
    --ui-radius-lg: var(--mt-radius-lg);
    --ui-shadow: var(--mt-shadow-lg);
    --ui-shadow-soft: var(--mt-shadow-md);
    --ui-focus: var(--mt-shadow-focus);

    /* -- System 3: --comp-* (Monday-style compliance palette; global now,
          the old app.css definitions targeted several scopes incl. all dialogs) -- */
    --comp-bg: var(--mt-bg);
    --comp-surface: var(--mt-surface);
    --comp-surface-soft: var(--mt-bg-muted);
    --comp-ink: var(--mt-ink);
    --comp-muted: var(--mt-text-muted);
    --comp-line: var(--mt-line);
    --comp-line-soft: var(--mt-line-soft);
    --comp-primary: var(--mt-primary);
    --comp-primary-dark: var(--mt-primary-strong);
    --comp-primary-soft: var(--mt-primary-soft);
    --comp-blue: var(--mt-info);
    --comp-blue-soft: var(--mt-info-soft);
    --comp-green: var(--mt-success);
    --comp-green-soft: var(--mt-success-soft);
    --comp-warning: var(--mt-warning);
    --comp-warning-soft: color-mix(in srgb, var(--mt-cat-yellow) 20%, transparent);
    --comp-yellow: var(--mt-cat-yellow);
    --comp-yellow-soft: color-mix(in srgb, var(--mt-cat-yellow) 20%, transparent);
    --comp-danger: var(--mt-danger);
    --comp-danger-soft: var(--mt-danger-soft);
    --comp-red: var(--mt-danger);
    --comp-red-soft: var(--mt-danger-soft);
    --comp-orange: var(--mt-cat-orange);
    --comp-orange-soft: color-mix(in srgb, var(--mt-cat-orange) 16%, transparent);
    --comp-purple: var(--mt-cat-purple);
    --comp-purple-soft: color-mix(in srgb, var(--mt-cat-purple) 14%, transparent);
    --comp-radius: var(--mt-radius-lg);
    --comp-shadow: var(--mt-shadow-lg);
    --comp-shadow-soft: var(--mt-shadow-sm);
}

/* -- System 6: --dm-* (dark-mode.css:1) — dark mode only -- */
html.dark-mode {
    --dm-bg: var(--mt-bg);
    --dm-shell: var(--mt-bg-muted);
    --dm-surface: var(--mt-surface);
    --dm-surface-2: var(--mt-surface-raised);
    --dm-surface-3: var(--mt-surface-hover);
    --dm-input: var(--mt-field-bg);
    --dm-border: var(--mt-line);
    --dm-text: var(--mt-text);
    --dm-text-strong: var(--mt-ink);
    --dm-text-muted: var(--mt-text-muted);
    --dm-text-soft: var(--mt-text-soft);
    --dm-border-soft: var(--mt-line-soft);
    --dm-primary: var(--mt-primary);
    --dm-primary-strong: var(--mt-primary-strong);
    --dm-primary-surface: var(--mt-primary-soft);
    --dm-orange: var(--mt-cat-orange);
    --dm-blue: var(--mt-info);
    --dm-green: var(--mt-success);
    --dm-yellow: var(--mt-warning);
    --dm-red: var(--mt-danger);
    --dm-purple: var(--mt-cat-purple);
    --dm-shadow: var(--mt-shadow-lg);

    /* -- System 7: --proj-* (dark-mode.css projects mapping) -- */
    --proj-bg: var(--mt-bg);
    --proj-surface: var(--mt-surface);
    --proj-ink: var(--mt-ink);
    --proj-primary: var(--mt-primary);
    --proj-muted: var(--mt-text-muted);
    --proj-line: var(--mt-line);
}

/* (System 3 --comp-* is bridged globally in the block above.) */


/* ============================================================
   4. BASE RESET — replaces Bootstrap Reboot
   (Bootstrap was removed from App.razor; only these rules
    from Reboot were actually load-bearing.)
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 0.5rem;
    font-weight: 600;
    line-height: 1.2;
}

p {
    margin: 0 0 1rem;
}

ul, ol {
    margin: 0 0 1rem;
    padding-left: 2rem;
}

hr {
    margin: 1rem 0;
    border: 0;
    border-top: 1px solid var(--mt-line);
}

img, svg {
    vertical-align: middle;
}

table {
    border-collapse: collapse;
}

label {
    display: inline-block;
}

button, input, optgroup, select, textarea {
    margin: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

button {
    cursor: pointer;
}

[hidden] {
    display: none !important; /* reset semantics: [hidden] must always win */
}


/* ============================================================
   5. BASE TYPOGRAPHY & ELEMENTS
   ============================================================ */
html, body {
    font-family: var(--mt-font);
    font-size: 16px;
    line-height: 1.5;
}

body {
    color: var(--mt-text);
    background-color: var(--mt-bg);
}

a {
    color: var(--mt-primary);
    text-decoration: none;
    transition: color var(--mt-fast) var(--mt-ease);
}

a:hover {
    color: var(--mt-primary-strong);
}

code, kbd, pre, samp {
    font-family: var(--mt-font-mono);
    font-size: 0.875em;
}

::selection {
    background: var(--mt-primary-soft-2);
}


/* ============================================================
   6. SCROLLBARS, FOCUS — one canonical definition
   ============================================================ */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--mt-line-strong) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--mt-line-strong);
    border-radius: var(--mt-radius-pill);
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--mt-text-soft);
}

/* Keyboard-only focus ring; :where() keeps specificity at 0 */
:where(a, button, [role="button"], [tabindex]):focus-visible {
    outline: 2px solid var(--mt-primary);
    outline-offset: 2px;
    border-radius: var(--mt-radius-xs);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important; /* accessibility: must override all animations */
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* ============================================================
   7. MUDBLAZOR HARMONIZATION (v8) — token-driven, gentle
   ============================================================ */
body,
.mud-typography,
.mud-button-root,
.mud-input,
.mud-input-label,
.mud-select,
.mud-menu-list,
.mud-table,
.mud-chip,
.mud-tooltip,
.mud-alert {
    font-family: var(--mt-font);
}

.mud-dialog {
    border-radius: var(--mt-radius-lg);
}

.mud-snackbar {
    border-radius: var(--mt-radius-md);
    font-family: var(--mt-font);
}

.mud-chip {
    font-weight: 600;
}

.mud-tooltip {
    font-size: var(--mt-text-xs);
    border-radius: var(--mt-radius-sm);
}


/* ============================================================
   8. CANONICAL COMPONENTS (.mt-*)
   Shared building blocks used by PageHeader.razor, AppDialog.razor,
   MetricTile.razor and all migrated modules.
   ============================================================ */

/* ---- Page header (replaces the 8 divergent hero/header patterns) ---- */
.mt-page-header {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 18px 22px;
    margin-bottom: 18px;
    background: var(--mt-surface);
    border: 1px solid var(--mt-line);
    border-radius: var(--mt-radius-lg);
    box-shadow: var(--mt-shadow-sm);
}

.mt-page-header__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border-radius: var(--mt-radius-md);
    background: var(--mt-gradient-brand);
    color: var(--mt-text-invert);
    box-shadow: var(--mt-shadow-sm);
}

.mt-page-header__body {
    min-width: 0;
    flex: 1 1 240px;
}

.mt-page-header__title {
    margin: 0;
    font-size: var(--mt-text-xl);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--mt-ink);
    line-height: 1.25;
}

.mt-page-header__subtitle {
    margin: 2px 0 0;
    font-size: var(--mt-text-sm);
    color: var(--mt-text-muted);
}

.mt-page-header__actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: auto;
}

/* ---- Card ---- */
.mt-card {
    background: var(--mt-surface);
    border: 1px solid var(--mt-line);
    border-radius: var(--mt-radius-lg);
    box-shadow: var(--mt-shadow-sm);
    transition: box-shadow var(--mt-normal) var(--mt-ease), border-color var(--mt-normal) var(--mt-ease);
}

.mt-card--hover:hover {
    border-color: var(--mt-line-strong);
    box-shadow: var(--mt-shadow-md);
}

/* ---- Metric / stat tile ---- */
.mt-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: var(--mt-surface);
    border: 1px solid var(--mt-line);
    border-left: 4px solid var(--mt-primary);
    border-radius: var(--mt-radius-md);
}

.mt-metric__label {
    font-size: var(--mt-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--mt-text-muted);
}

.mt-metric__value {
    font-size: var(--mt-text-2xl);
    font-weight: 800;
    line-height: 1.1;
    color: var(--mt-ink);
}

.mt-metric__hint {
    font-size: var(--mt-text-xs);
    color: var(--mt-text-soft);
}

.mt-metric--success { border-left-color: var(--mt-success); }
.mt-metric--warning { border-left-color: var(--mt-warning); }
.mt-metric--danger  { border-left-color: var(--mt-danger); }
.mt-metric--info    { border-left-color: var(--mt-info); }
.mt-metric--accent  { border-left-color: var(--mt-accent); }

/* ---- Dialog scaffold (used by AppDialog.razor) ---- */
.mt-dialog-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 4px 0 12px;
    border-bottom: 1px solid var(--mt-line-soft);
}

.mt-dialog-header__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border-radius: var(--mt-radius-md);
    background: var(--mt-primary-soft);
    color: var(--mt-primary);
}

html.dark-mode .mt-dialog-header__icon {
    color: var(--mt-primary-strong);
}

.mt-dialog-header__title {
    margin: 0;
    font-size: var(--mt-text-lg);
    font-weight: 700;
    color: var(--mt-ink);
    line-height: 1.3;
}

.mt-dialog-header__subtitle {
    margin: 2px 0 0;
    font-size: var(--mt-text-sm);
    color: var(--mt-text-muted);
}

.mt-dialog-section-label {
    display: block;
    margin: 18px 0 12px;
    padding-bottom: 8px;
    font-size: var(--mt-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--mt-primary);
    border-bottom: 1px solid var(--mt-line-soft);
}

.mt-dialog-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 6px;
}

/* ---- Empty state (canonical; EmptyState.razor uses this) ---- */
.mt-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 48px 24px;
    text-align: center;
    background: var(--mt-surface);
    border: 1px dashed var(--mt-line-strong);
    border-radius: var(--mt-radius-lg);
    color: var(--mt-text-muted);
}

.mt-empty__icon {
    color: var(--mt-text-soft);
}

.mt-empty__title {
    margin: 4px 0 0;
    font-size: var(--mt-text-base);
    font-weight: 700;
    color: var(--mt-ink);
}

.mt-empty__subtitle {
    margin: 0;
    font-size: var(--mt-text-sm);
    color: var(--mt-text-muted);
}

/* ---- Loading container (canonical) ---- */
.mt-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
}

/* ---- Stacked workspace header: title+metrics row, then full-width view tabs.
       Own class so legacy .page-header flex rules can't fight the layout. ---- */
.page-header.page-header--stacked {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 14px;
}

.page-header--stacked .page-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
    width: 100%;
}

.page-header--stacked .projects-command-metrics {
    width: auto;
}

/* ---- View tabs (canonical) — quiet underline switcher for workspace views.
       One row always; overflow scrolls horizontally with hidden scrollbar. ---- */
.mt-viewtabs {
    display: flex;
    align-items: stretch;
    gap: 2px;
    width: 100%;
    /* full row even inside wrapping flex parents (e.g. .page-header) */
    flex: 1 1 100%;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    border-top: 1px solid var(--mt-line-soft);
}

.mt-viewtabs::-webkit-scrollbar {
    display: none;
}

.mt-viewtabs__tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
    padding: 11px 14px 9px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--mt-text-muted);
    font: inherit;
    font-size: var(--mt-text-sm);
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: color var(--mt-fast) var(--mt-ease), background var(--mt-fast) var(--mt-ease);
}

.mt-viewtabs__tab .mud-icon-root {
    font-size: 1.05rem;
}

.mt-viewtabs__tab:hover {
    color: var(--mt-ink);
    background: var(--mt-bg-muted);
    border-radius: var(--mt-radius-sm) var(--mt-radius-sm) 0 0;
}

.mt-viewtabs__tab.is-active {
    color: var(--mt-primary);
    border-bottom-color: var(--mt-primary);
}

/* ---- Risk/alert stat pill (clickable, used in page headers) ---- */
.mt-risk {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 150px;
    padding: 8px 14px;
    background: var(--mt-surface);
    border: 1px solid var(--mt-line);
    border-radius: var(--mt-radius-md);
    font: inherit;
    text-align: left;
    cursor: default;
    transition: border-color var(--mt-fast) var(--mt-ease), box-shadow var(--mt-fast) var(--mt-ease);
}

.mt-risk__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: var(--mt-radius-sm);
}

.mt-risk--warning .mt-risk__icon {
    background: var(--mt-warning-soft);
    color: var(--mt-warning-strong);
}

.mt-risk--danger .mt-risk__icon {
    background: var(--mt-danger-soft);
    color: var(--mt-danger-strong);
}

.mt-risk__body {
    display: grid;
    line-height: 1.2;
}

.mt-risk__label {
    font-size: var(--mt-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--mt-text-muted);
}

.mt-risk__count {
    font-size: var(--mt-text-xl);
    font-weight: 800;
    color: var(--mt-ink);
}

.mt-risk__note {
    font-size: var(--mt-text-xs);
    color: var(--mt-text-soft);
}

.mt-risk--live {
    cursor: pointer;
}

.mt-risk--live:hover {
    border-color: var(--mt-line-strong);
    box-shadow: var(--mt-shadow-md);
}

/* ---- Data grids & tables: clean pass (applies to MudTable + MudDataGrid) ---- */
.mud-table {
    background: var(--mt-surface);
    border: 1px solid var(--mt-line);
    border-radius: var(--mt-radius-lg);
    box-shadow: none;
    overflow: hidden;
}

.mud-table .mud-table-container {
    background: transparent;
}

.mud-table-head .mud-table-cell {
    background: var(--mt-bg-muted);
    color: var(--mt-text-muted);
    font-size: var(--mt-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--mt-line);
    white-space: nowrap;
}

.mud-table:not(.mud-table-dense) .mud-table-head .mud-table-cell {
    padding: 10px 16px;
}

.mud-table-body .mud-table-cell {
    color: var(--mt-text);
    font-size: var(--mt-text-md);
    border-bottom: 1px solid var(--mt-line-soft);
}

.mud-table:not(.mud-table-dense) .mud-table-body .mud-table-cell {
    padding: 12px 16px;
}

.mud-table-body .mud-table-row:last-child .mud-table-cell {
    border-bottom: none;
}

/* zebra stripes off: row separation comes from the soft dividers */
.mud-table-striped .mud-table-body .mud-table-row:nth-of-type(odd) {
    background: transparent;
}

.mud-table-hover .mud-table-body .mud-table-row:hover {
    background: var(--mt-surface-hover);
}

.mud-table-pagination {
    color: var(--mt-text-muted);
    border-top: 1px solid var(--mt-line-soft);
}


/* ============================================================
   9. MODULE — AG MOTORS shared styles
   Extracted from the 8 dialogs and 8 sub-tabs that each embedded
   a copy of these rules. Scoped under .ag-motors-dialog (dialog
   root class) and .subtab-container (only used by AG Motors).
   Note: the original blocks styled ".modern-dialog" (a class these
   dialogs never had) and used ":deep()" (invalid in global CSS),
   so part of them never applied and part leaked into other
   modules' dialogs. This version fixes both.
   ============================================================ */
@keyframes agmDialogIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes agmFadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ag-motors-dialog {
    min-width: min(760px, calc(100vw - 48px));
    animation: agmDialogIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ag-motors-dialog .dialog-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 0;
}

.ag-motors-dialog .header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    flex: 0 0 auto;
    border-radius: var(--mt-radius-md);
    background: var(--mt-gradient-brand-soft);
    color: var(--mt-primary);
}

.ag-motors-dialog .header-title {
    font-weight: 700;
    color: var(--mt-ink);
}

.ag-motors-dialog .form-section {
    margin-bottom: 24px;
    animation: agmFadeUp 0.4s ease-out backwards;
}

.ag-motors-dialog .form-section:nth-child(1) { animation-delay: 0.05s; }
.ag-motors-dialog .form-section:nth-child(2) { animation-delay: 0.1s; }
.ag-motors-dialog .form-section:nth-child(3) { animation-delay: 0.15s; }
.ag-motors-dialog .form-section:nth-child(4) { animation-delay: 0.2s; }
.ag-motors-dialog .form-section:nth-child(5) { animation-delay: 0.25s; }
.ag-motors-dialog .form-section:nth-child(6) { animation-delay: 0.3s; }

.ag-motors-dialog .section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    font-size: var(--mt-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--mt-primary);
    border-bottom: 1px solid var(--mt-primary-soft-2);
}

.ag-motors-dialog .section-hint {
    display: block;
    margin: -4px 0 14px;
    color: var(--mt-text-soft);
    line-height: 1.5;
}

.ag-motors-dialog .form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.ag-motors-dialog .form-field {
    margin: 0;
}

.ag-motors-dialog .form-field.full-width {
    grid-column: 1 / -1;
}

.ag-motors-dialog .form-field .mud-input-filled {
    background: var(--mt-field-bg);
    border-radius: var(--mt-radius-sm);
    transition: background var(--mt-normal) var(--mt-ease), box-shadow var(--mt-normal) var(--mt-ease);
}

.ag-motors-dialog .form-field .mud-input-filled:hover {
    background: var(--mt-bg-muted);
}

.ag-motors-dialog .form-field .mud-input-filled.mud-input-filled-focused {
    background: var(--mt-bg-muted);
    box-shadow: var(--mt-shadow-focus);
}

.ag-motors-dialog .form-field .mud-input-filled::before {
    border-bottom: none;
}

.ag-motors-dialog .form-field .mud-input-filled::after {
    border-bottom: 2px solid var(--mt-primary);
}

.ag-motors-dialog .prefill-section {
    padding: 20px;
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--mt-primary) 5%, transparent),
        color-mix(in srgb, var(--mt-accent) 5%, transparent));
    border: 1px dashed var(--mt-primary-soft-2);
    border-radius: var(--mt-radius-lg);
}

.ag-motors-dialog .cancel-btn {
    color: var(--mt-text-muted);
}

.ag-motors-dialog .save-btn {
    padding: 8px 28px;
    background: var(--mt-gradient-brand);
    color: var(--mt-text-invert);
    box-shadow: var(--mt-shadow-md);
    transition: transform var(--mt-fast) var(--mt-ease), box-shadow var(--mt-normal) var(--mt-ease);
}

.ag-motors-dialog .save-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--mt-shadow-lg);
}

.ag-motors-dialog .save-btn:disabled {
    background: var(--mt-bg-muted);
    box-shadow: none;
}

/* PDF attachment card (MCP dialog) */
.ag-motors-dialog .pdf-info-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    margin-bottom: 14px;
    background: var(--mt-danger-soft);
    border: 1px solid color-mix(in srgb, var(--mt-danger) 18%, transparent);
    border-radius: var(--mt-radius-md);
    transition: border-color var(--mt-normal) var(--mt-ease), box-shadow var(--mt-normal) var(--mt-ease);
}

.ag-motors-dialog .pdf-info-card:hover {
    border-color: color-mix(in srgb, var(--mt-danger) 30%, transparent);
    box-shadow: var(--mt-shadow-sm);
}

.ag-motors-dialog .pdf-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: var(--mt-radius-sm);
    background: color-mix(in srgb, var(--mt-danger) 12%, transparent);
    color: var(--mt-danger-strong);
}

.ag-motors-dialog .pdf-details {
    flex: 1;
    min-width: 0;
}

.ag-motors-dialog .pdf-details .fw-600 {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ag-motors-dialog .pdf-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.ag-motors-dialog .pdf-upload-container {
    display: inline-block;
}

.ag-motors-dialog .upload-pdf-btn {
    border-radius: var(--mt-radius-sm);
    text-transform: none;
    font-weight: 600;
    letter-spacing: 0.02em;
}

@media (max-width: 600px) {
    .ag-motors-dialog {
        min-width: auto;
        width: 100%;
    }

    .ag-motors-dialog .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Sub-tab toolbar (identical block was embedded in all 8 sub-tabs) */
.subtab-container {
    padding: 0;
}

.subtab-container .tab-header {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 20px 22px;
    margin-top: 8px;
    margin-bottom: 24px;
    border: 1px solid var(--mt-line);
    border-radius: var(--mt-radius-xl);
    background: var(--mt-surface);
    box-shadow: var(--mt-shadow-md);
}

.subtab-container .search-field {
    flex: 1 1 200px;
    min-width: 160px;
    max-width: 400px;
}

.subtab-container .filter-select {
    flex: 0 1 170px;
    min-width: 140px;
}

.subtab-container .count-chip {
    margin-left: auto;
}


/* ============================================================
   9b. MODULE — RMM MONITORING (device cards, network map, NOC)
   ============================================================ */
.rmm-board {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    background: var(--mt-surface);
    border: 1px solid var(--mt-line);
    border-radius: var(--mt-radius-lg);
}

.rmm-board__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.rmm-board__actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.rmm-board__title {
    color: var(--mt-ink);
    font-weight: 700;
    line-height: 1.2;
}

.rmm-board__subtitle {
    color: var(--mt-text-muted);
}

.rmm-board__search {
    max-width: 360px;
}

.rmm-trap-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    background: var(--mt-bg-muted);
    border: 1px solid var(--mt-line);
    border-radius: var(--mt-radius-md);
}

.rmm-trap-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.rmm-trap-card__title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.rmm-trap-card__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
}

.rmm-trap-card__grid > div {
    min-width: 0;
    padding: 10px 12px;
    background: var(--mt-surface);
    border: 1px solid var(--mt-line-soft);
    border-radius: var(--mt-radius-sm);
}

.rmm-trap-card__grid span {
    display: block;
    color: var(--mt-text-muted);
    font-size: var(--mt-text-xs);
    font-weight: 800;
    line-height: 1.2;
    text-transform: uppercase;
}

.rmm-trap-card__grid strong {
    display: block;
    margin-top: 3px;
    color: var(--mt-ink);
    font-family: var(--mt-font-mono);
    font-size: var(--mt-text-sm);
    font-weight: 700;
    overflow-wrap: anywhere;
}

.rmm-mono {
    font-family: var(--mt-font-mono);
    overflow-wrap: anywhere;
}

/* Monitoring panel wrapper (dashboard selector above the board) */
.rmm-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.rmm-panel__select {
    max-width: 360px;
}

.rmm-panel__empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
    padding: 28px;
    text-align: center;
    border: 1px dashed var(--mt-line-strong);
    border-radius: var(--mt-radius-md);
    color: var(--mt-text-muted);
    font-weight: 600;
}

.rmm-views {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--mt-bg-muted);
    border: 1px solid var(--mt-line);
    border-radius: var(--mt-radius-sm);
}

.rmm-views__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--mt-text-muted);
    font: inherit;
    font-size: var(--mt-text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--mt-fast) var(--mt-ease), color var(--mt-fast) var(--mt-ease);
}

.rmm-views__btn:hover {
    color: var(--mt-ink);
}

.rmm-views__btn.is-active {
    background: var(--mt-surface);
    color: var(--mt-primary);
    box-shadow: var(--mt-shadow-sm);
}

.rmm-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

/* ---- Device cards ---- */
.rmm-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.rmm-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    background: var(--mt-surface);
    border: 1px solid var(--mt-line);
    border-radius: var(--mt-radius-md);
    cursor: pointer;
    transition: border-color var(--mt-fast) var(--mt-ease), box-shadow var(--mt-fast) var(--mt-ease);
}

.rmm-card:hover {
    border-color: var(--mt-line-strong);
    box-shadow: var(--mt-shadow-md);
}

.rmm-card__top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rmm-ring {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: var(--mt-radius-pill);
    background: var(--mt-surface);
    border: 2.5px solid var(--mt-line-strong);
    color: var(--mt-text-muted);
}

.rmm-ring--online { border-color: var(--mt-success); color: var(--mt-success-strong); }
.rmm-ring--warning { border-color: var(--mt-warning); color: var(--mt-warning-strong); }
.rmm-ring--down { border-color: var(--mt-danger); color: var(--mt-danger-strong); }
.rmm-ring--maintenance { border-color: var(--mt-warning); color: var(--mt-warning-strong); border-style: dashed; }
.rmm-ring--offline { border-color: var(--mt-line-strong); color: var(--mt-text-soft); }

.rmm-card__name {
    margin: 0;
    font-size: var(--mt-text-md);
    font-weight: 700;
    color: var(--mt-ink);
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rmm-card__meta {
    margin: 0;
    font-size: var(--mt-text-xs);
    color: var(--mt-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rmm-card__spark {
    width: 100%;
    height: 30px;
    display: block;
}

.rmm-card__spark.is-online { color: var(--mt-success); }
.rmm-card__spark.is-warning { color: var(--mt-warning); }
.rmm-card__spark.is-down { color: var(--mt-danger); }
.rmm-card__spark.is-maintenance { color: var(--mt-warning); }
.rmm-card__spark.is-offline { color: var(--mt-line-strong); }

.rmm-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: var(--mt-text-xs);
    color: var(--mt-text-muted);
}

.rmm-card__foot strong {
    color: var(--mt-ink);
    font-weight: 700;
}

.rmm-card__foot .is-danger { color: var(--mt-danger-strong); font-weight: 700; }
.rmm-card__foot .is-warning { color: var(--mt-warning-strong); font-weight: 700; }

.rmm-meter {
    position: relative;
    height: 4px;
    border-radius: var(--mt-radius-pill);
    background: var(--mt-line-soft);
    overflow: hidden;
}

.rmm-meter__fill {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: inherit;
    background: var(--mt-warning);
}

.rmm-meter__fill.is-danger { background: var(--mt-danger); }

/* ---- Network map ---- */
.rmm-map {
    position: relative;
    height: 480px;
    border: 1px solid var(--mt-line);
    border-radius: var(--mt-radius-md);
    background: var(--mt-bg);
    overflow: hidden;
    touch-action: none;
}

.rmm-map__world {
    position: absolute;
    inset: 0;
    transform-origin: 0 0;
}

.rmm-map__edges {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.rmm-map__edges line {
    stroke-width: 0.35;
    stroke: var(--mt-line-strong);
}

.rmm-map__edges line.is-warning { stroke: var(--mt-warning); }
.rmm-map__edges line.is-down { stroke: var(--mt-danger); stroke-dasharray: 1.6 1.2; }
.rmm-map__edges line.is-online { stroke: var(--mt-success); }

.rmm-map.is-linking .rmm-map__edges line { cursor: pointer; stroke-width: 0.7; }

.rmm-map__node {
    position: absolute;
    z-index: 3;
    width: 104px;
    margin-left: -52px;
    margin-top: -36px;
    text-align: center;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.rmm-map__node:active { cursor: grabbing; }
.rmm-map.is-readonly .rmm-map__node { cursor: pointer; }
.rmm-map.is-linking .rmm-map__node { cursor: crosshair; }

.rmm-map__node .rmm-ring {
    width: 46px;
    height: 46px;
    box-shadow: var(--mt-shadow-sm);
}

.rmm-map__node.is-down .rmm-ring {
    animation: rmmPulse 1.5s ease-in-out infinite;
}

@keyframes rmmPulse {
    0%, 100% { outline: 0 solid transparent; }
    50% { outline: 7px solid var(--mt-danger-soft); }
}

.rmm-map__node.is-link-source .rmm-ring {
    outline: 4px solid var(--mt-primary-soft-2);
}

.rmm-map__name {
    margin-top: 5px;
    font-size: var(--mt-text-xs);
    font-weight: 700;
    color: var(--mt-ink);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rmm-map__lat {
    font-size: 10.5px;
    color: var(--mt-text-muted);
}

.rmm-map__node.is-down .rmm-map__lat { color: var(--mt-danger-strong); font-weight: 700; }
.rmm-map__node.is-warning .rmm-map__lat { color: var(--mt-warning-strong); font-weight: 700; }

.rmm-map__site {
    position: absolute;
    z-index: 2;
    transform: translateX(-50%);
    padding: 3px 10px;
    border: 1px dashed var(--mt-line-strong);
    border-radius: var(--mt-radius-pill);
    background: var(--mt-surface);
    color: var(--mt-text-soft);
    font-size: var(--mt-text-xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--mt-fast) var(--mt-ease), border-color var(--mt-fast) var(--mt-ease);
}

.rmm-map__site:hover {
    color: var(--mt-primary);
    border-color: var(--mt-primary-soft-2);
}

/* Aggregate node for a collapsed site (click to expand) */
.rmm-map__sitenode {
    position: absolute;
    z-index: 3;
    width: 132px;
    margin-left: -66px;
    margin-top: -40px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.rmm-map__sitenode .rmm-ring {
    width: 54px;
    height: 54px;
    border-width: 3px;
    box-shadow: var(--mt-shadow-md);
}

.rmm-map__sitenode .rmm-map__name {
    font-size: var(--mt-text-sm);
}

.rmm-map--noc .rmm-map__site {
    background: #171F33;
    border-color: #33415C;
    color: #8B99B3;
}

.rmm-map__toolbar {
    position: absolute;
    z-index: 5;
    left: 12px;
    bottom: 12px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.rmm-map__tool {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border: 1px solid var(--mt-line);
    border-radius: var(--mt-radius-sm);
    background: var(--mt-surface);
    color: var(--mt-text-muted);
    font: inherit;
    font-size: var(--mt-text-xs);
    font-weight: 600;
    cursor: pointer;
    transition: color var(--mt-fast) var(--mt-ease), border-color var(--mt-fast) var(--mt-ease);
}

.rmm-map__tool:hover { color: var(--mt-ink); border-color: var(--mt-line-strong); }
.rmm-map__tool.is-active { color: var(--mt-primary); border-color: var(--mt-primary-soft-2); background: var(--mt-primary-soft); }

.rmm-map__zoom {
    position: absolute;
    z-index: 5;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rmm-map--noc .rmm-map__zoom {
    top: 44px;
}

.rmm-map__zoombtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--mt-line);
    border-radius: var(--mt-radius-sm);
    background: var(--mt-surface);
    color: var(--mt-text-muted);
    cursor: pointer;
    transition: color var(--mt-fast) var(--mt-ease), border-color var(--mt-fast) var(--mt-ease);
}

.rmm-map__zoombtn:hover {
    color: var(--mt-ink);
    border-color: var(--mt-line-strong);
}

.rmm-map--noc .rmm-map__zoombtn {
    background: #171F33;
    border-color: #26304A;
    color: #A7B2C5;
}

.rmm-map__banner {
    position: absolute;
    z-index: 5;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 14px;
    background: var(--mt-danger-soft);
    color: var(--mt-danger-strong);
    font-size: var(--mt-text-sm);
    font-weight: 600;
}

.rmm-map__clock {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

/* ---- Device detail slide-over (replaces the nested MudDrawer, which
       MudBlazor 8 does not support outside the layout container) ---- */
@keyframes rmmDrawerIn {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.rmm-drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 1440;
    background: rgba(15, 23, 42, 0.42);
}

.rmm-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1450;
    width: min(430px, 100vw);
    display: flex;
    flex-direction: column;
    background: var(--mt-surface);
    border-left: 1px solid var(--mt-line);
    box-shadow: var(--mt-shadow-lg);
    animation: rmmDrawerIn var(--mt-normal) var(--mt-ease);
}

.rmm-drawer__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--mt-line);
}

.rmm-drawer__title {
    margin: 0;
    font-size: var(--mt-text-lg);
    font-weight: 700;
    color: var(--mt-ink);
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rmm-drawer__subtitle {
    margin: 0;
    font-size: var(--mt-text-xs);
    color: var(--mt-text-muted);
}

.rmm-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px 24px;
}

.rmm-drawer__label {
    display: block;
    font-size: var(--mt-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--mt-text-muted);
}

.rmm-drawer__value {
    font-size: var(--mt-text-md);
    color: var(--mt-text);
}

.rmm-drawer__card {
    padding: 10px 12px;
    margin-top: 8px;
    background: var(--mt-bg-muted);
    border: 1px solid var(--mt-line);
    border-radius: var(--mt-radius-sm);
}

.rmm-drawer__danger {
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px dashed color-mix(in srgb, var(--mt-danger) 40%, transparent);
    border-radius: var(--mt-radius-md);
    background: var(--mt-danger-soft);
}

.rmm-inspect {
    padding: 10px 14px;
    background: var(--mt-bg-muted);
    border-radius: var(--mt-radius-sm);
    font-size: var(--mt-text-sm);
    color: var(--mt-text-muted);
}

.rmm-inspect strong { color: var(--mt-ink); }
.rmm-inspect .is-online { color: var(--mt-success-strong); font-weight: 700; }
.rmm-inspect .is-warning { color: var(--mt-warning-strong); font-weight: 700; }
.rmm-inspect .is-down { color: var(--mt-danger-strong); font-weight: 700; }

/* ---- NOC mode: deliberate dark wall-screen palette in BOTH themes ---- */
.rmm-map--noc,
.rmm-map--noc:fullscreen {
    background: #0B1120;
    border-color: #26304A;
}

.rmm-map--noc .rmm-map__edges line { stroke: #33415C; }
.rmm-map--noc .rmm-map__edges line.is-online { stroke: #34D399; }
.rmm-map--noc .rmm-map__edges line.is-warning { stroke: #FBBF24; }
.rmm-map--noc .rmm-map__edges line.is-down { stroke: #F87171; }

.rmm-map--noc .rmm-ring { background: #171F33; }
.rmm-map--noc .rmm-map__name { color: #EDF2F9; }
.rmm-map--noc .rmm-map__lat { color: #8B99B3; }
.rmm-map--noc .rmm-map__tool { background: #171F33; border-color: #26304A; color: #A7B2C5; }
.rmm-map--noc .rmm-map__tool:hover { color: #EDF2F9; }
.rmm-map--noc .rmm-map__banner { background: #3A1215; color: #FCA5A5; }

.rmm-map--noc:fullscreen .rmm-map__node { width: 128px; margin-left: -64px; margin-top: -44px; }
.rmm-map--noc:fullscreen .rmm-ring { width: 58px; height: 58px; }
.rmm-map--noc:fullscreen .rmm-map__name { font-size: var(--mt-text-sm); }
.rmm-map--noc:fullscreen .rmm-map__lat { font-size: var(--mt-text-xs); }


/* ============================================================
   10. SAFETY NETS — temporary, delete as legacy CSS shrinks
   ============================================================ */

/* Dialogs: hardcoded widths in app.css (1040/1120/980px, all !important)
   overflow tablets. Same-specificity later declaration caps them to the
   viewport. Fullscreen dialogs excluded. */
body .mud-dialog:not(.mud-dialog-fullscreen) {
    max-width: min(1120px, calc(100vw - 24px)) !important; /* beats app.css fixed widths */
}

/* Blazor reconnect/error overlays must sit above everything. */
#blazor-error-ui,
#components-reconnect-modal {
    z-index: 9999;
}

/* Inventory labels print as a focused sheet, independent of scoped CSS. */
@media print {
    body:has(.label-panel) * {
        visibility: hidden;
    }

    body:has(.label-panel) .label-panel,
    body:has(.label-panel) .label-panel * {
        visibility: visible;
    }

    body:has(.label-panel) .label-panel {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        border: 0;
    }
}
