/* TR-FMS Professional Dashboard Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Dark Mode Colors (Default) - Modern Industrial */
    --bg-dark: #090d16;
    --panel-bg: #0f1524;
    --panel-header: #151e30;
    --card-bg: #182337;
    --border-color: #24314c;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Accent Colors — primary retargeted to the T-Robotics brand cyan.
       --accent-blue is the app-wide primary lever; many components reference it. */
    --accent-blue: #11b5d6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --accent-purple: #8b5cf6;
    --accent-cyan: #22d3ee;
    --accent-teal: #14b8a6;
    --accent-orange: #f97316;
    --surface-raised: #1c273e;
    --surface-glass: rgba(15, 21, 36, 0.88);
    --border-strong: #3b4f76;
    /* Brand accent as an RGB triplet for rgba() tints (top bar, glows). */
    --accent-rgb: 34, 211, 238;

    /* Gradients */
    --gradient-blue: linear-gradient(135deg, #0891b2 0%, #22d3ee 100%);
    --gradient-green: linear-gradient(135deg, #059669 0%, #34d399 100%);
    --gradient-header: linear-gradient(180deg, #151e30 0%, #0f1524 100%);

    /* Canvas */
    --canvas-bg: #05080f;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.7);
    --shadow-glow: 0 0 20px rgba(34, 211, 238, 0.18);

    /* Dimensions */
    --sidebar-width: 340px;
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --control-height: 32px;

    /* Button variants */
    --btn-secondary-bg: #1e293b;

    /* Shared product surfaces */
    --surface-page: var(--bg-dark);
    --surface-panel: var(--panel-bg);
    --surface-card: #131b2d;
    --surface-card-raised: #1a243b;
    --surface-card-muted: #0b0f19;
    --surface-card-soft: rgba(148, 163, 184, 0.06);
    --surface-toolbar: rgba(15, 21, 36, 0.9);
    --surface-input: #090d16;
    --surface-input-hover: #131b2d;
    --surface-table-head: rgba(255, 255, 255, 0.02);
    --surface-table-row-alt: rgba(148, 163, 184, 0.04);
    --surface-table-row-hover: rgba(59, 130, 246, 0.08);
    --surface-heatmap: linear-gradient(180deg, rgba(15, 21, 36, 0.96), rgba(9, 13, 22, 0.98));
    --surface-overlay: rgba(11, 15, 26, 0.96);
    --surface-neutral-soft: rgba(148, 163, 184, 0.12);
    --surface-info-soft: rgba(59, 130, 246, 0.1);
    --surface-success-soft: rgba(16, 185, 129, 0.1);
    --surface-warning-soft: rgba(245, 158, 11, 0.1);
    --surface-danger-soft: rgba(239, 68, 68, 0.1);

    /* Shared text + emphasis */
    --text-heading: #f8fafc;
    --text-soft: #cbd5e1;
    --text-inverse: #ffffff;
    --icon-muted: #64748b;

    /* Controls */
    --control-bg: var(--surface-input);
    --control-border: var(--border-color);
    --control-border-strong: var(--border-strong);
    --focus-ring: rgba(59, 130, 246, 0.25);

    /* Shared shadows / radii / spacing */
    --card-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
    --toolbar-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    --radius-card: 16px;
    --radius-control: 10px;
    --radius-pill: 999px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 28px;
    --space-8: 32px;

    /* Type scale (Inter). Sizes equal what the busiest surfaces already use — visually a no-op;
       it just makes them nameable so pages stop drifting. */
    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-base: 14px;
    --fs-md: 16px;
    --fs-lg: 20px;
    --fs-xl: 24px;
    --fw-normal: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --lh-tight: 1.25;
    --lh-normal: 1.5;

    /* Canonical radius aliases — the codebase mixes --radius-card/control/pill with
       --border-radius/--border-radius-sm. Keep both; standardize new/migrated code on these: */
    --radius-sm: var(--border-radius-sm);   /* 4px  — controls, chips */
    --radius-md: var(--border-radius);      /* 8px  — buttons, small cards */
    --radius-lg: var(--radius-card);        /* 16px — panels, big cards */

    /* Shared chart palette */
    --chart-text: #cbd5e1;
    --chart-axis: #64748b;
    --chart-grid: rgba(148, 163, 184, 0.12);
    --chart-color-1: #3b82f6;
    --chart-color-2: #10b981;
    --chart-color-3: #f59e0b;
    --chart-color-4: #ef4444;
    --chart-color-5: #8b5cf6;
    --chart-color-6: #06b6d4;

    /* Scrollbars */
    --scrollbar-track: rgba(148, 163, 184, 0.04);
    --scrollbar-thumb: rgba(148, 163, 184, 0.25);
    --scrollbar-thumb-hover: rgba(148, 163, 184, 0.45);

    /* Main-canvas theme tokens */
    --map-bg: #090d16;
    --map-grid-major: #1e293b;
    --map-grid-minor: #0f172a;
    --map-edge: #334155;
    --map-node: #475569;
    --map-background: #1e293b;
    --map-pointcloud: #46506a;
}

/* Light Mode Theme */
body.light-mode {
    --bg-dark: #f4f7fb;
    --panel-bg: #ffffff;
    --panel-header: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #d9e2ec;
    --border-strong: #c6d3e1;
    --surface-raised: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.86);
    --text-primary: #172033;
    --text-secondary: #526173;
    --text-muted: #7b8797;
    --accent-blue: #0e8aa3;
    --accent-rgb: 14, 138, 163;
    --accent-green: #16803c;
    --accent-red: #dc2626;
    --accent-yellow: #b7791f;
    --accent-purple: #7c3aed;
    --accent-cyan: #0891b2;
    --accent-teal: #0f9f8f;
    --accent-orange: #ea580c;
    --canvas-bg: #edf3f8;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 22px rgba(15, 23, 42, 0.09);
    --shadow-lg: 0 18px 44px rgba(15, 23, 42, 0.13);
    --shadow-glow: 0 0 18px rgba(37, 99, 235, 0.1);
    --gradient-blue: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
    --gradient-green: linear-gradient(135deg, #16803c 0%, #22a35a 100%);
    --gradient-header: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    --btn-secondary-bg: #e2e8f0;
    --surface-page: var(--bg-dark);
    --surface-panel: #ffffff;
    --surface-card: #ffffff;
    --surface-card-raised: #ffffff;
    --surface-card-muted: #f8fafc;
    --surface-card-soft: rgba(37, 99, 235, 0.05);
    --surface-toolbar: rgba(255, 255, 255, 0.9);
    --surface-input: #ffffff;
    --surface-input-hover: #f8fafc;
    --surface-table-head: rgba(255, 255, 255, 0.96);
    --surface-table-row-alt: rgba(241, 245, 249, 0.84);
    --surface-table-row-hover: rgba(219, 234, 254, 0.66);
    --surface-heatmap: linear-gradient(180deg, rgba(226, 232, 240, 0.95), rgba(241, 245, 249, 0.98));
    --surface-overlay: rgba(15, 23, 42, 0.94);
    --surface-neutral-soft: rgba(148, 163, 184, 0.16);
    --surface-info-soft: rgba(37, 99, 235, 0.1);
    --surface-success-soft: rgba(22, 128, 60, 0.1);
    --surface-warning-soft: rgba(183, 121, 31, 0.12);
    --surface-danger-soft: rgba(220, 38, 38, 0.1);
    --text-heading: #172033;
    --text-soft: #334155;
    --text-inverse: #ffffff;
    --icon-muted: #7b8797;
    --control-bg: #ffffff;
    --control-border: #c6d3e1;
    --control-border-strong: #94a3b8;
    --focus-ring: rgba(37, 99, 235, 0.18);
    --card-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    --toolbar-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    --chart-text: #475569;
    --chart-axis: #64748b;
    --chart-grid: rgba(148, 163, 184, 0.2);
    --chart-color-1: #2563eb;
    --chart-color-2: #10b981;
    --chart-color-3: #f59e0b;
    --chart-color-4: #ef4444;
    --chart-color-5: #8b5cf6;
    --chart-color-6: #06b6d4;
    --scrollbar-track: rgba(148, 163, 184, 0.12);
    --scrollbar-thumb: rgba(100, 116, 139, 0.34);
    --scrollbar-thumb-hover: rgba(71, 85, 105, 0.5);
    --map-bg: #f5f5f5;
    --map-grid-major: #d0d0d0;
    --map-grid-minor: #e8e8e8;
    --map-edge: #999999;
    --map-node: #666666;
    --map-background: #cccccc;
    --map-pointcloud: #94a3b8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background:
        radial-gradient(circle at 18% 10%, rgba(57, 197, 207, 0.08), transparent 28%),
        radial-gradient(circle at 82% 0%, rgba(88, 166, 255, 0.07), transparent 26%),
        var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100dvh;
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body.product-scroll-page {
    overflow-y: auto;
    overflow-x: hidden;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    scrollbar-gutter: stable;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

html,
body,
#sidebar,
.fr-table-wrap,
.fr-heatmap-shell,
#sim-robot-list {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
#sidebar::-webkit-scrollbar,
.fr-table-wrap::-webkit-scrollbar,
.fr-heatmap-shell::-webkit-scrollbar,
#sim-robot-list::-webkit-scrollbar {
    width: 11px;
    height: 11px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
#sidebar::-webkit-scrollbar-track,
.fr-table-wrap::-webkit-scrollbar-track,
.fr-heatmap-shell::-webkit-scrollbar-track,
#sim-robot-list::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
#sidebar::-webkit-scrollbar-thumb,
.fr-table-wrap::-webkit-scrollbar-thumb,
.fr-heatmap-shell::-webkit-scrollbar-thumb,
#sim-robot-list::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
#sidebar::-webkit-scrollbar-thumb:hover,
.fr-table-wrap::-webkit-scrollbar-thumb:hover,
.fr-heatmap-shell::-webkit-scrollbar-thumb:hover,
#sim-robot-list::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    background-clip: padding-box;
}

.product-page-shell {
    width: 100%;
    margin: 0 auto;
    padding: 24px 24px 40px;
    box-sizing: border-box;
}

.product-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: var(--radius-control);
    border: 1px solid var(--control-border);
    background: var(--surface-card);
    color: var(--text-soft);
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.product-theme-toggle:hover {
    background: var(--surface-card-muted);
    border-color: var(--control-border-strong);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.product-theme-toggle:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.product-empty-state {
    color: var(--text-muted);
    background: var(--surface-card-soft);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-control);
    padding: 14px 16px;
}

.product-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-pill);
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.product-badge--neutral {
    background: var(--surface-neutral-soft);
    color: var(--text-soft);
}

.product-badge--info {
    background: var(--surface-info-soft);
    color: var(--accent-blue);
}

.product-badge--success {
    background: var(--surface-success-soft);
    color: var(--accent-green);
}

.product-badge--warning {
    background: var(--surface-warning-soft);
    color: var(--accent-yellow);
}

.product-badge--danger {
    background: var(--surface-danger-soft);
    color: var(--accent-red);
}

/* Layout */
/* Module pages: offset content below the fixed top bar */
body.has-top-nav { padding-top: 48px; }

/* Top navigation bar (module tabs) */
#top-nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 16px;
    background:
        linear-gradient(180deg, rgba(22, 27, 34, 0.98), rgba(13, 17, 23, 0.96)),
        var(--panel-header, #151e30);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.top-nav-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex: 0 0 auto;
}
.top-nav-logo {
    height: 26px;
    width: auto;
    object-fit: contain;
    display: block;
}
.top-nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 0 0 auto;
}
.top-nav-version {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    white-space: nowrap;
}
.top-nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
}
.top-nav-brand-mark {
    font-weight: 800;
    letter-spacing: 0.08em;
    font-size: 14px;
    color: var(--text-primary);
}
.top-nav-tabs {
    display: flex;
    align-items: stretch;
    gap: 4px;
    height: 100%;
}
.top-nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 100%;
    padding: 0 14px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}
