/* INRMABU Main Stylesheet - v7.12.4 */
/* Full Feature Suite: Dashboard, Measurement, Playback, Altitude, POI, Roles */

:root {
    --forest-green: #224229;
    --ember-red: #bd3513;
    --oat-white: #f4f4f2;
    --glass-bg: rgba(255, 255, 255, 0.9);
    --sidebar-width: 350px;

    /* Surface colors */
    --bg-primary: #f4f4f2;
    --bg-card: #ffffff;
    --bg-card-hover: #fdfdfd;
    --bg-input: #ffffff;
    --bg-input-readonly: #f5f5f5;
    --bg-overlay: rgba(244, 244, 242, 0.98);
    --bg-subsection: #f9f9f9;
    --bg-info: #e6f4ea;
    --bg-admin: #fff9f9;
    --bg-admin-border: #ffebeb;
    --bg-gpx: #f4fdf4;
    --bg-sort: #fff8f0;
    --bg-sos-alert: #fff5f5;
    --bg-playback: rgba(255, 255, 255, 0.95);

    /* Text colors */
    --text-primary: #333333;
    --text-secondary: #555555;
    --text-muted: #888888;
    --text-link: #666666;

    /* Border colors */
    --border-primary: #dddddd;
    --border-light: #eeeeee;
    --border-section: #f0f0f0;

    /* Status colors */
    --color-online: #1e8e3e;
    --color-online-bg: #e6f4ea;
    --color-offline: #888888;

    /* Component-specific */
    --scrollbar-thumb: #dddddd;
    --toggle-off: #cccccc;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --detail-header-bg: rgba(189, 53, 19, 1);
    --status-stream-bg: #142118;
    --auth-gradient-start: var(--forest-green);
    --auth-gradient-end: #1a3320;
}

[data-theme="dark"] {
    --forest-green: #3a7a4a;
    --ember-red: #e04a2a;
    --oat-white: #1a1a2e;
    --glass-bg: rgba(30, 30, 46, 0.92);

    --bg-primary: #1a1a2e;
    --bg-card: #25253e;
    --bg-card-hover: #2d2d4a;
    --bg-input: #2d2d4a;
    --bg-input-readonly: #222238;
    --bg-overlay: rgba(26, 26, 46, 0.98);
    --bg-subsection: #222238;
    --bg-info: #1e3328;
    --bg-admin: #2a2035;
    --bg-admin-border: #3a2a45;
    --bg-gpx: #1e3328;
    --bg-sort: #2a2520;
    --bg-sos-alert: #3a2020;
    --bg-playback: rgba(37, 37, 62, 0.95);

    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #808090;
    --text-link: #a0a0b0;

    --border-primary: #3a3a5a;
    --border-light: #2d2d4a;
    --border-section: #2d2d4a;

    --color-online: #4caf50;
    --color-online-bg: #1e3328;
    --color-offline: #808090;

    --scrollbar-thumb: #3a3a5a;
    --toggle-off: #555570;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --detail-header-bg: rgba(224, 74, 42, 0.9);
    --status-stream-bg: #0d0d1a;
    --auth-gradient-start: #1a1a2e;
    --auth-gradient-end: #0d0d1a;
}

/* ===== Utility Classes ===== */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-grow {
    flex-grow: 1;
}

.flex-shrink-0 {
    flex-shrink: 0;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.items-baseline {
    align-items: baseline;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-4 {
    gap: 4px;
}

.gap-6 {
    gap: 6px;
}

.gap-8 {
    gap: 8px;
}

.gap-10 {
    gap: 10px;
}

.gap-12 {
    gap: 12px;
}

.gap-15 {
    gap: 15px;
}

.grid {
    display: grid;
}

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

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.nowrap {
    white-space: nowrap;
}

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

.w-full {
    width: 100%;
}

.hidden {
    display: none !important;
}

.mb-0 {
    margin-bottom: 0;
}

.m-0 {
    margin: 0;
}

/* Compact Card Pattern */
.settings-card {
    border: 1px solid var(--border-primary);
    background: var(--bg-card);
    padding: 12px 15px;
    border-radius: 12px;
    box-shadow: 0 4px 6px var(--shadow-color);
    margin-bottom: 12px;
}

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

.settings-card-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--forest-green);
}

