/* internal/static/css/style.css */
body {
    background: #f8f9fa;
  }
  
  .navbar-brand {
    font-weight: bold;
  }
  
  .fullscreen-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    background: #fff; /* Optional to ensure a white background */
  }
  
  .fullscreen-controls {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 999;
  }

  .fullscreen-chart {
    width: 100%;
    height: 90vh;
    /* Ensures chart occupies most of the viewport minus the controls */
  }

  .left-nav {
    width: 200px;
    transition: width 0.35s cubic-bezier(0.4, 0.0, 0.2, 1), 
                box-shadow 0.35s ease,
                transform 0.35s cubic-bezier(0.4, 0.0, 0.2, 1);
    background: linear-gradient(180deg, #2c3136 0%, #343a40 100%);
    min-height: 100vh;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    position: relative;
  }
  
  .left-nav::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(180deg, 
      rgba(255, 255, 255, 0.1) 0%, 
      rgba(255, 255, 255, 0.05) 50%, 
      rgba(255, 255, 255, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.35s ease;
  }
  
  .left-nav:not(.collapsed)::after {
    opacity: 1;
  }

  .left-nav.collapsed {
    width: 0;
    overflow: hidden;
    box-shadow: none;
    transform: translateX(-8px);
  }

  .left-nav .nav-link {
    color: #e9ecef;
    padding: 0.75rem 1.25rem;
    margin: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    position: relative;
    font-weight: 500;
    letter-spacing: 0.01em;
  }
  
  .left-nav .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: linear-gradient(180deg, #4fc3f7, #29b6f6);
    border-radius: 0 2px 2px 0;
    transition: height 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
  }

  .left-nav .nav-link.active {
    background: linear-gradient(90deg, rgba(79, 195, 247, 0.15), rgba(41, 182, 246, 0.1));
    color: #fff;
    font-weight: 600;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
  }
  
  .left-nav .nav-link.active::before {
    height: 60%;
  }

  .left-nav .nav-link:hover {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    color: #fff;
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }
  
  .left-nav .nav-link:hover::before {
    height: 40%;
  }
  
  /* Special styling for logout link */
  .left-nav .nav-link[href*="logout"]:hover {
    background: linear-gradient(90deg, rgba(229, 57, 53, 0.15), rgba(229, 57, 53, 0.08));
    color: #ffcdd2;
  }
  
  .left-nav .nav-link[href*="logout"]:hover::before {
    background: linear-gradient(180deg, #ef5350, #e53935);
  }

  /* Alerts page tweaks */
  #alerts-config-list .list-group-item {
    transition: background-color .15s ease-in-out;
  }
  #alerts-config-list .list-group-item:hover {
    background-color: #eceff3; /* lighter gray for hover */
    color: #111; /* ensure text contrast */
  }
  #alerts-config-list .list-group-item:hover .btn { color: #111; border-color: #ced4da; }
  #alerts-config-list .list-group-item:hover .btn-outline-danger { color: #c1121f; border-color: #e7c3c3; }

  /* Hover-only controls for alerts list */
  #alerts-config-list .btn-group { opacity: 0; transition: opacity .15s ease-in-out; }
  #alerts-config-list .list-group-item:hover .btn-group { opacity: 1; }

  /* Split view separator when config list is visible */
  #alerts-config-col { border-right: 1px solid #e5e7eb; }

  /* Compact filter labels in both filter panels */
  .card .form-label.small {
    font-size: 0.7rem !important;
  }

  /* Compact icon buttons for alerts toolbars (match small gear button size) */
  .alerts-toolbar-btn {
    padding: 2px 6px !important; /* smaller than btn-sm default */
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 0 !important;
  }
  .alerts-toolbar-btn .material-symbols-outlined {
    font-size: 16px !important; /* shrink Material icon */
    line-height: 1 !important;
    vertical-align: middle !important;
  }
  .alerts-toolbar-btn i {
    font-size: 14px !important; /* shrink FontAwesome icon */
    line-height: 1 !important;
    vertical-align: middle !important;
  }

  /* Tag-like single-line multiselect appearance using native select as trigger */
  .tag-multiselect {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 2px 6px;
    border: 1px solid #ced4da;
    border-radius: .25rem;
    min-height: calc(1.5em + .5rem + 2px);
    background: #fff;
    overflow: visible; /* allow dropdown menu to overflow */
    font-size: .875rem; /* match form-control-sm */
  }
  .tag-multiselect .tags-container {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex: 1;
  }
  .tag-multiselect .tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #e9ecef;
    color: #212529;
    border-radius: 999px;
    padding: 1px 6px;
    font-size: .75rem;
    line-height: 1;
  }
  .tag-multiselect .tag-remove {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    font-size: .9rem;
    line-height: 1;
  }
  .tag-multiselect .dropdown-toggle::after { display: none; }
  .tag-multiselect .btn-dropdown {
    border: none;
    background: transparent;
    color: #495057;
    padding: 0 4px;
    font-size: .875rem;
  }
  .tag-multiselect .dropdown-menu { font-size: .875rem; }

  /* Center and darken backdrops for nested modals */
  .modal-backdrop.show { background-color: rgba(0,0,0,0.55); }

  /* Prevent layout shift when modal body starts/stops scrolling (avoid canvas blink) */
  #alert-config-modal .modal-body {
    scrollbar-gutter: stable both-edges;
  }

  /* Schedule modal styling */
  .schedule-mode-card {
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
  }
  .schedule-mode-card:hover {
    border-color: #4fc3f7;
    box-shadow: 0 2px 8px rgba(79, 195, 247, 0.15);
    transform: translateY(-2px);
  }
  .schedule-mode-card.active {
    border-color: #4fc3f7;
    background: linear-gradient(180deg, rgba(79, 195, 247, 0.1) 0%, rgba(41, 182, 246, 0.05) 100%);
    box-shadow: 0 2px 8px rgba(79, 195, 247, 0.2);
  }
  .schedule-mode-card[data-mode="always"].active {
    border-color: #6c757d;
    background: linear-gradient(180deg, rgba(108, 117, 125, 0.1) 0%, rgba(108, 117, 125, 0.05) 100%);
  }
  .schedule-mode-card[data-mode="events"].active {
    border-color: #28a745;
    background: linear-gradient(180deg, rgba(40, 167, 69, 0.1) 0%, rgba(40, 167, 69, 0.05) 100%);
  }

  .schedule-panel {
    animation: fadeIn 0.2s ease;
  }
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Time chip styling */
  .schedule-time-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background-color: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 12px;
    font-size: 0.875rem;
    color: #212529;
    margin: 2px;
    transition: all 0.15s ease;
  }
  .schedule-time-chip:hover {
    background-color: #d0e7ff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: scale(1.02);
  }
  .schedule-time-chip .chip-edit,
  .schedule-time-chip .chip-remove {
    opacity: 0;
    transition: opacity 0.15s ease;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
  }
  .schedule-time-chip:hover .chip-edit,
  .schedule-time-chip:hover .chip-remove {
    opacity: 1;
  }
  .schedule-time-chip .chip-edit:hover,
  .schedule-time-chip .chip-remove:hover {
    background-color: rgba(0, 0, 0, 0.1);
  }

  /* Exception/Event chip styling */
  .schedule-exception-chip,
  .schedule-event-chip {
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    border-left: 3px solid;
    transition: all 0.15s ease;
  }
  .schedule-exception-chip {
    background-color: #fff3cd;
    border-left-color: #ffc107;
  }
  .schedule-event-chip.on {
    background-color: #d4edda;
    border-left-color: #28a745;
  }
  .schedule-event-chip.off {
    background-color: #f8d7da;
    border-left-color: #dc3545;
  }
  .schedule-exception-chip:hover,
  .schedule-event-chip:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateX(2px);
  }

  /* Weekly preview bars */
  .schedule-preview-bar {
    flex: 1;
    background-color: #e5e7eb;
    border-radius: 4px 4px 0 0;
    position: relative;
    min-height: 20px;
    transition: background-color 0.15s ease;
  }
  .schedule-preview-bar.active {
    background-color: #4fc3f7;
  }
  .schedule-preview-bar.active-events {
    background-color: #28a745;
  }
  .schedule-preview-bar.inactive-events {
    background-color: #dc3545;
  }

  /* Events timeline preview */
  .events-timeline {
    width: 100%;
    border-radius: 6px;
    background: #f8f9fa;
    padding: 6px 8px;
    border: 1px solid #e5e7eb;
    position: relative;
    min-height: 140px;
  }
  .events-timeline-header {
    font-size: 0.75rem;
    color: #6c757d;
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
  }
  .events-timeline-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
  }
  .events-timeline-label {
    min-width: 110px;
    max-width: 140px;
    font-size: 0.8rem;
    color: #4b5563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .events-timeline-bar-container {
    position: relative;
    flex: 1;
    height: 10px;
  background-color: #e9ecef;
    border-radius: 999px;
    overflow: hidden;
  }
  .events-timeline-bar {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: 999px;
  }
  .events-timeline-bar.on {
    background: #28a745;
  }
  .events-timeline-bar.off {
    background: #dc3545;
    opacity: 0.8;
  }

  /* Stacking for nested schedule modal */
  .modal.alert-schedule-top {
    z-index: 1065; /* above parent modal (1055) */
  }
  .modal-backdrop.alert-schedule-backdrop {
    z-index: 1060; /* between parent (1055) and schedule (1065) */
  }
  /* Toggle switch styling */
  .schedule-day-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
  }
  .schedule-day-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
  }
  .schedule-day-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
  }
  .schedule-day-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
  }
  .schedule-day-toggle input:checked + .schedule-day-toggle-slider {
    background-color: #4fc3f7;
  }
  .schedule-day-toggle input:checked + .schedule-day-toggle-slider:before {
    transform: translateX(20px);
  }
  .schedule-day-toggle input:focus + .schedule-day-toggle-slider {
    box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.25);
  }

  .schedule-day-all-day {
    font-size: 0.85rem;
    color: #0d6efd;
    font-style: italic;
  }

  /* Alerts Modal Accordion Styling */
  .alerts-accordion .alerts-collapse-header {
    width: 100% !important;
    text-align: left !important;
    background: linear-gradient(180deg, #fefeff 0%, #f7f9fb 100%) !important;
    border: 0.5px solid #d1d5db !important;
    border-radius: 10px !important;
    padding: 9px 12px !important;
    color: #1f2937 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    cursor: pointer !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03) !important;
    appearance: none !important;
    line-height: 1.4 !important;
  }
  .alerts-accordion .alerts-collapse-header:hover { 
    background: linear-gradient(180deg, #ffffff, #eef2f7) !important; 
  }
  .alerts-accordion .alerts-collapse-header:focus { 
    outline: 0 !important; 
    box-shadow: 0 0 0 .2rem rgba(13,110,253,.08) !important; 
  }
  .alerts-accordion .alerts-collapse-header > span:first-child { 
    flex: 1 !important; 
    text-align: left !important;
    display: flex !important;
    align-items: center !important;
  }
  .alerts-accordion .chevron { 
    transition: transform .2s ease !important; 
    font-variation-settings: 'wght' 400 !important;
    display: flex !important;
    align-items: center !important;
    margin-left: auto !important;
  }
  /* Rotate chevron for general settings header like inner accordions */
  .general-collapse-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg) !important; }
  .alerts-accordion .section-body { 
    border-left: 2px solid #e5e7eb !important; 
    padding-left: 12px !important; 
    padding-right: 4px !important; 
    margin-top: 8px !important; 
  }
  /* Animate chevron using both aria-expanded and Bootstrap's collapsed class */
  .alerts-accordion .alerts-collapse-header[aria-expanded="true"] .chevron { 
    transform: rotate(180deg) !important; 
  }
  .alerts-accordion .alerts-collapse-header:not(.collapsed) .chevron { 
    transform: rotate(180deg) !important; 
  }

  .container-fluid {
    transition: margin-left 0.35s cubic-bezier(0.4, 0.0, 0.2, 1);
  }

  /* Main content area - no extra margin needed since left-nav is in flex container */
  .d-flex .flex-grow-1 {
    margin-left: 0;
    transition: margin-left 0.35s cubic-bezier(0.4, 0.0, 0.2, 1);
  }

  /* Center the fullscreen button icon, adjust padding for vertical centering, 
     force the image to appear black, and override the darker btn-secondary style */
  .fullscreen-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem !important; /* Adjust padding as needed */
  }

  .fullscreen-btn img {
    filter: brightness(0);
    display: block;
  }

  /* Make the fullscreen button background transparent,
     and highlight with a lighter grey on hover */
  .fullscreen-btn.btn-secondary {
    background-color: transparent !important;
    border-color: transparent !important;
    transition: background-color 0.3s, border-color 0.3s;
  }

  .fullscreen-btn.btn-secondary:hover {
    background-color: #E2E6EA !important;
    border-color: #DAE0E5 !important;
  }

  /* New styles for the download button to match the fullscreen button */
  .download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem !important;
    margin-right: 5px; /* 5px space between download and fullscreen buttons */
    background-color: transparent !important;
    border-color: transparent !important;
    transition: background-color 0.3s, border-color 0.3s;
  }

  .download-btn img {
    filter: brightness(0);
    display: block;
  }

  /* NEW: Style for Font Awesome icons within download/settings buttons */
  .download-btn i {
    color: #212529; /* Bootstrap default text color - usually near black/dark grey */
  }

  .download-btn.btn-secondary:hover {
    background-color: #E2E6EA !important;
    border-color: #DAE0E5 !important;
  }

  /* New class to group buttons with a fixed 5px gap */
  .btn-group-gap {
    display: flex;
    gap: 2px;
  }

  /* === Fullscreen Modal Styling === */
  .modal-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    background-color: #f8f9fa;
  }

  /* Style Sensor Modal Accordion Headers */
  #sensor-edit-modal .accordion-button {
    background-color: #f8f9fa; /* Match modal header background */
    color: #212529; /* Ensure text is readable */
    font-weight: bold; /* Make accordion header text bold */
  }

  /* Make form labels bold within the sensor modal */
  #sensor-edit-modal .form-label {
    font-weight: bold;
  }

  /* Adjust focus style for better visibility on light grey background */
  #sensor-edit-modal .accordion-button:focus {
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, .25); /* Default Bootstrap blue focus */
  }

  /* Keep collapsed style distinct */
  #sensor-edit-modal .accordion-button.collapsed {
    background-color: #f8f9fa;
  }

  /* Optional: Slightly darken on hover */
  #sensor-edit-modal .accordion-button:not(.collapsed):hover {
    background-color: #e9ecef; 
  }

  #sensor-edit-modal .accordion-button.collapsed:hover {
    background-color: #e9ecef;
  }

  /* Chart Navigation Buttons in Modal Header */
  #prev-chart,
  #next-chart {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa !important;
    border-color: #f8f9fa !important;
    color: #212529 !important;
    transition: background-color 0.15s ease-in-out;
  }

  #prev-chart:hover,
  #next-chart:hover {
    background-color: #E2E6EA !important;
    border-color: #DAE0E5 !important;
  }

  /* Sensor Navigation Container - positioned on top of the image */
  .fullscreen-sensor-nav-container {
    position: absolute;
    top: 15px;
    left: 0;
    width: 100%;
    background-color: rgba(248, 249, 250, 0.8);
    padding: 8px;
    text-align: center;
    z-index: 5;
    display: flex;
    justify-content: center;
    gap: 10px;
  }

  /* Sensor Navigation Buttons in Modal Body */
  .sensor-nav-btn-fullscreen {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa !important;
    border-color: #E2E6EA !important;
    color: #212529 !important;
    transition: background-color 0.15s ease-in-out;
  }

  .sensor-nav-btn-fullscreen:hover {
    background-color: #E2E6EA !important;
    border-color: #DAE0E5 !important;
  }

  /* === Sensor Modal Masks & Zones Styling === */
  .mask-zone-container {
    min-height: 500px; /* Ensure minimum height */
  }

  .mask-zone-toolbar {
    width: 60px; /* Fixed width for the toolbar */
    background-color: #f8f9fa; /* Light grey background */
    border-right: 1px solid #dee2e6; /* Separator line */
  }

  .mask-zone-toolbar .btn {
    width: 40px; /* Fixed button width */
    height: 40px; /* Fixed button height */
    padding: 0.5rem; /* Adjust padding for icon centering */
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Style for active/selected tool button */
  .mask-zone-toolbar .btn.active {
    background-color: #0d6efd; /* Bootstrap primary blue */
    color: white;
  }

  .mask-zone-canvas-area {
    position: relative;
    background-color: #f0f0f0; /* Add a background placeholder */
    min-height: 400px; /* Ensure a minimum height for Fabric initialization */
    height: 500px; /* Keep preferred height */
    overflow: hidden; /* Prevent content spillover */
    align-items: center;
  }

  #sensor-drawing-canvas {
    /* Style the canvas element itself if needed */
    border: 1px dashed #ccc; 
    display: block; /* Prevents extra space below canvas */
  }

  .canvas-container { /* Fabric.js wraps the canvas */
    flex-grow: 1; /* Allow container to grow */
    position: relative; /* Needed for absolute positioning of Fabric elements */
    width: 100% !important; /* Override Fabric inline style */
    height: auto !important; /* Let height be determined by content */
    min-height: 400px; /* Minimum drawing area height */
  }

  #sensor-drawing-properties {
    min-height: 50px; /* Minimum height for properties */
    border-top: 1px solid #dee2e6;
    display: flex;
    flex-wrap: wrap; /* Allow properties to wrap */
    gap: 15px; /* Spacing between property fields */
    align-items: center;
  }

  #sensor-drawing-properties .property-group {
    display: flex;
    flex-direction: column;
  }

  #sensor-drawing-properties label {
    font-size: 0.8rem;
    margin-bottom: 0.2rem;
    font-weight: bold;
  }

  #sensor-drawing-properties input[type="text"],
  #sensor-drawing-properties input[type="color"],
  #sensor-drawing-properties select {
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
    border: 1px solid #ced4da;
    border-radius: 0.2rem;
  }

  #sensor-drawing-properties input[type="color"] {
    height: 30px; /* Adjust height for color input */
    padding: 0.1rem; /* Minimal padding for color input */
  }

  /* Custom Plotly Modbar Styling for Zone Activity Tab */
  #zone-activity .modebar {
    background-color: transparent !important;
  }