.top-nav-tab svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}
.top-nav-tab:hover {
    color: var(--text-primary);
    background: rgba(var(--accent-rgb), 0.10);
    border-bottom-color: var(--accent-blue);
}
.top-nav-tab.is-active {
    color: var(--text-primary);
    border-bottom-color: var(--accent-blue);
    background: rgba(var(--accent-rgb), 0.12);
}
.top-nav-tab.module-disabled {
    opacity: 0.4;
    filter: grayscale(0.6);
    cursor: not-allowed;
    pointer-events: auto;   /* still hoverable for the tooltip; click blocked in JS */
}
.top-nav-tab.module-disabled:hover {
    color: var(--text-secondary);
    background: transparent;
    border-bottom-color: transparent;
}

/* Generic disabled state for any engine-dependent widget/link/panel (not just nav
   tabs): greyed out and non-interactive, so an unavailable module shows a clear
   disabled state instead of letting you click through to an error page. */
.module-disabled:not(.top-nav-tab) {
    opacity: 0.45 !important;
    filter: grayscale(0.65);
    cursor: not-allowed !important;
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Theme-switched brand logo: dark logo by default, white logo in light mode. */
.top-nav-logo--light { display: none; }
body.light-mode .top-nav-logo--dark { display: none; }
body.light-mode .top-nav-logo--light { display: block; }

/* Account chip + dropdown menu (replaces the flat role badge + logout button) */
.top-nav-account { position: relative; display: flex; align-items: center; }
.account-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 10px 0 7px;
    background: rgba(var(--accent-rgb), 0.10);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    cursor: pointer;
    color: var(--text-primary);
    font: inherit;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.account-chip:hover { background: rgba(var(--accent-rgb), 0.18); border-color: var(--accent-blue); }
.account-avatar {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: #fff;
    background: var(--accent-blue);
    flex: 0 0 auto;
}
.account-role { font-size: 12px; font-weight: 700; letter-spacing: 0.01em; }
.account-caret {
    width: 14px; height: 14px;
    fill: none; stroke: currentColor; stroke-width: 2.2;
    stroke-linecap: round; stroke-linejoin: round; opacity: 0.7;
    transition: transform 0.15s ease;
}
.account-chip[aria-expanded="true"] .account-caret { transform: rotate(180deg); }

.account-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 184px;
    padding: 6px;
    background: var(--panel-bg, #161b22);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 70;
}
.account-menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border-color); margin-bottom: 6px; }
.account-menu-name { display: block; font-size: 13px; font-weight: 700; color: var(--text-primary); }
.account-menu-role { display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; color: var(--text-muted); margin-top: 2px; }
.account-menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
}
.account-menu-item:hover { background: rgba(var(--accent-rgb), 0.12); color: var(--text-primary); }
.account-menu-item svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* The View Controls header now hosts the drawer pin alongside the collapse chevron. */
.nav-header-actions { display: inline-flex; align-items: center; gap: 8px; }

/* Software version — unobtrusive fixed footer tag on every page. */
.app-version-tag {
    position: fixed;
    right: 12px;
    bottom: 10px;
    z-index: 55;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    opacity: 0.85;
    padding: 2px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface-page) 70%, transparent);
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
}

#app-container {
    display: flex;
    height: calc(100dvh - 48px);
    margin-top: 48px;       /* clear the fixed top bar */
    width: 100vw;
    position: relative;
    overflow: hidden;
}

/* Sidebar */
#sidebar {
    width: var(--sidebar-width);
    background: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 30;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    background:
        linear-gradient(180deg, rgba(22, 27, 34, 0.96), rgba(13, 17, 23, 0.94)),
        color-mix(in srgb, var(--panel-bg) 92%, transparent);
    transform: translateX(calc(-100% + 8px));
    transition: transform 0.22s ease, box-shadow 0.22s ease;
}

/* Brand header: split logo and compact login card */
/* Sidebar header row — drawer pin only (brand/logo moved to the top bar) */
.sidebar-pin-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 8px 10px 4px;
}

.brand-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: center;
    padding: 12px;
}
.brand-text img#brand-logo {
    max-height: 64px;
    width: 100%;
    height: auto;
    object-fit: contain;
}
.brand-login .mini-login-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    gap: 6px;
    background: transparent;
}
.brand-login .mini-login-card .btn {
    padding: 8px 12px;
}

.sidebar-nav-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 8px;
    scrollbar-gutter: stable;
}

.sidebar-nav-scroll::-webkit-scrollbar {
    width: 11px;
    height: 11px;
}

.sidebar-nav-scroll::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

.sidebar-nav-scroll::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.sidebar-nav-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    background-clip: padding-box;
}

.sidebar-status {
    flex: 0 0 auto;
    padding: 10px 12px 12px;
    /* Match Current Operation panel background */
    background: rgba(1, 4, 9, 0.12);
    color: var(--text-primary);
    border-radius: 8px;
    border: 1px solid rgba(61, 71, 84, 0.18);
}

.sidebar-status-head {
    background: linear-gradient(180deg, color-mix(in srgb, var(--panel-header) 94%, #0b1220), var(--panel-header));
    padding: 10px 16px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}


.sidebar-status-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.sidebar-status-actions .drawer-pin-btn,
.sidebar-status-actions .drawer-close-btn {
    transform: scale(0.92);
    transform-origin: center;
}

.sidebar-close-btn {
    width: 32px;
    height: 32px;
}

.sidebar-divider {
    margin: 10px 14px;
    border-top: 1px solid rgba(61, 71, 84, 0.55);
}

.sidebar-divider > span {
    display: block;
    height: 0;
    overflow: hidden;
}

.sidebar-nav-row {
    display: flex;
    gap: 8px;
}

.sidebar-nav-row .sidebar-nav-link {
    flex: 1;
    justify-content: center;
    padding: 9px 8px;
}

.sidebar-nav-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    row-gap: 6px;
    align-items: center;
    margin-bottom: 8px;
}

.settings-action-row .tiny-status-badge {
    flex: 0 0 auto;
}

.tiny-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    min-width: 64px;
    padding: 0 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    border: 1px solid var(--control-border-strong);
    color: var(--text-secondary);
    background: var(--surface-neutral-soft);
}

.sidebar-status-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 10px;
    color: var(--text-heading);
}

.sidebar-status-title .nav-icon {
    width: 16px;
    height: 16px;
    color: var(--text-heading);
}

.sidebar-status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
    font-size: 10px;
    padding: 12px;
    position: relative;
    background: transparent;
    border-radius: 0;
}


.sb-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.sb-row.sb-conn {
    justify-content: flex-start;
}