.tag-live {
    background: var(--forest-green);
    color: white;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px;
}

.tag-manual {
    background: var(--ember-red);
    color: white;
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 6px;
}

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

.text-sm {
    font-size: 0.78rem;
}

.text-xs {
    font-size: 0.65rem;
}

.font-bold {
    font-weight: 700;
}

.color-forest {
    color: var(--forest-green);
}

.color-ember {
    color: var(--ember-red);
}

.color-green {
    color: var(--color-online);
}

.color-gray {
    color: var(--color-offline);
}

.input-standard {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    box-sizing: border-box;
}

.input-readonly {
    background: var(--bg-input-readonly);
}

/* Info card (green) - more compact */
.info-card {
    padding: 12px 15px;
    background: var(--bg-info);
    border: 1px solid var(--color-online);
    border-radius: 12px;
    margin-bottom: 12px;
}

/* Subsection background - more compact */
.sub-section {
    background: var(--bg-subsection);
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.sub-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 5px;
}

/* Admin section */
.admin-section {
    background: var(--bg-admin);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid var(--bg-admin-border);
}

/* ===== Drag-Sort (v7.8.0) ===== */
.drag-handle {
    cursor: grab;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    width: 10px;
    flex-shrink: 0;
    transition: color 0.2s;
}

.group-header:hover .drag-handle {
    color: rgba(255, 255, 255, 0.9);
}

.dragging {
    opacity: 0.4;
}

.drag-indicator-above {
    border-top: 3px solid var(--ember-red) !important;
}

.drag-indicator-below {
    border-bottom: 3px solid var(--ember-red) !important;
}

.sort-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--bg-sort);
    border-bottom: 1px solid var(--border-section);
    font-size: 0.72rem;
    color: #b86e1e;
}

.sort-indicator .reset-sort-btn {
    background: none;
    border: 1px solid #d9a05b;
    border-radius: 6px;
    color: #b86e1e;
    padding: 2px 8px;
    font-size: 0.68rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.sort-indicator .reset-sort-btn:hover {
    background: #b86e1e;
    color: white;
}

/* Device list group header (v8.0.0 Unified Design) */
.group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--forest-green);
    color: var(--oat-white);
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 0;
    z-index: 10;
    transition: background 0.2s, box-shadow 0.2s;
    user-select: none;
}

.group-header:hover {
    background: color-mix(in srgb, var(--forest-green) 80%, white);
}

.group-header.collapsed {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.group-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.group-title {
    letter-spacing: 0.5px;
}

.caret-icon {
    width: 14px;
    font-size: 0.8rem;
    opacity: 0.7;
    transition: transform 0.3s;
}

.group-badge {
    font-size: 0.7rem;
    background: var(--ember-red);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.group-visibility-toggle {
    cursor: pointer;
    font-size: 0.85rem;
    width: 18px;
    display: flex;
    justify-content: center;
    transition: opacity 0.2s;
}

.group-visibility-toggle:hover {
    opacity: 0.8;
}

.group-content {
    background: var(--bg-card);
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Status Stream (Log style) */
.status-stream {
    background: var(--status-stream-bg);
    color: var(--oat-white);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.7rem;
    padding: 8px 12px;
    border-radius: 8px;
    height: 580px;
    overflow-y: auto;
    border: 1px solid var(--forest-green);
}

.status-line {
    border-bottom: 1px solid rgba(244, 244, 242, 0.05);
    padding: 3px 0;
    display: flex;
    gap: 8px;
    align-items: center;
}

.status-line .time {
    color: #8fa394;
    flex-shrink: 0;
    font-size: 0.65rem;
}

.status-line .code {
    font-weight: bold;
    flex-shrink: 0;
    min-width: 32px;
}

.status-line .code.ok {
    color: #81c784;
}

.status-line .code.err {
    color: #e57373;
}

.status-line.status-error {
    background: rgba(229, 115, 115, 0.12);
    border-left: 3px solid var(--ember-red);
    padding-left: 6px;
}

/* Ember red variant */

.status-line .feed {
    color: #f4f4f2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.9;
}

/* Feed sub-header */
.feed-sub-header {
    padding: 8px 16px 6px 20px;
    font-size: 0.72rem;
    color: var(--forest-green);
    background: var(--oat-white);
    border-bottom: 1px solid rgba(0,0,0,0.04);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.7;
}

/* Device explore item */
.device-item-explore {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-section);
    cursor: pointer;
    gap: 12px;
    transition: all 0.2s;
    background: var(--bg-card);
}

.device-item-explore:hover {
    background: var(--bg-card-hover);
}

.device-item-explore.hidden-device {
    background: var(--bg-subsection);
    opacity: 0.6;
}

.device-item-explore.sos-alert {
    border-left: 4px solid var(--ember-red);
    background: var(--bg-sos-alert);
}

.device-item-explore.ipc-no-position {
    opacity: 0.45;
    border-left: 2px dashed var(--text-muted);
}

/* Load more styling */
.load-more-container {
    padding: 12px;
    display: flex;
    justify-content: center;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
}

.btn-load-more {
    background: var(--oat-white);
    border: 1px solid var(--forest-green);
    color: var(--forest-green);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-load-more:hover {
    background: var(--forest-green);
    color: white;
}

/* Color dot indicator */
.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
}

/* Detail action bar */
.detail-action-bar {
    display: flex;
    gap: 6px;
    padding: 8px 15px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
}

/* Panel header bar */
.panel-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-light);
}

