/* Devices Page Styles */

/* Page Header with View Toggle */
.page-header-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.page-header-row .page-title {
    margin: 0;
}

/* Header Search */
.header-search {
    position: relative;
    flex: 1;
    min-width: 150px;
    max-width: 280px;
}

.header-search-input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.8125rem;
    background: var(--color-content-bg);
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.header-search-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.15);
}

.header-search-input::placeholder {
    color: var(--color-text-secondary);
}

.header-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    fill: var(--color-text-secondary);
    pointer-events: none;
}

/* Header Status Filter */
.header-status-filter {
    display: flex;
    gap: 0.25rem;
}

/* Header Type Filter */
.header-type-filter {
    flex-shrink: 0;
}

.type-filter-select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.8125rem;
    background: var(--color-content-bg);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%23666'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.type-filter-select:hover {
    border-color: var(--color-text-secondary);
}

.type-filter-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.15);
}

/* Add Device Button - Push to right */
#add-device-btn {
    margin-left: auto;
}

/* View Toggle - Grouped Segmented Button */
.view-toggle {
    display: flex;
}

.view-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    background: var(--color-content-bg);
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    transition: all var(--transition-speed);
}

/* First button - rounded left corners */
.view-toggle-btn:first-child {
    border-radius: 6px 0 0 6px;
    border-right: none;
}

/* Middle button - no rounded corners */
.view-toggle-btn:not(:first-child):not(:last-child) {
    border-radius: 0;
    border-right: none;
}

/* Last button - rounded right corners */
.view-toggle-btn:last-child {
    border-radius: 0 6px 6px 0;
}

.view-toggle-btn:hover {
    background: #f5f5f5;
    color: var(--color-accent);
}

.view-toggle-btn.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
}

/* Adjacent active button border fix */
.view-toggle-btn.active + .view-toggle-btn {
    border-left-color: var(--color-accent);
}

.view-toggle-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Split View Layout (Map & Edit views) */
.devices-split-view {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1rem;
    flex: 1;
    min-height: 0;
}

/* Content container for views */
#devices-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Device List Panel */
.devices-list-panel {
    background: var(--color-content-bg);
    border-radius: 8px;
    border: 1px solid var(--color-border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.devices-list-header {
    padding: 0.75rem;
    border-bottom: 1px solid var(--color-border);
    background: #f8f9fa;
}

/* Search Input */
.devices-search {
    position: relative;
    width: 100%;
}

.devices-search-input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--color-content-bg);
    transition: border-color var(--transition-speed);
}

.devices-search-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.devices-search-input::placeholder {
    color: var(--color-text-secondary);
}

.devices-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    fill: var(--color-text-secondary);
    pointer-events: none;
}

/* Status Filter */
.devices-status-filter {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.status-filter-btn {
    flex: 1;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--color-border);
    background: var(--color-content-bg);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.status-filter-btn:hover {
    border-color: var(--color-text-secondary);
}

.status-filter-btn.active {
    background: var(--color-sidebar-bg);
    border-color: var(--color-sidebar-bg);
    color: white;
}

.status-filter-btn .filter-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-filter-btn .filter-dot.online {
    background: #ff9800;
}

.status-filter-btn .filter-dot.offline {
    background: #333;
}

.status-filter-btn .filter-count {
    opacity: 0.7;
    font-size: 0.6875rem;
}

/* Sort Control */
.devices-list-sort {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.devices-sort-select {
    flex: 1;
    padding: 0.3125rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    background: var(--color-content-bg);
    cursor: pointer;
}

.devices-sort-select:focus {
    outline: none;
    border-color: var(--color-accent);
}

.devices-sort-dir-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-content-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    fill: var(--color-text-secondary);
    flex-shrink: 0;
    transition: all var(--transition-speed);
}

.devices-sort-dir-btn:hover {
    border-color: var(--color-text-secondary);
    color: var(--color-text-primary);
    fill: var(--color-text-primary);
}

.devices-list-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Device List Item */
.device-list-item {
    display: flex;
    padding: 0.75rem;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background-color var(--transition-speed);
    gap: 0.75rem;
}

.device-list-item:hover {
    background: #f8f9fa;
}

.device-list-item.selected {
    background: rgba(255, 122, 0, 0.08);
    border-left: 3px solid var(--color-accent);
    padding-left: calc(0.75rem - 3px);
}

.device-list-item-content {
    flex: 1;
    min-width: 0;
}

.device-list-item-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.device-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.device-status-dot.online {
    background: #ff9800;
}

.device-status-dot.warning {
    background: #f44336;
}

.device-status-dot.recording {
    background: #4caf50;
}

.device-status-dot.recording-warning {
    background: #f44336;
}

.device-status-dot.offline {
    background: #333;
}

.device-status-dot.never-seen {
    background: #ccc;
}

.device-list-item-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-text-primary);
}