.sb-label {
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.sb-value {
    color: var(--text-primary);
    font-weight: 800;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

.sb-meta {
    color: var(--text-secondary);
    font-weight: 700;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

.sb-row.sb-conn .sb-meta {
    margin-left: auto;
}

.sb-row.sb-conn .status-dot {
    width: 8px;
    height: 8px;
    margin-right: 6px;
    flex: 0 0 auto;
}

/* System Status — enterprise header + per-row status tags */
.sys-status-header { border-bottom: 1px solid var(--border-color); }
.sys-status-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.sys-status-heading {
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 11px;
    color: var(--text-primary);
}
.sys-health-count {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.sb-conn-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.sb-conn-right .sb-meta { margin-left: 0; max-width: 96px; }

.sb-tag {
    flex: 0 0 auto;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 999px;
    border: 1px solid transparent;
    text-transform: uppercase;
}
.sb-tag-ok {
    color: var(--accent-green, #10b981);
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.35);
}
.sb-tag-warn {
    color: var(--accent-yellow, #f59e0b);
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.35);
}
.sb-tag-err {
    color: var(--accent-red, #ef4444);
    background: rgba(239, 68, 68, 0.13);
    border-color: rgba(239, 68, 68, 0.40);
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 12px;
    border: 1px solid rgba(61, 71, 84, 0.55);
    background: rgba(148, 163, 184, 0.06);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 700;
}

.sidebar-nav-link:hover {
    background: rgba(88, 166, 255, 0.12);
    border-color: rgba(88, 166, 255, 0.45);
}

#sidebar.drawer-expanded {
    transform: translateX(0);
}

#sidebar.drawer-pinned {
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(88, 166, 255, 0.08);
}

/* Logo/Brand Area */
.brand-header {
    background:
        linear-gradient(135deg, rgba(45, 212, 191, 0.08), transparent 42%),
        var(--gradient-header);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.drawer-panel-header {
    background: var(--gradient-header);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.brand-logo {
    width: 36px;
    height: 36px;
    background: var(--gradient-blue);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
    box-shadow: var(--shadow-md);
}

.brand-text {
    flex: 1;
}

.drawer-pin-btn {
    border: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--panel-header) 92%, transparent);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 0;
    width: 32px;
    min-width: 32px;
    height: 24px;
    min-height: 24px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.drawer-pin-btn::before {
    content: "";
    display: block;
    width: 8px;
    height: 8px;
    margin: 0 auto;
    border-radius: 999px;
    background: var(--text-muted);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-muted) 16%, transparent);
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.drawer-pin-btn:hover {
    background: color-mix(in srgb, var(--accent-blue) 18%, var(--panel-header));
    border-color: color-mix(in srgb, var(--accent-blue) 65%, var(--border-color));
    color: var(--text-primary);
    transform: translateY(-1px);
}

.drawer-pin-btn.is-pinned {
    background: color-mix(in srgb, var(--accent-blue) 18%, var(--panel-header));
    border-color: color-mix(in srgb, var(--accent-blue) 55%, var(--border-color));
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(88, 166, 255, 0.14);
}

.drawer-pin-btn.is-pinned::before {
    background: var(--accent-green);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-green) 18%, transparent), 0 0 12px color-mix(in srgb, var(--accent-green) 45%, transparent);
    transform: scale(1.08);
}

.brand-text h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.brand-text span {
    font-size: 11px;
    color: var(--text-muted);
}

.panel-section {
    border-bottom: 1px solid var(--border-color);
}

.panel-header {
    background: linear-gradient(180deg, color-mix(in srgb, var(--panel-header) 94%, #0b1220), var(--panel-header));
    padding: 10px 16px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-panel-header {
    min-height: 42px;
}

/* nav-panel-header rendered as a direct link to a full page (Reports / Throughput / Map) */
.nav-panel-link {
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.nav-panel-link:hover {
    background: var(--card-bg);
    color: var(--text-primary);
}

.nav-panel-go {
    font-size: 13px;
    color: var(--text-muted);
    transition: transform 0.2s, color 0.2s;
}

.nav-panel-link:hover .nav-panel-go {
    color: var(--accent-blue);
    transform: translateX(2px);
}

.nav-panel-title {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.nav-icon,
.btn-icon,
.report-search-icon {
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-icon {
    width: 17px;
    height: 17px;
    color: var(--accent-blue);
    opacity: 0.95;
}

.connection-health-pill,
.activity-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid rgba(110, 118, 129, 0.35);
    background: rgba(110, 118, 129, 0.16);
    color: var(--text-secondary);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.connection-health-pill::before,
.activity-live-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
    box-shadow: 0 0 12px currentColor;
}

.connection-health-pill.is-online,
.activity-live-badge {
    color: var(--accent-green);
    border-color: rgba(63, 185, 80, 0.34);
    background: rgba(63, 185, 80, 0.12);
}

.connection-health-pill.is-warning {
    color: var(--accent-yellow);
    border-color: rgba(210, 153, 34, 0.34);
    background: rgba(210, 153, 34, 0.12);
}

.connection-health-pill.is-offline {
    color: var(--accent-red);
    border-color: rgba(248, 81, 73, 0.34);
    background: rgba(248, 81, 73, 0.12);
}

.connection-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px;
}

.connection-card {
    position: relative;
    overflow: hidden;
    padding: 12px;
    min-height: 124px;
    border: 1px solid rgba(61, 71, 84, 0.78);
    border-radius: 8px;
    background:
        linear-gradient(145deg, rgba(27, 34, 43, 0.96), rgba(13, 17, 23, 0.9)),
        var(--surface-raised);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow-sm);
}

.connection-card::after {
    content: "";
    position: absolute;
    inset: auto -20px -32px 18px;
    height: 62px;
    background: radial-gradient(circle, rgba(88, 166, 255, 0.18), transparent 65%);
    pointer-events: none;
}

.connection-card.is-online::after {
    background: radial-gradient(circle, rgba(63, 185, 80, 0.2), transparent 65%);
}

.connection-card.is-offline::after {
    background: radial-gradient(circle, rgba(248, 81, 73, 0.2), transparent 65%);
}

.connection-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.connection-icon {
    display: inline-flex;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.12);
    border: 1px solid rgba(88, 166, 255, 0.24);
}

.connection-icon svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.connection-name {
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.connection-state {
    margin-top: 3px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.connection-meta {
    min-height: 28px;
    margin-top: 4px;
    color: var(--text-secondary);
    font-family: 'SF Mono', monospace;
    font-size: 10px;
    line-height: 1.35;
}

.health-meter {
    position: relative;
    height: 5px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(110, 118, 129, 0.22);
}

.health-meter span {
    display: block;
    width: 38%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-yellow), var(--accent-red));
    transition: width 0.25s ease, background 0.25s ease;
}

.connection-card.is-online .health-meter span {
    width: 100%;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-teal));
}

.connection-card.is-warning .health-meter span {
    width: 62%;
    background: linear-gradient(90deg, var(--accent-yellow), var(--accent-orange));
}

.connection-card.is-offline .health-meter span {
    width: 24%;
    background: linear-gradient(90deg, var(--accent-red), #7f1d1d);
}

.btn-icon {
    width: 15px;
    height: 15px;
}

.panel-content {
    padding: 16px;
}

/* Collapsible Sections */
.collapsible .panel-header {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.collapsible .panel-header:hover {
    background: var(--card-bg);
}

.collapse-icon {
    font-size: 10px;
    transition: transform 0.3s ease;
    color: var(--text-muted);
}

.collapsible.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    /* NOTE: expanded content must be large enough for admin panels (e.g. Users list)
       otherwise the bottom gets clipped with no way to scroll. */
    max-height: 5000px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.collapsible.collapsed .collapsible-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* Tabs */
.tabs-section {
    border-bottom: 1px solid var(--border-color);
}

.tabs-header {
    display: flex;
    background: var(--panel-header);
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(88, 166, 255, 0.05);
}

.tab-btn.active {
    color: var(--accent-blue);
    background: var(--panel-bg);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-blue);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.button-group {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.button-group .btn {
    flex: 1;
}

/* Modern Button Styles */
.btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    width: 100%;
    margin-bottom: 6px;
    text-align: center;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
}

.btn.compact {
    padding: 6px 10px;
    font-size: 11px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(0);
}

/* Avoid the browser default focus outline “sticking” after mouse clicks (looks like the
   button scaled). Keep an accessible ring for keyboard navigation only. */
.btn:focus {
    outline: none;
}

.btn:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.btn:disabled,
.btn[disabled] {
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    pointer-events: none;
}

.btn-sending {
    opacity: 0.55;
    filter: grayscale(0.4);
}

.btn-failed {
    background: linear-gradient(135deg, #4a1010 0%, #7d2020 100%) !important;
    border-color: #7d2020 !important;
    opacity: 0.7;
    filter: blur(0.6px) grayscale(0.3);
}

.btn-success-flash {
    background: linear-gradient(135deg, #1a4a2a 0%, var(--accent-green) 100%) !important;
    border-color: var(--accent-green) !important;
}

.btn-primary {
    background: var(--gradient-blue);
    border: none;
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1a5fc9 0%, #388bfd 100%);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.btn-secondary {
    background: var(--border-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--text-muted);
    border-color: var(--text-muted);
    color: var(--bg-dark);
}

.btn-danger {
    background: linear-gradient(135deg, #b62324 0%, var(--accent-red) 100%);
    border: none;
    color: white;
}

.btn-danger:hover {
    filter: brightness(1.1);
}

.btn-warning {
    background: linear-gradient(135deg, #9a6700 0%, var(--accent-yellow) 100%);
    border: none;
    color: white;
}

.btn-warning:hover {
    filter: brightness(1.1);
}

/* Professional Control Grid System */
.ctrl-grid {
    display: grid;
    gap: 12px;
}

/* Emulator panel — keep it visually consistent with the main product UI
   and responsive inside the sidebar drawer. */
.sim-panel {
    gap: var(--space-3);
}

/* ── Emulator license lock overlay ─────────────────────────────────────────
   Covers the sim panel content when simulation is disabled by license.
   The panel header stays clickable so users can see the locked state. */
#emulator-panel-section {
    position: relative;  /* anchor for the absolute overlay */
}

.sim-license-lock {
    display: none;       /* JS shows this when license_feature_disabled */
    position: absolute;
    inset: 0;
    z-index: 10;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--panel-bg, #0f1923) 80%, transparent);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border-radius: 0 0 4px 4px;
    animation: sim-lock-fadein 0.25s ease;
}

@keyframes sim-lock-fadein {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0);    }
}

.sim-license-lock-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    text-align: center;
}

.sim-license-lock-inner svg {
    width: 32px;
    height: 32px;
    color: var(--text-muted, #6b7685);
    opacity: 0.7;
}

.sim-license-lock-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary, #94a3b8);
}

.sim-license-lock-msg {
    font-size: 11px;
    color: var(--text-muted, #6b7685);
    line-height: 1.4;
}

.sim-license-lock-link {
    font-size: 11px;
    color: var(--accent-blue, #3b82f6);
    text-decoration: none;
    margin-top: 2px;
    transition: opacity 0.15s;
}

.sim-license-lock-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* When locked, prevent expand/collapse interaction on the panel content */
#emulator-panel-section.sim-panel-locked .nav-panel-header {
    cursor: default;
    pointer-events: none;
}


/* Grid items default to min-width:auto — one long unbreakable log token would
   otherwise widen the whole panel past the sidebar and clip every control. */
.sim-panel > * {
    min-width: 0;
    max-width: 100%;
}

/* Inputs (~20ch intrinsic width) and selects (longest option) can't shrink by
   default — they scale form rows past the sidebar and clip the buttons. */
.sim-panel .ctrl-input-group {
    min-width: 0;
}

.sim-panel .ctrl-input-group .ctrl-input,
.sim-panel .ctrl-input-group select {
    min-width: 0;
}

/* Background (point cloud / floor plan) selector */
.ctrl-select {
    width: 100%;
    min-width: 0;
    height: var(--control-height, 32px);
    padding: 0 8px;
    font-size: 11px;
    color: var(--text-primary);
    background: var(--surface-input, #090d16);
    border: 1px solid var(--control-border, var(--border-color));
    border-radius: var(--border-radius-sm, 4px);
    cursor: pointer;
}
.ctrl-select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.sim-status-row {
    align-items: center;
}

.sim-status-badge {
    flex: 1;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sim-panel .ctrl-row {
    flex-wrap: wrap;
}

.sim-panel .ctrl-row .ctrl-btn {
    flex: 1 1 92px;
    min-width: 92px;
}

/* Emulator: keep Add Robot button size stable (avoid perceived "scale" on click) */
#sim-add-one-btn:hover,
#sim-add-one-btn:active,
#sim-add-one-btn:focus {
    transform: none !important;
    outline: none !important;
}
/* Keyboard focus must stay visible (WCAG): restore the design-system focus ring. */
#sim-add-one-btn:focus-visible {
    transform: none !important;
    outline: 2px solid var(--focus-ring) !important;
    outline-offset: 2px;
}

.sim-subsection {
    border-top: 1px solid var(--border-color);
    margin-top: var(--space-2);
    padding-top: var(--space-3);
    display: grid;
    gap: var(--space-2);
}

.sim-subsection-title {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0;
}

.sim-add-status {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: var(--space-1);
    min-height: 14px;
}

.sim-btn-secondary {
    background: var(--btn-secondary-bg);
    color: var(--text-primary);
    border: 1px solid var(--control-border);
}

.sim-btn-secondary:hover {
    filter: brightness(1.06);
}

.sim-wrap-row {
    gap: var(--space-2);
}

/* Emulator apply controls (Speed / SafeDist): each value input pairs with its own
   compact apply button. The button sizes to its label instead of taking an equal
   flex column, so the numeric value is never squeezed out of view; the pairs wrap as
   whole units (not mid-pair) when the sidebar narrows. */
.sim-apply-row {
    flex-wrap: wrap;
}
.sim-set-pair {
    display: flex;
    align-items: flex-end;
    gap: var(--space-2, 8px);
    flex: 1 1 150px;
    min-width: 0;
}
.sim-set-pair .ctrl-input-group {
    flex: 1;
    min-width: 0;
}
.sim-set-btn {
    flex: 0 0 auto;
    min-width: 52px;
    padding-left: 12px;
    padding-right: 12px;
    white-space: nowrap;
}

.sim-robot-list {
    margin-top: var(--space-2);
    min-height: 24px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Emulator robot list — capped height with internal scroll so robot count
   cannot inflate the emulator panel height and trigger a sidebar scrollbar. */
#sim-robot-list {
    max-height: clamp(200px, 34vh, 360px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
}

.sim-robot-empty {
    padding: 6px 0;
    color: var(--text-muted);
}

.sim-robot-card {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: color-mix(in srgb, var(--surface-card) 80%, transparent);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    padding: 5px 8px;
    margin-bottom: 4px;
    cursor: pointer;
    overflow: hidden;
    max-width: 100%;
}

/* Compact by default: one summary line per robot; controls expand on row click */
.sim-robot-card .sim-robot-actions,
.sim-robot-card .sim-robot-extra {
    display: none;
}

.sim-robot-card.expanded {
    padding: 8px 10px;
}

.sim-robot-card.expanded .sim-robot-actions {
    display: flex;
    flex-wrap: wrap;
}

.sim-robot-card.expanded .sim-robot-extra {
    display: block;
}

/* Always surface stuck warnings, even collapsed — they are diagnostics, not chrome */
.sim-robot-card .sim-robot-extra:has(.sim-robot-stuck) {
    display: block;
}

.sim-robot-chevron {
    width: 10px;
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.sim-robot-header {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.sim-robot-card.expanded .sim-robot-header {
    flex-wrap: wrap;
    gap: 8px;
}

/* Collapsed rows hide the per-robot E-Stop/Remove buttons (available when expanded) */
.sim-robot-card:not(.expanded) .sim-robot-header .sim-mini-btn {
    display: none;
}

.sim-robot-id {
    width: 2.3rem;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-primary);
}

.sim-robot-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 0 1 auto;
    font-size: 0.72rem;
    overflow: hidden;
}

.sim-robot-card.expanded .sim-robot-meta {
    min-width: 92px;
    flex: 1 1 120px;
}

.sim-robot-meta-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sim-robot-kv {
    font-family: 'SF Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-muted);
    /* Fixed column so changing node IDs (N:7 vs N:21) don't shift the row */
    flex: 0 0 3.2rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sim-robot-batt {
    font-family: 'SF Mono', monospace;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    /* Fixed column so 9% vs 100% renders the same width */
    flex: 0 0 2.6rem;
    text-align: right;
}

.sim-robot-status {
    flex: 1 1 30px;
    min-width: 0;
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}

.sim-robot-card.expanded .sim-robot-status {
    flex: 1 1 140px;
    min-width: 120px;
    text-align: left;
}

.sim-mini-btn {
    height: 24px;
    padding: 0 8px;
    border-radius: 8px;
    border: 1px solid var(--control-border);
    background: var(--btn-secondary-bg);
    color: var(--text-primary);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
}

.sim-mini-btn:hover {
    filter: brightness(1.06);
}

.sim-mini-btn:active {
    transform: translateY(0.5px);
}

.sim-mini-btn:focus {
    outline: none;
}

.sim-mini-btn:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.sim-mini-btn.sim-remove {
    width: 26px;
    padding: 0;
    background: transparent;
    color: var(--text-muted);
}

.sim-mini-btn.sim-estop.is-on {
    background: linear-gradient(135deg, #b62324 0%, var(--accent-red) 100%);
    color: #ffffff;
    border-color: color-mix(in srgb, var(--accent-red) 65%, var(--border-color));
}

.sim-mini-btn.sim-mode.is-manual {
    background: #e3b341;
    color: #111827;
    border-color: color-mix(in srgb, #e3b341 70%, var(--border-color));
}

/* Manual-station confirm — prominent (amber, gently pulsing) so the operator sees
   which robot is waiting for a manual load/unload. */
.sim-mini-btn.sim-manual-confirm {
    background: #d97706;
    color: #fff;
    font-weight: 600;
    border-color: #b45309;
    animation: sim-manual-pulse 1.4s ease-in-out infinite;
}
.sim-mini-btn.sim-manual-confirm:hover { background: #b45309; }
@keyframes sim-manual-pulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, #d97706 60%, transparent); }
    50%      { box-shadow: 0 0 0 4px color-mix(in srgb, #d97706 0%, transparent); }
}

.sim-robot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.sim-pill {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    height: 24px;
    padding: 0 6px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    /* Fixed width so per-hop waypoint counts don't re-wrap the actions row */
    min-width: 3.2rem;
    color: var(--accent-blue);
}

.sim-robot-extra {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    display: grid;
    gap: 4px;
}

.sim-robot-stuck {
    font-size: 0.72rem;
    color: var(--accent-red);
    word-break: break-word;
}

.sim-robot-hops {
    font-size: 0.72rem;
    color: var(--text-muted);
    /* One clipped line — long hop chains must not grow the card while driving */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Collapsed cards surface only the stuck warning, never the hops line */
.sim-robot-card:not(.expanded) .sim-robot-hops {
    display: none;
}

.sim-log-section {
    border-top: 1px solid var(--border-color);
    margin-top: var(--space-2);
    padding-top: var(--space-2);
}

.sim-log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.sim-log-box {
    max-height: clamp(120px, 18vh, 240px);
    font-family: 'SF Mono', monospace;
    font-size: 0.72rem;
    overflow-x: hidden;
    /* MQTT topics are single long tokens — break anywhere instead of widening the panel */
    overflow-wrap: anywhere;
    word-break: break-all;
}

.sim-log-placeholder {
    color: var(--text-muted);
}

.ctrl-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ctrl-input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.ctrl-label {
    font-size: 10px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    height: 12px;
    display: flex;
    align-items: center;
}

.ctrl-input,
select {
    width: 100%;
    height: var(--control-height);
    background: var(--bg-dark);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0 10px;
    font-size: 12px;
    font-family: 'SF Mono', monospace;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    margin-bottom: 0;
}

.ctrl-input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.15);
}

.ctrl-input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

.btn.ctrl-btn {
    height: var(--control-height);
    margin-bottom: 0;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 600;

    /* Prevent “wrap jitter” in narrow sidebars (appears as a button suddenly scaling bigger).
       Allow slight shrinking instead of pushing sibling buttons onto a new line. */
    flex-shrink: 1;
    min-width: 0;
    width: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.report-title-block {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 20px;
    border-right: 1px solid var(--border-color);
    min-height: 62px;
}

.report-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.report-toolbar .report-tab {
    height: 100%;
    min-height: 62px;
    white-space: nowrap;
}

.report-search {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: auto;
    flex: 0 1 220px;
    min-width: 170px;
}

.report-search-icon {
    position: absolute;
    left: 12px;
    width: 15px;
    height: 15px;
    color: var(--text-secondary);
    pointer-events: none;
}

.report-search-input {
    background: var(--surface-input);
    border: 1px solid var(--control-border);
    color: var(--text-primary);
    padding: 0 14px 0 36px;
    border-radius: 6px;
    font-size: 13px;
    width: 100%;
    height: 38px;
    box-sizing: border-box;
    font-weight: 500;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.report-action {
    width: auto;
    min-width: 118px;
    height: 38px;
    padding: 0 13px;
    margin-bottom: 0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid rgba(240, 246, 252, 0.12);
    white-space: nowrap;
}

.report-action-success {
    background: var(--accent-green);
    color: var(--text-inverse);
}

.report-action-primary {
    background: var(--accent-blue);
    color: var(--text-inverse);
}

.report-action-danger {
    background: transparent;
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.report-action-danger:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: var(--text-inverse);
}

.report-toolbar-divider {
    width: 1px;
    height: 28px;
    background: var(--border-color);
    margin: 0 2px;
    flex: 0 0 auto;
}

.report-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    margin: 0;
    cursor: pointer;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--border-color);
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s;
}

.report-close-btn:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: #ffffff;
}

.fleet-report-body {
    /* Fleet Reports spacing tokens (page-scoped) */
    --fr-grid-gap: var(--space-5);
    --fr-section-gap: var(--space-5);
    --fr-table-card-height: 384px;

    margin: 0;
    min-height: 100vh;
    background: var(--surface-page);
    color: var(--text-primary);
}

/* Respect the hidden attribute inside Fleet Reports even on grid/flex containers. */
.fleet-report-body [hidden] {
    display: none !important;
}

.fr-page {
    max-width: 1680px;
}

.fr-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.fr-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-heading);
}

.fr-subtitle {
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 13px;
}

.fr-nav {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.fr-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-soft);
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.fr-nav-link:hover {
    color: var(--accent-blue);
    border-color: var(--control-border-strong);
}

.fr-nav-link.active {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.12);
    cursor: default;
}

.fr-toolbar-card,
.fr-card {
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: var(--card-shadow);
}

.fr-toolbar-card {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 14px 16px;
    margin-bottom: 18px;
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    background: var(--surface-toolbar);
    box-shadow: var(--toolbar-shadow);
}

.fr-toolbar {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px 14px;
    align-items: center;
}

.fr-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.fr-tab-btn {
    border: 1px solid var(--control-border);
    background: var(--surface-card-muted);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.fr-tab-btn.active {
    background: var(--gradient-blue);
    border-color: transparent;
    color: var(--text-inverse);
}

.fr-toolbar-controls {
    display: grid;
    grid-template-columns: minmax(220px, 320px) max-content max-content max-content max-content;
    gap: 10px;
    align-items: center;
    justify-content: end;
}

.fr-search {
    position: relative;
    min-width: 0;
}

.fr-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    width: 15px;
    height: 15px;
    color: var(--icon-muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.fr-search-input,
.fr-select {
    height: 36px;
    border: 1px solid var(--control-border);
    border-radius: 10px;
    background: var(--control-bg);
    color: var(--text-primary);
    font-size: 13px;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.fr-search-input {
    width: 100%;
    padding: 0 14px 0 38px;
}

.fr-select {
    width: auto;
    min-width: 116px;
    max-width: 220px;
    padding: 0 12px;
}

.fr-select-range {
    min-width: 0;
    width: max-content;
}

.fr-btn {
    height: 36px;
    border-radius: 10px;
    border: 1px solid transparent;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.fr-btn:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.fr-btn:hover {
    transform: translateY(-1px);
}

.fr-btn-primary {
    background: var(--gradient-blue);
    color: var(--text-inverse);
}

.fr-btn-secondary {
    background: var(--surface-card-muted);
    border-color: var(--control-border);
    color: var(--text-primary);
}

.fr-btn-secondary:hover {
    border-color: var(--control-border-strong);
}

.fr-btn-success {
    background: var(--gradient-green);
    color: var(--text-inverse);
}

.fr-btn-danger {
    background: var(--surface-card);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.fr-btn-danger:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: var(--text-inverse);
}

.fr-toolbar-meta {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}

.fr-shell {
    display: flex;
    flex-direction: column;
    gap: var(--fr-section-gap, 20px);
}

/* Ensure consistent vertical spacing between all Fleet Reports sections */
#fr-view-overview,
#fr-view-logs:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: var(--fr-section-gap, 20px);
}

.fr-table-wrap-scroll {
    overflow: auto;
    max-height: 260px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--surface-card);
}

.fr-table-compact thead th {
    padding: 8px 12px;
}

.fr-table-compact tbody td {
    padding: 8px 12px;
}

.fr-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: var(--fr-grid-gap, 16px);
}

.fr-kpi-card {
    min-width: 0;
    padding: 16px;
}

.fr-kpi-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.fr-kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.1;
}

.fr-kpi-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.fr-kpi-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fr-kpi-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Per-metric tints — icon color from the accent token, square from a 14% alpha mix */
.fr-kpi-icon.tint-blue   { color: var(--accent-blue);   background: color-mix(in srgb, var(--accent-blue) 14%, transparent); }
.fr-kpi-icon.tint-green  { color: var(--accent-green);  background: color-mix(in srgb, var(--accent-green) 14%, transparent); }
.fr-kpi-icon.tint-purple { color: var(--accent-purple); background: color-mix(in srgb, var(--accent-purple) 14%, transparent); }
.fr-kpi-icon.tint-cyan   { color: var(--accent-cyan);   background: color-mix(in srgb, var(--accent-cyan) 14%, transparent); }
.fr-kpi-icon.tint-orange { color: var(--accent-orange); background: color-mix(in srgb, var(--accent-orange) 14%, transparent); }
.fr-kpi-icon.tint-teal   { color: var(--accent-teal);   background: color-mix(in srgb, var(--accent-teal) 14%, transparent); }

.fr-kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
}

.fr-kpi-trend.is-positive {
    color: var(--accent-green);
    background: color-mix(in srgb, var(--accent-green) 12%, transparent);
}

.fr-kpi-trend.is-negative {
    color: var(--accent-red);
    background: color-mix(in srgb, var(--accent-red) 12%, transparent);
}

.fr-kpi-trend.is-flat {
    color: var(--text-muted);
    background: color-mix(in srgb, var(--text-muted) 12%, transparent);
}

.fr-kpi-previous {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.fr-section-heading {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-heading);
    margin: 0;
}

.fr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--fr-grid-gap, 16px);
}

.fr-card {
    min-width: 0;
    padding: 16px;
    overflow: hidden;
}

/* Table cards: consistent height + inner scroll (Recent Alerts / Top lists / Traffic tables). */
.fr-card-table {
    display: flex;
    flex-direction: column;
    min-height: var(--fr-table-card-height, 384px);
}

.fr-card-table .fr-table-wrap {
    flex: 1 1 auto;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--surface-card);
}

.fr-card-table .fr-table {
    width: 100%;
}

.fr-alert-message {
    max-width: 560px;
    white-space: normal;
    word-break: break-word;
}

.fr-card-span-2 {
    grid-column: span 2;
}

.fr-stack {
    display: grid;
    gap: var(--fr-grid-gap, 16px);
}

/* Traffic Analytics: more balanced layout (Grafana-like wide primary + 2x2 secondary grid). */
.fr-traffic-top {
    display: grid;
    grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr);
    gap: var(--fr-grid-gap, 16px);
    align-items: stretch;
}