/* Altitude chart container */
.alt-chart-container {
    padding: 8px 10px;
    height: 180px;
}

/* Playback info section */
.playback-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
}

.playback-speeds {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
}

.playback-time-display {
    font-size: 0.7rem;
    font-family: monospace;
    color: var(--text-secondary);
    min-width: 90px;
}

.playback-info-text {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: 10px;
    white-space: nowrap;
}

/* Toolbar divider */
.toolbar-divider {
    width: 1px;
    background: var(--border-primary);
    margin: 4px 2px;
}

/* Map filter card */
.map-filter-card {
    margin-bottom: 12px;
    border: 1px solid var(--forest-green);
    background: var(--bg-card-hover);
    padding: 10px;
    border-radius: 12px;
}

/* Dashboard section header */
.dash-section-header {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--forest-green);
    margin-bottom: 10px;
}

/* Dashboard stat card */
.dash-stat-card {
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    margin-bottom: 14px;
    background: var(--bg-card-hover);
}

/* Role badge pill */
.role-badge-pill {
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--forest-green);
    color: white;
    padding: 2px 10px;
    border-radius: 20px;
}

/* Header logo */
.header-logo {
    height: 32px;
    width: auto;
    background: white;
    padding: 4px;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* SOS badge */
.sos-badge {
    display: none;
    background: #bd3513;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    animation: pulse-live 1.5s infinite;
}

/* Share button in header */
.header-share-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px;
}

/* Version label */
.version-label {
    font-size: 0.7rem;
    opacity: 0.6;
}

.version-clickable {
    cursor: pointer;
    transition: opacity 0.2s;
    border-bottom: 1px dashed currentColor;
    padding-bottom: 1px;
}

.version-clickable:hover {
    opacity: 1;
}

/* Changelog */
.changelog-entry {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color, #eee);
}

.changelog-entry:last-child {
    border-bottom: none;
}

.changelog-version {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--forest-green);
}

.changelog-date {
    font-size: 0.7rem;
    color: #888;
    margin-left: 8px;
}

