/**
 * Mandatag
 * Admin UI Design System Styles
 *
 * FINAL: Phase 51 – SYSTEMIZED (Token + State Driven)
 * Status: Production Hardened / Regression Safe
 */

/* =========================
RESET + FOUNDATION
========================= */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

/* =========================
DESIGN TOKENS
========================= */

:root {

    /* COLOR SYSTEM */
    --mt-bg: #0b1220;
    --mt-surface: #111a2e;
    --mt-surface-2: #0f172a;
    --mt-border: #1e293b;

    --mt-text: #e2e8f0;
    --mt-text-dim: #94a3b8;

    /* SEMANTIC */
    --mt-success-bg: #052e1b;
    --mt-success-text: #4ade80;

    --mt-error-bg: #2a0a0a;
    --mt-error-text: #f87171;

    --mt-warning-bg: #2a1f0a;
    --mt-warning-text: #fbbf24;

    --mt-info-bg: #0a1f2a;
    --mt-info-text: #60a5fa;

    /* ACTION */
    --mt-primary: #2563eb;
    --mt-danger: #dc2626;

    /* TERMINAL */
    --mt-cmd: #00ff9c;
    --mt-result: #cbd5e1;
    --mt-meta: #64748b;
    --mt-glow: rgba(0, 255, 156, 0.25);

    /* SPACING */
    --mt-space-xs: 4px;
    --mt-space-sm: 8px;
    --mt-space-md: 12px;
    --mt-space-lg: 16px;
    --mt-space-xl: 24px;

    /* RADIUS */
    --mt-radius-sm: 6px;
    --mt-radius-md: 8px;
    --mt-radius-lg: 12px;

    /* MOTION */
    --mt-fast: 120ms ease;
    --mt-normal: 180ms ease;

    /* Z-INDEX SCALE */
    --mt-z-base: 1;
    --mt-z-dropdown: 100;
    --mt-z-modal: 1000;
}

/* LIGHT THEME */

[data-theme="light"] {

    --mt-bg: #f8fafc;
    --mt-surface: #ffffff;
    --mt-surface-2: #f1f5f9;
    --mt-border: #e2e8f0;

    --mt-text: #0f172a;
    --mt-text-dim: #475569;

    --mt-cmd: #0a7f5a;
    --mt-result: #cbd5e1;

    /* Terminal-specific semantic tokens */
    --mt-terminal-bg-1: #0f172a;
    --mt-terminal-bg-2: #020617;
    --mt-terminal-border: rgba(148,163,184,0.12);
    --mt-meta: #94a3b8;
    --mt-glow: rgba(10, 127, 90, 0.15);
}

/* =========================
BASE SCOPE
========================= */

.mt-scope {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--mt-bg);
    color: var(--mt-text);
    min-height: 100vh;
}

/* =========================
LAYOUT
========================= */

.mt-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.mt-header {
    height: 56px;
    background: var(--mt-surface);
    display: flex;
    align-items: center;
    padding: 0 var(--mt-space-lg);
    border-bottom: 1px solid var(--mt-border);
}

.mt-header-left {
    display: flex;
    align-items: center;
    gap: var(--mt-space-sm);
}

.mt-logo { height: 28px; }

.mt-title { font-weight: 600; }

.mt-body {
    display: flex;
    flex: 1;
}

.mt-sidebar {
    width: clamp(180px, 20vw, 260px);
    background: var(--mt-surface-2);
    border-right: 1px solid var(--mt-border);
    padding: var(--mt-space-md);
}

.mt-content {
    flex: 1;
    padding: var(--mt-space-lg);
}

/* =========================
   PAGE HEADERS
========================= */

.mt-page-header {
    margin-bottom: var(--mt-space-xl);
}

.mt-page-title {
    font-size: 24px;
    font-weight: 800;
    margin: 0 0 var(--mt-space-xs) 0;
    letter-spacing: -0.02em;
}

.mt-page-subtitle {
    font-size: 14px;
    color: var(--mt-text-dim);
    margin: 0;
}

/* =========================
   LAYOUT UTILITIES
========================= */

.mt-grid {
    display: grid;
    gap: var(--mt-space-lg);
    margin: var(--mt-space-lg) 0;
    width: 100%;
}

.mt-w-full { width: 100%; }
.mt-h-full { height: 100%; }

.mt-grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.mt-grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.mt-panel {
    background: var(--mt-surface);
    padding: var(--mt-space-lg);
    border-radius: var(--mt-radius-lg);
    border: 1px solid var(--mt-border);
    margin-bottom: var(--mt-space-xl);
}

.mt-card-glass {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(12px);
}

.mt-card-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--mt-cmd);
}

.mono { font-family: ui-monospace, monospace; }

/* =========================
   FORM LAYOUTS
========================= */

.mt-form-inline {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}