/* === Map Modal Konva Canvas Styling === */
#map-konva-toolbar {
    width: 50px; /* Fixed width, slightly less than sensor toolbar due to fewer buttons initially */
    flex-shrink: 0; /* Prevent toolbar from shrinking */
}

#map-konva-toolbar .btn {
    width: 36px; /* Adjust button width to fit 50px toolbar with padding */
    height: 36px;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#map-konva-canvas-container {
    flex-grow: 1;            /* Use all remaining width */
    position: relative;
    min-height: 300px;       /* Minimum height for Konva */
    overflow: hidden;
    min-width: 0 !important; /* Allow flex item to shrink */
    width: 100% !important;  /* Fill remaining space after toolbar fixed width */
    background-color: #e9ecef; /* Light background for canvas area for visibility */
}

#map-drawing-container.d-flex { display: flex; }

/* Ensure Konva's own container doesn't break flex layout */
#map-konva-canvas-container .konvajs-content {
    position: absolute; /* Align with Konva best practices for positioning its canvas */
}

/* Center the Konva canvas for the dashboard zone activity map chart */
/* The ID #chart-zone-map_zone_activity is an example; this should match the containerId passed to the chart */
#chart-zone-map_zone_activity {
    display: flex;
    justify-content: center; /* Horizontally center the .konvajs-content div */
    align-items: center;     /* Vertically center the .konvajs-content div */
    width: 100%; /* Ensure it takes full width of its parent column in the card */
    height: 100%; /* Ensure it takes full height (e.g., defined by card-body or specific chart CSS) */
    overflow: hidden; /* Prevent scrollbars if canvas is slightly larger due to rounding */
}

  /* Distinct style for AquAlert drowning alerts */
  .alert-drowning {
    border-left: 4px solid #d32f2f;
  }

  /* AquAlert media box */
  .aq-media-box {
    position: relative;
    display: inline-block;
    border: 1px solid #eee;
    background: #000;
    overflow: hidden;
  }
  .aq-media-img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: contain;
    background: #000;
  }
  .aq-media-video {
    display: block;
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: contain;
    background: #000;
  }
  .aq-media-fullscreen .aq-media-img { max-height: none; height: 100vh; width: 100vw; object-fit: contain; }
  .aq-media-fullscreen .aq-media-video { max-height: none; height: 100vh; width: 100vw; object-fit: contain; }
  .aq-media-fullscreen { width: 100vw; height: 100vh; }
  .aq-media-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity .15s ease-in-out;
  }
  .aq-media-box:hover .aq-media-overlay { opacity: 1; }
  .aq-icon-btn {
    background: rgba(255,255,255,0.85);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 6px;
    padding: 6px 8px;
    color: #212529;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
  }
  .aq-icon-btn.disabled { opacity: 0.35; pointer-events: none; }
  .aq-bbox {
    position: absolute;
    border: 2px solid #ff5252;
    box-shadow: 0 0 0 9999px rgba(255,82,82,0.12) inset;
    pointer-events: none;
  }

  /* User avatar in navbar */
  .avatar-toggle {
    border: none !important;
    background: transparent !important;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.2s ease;
  }
  .avatar-toggle:hover {
    transform: scale(1.05);
  }
  .user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    color: #fff;
    font-weight: 600;
    font-size: 1.125rem;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease;
  }
  .avatar-toggle:hover .user-avatar {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16), 0 2px 4px rgba(0, 0, 0, 0.1);
  }
  .avatar-toggle:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(13,110,253,.25);
    border-radius: 50%;
  }
  .user-menu {
    min-width: 240px;
    border: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    margin-top: 8px;
  }
  
  /* Live update indicator - rotating icon with time overlay */
  #live-update-indicator {
    display: inline-block;
    cursor: default;
  }
  
  .update-icon-wrapper {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .update-icon-rotating {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0.35;
    filter: brightness(0) saturate(100%);
    transition: filter 0.6s ease, opacity 0.6s ease;
    will-change: transform;
  }
  
  /* Color states via filter */
  .update-icon-rotating.fresh {
    filter: brightness(0) saturate(100%) invert(42%) sepia(93%) saturate(1352%) hue-rotate(187deg) brightness(94%) contrast(86%); /* #1e88e5 blue */
  }
  
  .update-icon-rotating.stale {
    filter: brightness(0) saturate(100%) invert(58%) sepia(85%) saturate(2150%) hue-rotate(5deg) brightness(98%) contrast(98%); /* #fb8c00 orange */
  }
  
  .update-icon-rotating.very-stale {
    filter: brightness(0) saturate(100%) invert(32%) sepia(98%) saturate(3319%) hue-rotate(348deg) brightness(91%) contrast(88%); /* #e53935 red */
  }
  
  .update-time-overlay {
    position: relative;
    z-index: 1;
    font-size: 0.7rem;
    font-weight: 700;
    color: #1a1a1a;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    text-align: center;
    padding: 3px 5px;
    background: rgba(30, 136, 229, 0.1); /* Light blue by default */
    border-radius: 50%;
    min-width: 28px;
    min-height: 28px;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.6s ease, opacity 0.15s ease-in-out;
  }
  
  /* Smooth fade on content change */
  .update-time-overlay.updating {
    opacity: 0.5;
  }
  
  /* Background colors matching icon states */
  .update-icon-rotating.fresh ~ .update-time-overlay {
    background: rgba(30, 136, 229, 0.1); /* Light blue */
  }
  
  .update-icon-rotating.stale ~ .update-time-overlay {
    background: rgba(251, 140, 0, 0.1); /* Light orange */
  }
  
  .update-icon-rotating.very-stale ~ .update-time-overlay {
    background: rgba(229, 57, 53, 0.1); /* Light red */
  }
  
  /* Continuous rotation animation - speed controlled by JS */
  @keyframes rotate-continuous {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }

  /* === Auth (Login/MFA) Enhancements === */
  .auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
  }
  .auth-card {
    width: 100%;
    max-width: 420px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 6px 24px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.04);
    animation: fadeIn 0.2s ease;
  }
  .auth-title {
    font-weight: 700;
    letter-spacing: 0.01em;
  }
  .auth-note {
    color: #6c757d;
  }
  .auth-input {
    letter-spacing: 0.25em; /* subtle spacing for OTP codes */
    text-align: center;
    font-weight: 600;
  }
  .auth-input:focus {
    box-shadow: 0 0 0 .2rem rgba(13,110,253,.15);
    border-color: #86b7fe;
  }
  .auth-actions .btn {
    transition: transform .08s ease, box-shadow .15s ease;
  }
  .auth-actions .btn:active {
    transform: translateY(1px);
    box-shadow: none !important;
  }
  .auth-msg {
    min-height: 1.2rem;
  }
  .auth-switch a {
    text-decoration: none;
  }
  .auth-switch a:hover {
    text-decoration: underline;
  }
  .method-pill {
    border: 1px solid #dee2e6;
    border-radius: 999px;
    padding: 6px 10px;
    cursor: pointer;
    user-select: none;
    transition: all .15s ease;
    background: #ffffff;
  }
  .method-pill.active {
    border-color: #4fc3f7;
    box-shadow: inset 0 1px 2px rgba(79,195,247,0.2);
    background: linear-gradient(180deg, rgba(79,195,247,0.08) 0%, rgba(41,182,246,0.04) 100%);
  }
  .method-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
  }

  /* System Health Dashboard Styles */
  .health-card {
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: none; /* prevent hover-induced layout jitter */
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
  }
  .health-card:hover {
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); /* same as base to avoid jumps */
    border-color: #e5e7eb; /* keep border stable */
  }
  .health-card-header {
    padding: 1rem;
    border-bottom: 1px solid #f3f4f6;
    background: #fff; /* Keep it clean white */
  }
  .health-host-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .health-host-meta {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 2px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }
  .health-role-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    background-color: #f3f4f6;
    color: #4b5563;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
    display: inline-block;
  }
  .health-metric-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
  }
  .health-metric-pill {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
  }
  .health-metric-pill.cpu { background: #e0f2fe; color: #0284c7; } /* Light Sky Blue */
  .health-metric-pill.mem { background: #f3e8ff; color: #7e22ce; } /* Light Purple */
  .health-metric-pill.eng { background: #ecfccb; color: #16a34a; } /* Light Lime/Green */
  
  .health-card-body {
    padding: 1rem;
  }
  
  /* Tree View for Engines */
  .health-tree-item {
    position: relative;
    padding-left: 0;
    margin-bottom: 8px;
  }
  .health-engine-row {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    padding: 6px 8px;
    background: #f9fafb;
    border-radius: 6px;
  }
  .health-engine-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
    margin-left: 6px;
  }
  .health-sensor-container {
    padding-left: 24px;
    position: relative;
  }
  .health-sensor-container::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 0;
    bottom: 8px;
    width: 2px;
    background-color: #e5e7eb;
    border-radius: 1px;
  }
  .health-sensor-row {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: #4b5563;
    margin-top: 4px;
    padding: 4px 0;
    position: relative;
  }
  .health-sensor-row::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    width: 10px;
    height: 2px;
    background-color: #e5e7eb;
  }
  .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    flex-shrink: 0;
  }
  .status-dot.ok { background-color: #10b981; box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2); }
  .status-dot.warn { background-color: #f59e0b; }
  .status-dot.err { background-color: #ef4444; }
  .status-dot.offline { background-color: #9ca3af; }