/* Traffic top row: make the heatmap feel like a primary panel and keep the
   hotspot list compact (it only renders top N rows). The card is a flex column
   so the heatmap shell grows to fill the whole card (the row stretches it to the
   taller neighbour) — full-scale rather than a fixed 240px chart-wrap. */
.fr-card-heatmap {
    display: flex;
    flex-direction: column;
}
.fr-card-heatmap .fr-heatmap-shell {
    flex: 1 1 auto;
    height: auto;
    min-height: clamp(340px, 46vh, 520px);
}

.fr-card-table.fr-card-table-compact {
    min-height: 320px;
}

.fr-traffic-bottom {
    display: grid;
    grid-template-columns: repeat(2, minmax(320px, 1fr));
    gap: var(--fr-grid-gap, 16px);
    align-items: stretch;
}

.fr-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.fr-card-header .fr-card-title {
    margin-bottom: 0;
}

.fr-card-title {
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-heading);
}

.fr-chart-wrap {
    position: relative;
    height: 240px;
    min-height: 200px;
}

.fr-chart-wrap-compact {
    height: 152px;
    min-height: 152px;
}

.fr-chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.fr-table-wrap {
    overflow-x: auto;
}

.fr-table-wrap-collapsible {
    position: relative;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--surface-card);
}