.mt-form-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.mt-form-actions-full {
    grid-column: 1 / -1;
    display: flex;
    gap: var(--mt-space-lg);
    margin: var(--mt-space-sm) 0;
}

.mt-btn-block {
    grid-column: 1 / -1;
    width: 100%;
}

/* =========================
   ALERT
========================= */

.mt-alert {
    padding: var(--mt-space-sm) var(--mt-space-md);
    border-radius: var(--mt-radius-md);
    margin-bottom: var(--mt-space-md);
    display: flex;
    gap: var(--mt-space-sm);
    align-items: center;
    font-family: ui-monospace, monospace;
}

.mt-success {
    background: var(--mt-success-bg);
    color: var(--mt-success-text);
}

.mt-error {
    background: var(--mt-error-bg);
    color: var(--mt-error-text);
}

.mt-warning {
    background: var(--mt-warning-bg);
    color: var(--mt-warning-text);
}

.mt-info {
    background: var(--mt-info-bg);
    color: var(--mt-info-text);
}

/* =========================
   STATUS UTILITIES
========================= */

.mt-border-success { border-left: 4px solid var(--mt-success-text) !important; }
.mt-border-warning { border-left: 4px solid var(--mt-warning-text) !important; }
.mt-border-error   { border-left: 4px solid var(--mt-danger) !important; }

.mt-status-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 var(--mt-space-sm) 0;
}

.mt-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    background: var(--mt-surface-2);
    border: 1px solid var(--mt-border);
}

.mt-stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mt-stat-item .mt-label {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 11px;
}

.mt-stat-item .mt-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--mt-text);
}

/* =========================
   LISTS
========================= */

.mt-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mt-list li {
    padding: var(--mt-space-sm) 0;
    border-bottom: 1px solid var(--mt-border);
    font-size: 14px;
}

.mt-list li:last-child {
    border-bottom: none;
}

.mt-list-telemetry li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: ui-monospace, monospace;
}

/* =========================
   BUTTON SYSTEM
========================= */


.mt-btn {
    padding: var(--mt-space-sm) var(--mt-space-md);
    border-radius: var(--mt-radius-md);
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: var(--mt-fast);
}

.mt-btn:hover {
    filter: brightness(1.1);
}

.mt-btn:active {
    transform: scale(0.97);
}

.mt-btn:focus-visible {
    outline: 2px solid var(--mt-cmd);
    outline-offset: 2px;
}

.mt-primary {
    background: var(--mt-primary);
    color: white;
}

.mt-secondary {
    border: 1px solid var(--mt-border);
    color: var(--mt-text);
    background: transparent;
}

.mt-danger {
    background: var(--mt-danger);
    color: white;
}

/* STATES */

.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.is-loading {
    opacity: 0.7;
    pointer-events: none;
}

/* =========================
MODAL SYSTEM
========================= */

.mt-modal {
    position: fixed;
    inset: 0;
    z-index: var(--mt-z-modal);
    display: none;
    align-items: center;
    justify-content: center;
}

.mt-modal.is-open,
.mt-modal:not(.hidden) {
    display: flex;
}

.mt-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
}

.mt-modal-card {
    position: relative;
    width: calc(100% - 40px);
    max-width: 500px;
    background: var(--mt-surface);
    border-radius: var(--mt-radius-lg);
    padding: var(--mt-space-lg);
    border: 1px solid var(--mt-border);
    animation: mtFade var(--mt-normal);
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    margin: auto;
}

.mt-modal-lg { max-width: 800px !important; }
.mt-modal-xl { max-width: 1140px; }

.mt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: var(--mt-surface);
    border-radius: var(--mt-radius-md);
    overflow: hidden;
}

.mt-table th,
.mt-table td {
    padding: var(--mt-space-md) var(--mt-space-lg);
    text-align: left;
    border-bottom: 1px solid var(--mt-border);
}

.mt-table th {
    background: var(--mt-surface-2);
    font-weight: 700;
    color: var(--mt-text-dim);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
}

.mt-table tbody tr:hover {
    background: rgba(255,255,255, 0.02);
}

[data-theme="light"] .mt-table tbody tr:hover {
    background: rgba(0,0,0, 0.02);
}

.mt-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mt-modal-close {
    background: none;
    border: none;
    color: var(--mt-text);
    font-size: 18px;
    cursor: pointer;
}

/* =========================================================
   MT-DESIGN-SYSTEM-MODAL-HARDENING-001
   Refined sticky headers and scroll isolation
========================================================= */

.mt-modal-scroll {
    position: relative;
    max-height: 480px;
    overflow-y: auto;
    overflow-x: auto;
    border-radius: var(--mt-radius-md);
    background: var(--mt-surface-2);
}

.mt-modal-scroll table {
    border-collapse: separate !important;
    border-spacing: 0;
    width: 100%;
}