.changelog-desc {
    font-size: 0.8rem;
    margin-top: 4px;
    line-height: 1.5;
    color: var(--text-primary, #333);
}

.changelog-tag {
    display: inline-block;
    font-size: 0.6rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
    margin-right: 4px;
    vertical-align: middle;
}

.changelog-tag-feat { background: #e3f2fd; color: #1565c0; }
.changelog-tag-fix { background: #fce4ec; color: #c62828; }
.changelog-tag-docs { background: #f3e5f5; color: #6a1b9a; }
.changelog-tag-chore { background: #fff3e0; color: #e65100; }

/* Subtitle bar */
.header-subtitle {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 5px;
}

/* Role inline badge */
.role-inline-badge {
    font-size: 0.6rem;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

/* Close panel button (transparent) */
.close-btn-transparent {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
}

/* Countdown display */
.countdown-display {
    font-size: 1.6rem;
    font-weight: 700;
    font-family: monospace;
    color: var(--text-muted);
}



/* Detail title section */
.detail-title-text {
    font-weight: 700;
    font-size: 1.1rem;
}

.detail-subtitle-text {
    font-size: 0.7rem;
    opacity: 0.7;
}

/* Settings page title area */
.settings-title-area {
    margin-bottom: 30px;
    border-bottom: 2px solid var(--forest-green);
    padding-bottom: 15px;
}

/* Settings grid layout */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}

/* No data placeholder */
.no-data-text {
    text-align: center;
    color: var(--text-muted);
    margin-top: 50px;
}

/* GPX export bar */
.gpx-export-bar {
    padding: 12px;
    border-bottom: 2px solid var(--forest-green);
    background: var(--bg-gpx);
    margin-bottom: 8px;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}

#map {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 1;
    transition: all 0.3s ease-in-out;
}

.side-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100%;
    background-color: var(--bg-primary);
    box-shadow: 2px 0 20px var(--shadow-color);
    z-index: 2005;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    border-right: 1px solid rgba(34, 66, 41, 0.1);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(0);
    /* Default open on desktop */
}

.side-panel.closed {
    transform: translateX(-100%);
}

/* Float Toggle for map (only visible when sidebar closed) */
.map-floating-toggle {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 2000;
    background: var(--forest-green);
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: none;
    /* Default hidden on desktop unless sidebar closed */
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s;
}

@media (max-width: 768px) {
    .map-floating-toggle {
        display: flex !important;
        /* Always show hamburger on mobile */
    }


}

header {
    padding: 20px 20px;
    background: var(--forest-green);
    color: var(--oat-white);
}

h1 {
    font-size: 1.4rem;
    margin: 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 3D Mode Toggle Button */
.mode-toggle-container {
    position: absolute;
    left: 20px;
    bottom: 30px;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mode-btn {
    background: var(--bg-card);
    border: none;
    padding: 12px 18px;
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-color);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--forest-green);
    transition: all 0.2s;
}

.mode-btn:hover {
    transform: translateY(-2px);
    background: var(--bg-card-hover);
}

.mode-btn.active {
    background: var(--forest-green);
    color: white;
}

#map-3d {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    display: none;
    z-index: 1;
    /* Match 2D map when shown */
    transition: all 0.3s ease-in-out;
}

#map-3d.full-width {
    left: 0;
}

h1::after {
    content: 'LIVE';
    font-size: 0.6rem;
    background: var(--ember-red);
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
    animation: pulse-live 2s infinite;
}

@keyframes pulse-live {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes sos-flash {

    0%,
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 5px var(--ember-red));
    }

    50% {
        transform: scale(1.2);
        filter: drop-shadow(0 0 15px var(--ember-red));
    }
}

.sos-flash {
    animation: sos-flash 1s infinite ease-in-out;
}

.sos-marker-outer {
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn {
    border: 1px solid var(--border-primary);
    padding: 4px;
    border-radius: 8px;
    font-size: 0.65rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 48px;
    background: var(--bg-card);
    color: var(--text-secondary);
    box-shadow: 0 1px 2px var(--shadow-color);
    transition: all 0.2s;
    gap: 2px;
    flex: 1;
    min-width: 0;
    font-weight: 500;
}

.action-btn i {
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.action-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--forest-green);
    color: var(--forest-green);
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

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

.action-btn.active {
    background: var(--forest-green) !important;
    color: white !important;
    border-color: var(--forest-green);
    box-shadow: 0 4px 10px rgba(34, 66, 41, 0.2);
}

.action-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 5px;
    padding: 0 12px;
    margin: 15px 0;
    justify-content: stretch;
}

.map-btn-floating {
    position: absolute;
    z-index: 2000;
    background: var(--bg-card);
    border: 2px solid var(--border-primary);
    width: 44px;
    height: 44px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px var(--shadow-color);
    transition: all 0.2s;
    color: var(--text-primary);
}

.map-btn-floating:hover {
    background: var(--bg-card-hover);
}

.map-btn-fullscreen {
    top: 80px;
    /* Below layers control */
    right: 10px;
    z-index: 900;
}