.device-list-item-info {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.25rem;
}

.device-list-item-meta {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

.device-list-item-meta span {
    display: flex;
    gap: 0.25rem;
}

.device-list-item-meta strong {
    color: var(--color-text-primary);
    font-weight: 500;
}

/* Device Actions - More menu */
.device-list-item-actions {
    position: relative;
    flex-shrink: 0;
    align-self: flex-start;
}

.device-more-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed);
    color: var(--color-text-secondary);
    opacity: 0;
}

/* Show more button on list item hover */
.device-list-item:hover .device-more-btn {
    opacity: 1;
}

/* Keep button visible when dropdown is open */
.device-list-item-actions:has(.device-actions-dropdown.open) .device-more-btn {
    opacity: 1;
    background: var(--color-border);
}

.device-more-btn:hover {
    background: var(--color-border);
    color: var(--color-text-primary);
}

.device-more-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Actions Dropdown */
.device-actions-dropdown {
    position: fixed;
    background: var(--color-content-bg);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 140px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-speed);
}

.device-actions-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.device-action-btn {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.8125rem;
    color: var(--color-text-primary);
    transition: background-color var(--transition-speed);
    text-align: left;
}

.device-action-btn:first-child {
    border-radius: 8px 8px 0 0;
}

.device-action-btn:last-child {
    border-radius: 0 0 8px 8px;
}

.device-action-btn:hover:not(:disabled) {
    background: #f5f5f5;
}

.device-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.device-action-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.device-action-btn.edit svg {
    fill: #666;
}

.device-action-btn.play svg {
    fill: var(--color-accent);
}

.device-action-btn.chart svg {
    fill: #2196f3;
}

.device-action-btn.link svg {
    fill: #9e9e9e;
}

.device-action-btn.delete {
    color: #dc3545;
}

.device-action-btn.delete svg {
    fill: #dc3545;
}

.device-action-btn.delete:hover:not(:disabled) {
    background: rgba(220, 53, 69, 0.1);
}

/* Dropdown divider */
.device-actions-dropdown .dropdown-divider {
    height: 1px;
    background-color: var(--color-border);
    margin: 0.25rem 0;
}

/* Map Panel */
.devices-map-panel {
    background: var(--color-content-bg);
    border-radius: 8px;
    border: 1px solid var(--color-border);
    overflow: hidden;
    position: relative;
    isolation: isolate;
}

#devices-map {
    width: 100%;
    height: 100%;
}

/* Map Reset Button */
.map-reset-btn {
    position: absolute;
    top: 80px;
    left: 10px;
    z-index: 1000;
    width: 34px;
    height: 34px;
    border-radius: 4px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    background: var(--color-content-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease-in-out;
    box-shadow: 0 1px 5px rgba(0,0,0,0.15);
}

/* No shift needed - reset button is now on the left under zoom controls */

.map-reset-btn:hover {
    background: #f4f4f4;
    border-color: rgba(0, 0, 0, 0.3);
}

.map-reset-btn svg {
    width: 18px;
    height: 18px;
    fill: var(--color-text-secondary);
}

.map-reset-btn:hover svg {
    fill: var(--color-text-primary);
}

/* Map Warning Badge */
.map-warning-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: #f44336;
    color: white;
    border-radius: 16px;
    font-size: 0.8125rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.4);
    transition: right 0.3s ease-in-out;
}

/* Shift warning badge left when stats panel is open */
.main-content:has(.stats-panel.open) .map-warning-badge {
    right: 490px;
}

.map-warning-badge svg {
    flex-shrink: 0;
}