.mt-modal-scroll thead {
    position: sticky;
    top: 0;
    z-index: 101;
}

.mt-modal-scroll thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    background: var(--mt-surface-2) !important;
    background-clip: padding-box;
    color: var(--mt-text);
    font-weight: 700;
    padding: var(--mt-space-md);
    text-align: left;
    border-bottom: 2px solid var(--mt-border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mt-modal-scroll tbody td {
    padding: var(--mt-space-md);
    border-bottom: 1px solid var(--mt-border);
    background: var(--mt-surface-2);
}

.mt-modal-scroll tbody tr:hover td {
    background: var(--mt-surface);
}

/* =========================================================
   MT-DESIGN-SYSTEM-TELEMETRY-STREAM-001
   High-contrast, premium real-time feed
========================================================= */

.mt-stream-feed {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 600px;
    overflow-y: auto;
    padding: var(--mt-space-md);
    background: #020617; /* Hard black for maximum telemetry contrast */
    border-radius: var(--mt-radius-lg);
    border: 1px solid var(--mt-border);
}

.mt-stream-row {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: rgba(30, 41, 59, 0.4);
    border-left: 3px solid var(--mt-info-text);
    border-radius: var(--mt-radius-sm);
    font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
    font-size: 13px;
    transition: var(--mt-fast);
    animation: mtFadeIn 300ms ease-out;
}

.mt-stream-row:hover {
    background: rgba(30, 41, 59, 0.7);
    transform: translateX(4px);
}

/* RISK COLOR OVERRIDES */
.mt-stream-row.risk-low { border-left-color: var(--mt-info-text); }
.mt-stream-row.risk-medium { border-left-color: var(--mt-warning-text); }
.mt-stream-row.risk-high { border-left-color: var(--mt-danger); }
.mt-stream-row.risk-critical { 
    border-left-color: var(--mt-danger); 
    background: rgba(220, 38, 38, 0.1);
    box-shadow: inset 0 0 10px rgba(220, 38, 38, 0.05);
}

.mt-stream-main {
    display: grid;
    grid-template-columns: 80px 1fr 1fr 100px 100px;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.mt-risk-pill {
    font-weight: 800;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    text-align: center;
}

.risk-low .mt-risk-pill { background: var(--mt-info-bg); color: var(--mt-info-text); }
.risk-medium .mt-risk-pill { background: var(--mt-warning-bg); color: var(--mt-warning-text); }
.risk-high .mt-risk-pill { background: var(--mt-error-bg); color: var(--mt-error-text); }
.risk-critical .mt-risk-pill { 
    background: var(--mt-danger); 
    color: white;
    animation: mtPulse 2s infinite;
}

.mt-license { color: var(--mt-text); font-weight: 600; }
.mt-install { color: var(--mt-text-dim); }
.mt-score { color: var(--mt-cmd); font-weight: 700; text-align: right; }
.mt-time { color: var(--mt-meta); font-size: 11px; text-align: right; }

@keyframes mtFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes mtPulse {
    0% { opacity: 1; box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    70% { opacity: 0.8; box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); }
    100% { opacity: 1; box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}


/* =========================
   FORM SYSTEM
========================= */

.mt-form {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: var(--mt-space-lg);
    width: 100% !important;
}

.mt-input-group {
    display: flex;
    flex-direction: column;
    gap: var(--mt-space-xs);
}

.mt-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--mt-text-dim);
}

.mt-input, 
.mt-form input[type="text"],
.mt-form input[type="number"],
.mt-form select {
    background: var(--mt-surface-2);
    border: 1px solid var(--mt-border);
    color: var(--mt-text);
    padding: var(--mt-space-sm) var(--mt-space-md);
    border-radius: var(--mt-radius-md);
    font-size: 14px;
    transition: var(--mt-fast);
}

.mt-input:focus,
.mt-form input:focus,
.mt-form select:focus {
    outline: none;
    border-color: var(--mt-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.mt-checkbox-group {
    display: flex;
    align-items: center;
    gap: var(--mt-space-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--mt-text);
}

.mt-checkbox-group input {
    width: 16px;
    height: 16px;
    accent-color: var(--mt-primary);
}

/* =========================
   ANIMATIONS
========================= */

@keyframes mtFade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================
MOBILE
========================= */

@media (max-width: 768px) {
    .mt-sidebar { display: none; }
    .mt-content { padding: var(--mt-space-md); }
}

/* =========================================================
   MT-PATCH-LICENSE-INTELLIGENCE-CONTAINMENT-001
   Prevent dashboard table overflow + header stacking
   Scoped only to intelligence dashboard grids
========================================================= */

.dashboard-grid {
    display: grid;
    gap: 24px;

    grid-template-columns:
        repeat(auto-fit, minmax(340px, 1fr));

    align-items: start;

    min-width: 0;
}

.dashboard-grid .metric-card {
    min-width: 0;
    overflow: hidden;
}

.dashboard-grid .mt-table-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

/* ---------------------------------------------------------
   Restore sane table rendering
--------------------------------------------------------- */

.dashboard-grid .mt-table {
    width: 100%;
    table-layout: auto;
}

/* ---------------------------------------------------------
   Prevent vertical letter stacking regression
--------------------------------------------------------- */

.dashboard-grid .mt-table th {
    white-space: nowrap;

    word-break: normal;
    overflow-wrap: normal;
}

/* ---------------------------------------------------------
   Allow data wrapping safely
--------------------------------------------------------- */

.dashboard-grid .mt-table td {
    overflow-wrap: break-word;
}

/* ---------------------------------------------------------
   Stable identifiers
--------------------------------------------------------- */

.dashboard-grid .mono {
    white-space: nowrap;
}

/* =========================================================
   MT TERMINAL BLOCK SYSTEM (PHASE 91 – CONSOLIDATED)
   Token-driven + hardened observability rendering
   Zero duplication
   Regression safe
========================================================= */

/* ---------------------------------------------------------
   Terminal Container
--------------------------------------------------------- */

.mt-card-body {

    background:
        linear-gradient(
            180deg,
            var(--mt-terminal-bg-1, rgba(15,23,42,0.98)) 0%,
            var(--mt-terminal-bg-2, rgba(11,18,32,1)) 100%
        );

    border:
        1px solid var(
            --mt-terminal-border,
            rgba(148,163,184,0.08)
        );

    border-radius: var(--mt-radius-md);

    padding: 14px;

    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        monospace;

    font-size: 13px;
    line-height: 1.55;

    color: var(--mt-text);

    overflow: hidden;

    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.03),
        0 10px 30px rgba(0,0,0,0.16);
}

/* ---------------------------------------------------------
   Command Line
--------------------------------------------------------- */

.mt-cmd {

    color: var(--mt-cmd);

    margin-bottom: 6px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    font-weight: 600;

    letter-spacing: 0.02em;

    text-shadow:
        0 0 4px var(--mt-glow),
        0 0 10px rgba(0,255,156,0.12);
}

.mt-cmd::before {

    content: "> ";

    opacity: 0.72;

    color: var(--mt-meta);
}

/* ---------------------------------------------------------
   Terminal Result
--------------------------------------------------------- */

.mt-result {

    color: var(--mt-result);

    text-shadow:
        0 0 1px rgba(255,255,255,0.04);

    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;

    max-height: 300px;

    overflow-y: auto;
    overflow-x: auto;

    padding-right: 4px;

    font-variant-ligatures: none;
}

/* ---------------------------------------------------------
   Metadata
--------------------------------------------------------- */

.mt-meta {

    color: var(--mt-meta);

    font-size: 11px;

    margin-top: 6px;

    opacity: 0.9;
}

/* ---------------------------------------------------------
   Muted States
--------------------------------------------------------- */

.mt-result.is-muted {
    opacity: 0.6;
}

/* ---------------------------------------------------------
   Scrollbar Polish
--------------------------------------------------------- */

.mt-result::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.mt-result::-webkit-scrollbar-thumb {

    background:
        linear-gradient(
            180deg,
            #334155,
            #1e293b
        );

    border-radius: 999px;
}

.mt-result::-webkit-scrollbar-track {
    background: transparent;
}

/* ---------------------------------------------------------
   Legacy <pre> Compatibility
--------------------------------------------------------- */

.mt-card pre {

    white-space: pre-wrap;

    word-break: break-word;

    overflow-wrap: anywhere;

    max-height: 300px;

    overflow: auto;

    margin: 0;

    font: inherit;

    color: inherit;

    background: transparent;

    border: 0;
}

/* =========================================================
   🔥 MT-PATCH-EMAIL-QUEUE-TELEMETRY-SYSTEM-001 START
   Purpose:
   - Queue intelligence telemetry stabilization
   - Prevent first-paint flicker
   - Responsive observability tables
   - High-density telemetry rendering
   - Zero duplication with existing DS primitives
========================================================= */

/* ---------------------------------------------------------
   🔒 ROOT TELEMETRY CONTAINMENT
--------------------------------------------------------- */

[data-email-queue-root] {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* ---------------------------------------------------------
   🔒 PREVENT HYDRATION REPAINT FLICKER
--------------------------------------------------------- */

[data-email-queue-root] *,
[data-email-queue-root] *::before,
[data-email-queue-root] *::after {
    transition: none !important;
}

/* ---------------------------------------------------------
   🔒 TELEMETRY TABLE CONTAINER
--------------------------------------------------------- */

.email-telemetry-card {
    width: 100%;
    overflow: hidden;
    border-radius: var(--mt-radius-lg);

    background: var(--mt-surface);

    border: 1px solid var(--mt-border);

    backdrop-filter: blur(18px);

    box-shadow:
        0 15px 40px rgba(0,0,0,0.08);
}

/* ---------------------------------------------------------
   🔒 HORIZONTAL SCROLL GOVERNANCE
--------------------------------------------------------- */

.email-telemetry-scroll {
    width: 100%;

    overflow-x: auto;
    overflow-y: hidden;

    scrollbar-width: thin;
}

/* ---------------------------------------------------------
   🔒 STABLE TABLE ENGINE
--------------------------------------------------------- */

.email-telemetry-table {
    width: 100%;

    min-width: 1600px;

    border-collapse: collapse;

    table-layout: fixed;
}

/* ---------------------------------------------------------
   🔒 CELL STABILITY
--------------------------------------------------------- */

.email-telemetry-table th,
.email-telemetry-table td {
    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;

    vertical-align: middle;
}

/* ---------------------------------------------------------
   🔥 COLUMN WIDTH GOVERNANCE
--------------------------------------------------------- */

.email-telemetry-table th:nth-child(1),
.email-telemetry-table td:nth-child(1) {
    width: 70px;
}

.email-telemetry-table th:nth-child(2),
.email-telemetry-table td:nth-child(2) {
    width: 190px;
}

.email-telemetry-table th:nth-child(3),
.email-telemetry-table td:nth-child(3) {
    width: 240px;
}

.email-telemetry-table th:nth-child(4),
.email-telemetry-table td:nth-child(4) {
    width: 320px;
}

.email-telemetry-table th:nth-child(14),
.email-telemetry-table td:nth-child(14) {
    white-space: normal;

    word-break: break-word;

    overflow-wrap: anywhere;
}

/* ---------------------------------------------------------
   🔥 OBSERVABILITY GLOW
--------------------------------------------------------- */

.email-live-pulse {
    color: #fbbf24;

    text-shadow:
        0 0 8px rgba(251,191,36,0.45);
}

/* ---------------------------------------------------------
   🔥 TELEMETRY SCROLLBAR
--------------------------------------------------------- */

.email-telemetry-scroll::-webkit-scrollbar {
    height: 10px;
}

.email-telemetry-scroll::-webkit-scrollbar-thumb {
    background: var(--mt-border);

    border-radius: 999px;
}

/* ---------------------------------------------------------
   🔥 RESPONSIVE COLUMN COLLAPSE
--------------------------------------------------------- */

@media (max-width: 1600px) {

    .desktop-xl {
        display: none;
    }
}

@media (max-width: 1400px) {

    .desktop-lg {
        display: none;
    }
}

@media (max-width: 1200px) {

    .desktop-md {
        display: none;
    }

    .email-telemetry-table {
        min-width: 1200px;
    }
}

/* =========================================================
   🔥 MT-PATCH-EMAIL-QUEUE-TELEMETRY-SYSTEM-001 END
========================================================= */

/* =========================================================
   🔥 MT-PATCH-EMAIL-QUEUE-TABLE-REARCHITECTURE-001 START
========================================================= */

.email-telemetry-table {
    width: 100%;
    min-width: 1100px;
    table-layout: auto;
}

.email-recipient {
    font-weight: 600;
}

.email-subject {
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.75;
}

.email-telemetry-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;

    min-width: 320px;

    font-size: 12px;
}

.email-message-id {
    font-family: ui-monospace, monospace;
    opacity: 0.7;
}

.email-error-block {
    color: #f87171;

    white-space: normal;

    word-break: break-word;

    overflow-wrap: anywhere;

    padding: 8px;

    border-radius: 8px;

    background: rgba(239,68,68,0.08);
}

/* =========================================================
   🔥 MT-PATCH-EMAIL-QUEUE-TABLE-REARCHITECTURE-001 END
========================================================= */

/* =========================================================
   🔥 MT-PATCH-EMAIL-LIVE-TOOLBAR-001 START
========================================================= */

.email-toolbar {
    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 16px;

    margin-bottom: 18px;

    flex-wrap: wrap;
}

.email-toolbar-left,
.email-toolbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.email-live-indicator {
    display: flex;
    align-items: center;
    gap: 8px;

    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;

    color: #22c55e;
}

.email-live-dot {
    width: 10px;
    height: 10px;

    border-radius: 999px;

    background: #22c55e;

    box-shadow:
        0 0 12px rgba(34,197,94,0.7);
}

/* =========================================================
   🔥 MT-PATCH-EMAIL-LIVE-TOOLBAR-001 END
========================================================= */

/* ==========================================================
   MT-PATCH-LIVE-STREAM-UI-STABILIZATION-001
========================================================== */

[data-mt-stream="activation"] {
    position: relative;

    height: 620px;
    max-height: 70vh;
    overflow-y: auto;

    padding: 12px;

    border-radius: 12px;

    background: #0f172a;
    border: 1px solid rgba(255,255,255,0.08);

    display: flex;
    flex-direction: column;
    gap: 8px;

    contain: layout paint;
}

.mt-stream-row:hover {
    background: rgba(255,255,255,0.06);
}

.mt-stream-main {
    display: flex;
    align-items: center;
    gap: 10px;

    width: 100%;

    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mt-risk-pill {
    min-width: 58px;

    text-align: center;

    padding: 4px 8px;

    border-radius: 999px;

    font-size: 11px;
    font-weight: 700;
}

.risk-high .mt-risk-pill {
    background: rgba(239,68,68,0.18);
    color: #fca5a5;
}

.risk-medium .mt-risk-pill {
    background: rgba(245,158,11,0.18);
    color: #fcd34d;
}

#activationFeed {
    overflow-y: auto;
    contain: content;
    will-change: scroll-position;
}

.mt-stream-shell{
    border-radius:14px;
    overflow:hidden;
    background:#ffffff;
    border:1px solid #e2e8f0;
}

.mt-stream-toolbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:14px 16px;
    border-bottom:1px solid #e2e8f0;
    background:#f8fafc;
}

.mt-stream-title{
    font-size:14px;
    font-weight:600;
    color:#0f172a;
}

.mt-stream-meta{
    display:flex;
    align-items:center;
    gap:10px;
    font-size:12px;
    color:#64748b;
}

.mt-stream-divider{
    width:1px;
    height:12px;
    background:#cbd5e1;
}

.mt-stream-feed{
    height:420px;
    overflow-y:auto;
    overflow-x:hidden;
    background:#020617;
    padding:10px;
    display:flex;
    flex-direction:column;
    gap:8px;
    scroll-behavior:smooth;
}

/* =========================================================
   MT STREAM ROW SYSTEM
   Consolidated / Stable / Token Driven
   Replaces all duplicated .mt-stream-row blocks
========================================================= */

.mt-stream-row {

    /* Layout */
    display: flex;
    align-items: center;

    /* Sizing */
    min-height: 44px;

    /* Spacing */
    padding: 10px 12px;

    /* Visual */
    border-radius: 10px;

    background: var(
        --mt-stream-row-bg,
        rgba(255,255,255,0.03)
    );

    border: 1px solid var(
        --mt-stream-row-border,
        rgba(255,255,255,0.04)
    );

    /* Typography */
    font-size: 13px;
    line-height: 1.3;

    /* Rendering Stability */
    overflow: hidden;

    contain: layout style paint;

    /* Motion */
    transition:
        background 120ms ease,
        border-color 120ms ease,
        transform 120ms ease;
}

.mt-stream-row:hover {

    background: var(
        --mt-stream-row-hover-bg,
        rgba(255,255,255,0.06)
    );

    border-color: rgba(255,255,255,0.08);
}

/* =========================================================
   LIGHT THEME OVERRIDES
========================================================= */

[data-theme="light"] .mt-stream-row {

    --mt-stream-row-bg: #ffffff;

    --mt-stream-row-border: #e2e8f0;

    --mt-stream-row-hover-bg: #f8fafc;
}

.mt-stream-row:hover{
    background:#172554;
}

.mt-stream-main{
    display:flex;
    align-items:center;
    gap:12px;
    width:100%;
    overflow:hidden;
}

.mt-risk-pill{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-width:72px;
    height:24px;
    border-radius:999px;
    font-size:11px;
    font-weight:700;
    letter-spacing:.04em;
}

.risk-low .mt-risk-pill{
    background:#052e16;
    color:#4ade80;
}

.risk-medium .mt-risk-pill{
    background:#3f2f04;
    color:#facc15;
}

.risk-high .mt-risk-pill{
    background:#3f0d0d;
    color:#f87171;
}

.risk-critical .mt-risk-pill{
    background:#4c0519;
    color:#fb7185;
}

.mt-license{
    font-weight:600;
    color:#f8fafc;
    min-width:130px;
}

.mt-install{
    color:#94a3b8;
    flex:1;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.mt-score{
    color:#cbd5e1;
    font-size:12px;
}

.mt-time{
    color:#64748b;
    font-size:11px;
    min-width:80px;
    text-align:right;
}

.mt-section{
    margin-top:32px;
}

.mt-section-title{
    margin-bottom:12px;
    font-size:15px;
    font-weight:700;
    color:#0f172a;
}

.metric-card{
    border-radius:14px;
    background:#fff;
    border:1px solid #e2e8f0;
    box-shadow:
        0 1px 2px rgba(15,23,42,.04),
        0 8px 24px rgba(15,23,42,.03);
}

#activationMap{
    background:
        radial-gradient(circle at center,
        rgba(59,130,246,.12),
        transparent 70%),
        #020617;
}

.mt-modal-content{
    max-height:88vh;
}

.dashboard-content{
    max-width:1600px;
    margin:0 auto;
}

/* =========================================================
   MT-PATCH-ACTIVATION-STREAM-PAGE-001
   Real-Time Activation Stream Page
========================================================= */

.mt-page-title{
    margin-bottom:20px;
}

.mt-activation-stream-layout{
    display:grid;
    grid-template-columns:280px 1fr;
    gap:20px;
    align-items:start;
}

.mt-stream-metrics-card{
    position:sticky;
    top:20px;
}

.mt-stream-actions{
    margin-top:16px;

    display:flex;
    flex-wrap:wrap;
    gap:10px;
}

.mt-stream-btn-muted{
    background:#64748b;
}

.mt-stream-btn-info{
    background:#0ea5e9;
}

.metric-line{
    margin-bottom:10px;
}

.mt-stream-feed{
    height:620px;
    max-height:70vh;

    overflow-y:auto;
    overflow-x:hidden;

    padding:12px;

    border-radius:12px;

    background:#020617;

    display:flex;
    flex-direction:column;

    gap:8px;

    contain:layout paint;
}

@media (max-width: 900px){

    .mt-activation-stream-layout{
        grid-template-columns:1fr;
    }

    .mt-stream-metrics-card{
        position:relative;
        top:auto;
    }
}

/* =========================================================
   MT-PATCH-NOTIFICATION-LAYER-001
   Stable topbar notification interaction layer
========================================================= */

.topbar{
    position:relative;
    z-index:5000;
}

.top-actions{
    position:relative;
    z-index:5001;
    display:flex;
    align-items:center;
    gap:14px;
}

.mt-notification-wrapper{
    position:relative;
    z-index:5002;
}

.notif-bell{
    position:relative;
    z-index:5003;
    cursor:pointer;
    pointer-events:auto;
}

.notif-panel{
    position:absolute;
    top:calc(100% + 12px);
    right:0;
    width:380px;
    max-width:92vw;
    z-index:999999;
}

.notif-panel.hidden{
    display:none !important;
}
/* =========================================================
   DASHBOARD REFINEMENT (PHASE 82)
   Premium hardening and modular styling
   ========================================================= */

.mt-dashboard-container {
    padding: var(--mt-space-lg);
    animation: mtFadeIn 400ms ease-out;
}

.mt-alert {
    padding: var(--mt-space-md);
    border-radius: var(--mt-radius-md);
    margin-bottom: var(--mt-space-lg);
    border: 1px solid transparent;
}

.mt-alert-danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.mt-node-badge {
    padding: 8px 12px;
    border-radius: var(--mt-radius-sm);
    font-size: 12px;
    font-weight: 600;
    color: white;
    text-align: center;
    transition: var(--mt-fast);
}

.mt-node-badge.healthy { background: var(--mt-success); }
.mt-node-badge.degraded { background: var(--mt-danger); }

.mt-gauge-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--mt-space-xl) !important;
}