.fr-table-wrap-collapsible.is-collapsed {
    max-height: 380px;
    overflow-x: auto;
    overflow-y: hidden;
    transition: max-height 0.2s ease;
}

.fr-table-wrap-collapsible.is-expanded {
    max-height: 70vh;
    overflow: auto;
    transition: max-height 0.2s ease;
}

.fr-table-wrap-collapsible.is-collapsed::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 56px;
    background: linear-gradient(to bottom, rgba(0,0,0,0), var(--surface-card));
    pointer-events: none;
}

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

.fr-table thead th {
    text-align: left;
    color: var(--text-secondary);
    font-weight: 600;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-table-head);
}

.fr-table tbody td {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-soft);
    vertical-align: top;
}

.fr-table-logs thead th {
    position: sticky;
    top: 0;
    background: var(--surface-card);
    z-index: 1;
    padding: 10px 12px;
}

.fr-table-logs tbody td {
    padding: 10px 14px;
}

.fr-empty-row {
    text-align: center;
    padding: 32px 16px !important;
    color: var(--text-secondary) !important;
}

.fr-heatmap-shell {
    position: relative;
    height: 320px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--surface-heatmap);
}

.fr-heatmap-shell canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.fr-heatmap-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 12px;
}

.fr-heatmap-tooltip {
    position: absolute;
    display: none;
    pointer-events: none;
    min-width: 180px;
    max-width: 240px;
    background: var(--surface-overlay);
    border: 1px solid var(--control-border-strong);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-inverse);
    font-size: 11px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
    z-index: 3;
}

.fr-menu {
    position: relative;
}

.fr-menu > summary {
    list-style: none;
}

.fr-menu > summary::-webkit-details-marker {
    display: none;
}

.fr-menu-pop {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 210px;
    background: var(--surface-card);
    border: 1px solid var(--control-border-strong);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
    z-index: 30;
}

.fr-menu[open] .fr-menu-pop {
    display: block;
}

.fr-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    text-align: left;
}

.fr-menu-item:hover {
    background: var(--surface-card-muted);
    border-color: var(--control-border);
}

.fr-hotspot-list {
    display: grid;
    gap: 10px;
}

.fr-hotspot-item {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--surface-card-muted), var(--surface-card));
}

.fr-hotspot-item-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-bottom: 6px;
}

.fr-hotspot-rank {
    font-weight: 700;
    color: var(--text-heading);
}

.fr-hotspot-score {
    font-size: 11px;
    color: var(--accent-yellow);
}

.fr-hotspot-metrics {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 8px;
    font-size: 11px;
}

.fr-hotspot-metrics span:nth-child(odd) {
    color: var(--text-secondary);
}

.fr-data-availability {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.fr-tooltip-title {
    font-weight: 700;
    margin-bottom: 6px;
}

.fr-tooltip-grid {
    display: grid;
    gap: 4px;
    color: rgba(255, 255, 255, 0.84);
}

.fr-log-robot {
    color: var(--text-soft);
    font-weight: 600;
}

@media (max-width: 960px) {
    .fleet-report-body {
        --fr-table-card-height: 360px;
    }

    .fr-traffic-top,
    .fr-traffic-bottom {
        grid-template-columns: 1fr;
    }

    .report-title-block {
        min-height: 56px;
        padding-right: 12px;
    }

    .report-toolbar {
        gap: 8px;
        overflow-x: auto;
    }

    .report-toolbar .report-tab {
        min-height: 56px;
        padding: 0 14px !important;
    }

    .report-action {
        min-width: 104px;
    }

    .connection-grid {
        grid-template-columns: 1fr;
    }

    .product-page-shell {
        padding: 18px 16px 28px;
    }

    .fr-toolbar-card {
        position: static;
    }

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

    .fr-card-span-2 {
        grid-column: span 1;
    }

    .fr-chart-wrap {
        height: 240px;
    }
}

@media (max-width: 720px) {
    .fleet-report-body {
        --fr-table-card-height: 340px;
    }

    .fr-title {
        font-size: 24px;
    }

    .product-page-shell {
        padding: 16px 14px 24px;
    }

    .fr-toolbar {
        grid-template-columns: 1fr;
    }

    .fr-toolbar-controls {
        grid-template-columns: 1fr;
        justify-content: stretch;
    }

    .fr-search {
        max-width: none;
    }

    .fr-menu > summary,
    .fr-btn,
    .fr-select {
        width: 100%;
    }

    .fr-menu-pop {
        position: static;
        min-width: 0;
        margin-top: 8px;
        box-shadow: none;
    }

    .fr-kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: var(--fr-grid-gap, 16px);
    }

    .fr-table-logs {
        min-width: 880px;
    }
}

.job-system-header {
    padding: 2px 0 6px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}

.job-system-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.job-system-name {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.job-system-meta {
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-muted);
}

.system-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    border: 1px solid transparent;
}

.system-badge-source-fleet {
    color: #bfdbfe;
    background: rgba(31, 111, 235, 0.18);
    border-color: rgba(88, 166, 255, 0.3);
}

.system-badge-source-acs {
    color: #f5d0fe;
    background: rgba(163, 113, 247, 0.18);
    border-color: rgba(163, 113, 247, 0.3);
}

.system-badge-protocol-mqtt {
    color: #bbf7d0;
    background: rgba(63, 185, 80, 0.16);
    border-color: rgba(63, 185, 80, 0.28);
}

.system-badge-protocol-tcp {
    color: #fde68a;
    background: rgba(210, 153, 34, 0.16);
    border-color: rgba(210, 153, 34, 0.28);
}

.assignment-row {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 10px;
    border: 1px solid rgba(61, 71, 84, 0.64);
    border-left: 3px solid var(--text-muted);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(27, 34, 43, 0.94), rgba(13, 17, 23, 0.86));
    flex-wrap: wrap;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.assignment-row + .assignment-row {
    margin-top: 8px;
}

.assignment-row.status-active {
    border-left-color: var(--accent-green);
}

.assignment-row.status-moving {
    border-left-color: var(--accent-blue);
}

.assignment-row.status-waiting {
    border-left-color: var(--accent-yellow);
}

.assignment-row.status-error {
    border-left-color: var(--accent-red);
}

/* Override: ensure only the inline SVG inside the drawer-pin-btn is shown (hide pseudo icon) */
.drawer-pin-btn::before {
    display: none !important;
    content: none !important;
}

.drawer-pin-btn svg {
    width: 16px;
    height: 16px;
    display: inline-block;
    vertical-align: middle;
    fill: none;
    stroke: currentColor;
}

.drawer-pin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.assignment-id {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 80px;
}

.assignment-route,
.assignment-robot {
    color: var(--text-secondary);
}

.assignment-status {
    margin-left: auto;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(110, 118, 129, 0.12);
    border: 1px solid rgba(110, 118, 129, 0.2);
}

.assignment-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.assignment-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.assignment-badge-source {
    color: var(--text-primary);
    background: rgba(110, 118, 129, 0.18);
    border: 1px solid rgba(110, 118, 129, 0.28);
}

.assignment-badge-protocol {
    color: var(--text-primary);
    background: rgba(88, 166, 255, 0.12);
    border: 1px solid rgba(88, 166, 255, 0.25);
}

.assignment-cancel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-left: auto;
    cursor: pointer;
    color: var(--text-muted);
    border: 1px solid rgba(110, 118, 129, 0.28);
    border-radius: 7px;
    background: rgba(110, 118, 129, 0.1);
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.assignment-cancel-btn:hover {
    color: #ffffff;
    border-color: rgba(248, 81, 73, 0.55);
    background: rgba(248, 81, 73, 0.2);
}

.assignment-cancel-btn svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Specific Section Grid Layouts */
.acs-action-group {
    display: flex;
    gap: 6px;
    align-items: flex-end;
}

.acs-move-group {
    display: flex;
    gap: 6px;
    align-items: flex-end;
}

#acs-log {
    font-size: 11px;
    font-family: 'SF Mono', monospace;
    background: #010409;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 10px;
    margin-top: 12px;
    min-height: 80px;
    max-height: 120px;
    overflow-y: auto;
    color: var(--accent-cyan);
    white-space: pre-wrap;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

#acs-log::-webkit-scrollbar {
    width: 4px;
}

#acs-log::-webkit-scrollbar-thumb {
    background: var(--border-color);
}

/* Ensure System Status uses theme-aware background (dark/light) */
.sidebar-status {
    background: var(--surface-panel);
    border-top: 1px solid var(--border-color);
    color: var(--text-primary);
}





/* Toggle Switches */
.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
    transition: background 0.2s;
}

.checkbox-row label:hover {
    background: var(--card-bg);
}

.checkbox-row input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.checkbox-row input[type="checkbox"]:checked {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

.checkbox-row input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Form Inputs */
select,
input[type="text"],
input[type="number"] {
    width: 100%;
    height: var(--control-height);
    padding: 0 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    font-family: 'SF Mono', monospace;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 0;
    box-sizing: border-box;
}

select:focus,
input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.15);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236e7681' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 10px) center;
}

/* Robot List */
#robot-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.robot-card {
    background:
        linear-gradient(135deg, rgba(27, 34, 43, 0.98), rgba(13, 17, 23, 0.94)),
        var(--card-bg);
    border: 1px solid rgba(61, 71, 84, 0.72);
    border-radius: var(--border-radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
    position: relative;
    overflow: hidden;
}

.robot-card.fleet-disabled {
    opacity: 0.82;
    background: rgba(110, 118, 129, 0.12);
    border-color: rgba(110, 118, 129, 0.45);
}

.robot-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--text-muted);
    transition: background 0.2s;
}

.robot-card:hover {
    border-color: color-mix(in srgb, var(--accent-blue) 55%, var(--border-color));
    transform: translateX(2px);
    box-shadow: var(--shadow-md);
}

.robot-card.selected {
    border-color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.1);
}

.robot-card.selected::before {
    background: var(--accent-blue);
}

.robot-card.status-IDLE::before {
    background: var(--text-muted);
}

.robot-card.status-MOVING::before {
    background: var(--accent-green);
}

.robot-card.status-ERROR::before {
    background: var(--accent-red);
}

.robot-card.status-CHARGING::before {
    background: var(--accent-yellow);
}

.robot-card.status-OFFLINE::before {
    background: var(--text-muted);
}

.robot-card.robot-slot-empty {
    opacity: 0.45;
    border-color: var(--border-color);
}

.robot-card.robot-slot-empty::before {
    background: var(--border-color);
}

.robot-card.robot-slot-empty .robot-id {
    color: var(--text-muted) !important;
}