@media (max-width: 768px) {

    /* Force show toggle on mobile if sidebar is not open */
    .map-floating-toggle {
        display: flex !important;
        z-index: 2100;
        /* Highest priority */
    }

    .map-btn-fullscreen {
        top: 80px;
        right: 10px;
    }
}

.tab-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 10px 10px 10px;
}

.content-section {
    display: none;
}

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

.device-item {
    background: var(--bg-card);
    padding: 10px 12px;
    border-radius: 12px;
    margin-bottom: 6px;
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.device-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.device-item .name {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.device-item .meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.3;
}

.message-item {
    background: var(--bg-card);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 10px;
    border-left: 4px solid var(--forest-green);
    box-shadow: 0 2px 5px var(--shadow-color);
}

.message-item .msg-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-link);
    margin-bottom: 8px;
}

.message-item .msg-text {
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--forest-green);
}

.status-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-subsection);
}

.status-badge.online {
    background: var(--color-online-bg);
    color: var(--color-online);
}

.leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 5px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-tip-container {
    display: none;
}

/* ===== Full Screen Settings Page ===== */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    backdrop-filter: blur(10px);
    z-index: 5000;
    display: none;
    overflow-y: auto;
    padding: 40px 20px;
    box-sizing: border-box;
}

.settings-overlay.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.settings-container {
    max-width: 1600px;
    width: 95%;
    margin: 0 auto;
}

.settings-close-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--forest-green);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 5001;
    transition: all 0.2s;
}

.settings-close-btn:hover {
    transform: rotate(90deg) scale(1.1);
}

/* ===== Device Detail Styles ===== */
.detail-view {
    display: none;
    flex-direction: column;
    height: 100%;
    background: var(--bg-primary);
}

/* RWD Mobile Styles */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    #map {
        left: 0;
    }

    .side-panel {
        transform: translateX(-100%);
        width: 85%;
        /* Mobile sidebar width */
        max-width: 380px;
    }

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

    .side-panel.closed {
        transform: translateX(-100%);
    }

    .sidebar-toggle {
        display: flex;
    }

    .side-panel-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(2px);
        z-index: 900;
    }

    .side-panel-overlay.show {
        display: block;
    }

    /* Header padding inherited */
}

.detail-header {
    background: var(--detail-header-bg);
    color: white;
    padding: 15px;
    /* Padding reduced as it now sits below the main header */
    display: flex;
    align-items: center;
    gap: 15px;
}

.back-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.detail-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
}

.stat-item {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--forest-green);
}

.detail-section {
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
}

.detail-section h4 {
    margin: 0 0 15px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.detail-list-item {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.82rem;
    background: var(--bg-card);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border-section);
}

.count-badge {
    /* Reset styles as requested */
    background: none !important;
    color: black !important;
    padding: 0 4px;
    font-size: 0.85rem;
}

.detail-list-item .time {
    color: var(--text-muted);
    font-size: 0.7rem;
    min-width: 60px;
}

.message-bubble-icon {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    transition: transform 0.2s;
}

.message-bubble-icon:hover {
    transform: scale(1.1);
}

::-webkit-scrollbar {
    width: 4px;
}

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

/* ===== Feed Management Styles ===== */
.feed-card {
    background: var(--bg-card);
    padding: 8px 15px;
    border-radius: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--border-light);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 15px;
}

.feed-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-color: var(--forest-green);
}

.feed-card .feed-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--forest-green);
    min-width: 100px;
}

.feed-card .feed-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed-card .feed-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
}


.feed-card .feed-actions button {
    font-family: inherit;
    font-size: 0.7rem;
    padding: 4px 10px;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    cursor: pointer;
    background: var(--bg-card);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.feed-card .feed-actions button:hover {
    background: var(--forest-green);
    color: white;
    border-color: var(--forest-green);
}

.feed-card .feed-actions button.danger:hover {
    background: var(--ember-red);
    border-color: var(--ember-red);
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    display: inline-block;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--toggle-off);
    border-radius: 22px;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    left: 3px;
    bottom: 3px;
    transition: 0.3s;
}

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

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

/* Add Feed Form */
.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 3px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
    background: var(--bg-input);
    color: var(--text-primary);
}

.form-group input:focus {
    outline: none;
    border-color: var(--forest-green);
}