.mt-risk-needle {
    position: absolute;
    left: 50%;
    bottom: 50%;
    width: 4px;
    height: 80px;
    background: var(--mt-text);
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(-90deg);
    transition: transform 1s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 2px;
}

.mt-risk-summary {
    margin-top: var(--mt-space-lg);
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mt-risk-delta {
    font-size: 14px;
    font-weight: 600;
}

.mt-risk-delta.up { color: var(--mt-danger); }
.mt-risk-delta.down { color: var(--mt-success); }

.mt-intel-card {
    border-left: 4px solid var(--risk-color, var(--mt-border));
    padding: var(--mt-space-lg) !important;
    transition: var(--mt-normal);
}

.mt-intel-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--mt-shadow-lg);
}

.mt-intel-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: var(--mt-space-md) 0;
    font-size: 13px;
    color: var(--mt-text-dim);
}

.mt-intel-stats strong { color: var(--mt-text); }

.mt-ai-intel {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(168, 85, 247, 0.05) 100%);
    border: 1px solid rgba(99, 102, 241, 0.1);
}

.mt-map-container {
    padding: 0 !important;
    overflow: hidden;
    background: #0f172a;
    border-radius: var(--mt-radius-lg);
}

.mt-activation-map {
    width: 100%;
    height: 340px;
    display: flex;
}