.robot-card.mismatch-alarm {
    border-color: var(--accent-red);
    animation: pulse-warning 2s infinite;
}

@keyframes pulse-warning {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(248, 81, 73, 0);
    }
}

.robot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}

.robot-title-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.robot-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.robot-id {
    font-weight: 800;
    font-size: 14px;
    color: var(--accent-blue);
}

.robot-manufacturer {
    overflow: hidden;
    color: var(--text-muted);
    font-family: 'SF Mono', monospace;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.robot-connection-chip,
.robot-warning-chip {
    flex: 0 0 auto;
    padding: 3px 7px;
    border-radius: 999px;
    color: var(--text-secondary);
    background: rgba(110, 118, 129, 0.14);
    border: 1px solid rgba(110, 118, 129, 0.24);
    font-family: 'SF Mono', monospace;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.robot-warning-chip {
    color: var(--accent-yellow);
    border-color: rgba(210, 153, 34, 0.32);
    background: rgba(210, 153, 34, 0.12);
}

.robot-status-text {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--panel-header);
    letter-spacing: 0.04em;
}

.robot-metrics {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 10px;
}

.robot-submetrics {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 10px;
}

.robot-charge-text {
    color: var(--accent-green);
    font-weight: 800;
}

.robot-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 9px;
    border-radius: 8px;
    border: 1px solid rgba(110, 118, 129, 0.22);
    color: var(--text-primary);
    background: rgba(110, 118, 129, 0.1);
    font-size: 11px;
    font-weight: 650;
}

.robot-info-row strong {
    display: inline-flex;
    align-items: center;
    margin-right: 5px;
    color: var(--text-primary);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.robot-info-row.is-load {
    color: #f3e8ff;
    border-color: rgba(163, 113, 247, 0.42);
    background: linear-gradient(135deg, rgba(163, 113, 247, 0.22), rgba(88, 166, 255, 0.08));
}

/* Robot is holding at a manual station awaiting an operator confirm. */
.robot-info-row.is-manual-wait {
    color: #fde9c8;
    border-color: rgba(217, 119, 6, 0.55);
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.26), rgba(217, 119, 6, 0.08));
}
.manual-confirm-btn {
    background: #d97706;
    color: #fff;
    font-weight: 600;
    border: 1px solid #b45309;
    border-radius: 5px;
    padding: 2px 10px;
    cursor: pointer;
    font-size: 11px;
    animation: sim-manual-pulse 1.4s ease-in-out infinite;
}
.manual-confirm-btn:hover { background: #b45309; }

.robot-info-row.is-target {
    color: #d8fff7;
    border-color: rgba(45, 212, 191, 0.42);
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.2), rgba(88, 166, 255, 0.08));
    flex-direction: column;
    align-items: center;
}

.robot-info-row.is-load strong {
    color: #f5d0fe;
}

.robot-info-row.is-target strong {
    color: #b8fff0;
}

.robot-target-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.robot-info-row.is-target .robot-route-row {
    margin-top: 6px;
    width: 100%;
    min-width: 0;
}

.robot-detail-row {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 9px;
}

.robot-detail-row.is-warning {
    color: var(--accent-yellow);
}

.robot-alert {
    margin-top: 8px;
    padding: 7px 8px;
    border-radius: 7px;
    font-size: 10px;
    line-height: 1.4;
}

.robot-alert.is-error,
.robot-alert.is-critical {
    color: #ff1509;
    border: 1px solid rgba(248, 81, 73, 0.5);
    background: rgba(248, 81, 73, 0.12);
}

.robot-alert.is-critical {
    color: #ffffff;
    background: rgba(248, 81, 73, 0.2);
}

.robot-comm-note {
    margin-bottom: 6px;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 10px;
    color: #d2d7de;
    background: rgba(110, 118, 129, 0.16);
    border: 1px solid rgba(110, 118, 129, 0.35);
}

.robot-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 38px;
    height: 22px;
    cursor: pointer;
}

.robot-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.robot-switch-slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(110, 118, 129, 0.55);
    transition: background 0.18s ease;
}

.robot-switch-slider::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
    transition: transform 0.18s ease;
}

.robot-switch input:checked + .robot-switch-slider {
    background: var(--accent-green);
}

.robot-switch input:checked + .robot-switch-slider::before {
    transform: translateX(16px);
}

.robot-switch input:disabled + .robot-switch-slider {
    cursor: wait;
    opacity: 0.72;
}

/* ── Battery row (inline: label + bar on same line) ── */
.robot-batt-row {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 9px;
}

.robot-batt-pct {
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 36px;
    white-space: nowrap;
}

.robot-battery-inline {
    flex: 1;
    height: 5px;
    background: rgba(110, 118, 129, 0.2);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.battery-level {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.battery-level-label {
    flex: 0 0 auto;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    min-width: 30px;
}

/* ── Route progress bar ── */
.robot-route-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 7px;
    min-width: 0;
}

.robot-route-label {
    flex: 0 0 auto;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    min-width: 30px;
}

.robot-route-bar {
    flex: 1;
    height: 4px;
    background: rgba(110, 118, 129, 0.18);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.04);
    min-width: 40px;
}

.robot-route-pct,
.robot-route-remain {
    white-space: nowrap;
}

.robot-route-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s ease;
    box-shadow: 0 0 4px currentColor;
}

.robot-route-pct {
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 800;
    min-width: 30px;
    text-align: right;
    font-family: 'SF Mono', monospace;
}

.robot-route-remain {
    flex: 0 0 auto;
    font-size: 9px;
    color: var(--text-muted);
    font-family: 'SF Mono', monospace;
    min-width: 34px;
    text-align: right;
}

/* Light-mode adjustments */
body.light-mode .robot-battery-inline,
body.light-mode .robot-route-bar {
    background: rgba(100, 116, 139, 0.15);
}

/* Main View */
#main-view {
    flex: 1;
    position: relative;
    background:
        radial-gradient(circle at 50% 40%, rgba(88, 166, 255, 0.06), transparent 34%),
        linear-gradient(180deg, #081018 0%, var(--canvas-bg) 100%);
    overflow: hidden;
    min-width: 0;
}

/* Right Panel */
#right-panel {
    width: 350px;
    background: var(--panel-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 30;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    background:
        linear-gradient(180deg, rgba(22, 27, 34, 0.97), rgba(9, 14, 20, 0.96)),
        color-mix(in srgb, var(--panel-bg) 92%, transparent);
    transform: translateX(calc(100% - 8px));
    transition: transform 0.22s ease, box-shadow 0.22s ease;
}

#right-panel.drawer-expanded {
    transform: translateX(0);
}

#right-panel.drawer-pinned {
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(88, 166, 255, 0.08);
}

canvas {
    display: block;
    cursor: grab;
    width: 100%;
    height: 100%;
}

canvas:active {
    cursor: grabbing;
}

/* Map Operations HUD */
#mqtt-status-bar {
    color: var(--text-primary);
}

#mqtt-status-bar.status-disconnected .ops-hud-header {
    border-color: color-mix(in srgb, var(--accent-red) 34%, var(--border-color));
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 170px;
    padding-right: 14px;
    border-right: 1px solid rgba(110, 118, 129, 0.18);
}

.map-status-card {
    min-width: 136px;
    border-right: 0;
}

.status-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.status-value {
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.02em;
}

.status-meta {
    font-family: 'SF Mono', monospace;
    font-size: 10px;
    opacity: 0.82;
    margin-left: 16px;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text-muted);
    box-shadow: 0 0 0 4px rgba(100, 116, 139, 0.18);
}

.status-dot.status-connected {
    background: var(--accent-green);
    box-shadow: 0 0 0 4px rgba(63, 185, 80, 0.18);
}

.status-dot.status-disconnected {
    background: var(--accent-red);
    box-shadow: 0 0 0 4px rgba(248, 81, 73, 0.18);
}

.status-dot.status-warning {
    background: var(--accent-yellow);
    box-shadow: 0 0 0 4px rgba(210, 153, 34, 0.18);
}

#map-overlay-hud {
    position: absolute;
    top: 14px;
    left: 56px;
    right: 56px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    pointer-events: none;
    z-index: 26;
    transition: left 0.22s ease, right 0.22s ease, transform 0.22s ease;
}

#map-overlay-hud>* {
    pointer-events: auto;
}

.ops-hud-panel {
    width: min(760px, calc(100vw - 150px));
    max-width: calc(100vw - 150px);
    overflow: hidden;
    border: 1px solid rgba(61, 71, 84, 0.82);
    border-radius: 14px;
    background:
        linear-gradient(135deg, rgba(27, 34, 43, 0.94), rgba(13, 17, 23, 0.88)),
        color-mix(in srgb, var(--panel-bg) 88%, transparent);
    box-shadow: var(--shadow-md);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    transition: width 0.22s ease, max-height 0.24s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.ops-hud-header {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 10px 8px 14px;
    border-bottom: 1px solid rgba(110, 118, 129, 0.18);
}

.ops-hud-title {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ops-hud-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.hud-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 24px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: color-mix(in srgb, var(--panel-header) 92%, transparent);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.hud-icon-btn:hover {
    background: color-mix(in srgb, var(--accent-blue) 14%, var(--panel-header));
    border-color: color-mix(in srgb, var(--accent-blue) 44%, var(--border-color));
    color: var(--text-primary);
}

.hud-icon-btn svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.22s ease;
}

.ops-hud-content {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr minmax(130px, 0.75fr);
    gap: 10px;
    padding: 10px;
    max-height: 170px;
    opacity: 1;
    transform: translateY(0);
    transition: max-height 0.24s ease, opacity 0.2s ease, padding 0.24s ease, transform 0.2s ease;
}

.hud-connection-card {
    min-height: 104px;
    padding: 10px;
}

.hud-connection-card .connection-card-top {
    margin-bottom: 7px;
}

.hud-connection-card .connection-icon {
    width: 26px;
    height: 26px;
}

.hud-connection-card .connection-state {
    font-size: 13px;
}

.hud-connection-card .connection-meta {
    min-height: 22px;
    font-size: 9px;
}

.ops-map-card {
    display: grid;
    gap: 8px;
    min-height: 104px;
    padding: 10px;
    border: 1px solid rgba(61, 71, 84, 0.72);
    border-radius: 8px;
    background: linear-gradient(145deg, rgba(27, 34, 43, 0.94), rgba(13, 17, 23, 0.88));
}

.ops-map-metric {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ops-user-row {
    align-items: center;
    gap: 6px;
    padding-top: 7px;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
}

.ops-user-row #user-role-badge {
    padding: 2px 7px;
    border-radius: 999px;
    color: #ffffff;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.ops-logout-btn {
    margin-left: auto;
    border: 0;
    background: transparent;
    color: var(--accent-red);
    cursor: pointer;
    font-size: 10px;
    font-weight: 800;
}

#map-overlay-hud.hud-collapsed .ops-hud-panel {
    width: min(330px, calc(100vw - 120px));
}

#map-overlay-hud.hud-collapsed .ops-hud-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
}

#map-overlay-hud.hud-collapsed .hud-icon-btn svg {
    transform: rotate(180deg);
}

#map-overlay-hud.hud-pinned .ops-hud-panel {
    border-color: color-mix(in srgb, var(--accent-blue) 42%, var(--border-color));
    box-shadow: var(--shadow-md), 0 0 0 1px color-mix(in srgb, var(--accent-blue) 18%, transparent);
}

body:has(#sidebar.drawer-expanded) #map-overlay-hud {
    left: calc(var(--sidebar-width) + 18px);
}

body:has(#right-panel.drawer-expanded) #map-overlay-hud {
    right: 368px;
}

#map-ops-strip {
    position: absolute;
    left: 56px;
    bottom: 20px;
    z-index: 24;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    border: 1px solid rgba(61, 71, 84, 0.82);
    border-radius: 12px;
    background: var(--surface-glass);
    box-shadow: var(--shadow-md);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    pointer-events: none;
}