/* Edit Panel */
.devices-edit-panel {
    background: var(--color-content-bg);
    border-radius: 8px;
    border: 1px solid var(--color-border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.device-edit-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    background: #f8f9fa;
}

.device-edit-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.device-edit-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.device-edit-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-text-secondary);
    text-align: center;
    padding: 2rem;
}

.device-edit-empty svg {
    width: 64px;
    height: 64px;
    fill: var(--color-border);
    margin-bottom: 1rem;
}

/* Device Detail Fields */
.device-detail-section {
    margin-bottom: 1.5rem;
}

.device-detail-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.device-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.875rem;
}

.device-detail-label {
    color: var(--color-text-secondary);
}

.device-detail-value {
    color: var(--color-text-primary);
    font-weight: 500;
    text-align: right;
}

.device-detail-value.online {
    color: #ff9800;
}

.device-detail-value.offline {
    color: #f44336;
}

/* Map Marker Styles */
.device-map-marker-wrapper {
    background: none !important;
    border: none !important;
}

.device-map-marker {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    position: relative;
    z-index: 2;
}

.device-map-marker.online {
    background: #ff9800;
}

.device-map-marker.recording {
    background: #4caf50;
}

.device-map-marker.warning {
    background: #f44336;
}

.device-map-marker.recording-warning {
    background: #f44336;
}

.device-map-marker.offline {
    background: #333;
}

.device-map-marker.never-seen {
    background: #ccc;
}

.device-map-marker.selected {
    border-color: var(--color-accent);
    transform: scale(1.2);
}

/* Recording pulse ring */
.device-map-marker-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin-top: -15px;
    margin-left: -15px;
    border-radius: 50%;
    background: rgba(76, 175, 80, 0.6);
    z-index: 3;
    animation: map-pulse 1.5s ease-out infinite;
    pointer-events: none;
}

.device-map-marker-pulse.recording-warning {
    background: rgba(244, 67, 54, 0.6);
}

@keyframes map-pulse {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.leaflet-popup-content {
    margin: 0.75rem 1rem;
}

.device-popup {
    min-width: 200px;
}

.device-popup-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.device-popup-info {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

/* List View Table Styles */
#devices-content > .card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.devices-table-container {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.devices-table {
    width: 100%;
    border-collapse: collapse;
}

.devices-table th,
.devices-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.devices-table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.devices-table th.sortable-th {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.devices-table th.sortable-th:hover {
    color: var(--color-text-primary);
}

.devices-table th.sortable-th.active {
    color: var(--color-accent);
}

.sortable-th-inner {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.sort-arrow {
    fill: currentColor;
    flex-shrink: 0;
}

.devices-table td {
    font-size: 0.875rem;
}

.devices-table tbody tr:hover {
    background: #f8f9fa;
}

/* Table Actions Cell */
.table-actions-cell {
    width: 50px;
    text-align: center;
    position: relative;
}

.table-actions-cell .device-list-item-actions {
    display: flex;
    justify-content: center;
}

/* Table more button - always visible but subtle */
.table-more-btn {
    opacity: 0;
}

.devices-table tbody tr:hover .table-more-btn {
    opacity: 1;
}

/* Keep button visible when dropdown is open */
.table-actions-cell:has(.device-actions-dropdown.open) .table-more-btn {
    opacity: 1;
    background: var(--color-border);
}

/* Table empty state */
.table-empty {
    text-align: center;
    padding: 2rem !important;
    color: var(--color-text-secondary);
}

/* Device Status Badge */
.device-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.device-status-badge::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.device-status-badge.online {
    background: rgba(255, 152, 0, 0.1);
    color: #e65100;
}

.device-status-badge.online::before {
    background: #ff9800;
}

.device-status-badge.recording {
    background: rgba(76, 175, 80, 0.1);
    color: #2e7d32;
}

.device-status-badge.recording::before {
    background: #4caf50;
    animation: pulse-recording 1.5s ease-in-out infinite;
}

.device-status-badge.warning {
    background: rgba(244, 67, 54, 0.1);
    color: #c62828;
}

.device-status-badge.warning::before {
    background: #f44336;
}

.device-status-badge.recording-warning {
    background: rgba(244, 67, 54, 0.1);
    color: #c62828;
}

.device-status-badge.recording-warning::before {
    background: #f44336;
    animation: pulse-recording 1.5s ease-in-out infinite;
}

@keyframes pulse-recording {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.device-status-badge.offline {
    background: rgba(0, 0, 0, 0.06);
    color: #555;
}

.device-status-badge.offline::before {
    background: #333;
}

.device-status-badge.never-seen {
    background: rgba(0, 0, 0, 0.04);
    color: #999;
}

.device-status-badge.never-seen::before {
    background: #ccc;
}

/* Device Type Badge */
.device-type-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: #f0f0f0;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

/* ============================================
   Stats Panel - Slide-in Panel
   ============================================ */

/* Main panel container - slides in from right */
.stats-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 480px;
    max-width: calc(100vw - var(--sidebar-width));
    background: var(--color-content-bg);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 500;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.stats-panel.open {
    transform: translateX(0);
}

/* Stats Panel Header */
.stats-panel-header {
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid var(--color-border);
}

.stats-panel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.stats-panel-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-speed);
}

.stats-close-btn:hover {
    background: var(--color-border);
}

.stats-close-btn svg {
    width: 20px;
    height: 20px;
    fill: var(--color-text-secondary);
}

.stats-panel-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.stats-range-select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.8125rem;
    background: var(--color-content-bg);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%23666'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.stats-range-select:hover {
    border-color: var(--color-text-secondary);
}

.stats-range-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.15);
}