.btn-primary {
    background: var(--forest-green);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--forest-green);
    border: 1px solid var(--border-primary);
    padding: 10px 20px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-subsection);
}

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

.section-header h3 {
    margin: 0;
    font-size: 0.95rem;
}

.section-header .count-badge {
    background: var(--forest-green);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--forest-green);
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 0.85rem;
    z-index: 9999;
    transition: transform 0.3s;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* ===== Device Search Filter ===== */
.device-search-bar {
    padding: 8px 12px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
}

.device-search-bar input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border: 1px solid var(--border-primary);
    background: var(--bg-input);
    color: var(--text-primary);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.82rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.device-search-bar input:focus {
    outline: none;
    border-color: var(--forest-green);
}

.device-search-bar input::placeholder {
    color: #bbb;
}

/* ===== Dashboard Cards (v7.4.0) ===== */
.dash-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 16px 14px;
    text-align: center;
    transition: all 0.2s;
    box-shadow: 0 2px 6px var(--shadow-color);
}

.dash-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dash-card-icon {
    font-size: 1.3rem;
    margin-bottom: 6px;
}

.dash-card-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    color: var(--forest-green);
    margin-bottom: 4px;
}

.dash-card-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== Device Health Dashboard (v8.1.0) ===== */
.dash-health-divider {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--ember-red);
    padding: 12px 0 8px;
    margin-top: 4px;
    border-top: 2px solid var(--border-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dash-count-badge {
    font-size: 0.65rem;
    font-weight: 700;
    background: var(--color-online);
    color: #fff;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: auto;
}

.dash-count-badge.dash-count-warn {
    background: #e8710a;
}

.dash-sub-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--border-light);
}

.health-device-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-section);
    font-size: 0.8rem;
}

.health-device-row:last-child {
    border-bottom: none;
}

.health-device-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.battery-bar-mini {
    width: 60px;
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.battery-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.health-device-pct {
    font-weight: 700;
    font-size: 0.75rem;
    min-width: 32px;
    text-align: right;
}

.stale-badge {
    font-size: 0.68rem;
    font-weight: 600;
    color: #e8710a;
    background: var(--bg-sort);
    padding: 2px 8px;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== Measurement Toolbar (v7.4.0) ===== */
.measure-toolbar {
    position: fixed;
    left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width)) / 2);
    bottom: 25px;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    gap: 6px;
    background: var(--bg-card);
    padding: 6px 10px;
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow-color);
    border: 1px solid var(--border-primary);
}

.measure-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
}

.measure-btn:hover {
    background: var(--bg-subsection);
    border-color: var(--forest-green);
    color: var(--forest-green);
}

.measure-btn.active {
    background: var(--forest-green);
    color: white;
    border-color: var(--forest-green);
}

.measure-btn-confirm {
    color: #1e8e3e;
    border-color: #1e8e3e;
}

.measure-btn-confirm:hover {
    background: #1e8e3e;
    color: white;
}

.measure-btn-cancel {
    color: #bd3513;
    border-color: #bd3513;
}

.measure-btn-cancel:hover {
    background: #bd3513;
    color: white;
}

.measure-total-display {
    position: fixed;
    bottom: 75px;
    left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width)) / 2);
    transform: translateX(-50%);
    z-index: 3000;
    background: var(--bg-card);
    padding: 8px 18px;
    border-radius: 10px;
    box-shadow: 0 4px 15px var(--shadow-color);
    font-size: 0.85rem;
    color: var(--forest-green);
    font-weight: 600;
    white-space: nowrap;
}

.measure-popup .leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #bd3513;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(189, 53, 19, 0.2);
}

.measure-popup-sm .leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #bd3513;
    border-radius: 8px;
    padding: 2px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.measure-tooltip {
    background: rgba(34, 66, 41, 0.9) !important;
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 3px 8px !important;
    font-size: 0.7rem !important;
    font-weight: 600 !important;
    font-family: 'Outfit', sans-serif !important;
}

.measure-tooltip::before {
    border-top-color: rgba(34, 66, 41, 0.9) !important;
}

/* ===== Detail View Actions (v7.5.0) ===== */
.detail-action-btn {
    flex: 1;
    background: var(--bg-subsection);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 8px 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--forest-green);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.detail-action-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--forest-green);
}