.mt-live-feed {
    min-height: 100px;
}

.mt-activity-controls {
    display: flex;
    align-items: center;
    gap: var(--mt-space-md);
    margin-bottom: var(--mt-space-md);
}

.mt-w-full { width: 100%; }
.mt-text-center { text-align: center; }
.mt-mt-lg { margin-top: var(--mt-space-lg); }


/* =========================================================
   LICENSES UI REFINEMENT (PHASE 82)
   ========================================================= */

.mt-filter-card {
    padding: var(--mt-space-lg);
    margin: var(--mt-space-lg) 0;
    border-radius: var(--mt-radius-lg);
    background: var(--mt-surface);
    border: 1px solid var(--mt-border);
}

.mt-filter-grid {
    display: grid !important;
    grid-template-columns: 1fr auto auto auto !important;
    gap: var(--mt-space-md);
    align-items: center;
    width: 100%;
}

.mt-mono {
    font-family: var(--mt-font-mono);
    font-size: 12px;
    color: var(--mt-text);
}

.mt-risk-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.mt-risk-badge.risk-green { background: #dcfce7; color: #166534; }
.mt-risk-badge.risk-orange { background: #fef3c7; color: #92400e; }
.mt-risk-badge.risk-red { background: #fee2e2; color: #991b1b; }

.mt-table-container {
    margin-top: var(--mt-space-lg);
    overflow-x: auto;
}

.mt-btn-group {
    display: flex;
    gap: 8px;
}


/* =========================================================
   ACTIVATIONS UI REFINEMENT (PHASE 82)
   ========================================================= */



.mt-modal-footer {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-top: var(--mt-space-lg);
    padding-top: var(--mt-space-lg);
    border-top: 1px solid var(--mt-border);
    width: 100% !important;
    max-width: 100% !important;
    gap: var(--mt-space-lg);
    overflow: hidden !important;
}

#mt-bulk-actions {
    display: flex !important;
    align-items: center !important;
    gap: var(--mt-space-md) !important;
    flex: 1 !important;
    min-width: 0 !important;
}

.mt-bulk-summary {
    flex: 1 !important;
    font-size: 12px !important;
    color: var(--mt-text-dim) !important;
    white-space: normal !important;
    word-break: break-word !important;
    min-width: 0 !important;
    padding: 0 10px !important;
    line-height: 1.4 !important;
}

#mt-bulk-action-select {
    width: 180px !important;
    flex-shrink: 0;
}

.mt-btn-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    background: var(--mt-surface-3);
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: none; /* Controlled by JS */
    align-items: center;
    justify-content: center;
    color: var(--mt-text-dim);
}