body:has(#sidebar.drawer-expanded) #map-ops-strip {
    left: calc(var(--sidebar-width) + 18px);
}

body:has(#right-panel.drawer-expanded) #map-ops-strip {
    right: 368px;
}

.map-ops-card {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 30px;
    padding: 0 10px;
    color: var(--text-secondary);
    border: 1px solid rgba(110, 118, 129, 0.18);
    border-radius: 8px;
    background: rgba(1, 4, 9, 0.28);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.map-ops-icon {
    position: relative;
    display: inline-block;
    width: 18px;
    height: 10px;
    border-radius: 999px;
}

.map-ops-icon.route {
    background: linear-gradient(90deg, rgba(240, 136, 62, 0.2), rgba(240, 136, 62, 0.95));
}

.map-ops-icon.planned {
    background: repeating-linear-gradient(90deg, var(--accent-green) 0 5px, transparent 5px 8px);
    border: 1px solid rgba(63, 185, 80, 0.5);
}

.map-ops-icon.active {
    width: 12px;
    height: 12px;
    background: var(--accent-blue);
    box-shadow: 0 0 14px rgba(252, 163, 30, 0.829);
}

.map-ops-icon.charger {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    background: var(--accent-green);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22);
}

.activity-section,
.fleet-section {
    background: rgba(1, 4, 9, 0.12);
}

/* Ensure logo appears only in the body of the System Status panel */





.activity-header {
    min-height: 42px;
}

.activity-job-list {
    flex: 1;
    min-height: 20px;
    max-height: 430px;
    overflow-y: auto;
    padding: 10px;
    font-size: 11px;
}

.event-log-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 180px;
    max-height: 300px;
    border: 1px solid rgba(61, 71, 84, 0.55);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(1, 4, 9, 0.18);
}

.event-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mini-clear-btn {
    height: 24px;
    padding: 0 9px;
    cursor: pointer;
    border: 1px solid rgba(110, 118, 129, 0.38);
    border-radius: 999px;
    color: var(--text-muted);
    background: rgba(110, 118, 129, 0.1);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.mini-clear-btn:hover {
    color: var(--text-primary);
    border-color: rgba(88, 166, 255, 0.44);
    background: rgba(88, 166, 255, 0.14);
}

.event-log-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    font-family: 'SF Mono', monospace;
    font-size: 10px;
    line-height: 1.45;
    scroll-behavior: smooth;
}

.log-entry {
    display: grid;
    grid-template-columns: 58px 76px 1fr;
    gap: 7px;
    align-items: start;
    padding: 7px 8px;
    border: 1px solid rgba(61, 71, 84, 0.38);
    border-left: 3px solid var(--text-muted);
    border-radius: 7px;
    background: rgba(13, 17, 23, 0.66);
}

.log-entry + .log-entry {
    margin-top: 6px;
}

.log-entry.is-warning {
    border-left-color: var(--accent-yellow);
    background: rgba(210, 153, 34, 0.08);
}

.log-entry.is-error {
    border-left-color: var(--accent-red);
    background: rgba(248, 81, 73, 0.08);
}

.log-entry.is-operation {
    border-left-color: var(--accent-green);
}

.log-entry.is-muted {
    opacity: 0.46;
}

.log-time {
    color: var(--text-muted);
    opacity: 0.86;
}

.log-type {
    color: var(--text-primary);
    font-weight: 800;
    letter-spacing: 0.04em;
}

.log-message {
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

#map-overlay-hud>* {
    pointer-events: auto;
}

#map-quick-toolbar {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 8px;
    padding: 6px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--panel-bg) 86%, transparent);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

.map-hud-btn {
    border: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--panel-header) 92%, transparent);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.map-hud-btn:hover {
    background: color-mix(in srgb, var(--accent-blue) 22%, var(--panel-header));
    border-color: color-mix(in srgb, var(--accent-blue) 60%, var(--border-color));
    transform: translateY(-1px);
}

.drawer-handle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 25;
    border: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--panel-bg) 88%, transparent);
    color: var(--text-primary);
    border-radius: 14px;
    padding: 12px 10px;
    min-height: 124px;
    width: 34px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.drawer-handle:hover {
    background: color-mix(in srgb, var(--accent-blue) 22%, var(--panel-bg));
    border-color: color-mix(in srgb, var(--accent-blue) 60%, var(--border-color));
}

.drawer-handle.is-pinned {
    background: color-mix(in srgb, var(--accent-blue) 28%, var(--panel-bg));
    border-color: color-mix(in srgb, var(--accent-blue) 70%, var(--border-color));
    color: #ffffff;
}

.drawer-handle-left {
    left: 8px;
}

.drawer-handle-right {
    right: 8px;
}

/* Compact collapse button inside drawer headers */
.drawer-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 24px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: color-mix(in srgb, var(--panel-header) 92%, transparent);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.drawer-close-btn:hover {
    background: color-mix(in srgb, var(--accent-red) 14%, var(--panel-header));
    border-color: color-mix(in srgb, var(--accent-red) 50%, var(--border-color));
    color: var(--accent-red);
    transform: scale(1.08);
}

.drawer-close-btn svg {
    width: 13px;
    height: 13px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Group pin + close buttons in drawer headers */
.drawer-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Count Badges */
#robot-count-badge,
#map-robot-count-badge,
#current-ops-job-badge {
    background: var(--gradient-blue);
    padding: 2px 5px;
    border-radius: 2px;
    font-size: 13px;
    font-weight: 700;
    color: rgb(239, 239, 241);
    box-shadow: var(--shadow-sm);
    min-width: 10px;
    text-align: center;
}

/* Legend Styling */
.legend-panel {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.legend-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.legend-count {
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.04em;
    opacity: 0.78;
}

.legend-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.legend-group + .legend-group {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed color-mix(in srgb, var(--border-color) 80%, transparent);
}

.legend-group-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    min-height: 28px;
    padding: 5px 7px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 7px;
    background: color-mix(in srgb, var(--panel-header) 72%, transparent);
    border: 1px solid color-mix(in srgb, var(--border-color) 78%, transparent);
}

.legend-item span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.legend-color {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 0 10px color-mix(in srgb, currentColor 25%, transparent);
}

.legend-swatch-square {
    border-radius: 3px;
}

.legend-swatch-dot {
    border-radius: 999px;
}

/* Light mode: brighter industrial surfaces without the heavy dark shell. */
body.light-mode {
    background:
        radial-gradient(circle at 16% 8%, rgba(37, 99, 235, 0.08), transparent 30%),
        radial-gradient(circle at 86% 4%, rgba(15, 159, 143, 0.08), transparent 28%),
        var(--bg-dark);
}

/* Light mode wears the company cyan/blue branding on the top bar (white logo + text). */
body.light-mode #top-nav-bar {
    background: linear-gradient(135deg, #0891b2 0%, #11b5d6 55%, #22d3ee 100%);
    border-bottom-color: rgba(8, 47, 73, 0.18);
    box-shadow: 0 2px 14px rgba(8, 145, 178, 0.28);
}
body.light-mode .top-nav-tab { color: rgba(255, 255, 255, 0.82); }
body.light-mode .top-nav-tab:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
    border-bottom-color: #fff;
}
body.light-mode .top-nav-tab.is-active {
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
    border-bottom-color: #fff;
}
body.light-mode .account-chip {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.38);
    color: #fff;
}
body.light-mode .account-chip:hover { background: rgba(255, 255, 255, 0.28); border-color: #fff; }
/* The dropdown opens over the white page body, so keep it light-surfaced. */
body.light-mode .account-menu { background: #ffffff; border-color: var(--border-color); }

body.light-mode #sidebar,
body.light-mode #right-panel {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(248, 250, 252, 0.96)),
        var(--panel-bg);
    border-color: var(--border-color);
    box-shadow: var(--shadow-lg);
}

body.light-mode .brand-header,
body.light-mode .drawer-panel-header,
body.light-mode .panel-header {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-color: var(--border-color);
}

body.light-mode .panel-section {
    border-color: var(--border-color);
}

body.light-mode .connection-card,
body.light-mode .robot-card,
body.light-mode .assignment-row,
body.light-mode .legend-item,
body.light-mode .event-log-shell,
body.light-mode .log-entry {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.92));
    border-color: rgba(203, 213, 225, 0.86);
    box-shadow: var(--shadow-sm);
}

body.light-mode .connection-card::after {
    opacity: 0.45;
}

body.light-mode #main-view {
    background:
        radial-gradient(circle at 50% 38%, rgba(219, 234, 254, 0.72), transparent 34%),
        linear-gradient(180deg, #f8fbff 0%, #eaf1f8 100%);
}

body.light-mode #mqtt-status-bar,
body.light-mode #map-ops-strip {
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(203, 213, 225, 0.9);
    box-shadow: var(--shadow-md);
}

body.light-mode .ops-map-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.9));
    border-color: rgba(203, 213, 225, 0.86);
}

body.light-mode .ops-hud-header {
    border-color: rgba(203, 213, 225, 0.72);
}

body.light-mode .map-ops-card {
    background: rgba(248, 250, 252, 0.82);
    border-color: rgba(203, 213, 225, 0.76);
}

body.light-mode .drawer-handle,
body.light-mode .drawer-pin-btn,
body.light-mode .mini-clear-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(203, 213, 225, 0.9);
    color: var(--text-secondary);
}

body.light-mode .ctrl-input,
body.light-mode select,
body.light-mode input[type="text"],
body.light-mode input[type="number"] {
    background: #ffffff;
    border-color: #d9e2ec;
    color: var(--text-primary);
}

/* Pre-existing gap: the theme override above outranked every :focus rule, so light mode never
   showed the accent focus border. Restore it at matching specificity. */
body.light-mode .ctrl-input:focus,
body.light-mode select:focus,
body.light-mode input:focus,
body.light-mode textarea:focus {
    border-color: var(--accent-blue);
}

body.light-mode .btn-secondary {
    background: #edf2f7;
    border-color: #d9e2ec;
    color: var(--text-primary);
}

body.light-mode .robot-info-row.is-load {
    color: #4c1d95;
    border-color: rgba(124, 58, 237, 0.28);
    background: linear-gradient(135deg, rgba(237, 233, 254, 0.95), rgba(255, 255, 255, 0.82));
}

body.light-mode .robot-info-row.is-target {
    color: #115e59;
    border-color: rgba(13, 148, 136, 0.28);
    background: linear-gradient(135deg, rgba(204, 251, 241, 0.86), rgba(255, 255, 255, 0.82));
}

body.light-mode .robot-info-row.is-load strong {
    color: #6d28d9;
}

body.light-mode .robot-info-row.is-target strong {
    color: #0f766e;
}

body.light-mode .status-dot {
    box-shadow: 0 0 0 4px rgba(100, 116, 139, 0.12);
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Mismatch Warning */
.mismatch-warning {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--accent-red);
    border-radius: var(--border-radius-sm);
    padding: 8px 10px;
    margin-top: 8px;
    font-size: 10px;
    color: var(--accent-red);
}

/* Animations - removed fadeIn from robot-card to prevent blinking on updates */