.detail-action-btn i {
    font-size: 1rem;
}

/* ===== Playback Panel (v7.5.0) ===== */
.playback-panel {
    position: fixed;
    bottom: 25px;
    left: calc(var(--sidebar-width) + 20px);
    right: 20px;
    height: 60px;
    background: var(--bg-playback);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 8px 32px var(--shadow-color);
    border: 1px solid var(--border-light);
    z-index: 4000;
    display: flex;
    align-items: center;
    padding: 0 15px;
    gap: 15px;
}

.playback-ctrl-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--forest-green);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.playback-ctrl-btn.playback-stop {
    background: #888;
}

.playback-slider {
    flex-grow: 1;
    height: 4px;
    border-radius: 2px;
    appearance: none;
    background: #e0e0e0;
    outline: none;
}

.playback-slider::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--forest-green);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.speed-btn {
    background: var(--bg-subsection);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-link);
}

.speed-btn.active {
    background: var(--forest-green);
    color: white;
    border-color: var(--forest-green);
}

/* ===== Altitude Profile (v7.5.0) ===== */
.altitude-panel {
    position: fixed;
    bottom: 95px;
    left: calc(var(--sidebar-width) + 20px);
    right: 20px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 24px var(--shadow-color);
    z-index: 3999;
    overflow: hidden;
    border: 1px solid var(--border-light);
}

/* ===== POI Markers (v7.5.0) ===== */

.poi-form-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.poi-form-card {
    background: var(--bg-card);
    border-radius: 16px;
    width: 100%;
    max-width: 450px;
    padding: 24px;
    box-shadow: 0 15px 50px var(--shadow-color);
    border: 1px solid var(--border-light);
}

/* ===== Playback Marker (v7.5.0) ===== */
.playback-marker {
    background: none !important;
    border: none !important;
}

.playback-dot {
    width: 32px;
    height: 32px;
    background: #bd3513;
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    box-shadow: 0 0 12px rgba(189, 53, 19, 0.6);
    animation: marker-bounce 0.5s infinite alternate;
}

@keyframes marker-bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-5px);
    }
}

/* ===== POI Marker (v7.5.0) ===== */
.poi-marker-icon {
    background: none !important;
    border: none !important;
}

.poi-icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
    transition: transform 0.2s;
}

.poi-icon-wrapper:hover {
    transform: rotate(-45deg) scale(1.1);
}

.poi-icon-wrapper span {
    transform: rotate(45deg);
    font-size: 1.2rem;
    line-height: 1;
}

/* ===== Mobile Adjustments v7.5.0 ===== */

@media (max-width: 768px) {
    .playback-panel {
        left: 10px;
        right: 10px;
        bottom: 80px;
        flex-direction: column;
        height: auto;
        padding: 10px;
        gap: 8px;
    }

    .altitude-panel {
        left: 10px;
        right: 10px;
        bottom: 150px;
    }

    .measure-toolbar {
        left: 50%;
        bottom: 15px;
    }

    .measure-total-display {
        left: 50%;
        bottom: 65px;
    }
}

/* ─── IPC Import Device Cards (v7.10.2) ─── */
.ipc-device-card {
    background: var(--bg-card);
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.ipc-device-card:hover {
    border-color: var(--forest-green);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ipc-device-card.imported {
    opacity: 0.5;
    background: var(--bg-subsection);
}

.ipc-device-card .ipc-imei {
    font-family: monospace;
    font-size: 0.72rem;
    color: var(--text-link);
    letter-spacing: 0.5px;
}

.ipc-badge-imported {
    background: #e8e8e8;
    color: #888;
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.ipc-badge-tracking {
    background: #d4edda;
    color: #1e8e3e;
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.ipc-badge-offline {
    background: #f8d7da;
    color: #bd3513;
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

/* Map attribution readability */
.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.75) !important;
    backdrop-filter: blur(2px);
    padding: 2px 6px !important;
    font-size: 0.7rem;
}

[data-theme="dark"] .leaflet-control-attribution {
    background: rgba(0, 0, 0, 0.65) !important;
    color: #ccc;
}

[data-theme="dark"] .leaflet-control-attribution a {
    color: #8bb8f8;
}