.mt-btn-clear:hover { background: var(--mt-border); color: var(--mt-text); }

.mt-audit-display {
    background: #020617;
    color: #22c55e;
    padding: var(--mt-space-md);
    border-radius: var(--mt-radius-md);
    overflow: auto;
    max-height: 400px;
    font-family: var(--mt-font-mono);
    font-size: 13px;
    line-height: 1.5;
}

.mt-pagination-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: 6px;
    background: var(--mt-surface);
    border: 1px solid var(--mt-border);
    color: var(--mt-text);
    text-decoration: none;
    font-weight: 600;
    transition: var(--mt-fast);
}

.mt-pagination-item:hover { border-color: var(--mt-info-text); background: var(--mt-surface-2); }
.mt-pagination-item.is-active { background: var(--mt-info-text); color: white; border-color: var(--mt-info-text); }

.mt-mb-md { margin-bottom: var(--mt-space-md); }
.mt-mb-lg { margin-bottom: var(--mt-space-lg); }
.mt-mt-sm { margin-top: var(--mt-space-sm); }
.mt-mt-lg { margin-top: var(--mt-space-lg); }
.mt-flex-1 { flex: 1; }
.mt-relative { position: relative; }
.mt-text-xs { font-size: 11px; }
.mt-text-sm { font-size: 13px; }