/* Responsive Adjustments */
@media (max-width: 1200px) {
    :root {
        --sidebar-width: 300px;
    }

    #right-panel {
        width: 320px;
    }

    #map-overlay-hud {
        left: 50px;
        right: 50px;
        flex-wrap: wrap;
    }

    #mqtt-status-bar {
        min-width: 0;
        width: min(760px, 100%);
        max-width: none;
    }

    .ops-hud-content {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .ops-map-card {
        grid-column: 1 / -1;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: center;
    }

    #map-ops-strip {
        left: 50px;
        right: 50px;
        bottom: 14px;
    }

    body:has(#sidebar.drawer-expanded) #map-ops-strip,
    body:has(#right-panel.drawer-expanded) #map-ops-strip {
        left: 50px;
        right: 50px;
    }

    body:has(#sidebar.drawer-expanded) #map-overlay-hud,
    body:has(#right-panel.drawer-expanded) #map-overlay-hud {
        left: 50px;
        right: 50px;
    }
}

@media (max-width: 820px) {
    #map-overlay-hud {
        top: 10px;
        left: 44px;
        right: 44px;
        justify-content: flex-start;
    }

    #map-quick-toolbar {
        position: static;
        width: 100%;
        justify-content: flex-end;
    }

    .ops-hud-content {
        grid-template-columns: 1fr;
    }

    .ops-map-card {
        grid-column: auto;
        grid-template-columns: 1fr;
    }

    #map-ops-strip {
        left: 44px;
        right: 44px;
    }

    body:has(#sidebar.drawer-expanded) #map-ops-strip,
    body:has(#right-panel.drawer-expanded) #map-ops-strip {
        left: 44px;
        right: 44px;
    }

    body:has(#sidebar.drawer-expanded) #map-overlay-hud,
    body:has(#right-panel.drawer-expanded) #map-overlay-hud {
        left: 44px;
        right: 44px;
    }

    .drawer-handle {
        width: 30px;
        min-height: 110px;
        font-size: 10px;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 100vw;
    }
    #sidebar {
        width: 100vw;
    }
    #right-panel {
        width: 100vw;
    }
    #mqtt-status-bar {
        width: calc(100vw - 76px);
        font-size: 10px;
    }
    .ops-hud-header {
        gap: 8px;
        padding: 8px 9px;
    }
    .ops-hud-title {
        font-size: 10px;
    }
    .ops-hud-content {
        gap: 8px;
        padding: 8px;
    }
    #map-ops-strip {
        left: 38px;
        right: 38px;
        bottom: 12px;
    }
    body:has(#sidebar.drawer-expanded) #map-ops-strip,
    body:has(#right-panel.drawer-expanded) #map-ops-strip {
        left: 38px;
        right: 38px;
    }
    body:has(#sidebar.drawer-expanded) #map-overlay-hud,
    body:has(#right-panel.drawer-expanded) #map-overlay-hud {
        left: 38px;
        right: 38px;
    }
    .map-ops-card {
        flex: 1 1 130px;
        justify-content: center;
    }
    .modal-header {
        flex-direction: column;
        height: auto !important;
        padding: 15px !important;
        gap: 12px;
        align-items: stretch !important;
    }
    .drawer-panel-header {
        flex-wrap: wrap;
    }
    .btn {
        min-height: 44px;
        font-size: 13px !important;
    }
    .modal-content {
        width: 98% !important;
    }
}

/* Localization Alarm styling */
.robot-card.localization-alarm {
    border-color: #ff3d00 !important;
    background: linear-gradient(135deg, rgba(255, 61, 0, 0.12), rgba(13, 17, 23, 0.95)) !important;
    box-shadow: 0 0 10px rgba(255, 61, 0, 0.25) !important;
    animation: loc-pulse 2s infinite ease-in-out;
}

@keyframes loc-pulse {
    0% { box-shadow: 0 0 5px rgba(255, 61, 0, 0.2); }
    50% { box-shadow: 0 0 15px rgba(255, 61, 0, 0.5); }
    100% { box-shadow: 0 0 5px rgba(255, 61, 0, 0.2); }
}

.badge-loc-lost {
    display: inline-block;
    background: #ff3d00;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 6px;
    animation: badge-pulse 1.5s infinite ease-in-out;
}

/* Fleet-sizing over-provisioning advisory (Current Operations header) */
.fleet-size-warning {
    display: inline-block;
    background: var(--surface-warning-soft);
    color: var(--accent-yellow);
    border: 1px solid var(--accent-yellow);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    cursor: help;
    vertical-align: middle;
}

@keyframes badge-pulse {
    0% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 0.9; }
}

.robot-alert.localization-alert {
    border: 1px solid rgba(255, 61, 0, 0.5) !important;
    background: rgba(255, 61, 0, 0.12) !important;
    color: #ff521a !important;
}

/* ═══ Tier 1: top bar · fleet donut · KPI strip (reference: img/main.png) ═══ */

#app-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 42px;
    padding: 0 16px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Topbar takes 42px; the app row fills the rest */
body:has(#app-topbar) #app-container { height: calc(100dvh - 42px); }

.tb-brand { display: flex; align-items: center; gap: 10px; }
.tb-product { font-size: 13px; font-weight: 800; letter-spacing: 0.5px; color: var(--text-primary); }
.tb-map-pill {
    font-size: 10px; font-weight: 600; color: var(--accent-blue);
    background: color-mix(in srgb, var(--accent-blue) 10%, transparent);
    padding: 2px 9px; border-radius: 20px;
}
.tb-spacer { flex: 1; }
.tb-sep { width: 1px; height: 18px; background: var(--border-color); flex-shrink: 0; }
.tb-health { display: flex; align-items: center; gap: 12px; }
.tb-pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 10px; font-weight: 600; letter-spacing: 0.3px;
    color: var(--text-secondary); white-space: nowrap; cursor: default;
}
/* Status detail appears on hover — dots carry the state at a glance */
.tb-pill-meta {
    display: none; font-weight: 500; color: var(--text-muted);
    max-width: 130px; overflow: hidden; text-overflow: ellipsis;
}
.tb-pill:hover .tb-pill-meta { display: inline; }
#app-topbar .ops-user-row { display: flex; align-items: center; gap: 8px; }
.tb-links { display: flex; gap: 2px; }
.tb-links a {
    font-size: 11px; font-weight: 600; color: var(--text-secondary);
    text-decoration: none; padding: 5px 11px; border-radius: 7px;
}
.tb-links a:hover { color: var(--accent-blue); background: color-mix(in srgb, var(--accent-blue) 10%, transparent); }
.tb-clock { font-family: 'SF Mono', monospace; font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.tb-clock .tb-clock-label { font-family: inherit; font-size: 9px; color: var(--text-muted); margin-right: 3px; }

/* Shared card grammar: uppercase micro-title + View-detail link */
.kpi-card-title {
    display: flex; align-items: baseline; justify-content: space-between;
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.6px; color: var(--text-secondary); margin-bottom: 8px;
}
.kpi-detail-link { font-size: 10px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--accent-blue); text-decoration: none; }
.kpi-detail-link:hover { text-decoration: underline; }

/* Fleet Status donut (conic-gradient — no chart lib on the ops page) */
.fleet-donut-card { padding: 10px 12px; }
.fleet-donut-body { display: flex; align-items: center; gap: 14px; }
.fleet-donut {
    width: 86px; height: 86px; border-radius: 50%; position: relative; flex-shrink: 0;
    background: conic-gradient(var(--border-color) 0deg 360deg);
}
.fleet-donut::after {
    content: ""; position: absolute; inset: 11px; border-radius: 50%;
    background: var(--panel-bg);
}
.fleet-donut-center {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; z-index: 1;
}
.fleet-donut-total { font-size: 22px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.fleet-donut-caption { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.fleet-donut-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; font-size: 11px; flex: 1; }
.fleet-donut-legend .fd-item { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.fleet-donut-legend .fd-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.fleet-donut-legend .fd-n { margin-left: auto; font-weight: 700; color: var(--text-primary); }

/* Throughput + incidents now live inside the Fleet Status card (right panel) */
.fleet-stat-row { display: flex; gap: 18px; }
.fleet-stat { display: flex; flex-direction: column; gap: 1px; }
.fleet-stat .fs-value { font-size: 17px; font-weight: 700; color: var(--text-primary); line-height: 1.1; }
.fleet-stat .fs-label { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.kpi-mini-list { display: flex; flex-direction: column; gap: 3px; font-size: 11px; }
.kpi-mini-row { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; }
.kpi-mini-row .kr-id { font-weight: 700; color: var(--text-primary); min-width: 26px; }
.kpi-mini-row .kr-meta { margin-left: auto; color: var(--text-muted); font-size: 10px; }
.kpi-empty { color: var(--text-muted); font-size: 11px; }
.kpi-card-subtitle { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 5px; }
.fleet-card-divider { border-top: 1px solid var(--border-color); margin: 10px -12px; }

/* ── Accessibility: reduced motion ──────────────────────────────────────────
   Honor the OS "reduce motion" setting (PRODUCT.md + DESIGN.md mandate). Pulses
   and transitions collapse to instant state changes; no visual change for
   default users. Restrained animations only. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── Premium elevation layer ─────────────────────────────────────────────────
   Enterprise polish on the shared design system (DESIGN.md). Additive only —
   refines data-table presentation, numeric precision, and card state. No layout,
   workflow, or component-structure change. Applies across Main Dashboard, Fleet
   Reports, and Throughput Prediction (the forecast page mirrors it on .fc-*). */

/* Numeric precision — figures align in tabular columns (mission-control legibility). */
.fr-table td, .fr-table th,
.fr-kpi-value, .kpi-card-value, .kpi-mini-row .kr-val,
.robot-batt-pct, .sb-row.sb-conn .sb-meta,
table td, table th {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* Data-grid headers — quiet uppercase micro-labels, pinned while the body scrolls. */
.fr-table thead th {
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-card);
}

/* Quiet row hover for scannability — no zebra (keeps the table calm). */
.fr-table tbody tr:hover td {
    background: var(--surface-card-soft);
    color: var(--text-primary);
}

/* Card cohesion — a calm, responsive lift on hover: the border brightens and the
   shadow deepens. The blue glow stays reserved for live / selected state
   (DESIGN.md "The Glow-Means-Live Rule"). */
.fr-card, .fr-kpi-card, .fr-card-table, .ops-map-card, .map-ops-card,
.connection-card, .hud-connection-card {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.fr-card:hover, .fr-kpi-card:hover, .ops-map-card:hover, .map-ops-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

/* Premium finish — branded text selection, a "lit-from-above" 1px top edge on
   surfaces (depth without heavier shadow, per DESIGN.md tonal layering), and
   tighter tracking on the big hero figures. */
::selection { background: rgba(88, 166, 255, 0.26); }
.fr-card, .fr-kpi-card, .ops-map-card, .map-ops-card, .connection-card {
    box-shadow: var(--card-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.045);
}
.fr-kpi-value, .kpi-card-value, .fc-kpi-value { letter-spacing: -0.015em; }

/* === Canonical component polish (2026-07-04 refine) === */

/* One accessible keyboard-focus ring everywhere (baseline; component rules like .btn:focus-visible
   keep their own identical treatment). Mouse clicks don't trigger :focus-visible, so this adds
   keyboard a11y without changing the click look. Same --focus-ring convention as existing components. */
:where(button, a, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Buttons: consistent hover/active/disabled states via tokens (color identity unchanged). */
:where(.btn, button.btn) { transition: background-color .12s ease, border-color .12s ease, opacity .12s ease; }
:where(.btn, button.btn):hover { filter: brightness(1.06); }
:where(.btn, button.btn):active { filter: brightness(0.96); }
:where(.btn, button.btn):disabled,
:where(.btn, button.btn)[aria-disabled="true"] { opacity: .5; cursor: not-allowed; filter: none; }

/* Tables: right-align + tabular monospace numeric cells for scannable metrics. */
td.num, th.num, .table-num { text-align: right; font-variant-numeric: tabular-nums; font-family: 'SF Mono', ui-monospace, monospace; }

/* Inputs/selects: baseline focus = the established accent-blue treatment (matches .ctrl-input:focus
   and input[type=text]:focus above, extending it to untyped inputs/textareas). Element-level
   specificity so component-specific rules still win. */
input:focus, select:focus, textarea:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.15); }