.stats-refresh-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-content-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--transition-speed);
}

.stats-refresh-btn:hover {
    border-color: var(--color-text-secondary);
}

.stats-refresh-btn svg {
    width: 16px;
    height: 16px;
    fill: var(--color-text-secondary);
}

/* Stats Panel Body */
.stats-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

/* Stats Metrics Grid */
.stats-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

/* Stat Card */
.stat-card {
    background: var(--color-content-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1rem;
}

.stat-card-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
}

.stat-card-range {
    display: flex;
    justify-content: space-between;
    font-size: 0.6875rem;
    color: var(--color-text-secondary);
}

.stat-card-range span {
    display: flex;
    gap: 0.25rem;
}

/* Progress Bar (for bytes metrics) */
.stat-card-bar {
    height: 6px;
    background: #f0f0f0;
    border-radius: 3px;
    margin-top: 0.75rem;
    overflow: hidden;
}

.stat-card-bar-fill {
    height: 100%;
    background: var(--color-accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Stats Loading State */
.stats-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--color-text-secondary);
}

.stats-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: stats-spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

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

/* Stats Error State */
.stats-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: var(--color-text-secondary);
}

.stats-error p {
    margin-bottom: 1rem;
}

.stats-retry-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--color-accent);
    background: transparent;
    color: var(--color-accent);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

.stats-retry-btn:hover {
    background: var(--color-accent);
    color: white;
}

/* Stats Empty State */
.stats-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--color-text-secondary);
    text-align: center;
}

/* External Stats - Section */
.stats-section {
    margin-top: 1.5rem;
    padding: 0 0.25rem;
}

.stats-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.75rem 0;
}

/* Status History Chart */
.status-chart {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.status-chart-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-chart-label {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    min-width: 80px;
    text-align: right;
}

.status-chart-bar {
    flex: 1;
    display: flex;
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--color-bg-secondary);
}

.status-chart-segment {
    height: 100%;
    transition: width 0.3s ease;
    cursor: default;
}

.status-chart-segment.recording {
    background: var(--color-recording, #22c55e);
}

.status-chart-segment.online {
    background: var(--color-online, #3b82f6);
}

.status-chart-segment.unreachable {
    background: var(--color-offline, #ef4444);
}

.status-chart-legend {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-border);
}

.status-chart-legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

.status-dot.recording {
    background: var(--color-recording, #22c55e);
}

.status-dot.online {
    background: var(--color-online, #3b82f6);
}

.status-dot.unreachable {
    background: var(--color-offline, #ef4444);
}

/* Stats Panel Responsive */
@media (max-width: 768px) {
    .stats-panel {
        width: 100vw;
        max-width: 100vw;
    }
    .stats-metrics-grid {
        grid-template-columns: 1fr;
    }
}