/* =========================================================
   GENERIC UI COMPONENTS (PHASE 82)
   ========================================================= */

.mt-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    background: var(--mt-surface-2);
    color: var(--mt-text-dim);
    border: 1px solid var(--mt-border);
    text-transform: uppercase;
}

.mt-badge-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.mt-badge-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.mt-badge-danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.mt-badge-info { background: #e0f2fe; color: #075985; border-color: #bae6fd; }

.mt-text-xs { font-size: 11px; }
.mt-text-dim { color: var(--mt-text-dim); }

.mt-gap-md { gap: var(--mt-space-md); }
.mt-items-center { align-items: center; }
.mt-flex { display: flex; }


.mt-alert-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}


.mt-border-success { border-left: 4px solid #22c55e !important; }
.mt-border-warning { border-left: 4px solid #f59e0b !important; }
.mt-border-danger  { border-left: 4px solid #ef4444 !important; }
.mt-status-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.mt-stat-item .mt-label { font-size: 11px; text-transform: uppercase; color: var(--mt-text-dim); font-weight: 600; }
.mt-stat-item .mt-value { font-size: 15px; font-weight: 600; }
.mt-chart-container { background: var(--mt-surface); border-radius: 8px; padding: 16px; border: 1px solid var(--mt-border); height: 300px; }

