/* ============================================================
   OE GPS Tracker — Mobile PWA CSS
   v18 — Full mobile redesign
============================================================ */

:root {
    --primary: #00b4d8;
    --primary-dark: #0096b4;
    --primary-light: #e0f7fc;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.95);
    --surface-glass-heavy: rgba(255, 255, 255, 0.98);
    --surface-hover: #f1f5f9;
    --text: #334155;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;
    --border: #e5e7eb;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --nav-height: 60px;
    --top-bar-height: 56px;
    --sheet-radius: 20px;
    --safe-bottom: max(env(safe-area-inset-bottom, 0px), 14px);
    --safe-top: env(safe-area-inset-top, 0px);
    --locate-icon: var(--text-muted);

    /* Golden Ratio Typography (Base, Base*1.618, Base*1.618^2) */
    --fs-base: clamp(0.875rem, 0.8rem + 0.3vw, 1rem);
    /* 14px - 16px */
    --fs-sub: clamp(1.416rem, 1.3rem + 0.5vw, 1.618rem);
    /* 22px - 26px */
    --fs-title: clamp(2.29rem, 2.1rem + 0.8vw, 2.618rem);
    /* 36px - 41px */
}

[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-glass: rgba(30, 41, 59, 0.95);
    --surface-glass-heavy: rgba(30, 41, 59, 0.98);
    --surface-hover: #334155;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --text-subtle: #475569;
    --border: #334155;
    --locate-icon: var(--text-muted);
    --primary: #38bdf8;
    --primary-dark: #0284c7;
    --primary-light: rgba(56, 189, 248, 0.15);
}

/* ── Reset ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

[data-theme="dark"] .leaflet-layer,
[data-theme="dark"] .leaflet-control-zoom-in,
[data-theme="dark"] .leaflet-control-zoom-out,
[data-theme="dark"] .leaflet-control-attribution {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

/* Hide scrollbar globally for web app feel */
::-webkit-scrollbar {
    display: none;
}

html,
body {
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

/* Leaflet touchmove fix for mobile warnings */
.leaflet-container {
    touch-action: none !important;
}

/* Fix Leaflet map flickering/white lines on zoom */
.leaflet-tile-container img {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    transition: opacity 0.3s ease-in-out;
}

/* Smooth tile loading */
.map-tiles {
    transition: opacity 0.3s ease;
}

.leaflet-tile {
    opacity: 0;
    animation: fadeInTile 0.3s ease-in forwards;
}

@keyframes fadeInTile {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Hide Leaflet map attribution globally */
.leaflet-control-attribution {
    display: none !important;
}

/* Leaflet Popup Dark Mode Support */
[data-theme="dark"] .leaflet-popup-content-wrapper,
[data-theme="dark"] .leaflet-popup-tip {
    background-color: var(--surface);
    color: var(--text);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .leaflet-popup-close-button {
    color: var(--text-muted) !important;
}

/* Micro-animations for map control buttons */
.leaflet-control-custom {
    transition: none;
}

.leaflet-control-custom:active {
    transform: scale(0.92);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2) !important;
}

/* Global spin animation */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* App Load Animation */
@keyframes fadeInApp {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes avatarBreathe {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.06);
    }
}



body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: var(--fs-base, 14px);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-y;
    animation: fadeInApp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
}

input,
select {
    font-family: inherit;
    outline: none;
}

a {
    color: var(--primary);
}

/* ── MAP (full screen) ── */
#map {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 1;
    /* iOS safe area fix - ensure map doesn't overlap status bar */
    padding-top: max(env(safe-area-inset-top, 0px), 0px);
}

.leaflet-control-zoom {
    display: none !important;
}

/* Hide default zoom, use custom buttons */
.gps-vehicle-icon {
    overflow: visible !important;
    background: none !important;
    border: none !important;
}

.gps-vehicle-icon div {
    overflow: visible !important;
}

.leaflet-tile-container img {
    width: 256px !important;
    height: 256px !important;
}

.motor-tooltip {
    background: var(--surface-glass) !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    color: var(--text) !important;
    font-family: 'Outfit', sans-serif !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    padding: 3px 8px !important;
    white-space: nowrap !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12) !important;
}

.motor-tooltip::before {
    display: none !important;
}

/* ── TOP SEARCH BAR ── */
#top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    min-height: calc(var(--top-bar-height) + env(safe-area-inset-top, 0px));
    background: var(--surface-glass);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: calc(env(safe-area-inset-top, 0px) + 6px) 12px 6px 12px;
    gap: 8px;
    border-bottom: 1px solid var(--border);
}

#top-search-wrap {
    flex: 1;
    display: flex;
        justify-content: center;
    align-items: center;
    background: var(--surface-hover);
    border-radius: 10px;
    padding: 0 12px;
    height: 36px;
    gap: 8px;
    min-width: 0;
}

.top-search-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.top-search-input {
    flex: 1;
    background: none;
    border: none;
    font-size: 0.825rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    color: var(--text-muted);
    min-width: 0;
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    cursor: pointer;
    letter-spacing: -0.01em;
}

.top-search-input option {
    background: var(--surface);
    color: var(--text);
    font-size: 0.8rem;
    font-family: 'Outfit', sans-serif;
    padding: 6px 8px;
}

.top-icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--surface-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: none;
}

.top-icon-btn svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.top-icon-btn--accent {
        justify-content: center !important;
    align-items: center !important;
    padding : 0;
    margin : 0;
    background: transparent;
    border: 1px solid var(--primary);
    box-shadow: 0 2px 8px rgba(56, 189, 248, 0.2);
}

.top-icon-btn--accent svg {
    color: var(--primary);
    width: 18px;
    height: 18px;
}

[data-theme="dark"] .top-icon-btn--accent {
    background: rgba(0, 180, 216, 0.15);
    border: none;
}

[data-theme="dark"] .top-icon-btn--accent svg {
    color: var(--primary);
}

.top-icon-btn:active {
    opacity: 0.7;
}

/* ── LEFT FLOATING BUTTONS ── */
#left-fab {
    position: fixed;
    left: 12px;
    top: calc(var(--top-bar-height) + max(env(safe-area-inset-top, 0px), 12px) + 12px);
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Ensure Leaflet's right-side controls (Locate, Map Layers, Refresh) are pushed below the top bar */
.leaflet-top {
    top: calc(var(--top-bar-height) + env(safe-area-inset-top, 0px) + 4px) !important;
}

.fab-btn {
    width: 52px;
    min-height: 52px;
    background: var(--surface-glass);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transition: transform 0.15s, box-shadow 0.15s;
}

.fab-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.fab-btn span {
    font-size: 9px;
    color: var(--text-muted);
    font-weight: 500;
    text-align: center;
    line-height: 1.1;
}

.fab-btn:active {
    transform: scale(0.94);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* ── BOTTOM NAVIGATION ── */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--surface-glass-heavy);
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: nowrap;
    z-index: 1000;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 4px;
    padding-bottom: 4px;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text-subtle);
    font-size: 10px;
    font-weight: 500;
    position: relative;
    transition: color 0.2s, transform 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.nav-tab svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    transition: stroke 0.2s;
}

.nav-tab:active {
    transform: scale(0.92);
    opacity: 0.8;
}

/* Small devices fix for navigation text */
@media (max-width: 375px) {
    .nav-tab {
        font-size: 9px;
        gap: 2px;
    }
}

@media (max-width: 320px) {
    .nav-tab {
        font-size: 8px;
        gap: 1px;
    }
}

.nav-tab.active {
    color: var(--primary);
}

.nav-tab.active svg {
    stroke: var(--primary);
}

[data-theme="dark"] .nav-tab.active {
    color: #e2e8f0;
}

[data-theme="dark"] .nav-tab.active svg {
    stroke: #e2e8f0;
}

.nav-badge {
    position: absolute;
    top: 6px;
    right: calc(50% - 22px);
    background: var(--danger);
    color: white;
    font-size: 9px;
    font-weight: 700;
    border-radius: 10px;
    padding: 0 5px;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── DEVICE BOTTOM SHEET ── */
.bottom-sheet {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--safe-bottom));
    left: 0;
    right: 0;
    background: var(--surface-glass-heavy);
    border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
    z-index: 800;
    max-height: 60vh;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
}

.bottom-sheet.no-transition {
    transition: none !important;
}

/* Peek state: only header + handle visible (~110px) */
.bottom-sheet.minimized {
    transform: translateY(calc(100% - 110px));
    overflow: hidden;
    min-height: 110px;
}

/* Fully closed: completely hidden below nav */
.bottom-sheet.closed {
    transform: translateY(100%);
}

/* ── iPhone-style Handle Pill ── */
.sheet-handle-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0 4px;
    cursor: grab;
    flex-shrink: 0;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

.sheet-handle-zone:active {
    cursor: grabbing;
}

.sheet-handle {
    width: 36px;
    height: 5px;
    background: rgba(120, 120, 128, 0.3);
    border-radius: 100px;
    flex-shrink: 0;
    pointer-events: none;
}

[data-theme="dark"] .sheet-handle {
    background: rgba(255, 255, 255, 0.2);
}

.sheet-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 6px 16px 8px;
    flex-shrink: 0;
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

.sheet-header:active {
    cursor: grabbing;
}


.sheet-device-name {
    font-size: var(--fs-sub);
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.sheet-device-sub {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.state-pill {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #fee2e2;
    color: #dc2626;
}

.state-pill.awake {
    background: #dcfce7;
    color: #16a34a;
}

.state-pill.sleep {
    background: #f1f5f9;
    color: #64748b;
}

.sheet-device-sn {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.sheet-signal-icons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sig-icon {
    color: var(--primary);
}

.sig-icon svg {
    width: 16px;
    height: 16px;
}

.sig-battery {
    display: flex;
    align-items: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
}

.sig-battery svg {
    width: 18px;
    height: 18px;
}

.sheet-stats {
    padding: 0 16px 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
    overflow-y: auto;
    flex: 1;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1px 0;
    border-bottom: 1px solid var(--border);
}

.stat-row--full {
    grid-column: 1 / -1;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-val {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    text-align: right;
}

.stat-addr {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text);
    text-align: right;
    word-break: break-word;
    white-space: normal;
    line-height: 1.4;
}

[data-theme="light"] .stat-addr {
    color: #1e293b;
}

[data-theme="dark"] .stat-addr {
    color: #f1f5f9;
}

.sheet-actions {
    display: flex;
    gap: 0;
    padding: 8px 4px 12px;
    border-top: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
    justify-content: center;
    -webkit-overflow-scrolling: touch;
}

.sheet-actions::-webkit-scrollbar {
    display: none;
}

.action-btn {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    padding: 2px 4px;
    min-width: 60px;
    min-height: 44px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.15s;
}

.action-btn svg {
    width: 22px;
    height: 22px;
    color: var(--primary);
}

.action-btn:active {
    opacity: 0.7;
}

.action-btn span {
    white-space: nowrap;
}

/* ── TAB VIEWS ── */
.tab-view {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 700;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

/* ── ALARM TAB ── */
.tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(12px + max(env(safe-area-inset-top, 0px), 12px)) 16px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.tab-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.alarm-count-badge {
    background: #fef3c7;
    color: #d97706;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 10px;
}

.tab-header-actions {
    display: flex;
    gap: 4px;
}

.tab-action-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--surface-hover);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-action-btn svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.alarm-item {
    background: var(--surface);
    margin: 6px 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    transition: transform 0.1s, box-shadow 0.1s;
}
[data-theme="dark"] .alarm-item {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.alarm-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.alarm-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.alarm-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    background: rgba(245, 158, 11, 0.1);
}
/* Type-specific icon colors */
.alarm-icon--power { background: rgba(239, 68, 68, 0.1); }
.alarm-icon--speed { background: rgba(245, 158, 11, 0.1); }
.alarm-icon--geofence { background: rgba(16, 185, 129, 0.1); }
.alarm-icon--service { background: rgba(99, 102, 241, 0.1); }
.alarm-icon--offline { background: rgba(100, 116, 139, 0.1); }
.alarm-icon--lowbat { background: rgba(234, 179, 8, 0.1); }
[data-theme="dark"] .alarm-icon { background: rgba(245, 158, 11, 0.15); }
[data-theme="dark"] .alarm-icon--power { background: rgba(239, 68, 68, 0.18); }
[data-theme="dark"] .alarm-icon--speed { background: rgba(245, 158, 11, 0.18); }
[data-theme="dark"] .alarm-icon--geofence { background: rgba(16, 185, 129, 0.18); }
[data-theme="dark"] .alarm-icon--service { background: rgba(99, 102, 241, 0.18); }
[data-theme="dark"] .alarm-icon--offline { background: rgba(100, 116, 139, 0.2); }
[data-theme="dark"] .alarm-icon--lowbat { background: rgba(234, 179, 8, 0.18); }

.alarm-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.alarm-device {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.alarm-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    text-align: right;
    line-height: 1.4;
    flex-shrink: 0;
}
.alarm-time-relative {
    font-size: 0.68rem;
    color: var(--text-subtle);
    margin-top: 1px;
}

/* Location card within alarm */
.alarm-location-card {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
[data-theme="dark"] .alarm-location-card {
    background: rgba(15, 23, 42, 0.5);
    border-color: rgba(51, 65, 85, 0.6);
}

.alarm-location-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    transition: opacity 0.15s;
}
.alarm-location-row:active { opacity: 0.7; }

.alarm-location-pin {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 180, 216, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}
[data-theme="dark"] .alarm-location-pin {
    background: rgba(56, 189, 248, 0.15);
}
.alarm-location-pin svg {
    width: 14px;
    height: 14px;
    color: var(--primary);
}

.alarm-location-info {
    flex: 1;
    min-width: 0;
}

.alarm-addr-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
    word-break: break-word;
}

.alarm-coord-text {
    font-size: 0.7rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--text-muted);
    margin-top: 2px;
    letter-spacing: 0.02em;
}

.alarm-location-arrow {
    color: var(--text-subtle);
    flex-shrink: 0;
    align-self: center;
}
.alarm-location-arrow svg {
    width: 14px;
    height: 14px;
}

.alarm-navigate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    background: var(--primary);
    color: #fff;
    transition: opacity 0.15s, transform 0.1s;
    align-self: flex-end;
    letter-spacing: 0.01em;
}
.alarm-navigate-btn:active {
    opacity: 0.8;
    transform: scale(0.97);
}
.alarm-navigate-btn svg {
    width: 13px;
    height: 13px;
}
[data-theme="dark"] .alarm-navigate-btn {
    background: rgba(56, 189, 248, 0.2);
    color: #7dd3fc;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.alarm-no-location {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--text-subtle);
    font-style: italic;
}
.alarm-no-location svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--text-subtle);
}

.alarm-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ── MINE TAB ── */
.mine-header {
    background: var(--surface);
    position: relative;
    overflow: hidden;
    padding: calc(32px + max(env(safe-area-inset-top, 0px), 12px)) 20px 24px;
    flex-shrink: 0;
}

.mine-bg-decoration {
    position: absolute;
    right: -30px;
    top: -30px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 180, 216, 0.12) 0%, transparent 70%);
}

.mine-profile {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.mine-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(0, 180, 216, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mine-avatar svg {
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.mine-username {
    font-size: var(--fs-sub);
    font-weight: 700;
    color: var(--text);
}

.mine-email {
    font-size: 0.825rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.mine-menu-card {
    background: var(--surface);
    margin: 12px 12px 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.mine-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px 16px;
    background: none;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 500;
    transition: background 0.1s;
}

.mine-menu-item:last-child {
    border: none;
}

.mine-menu-item:active {
    background: var(--surface-hover);
}

.mine-menu-icon {
    width: 34px;
    height: 34px;
    background: rgba(0, 180, 216, 0.08);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mine-menu-icon svg {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

.mine-menu-label {
    flex: 1;
    text-align: left;
}

.mine-menu-arrow {
    width: 16px;
    height: 16px;
    color: #d1d5db;
    flex-shrink: 0;
}

.mine-signout-btn {
    margin: 20px auto;
    display: block;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

/* Custom Calendar (Data Usage) */
.du-cal-date-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.9rem;
    position: relative;
    cursor: default;
    color: var(--text);
    transition: all 0.2s ease;
}

.du-cal-date-cell.no-data {
    opacity: 0.25;
    pointer-events: none;
}

.du-cal-date-cell.has-data {
    opacity: 1;
    cursor: pointer;
}

.du-cal-date-cell.has-data:hover {
    background: var(--primary-glow);
    color: var(--primary);
}

.du-cal-date-cell.has-data:active {
    transform: scale(0.95);
}

.du-cal-date-cell.selected {
    background: var(--primary) !important;
    color: white !important;
    font-weight: 700;
}


/* ── SHEET OVERLAYS ── */
.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.sheet-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Side Sheet (full height, slides from right) */
.side-sheet {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100vw;
    background: var(--surface);
    z-index: 1200;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.side-sheet.active {
    transform: translateX(0);
}

.drawer-btn-secondary,
.drawer-btn-danger {
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

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

.drawer-btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.drawer-btn-secondary:active,
.drawer-btn-danger:active {
    transform: scale(0.96);
    opacity: 0.8;
}

.side-sheet-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    padding-top: calc(12px + var(--safe-top));
    border-bottom: 1px solid var(--border);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    flex-shrink: 0;
    background: var(--surface);
    min-height: 56px;
}

.side-sheet-back {
    width: 44px;
    height: 44px;
    background: var(--surface-hover);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    border: none;
    outline: none;
    touch-action: manipulation;
    transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.side-sheet-back:active {
    transform: scale(0.92);
    opacity: 0.8;
    background: var(--border);
}

.side-sheet-back svg {
    width: 22px;
    height: 22px;
    color: var(--text);
    stroke-width: 2.5;
}

/* Bottom Drawer (slides from bottom) */
.bottom-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
    z-index: 1200;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    padding-bottom: calc(16px + var(--safe-bottom));
}

.bottom-drawer--tall {
    max-height: 90vh;
}

.bottom-drawer.active {
    transform: translateY(0);
}

.drawer-handle {
    width: 36px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 12px auto 0;
    flex-shrink: 0;
}

.drawer-title {
    font-size: var(--fs-title);
    font-weight: 700;
    color: var(--text);
    padding: 14px 20px 0;
    flex-shrink: 0;
}

.drawer-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.drawer-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.drawer-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.drawer-select {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    font-size: 0.875rem;
    color: var(--text);
    -webkit-appearance: none;
    appearance: none;
}

.drawer-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    font-size: 0.875rem;
    color: var(--text);
}

.drawer-btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: opacity 0.15s;
}

.drawer-btn-primary:active {
    opacity: 0.85;
}

.drawer-btn-secondary {
    padding: 12px;
    background: var(--surface-hover);
    color: var(--text);
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.875rem;
}

.drawer-btn-danger {
    padding: 12px;
    background: #fee2e2;
    color: var(--danger);
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.875rem;
    transition: background-color 0.2s, color 0.2s, opacity 0.15s;
}

.drawer-btn-secondary:active,
.drawer-btn-danger:active {
    opacity: 0.8;
}

/* ============================================================
   PWA Desktop Layout Constraint
   Memaksa tampilan agar seperti layar HP ketika dibuka di Desktop/PC
============================================================ */
@media (min-width: 768px) {
    html {
        background-color: #0f172a;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        margin: 0;
        padding: 0;
    }

    body {
        width: 100%;
        max-width: 414px;
        /* Lebar maksimal iPhone Pro Max */
        height: 100dvh;
        max-height: 896px;
        position: relative;
        overflow: hidden;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
        border-radius: 4px;
        background-color: var(--bg);
    }

    /* Pastikan komponen absolut di dalam body tidak keluar/bocor */
    .leaflet-container,
    .top-bar,
    .bottom-nav,
    .side-sheet,
    .bottom-sheet,
    .sheet-overlay {
        position: absolute !important;
    }

    /* Pastikan modal/overlay tidak menutupi seluruh layar desktop */
    .sheet-overlay,
    .modal-overlay {
        position: absolute !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 4px;
    }
}

[data-theme="dark"] .drawer-btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.share-link-box {
    background: #f1f5f9;
    padding: 12px;
    border-radius: 8px;
    word-break: break-all;
    font-family: monospace;
    font-size: 0.85rem;
    color: #0891b2;
    margin-bottom: 16px;
    border: 1px solid #e2e8f0;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    text-align: center;
}

[data-theme="dark"] .share-link-box {
    color: #22d3ee;
    border-color: #334155;
}

.drawer-btn-sm {
    padding: 10px 16px;
    background: var(--primary);
    color: white;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.drawer-btn-sm--success {
    background: var(--success);
}

.drawer-section-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 4px 0 -4px;
}

.drawer-big-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    color: white;
    text-align: left;
}

.drawer-big-btn svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.drawer-btn--danger {
    background: #ef4444;
}

.drawer-btn--success {
    background: #22c55e;
}

/* More Sheet Grid */
.more-device-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
}

.more-device-icon {
    width: 52px;
    height: 52px;
    background: var(--surface-hover);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.more-device-icon svg {
    width: 30px;
    height: 30px;
    color: #475569;
}

.more-device-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

.more-device-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.more-device-type {
    font-size: 0.75rem;
    color: var(--primary);
    margin-top: 1px;
}

.more-info-strip {
    padding: 10px 20px;
    background: var(--surface-hover);
    border-bottom: 1px solid var(--border);
    font-size: 0.775rem;
    color: var(--text-muted);
    line-height: 1.8;
    position: relative;
    z-index: 10;
}

.more-section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    padding: 14px 20px 8px;
    position: relative;
    z-index: 10;
}

.more-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    padding: 0 12px 4px;
    position: relative;
    z-index: 1;
}

.more-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 4px;
    background: none;
    font-size: 0.72rem;
    color: var(--text);
    font-weight: 600;
    text-align: center;
    opacity: 1;
}

[data-theme="dark"] .more-grid-item {
    color: #e2e8f0;
    font-weight: 700;
}

.more-grid-item:active {
    opacity: 0.75;
    transform: scale(0.95);
}

.more-grid-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-hover);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] .more-grid-icon {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.more-grid-icon svg {
    width: 26px;
    height: 26px;
    color: var(--primary);
}

.more-grid-icon--red {
    border: 2px solid rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.3) !important;
    background: rgba(239, 68, 68, 0.05) !important;
}

.more-grid-icon--red svg {
    color: #ef4444 !important;
}

.more-grid-icon--gray {
    border: 2px solid rgba(156, 163, 175, 0.4);
    box-shadow: 0 0 12px rgba(156, 163, 175, 0.3) !important;
    background: rgba(156, 163, 175, 0.05) !important;
}

.more-grid-icon--gray svg {
    color: #9ca3af !important;
}

[data-theme="dark"] .more-grid-icon svg {
    color: var(--text-muted);
    filter: none;
}

[data-theme="dark"] .more-grid-icon--red {
    border: 2px solid rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.4) !important;
    background: rgba(239, 68, 68, 0.1) !important;
}

[data-theme="dark"] .more-grid-icon--red svg {
    color: #f87171 !important;
}

[data-theme="dark"] .more-grid-icon--gray {
    border: 2px solid rgba(156, 163, 175, 0.5);
    box-shadow: 0 0 16px rgba(156, 163, 175, 0.4) !important;
    background: rgba(156, 163, 175, 0.1) !important;
}

[data-theme="dark"] .more-grid-icon--gray svg {
    color: #d1d5db !important;
}

/* Settings List */
.settings-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.settings-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: none;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text);
    transition: background 0.1s;
}

.settings-item:active {
    background: var(--surface-hover);
}

.settings-divider {
    height: 8px;
    background: var(--bg);
}

.settings-signout {
    color: var(--primary);
    margin: 16px auto;
}

/* Detail rows */
.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.detail-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.detail-val {
    font-size: 0.8rem;
    color: var(--text);
    font-weight: 500;
    text-align: right;
}

/* Toggle switches */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--text);
}

.toggle-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #d1d5db;
    border-radius: 24px;
    transition: .3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: .3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

input:checked+.toggle-slider {
    background: var(--primary);
}

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

/* Summary cards */
.summary-card {
    padding: 12px;
    border-radius: 10px;
    text-align: center;
}

.summary-card--blue {
    background: rgba(0, 180, 216, 0.08);
    border: 1px solid rgba(0, 180, 216, 0.15);
}

.summary-card--red {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.summary-card-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 4px;
}

.summary-card-val {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
}

/* Legal content */
.legal-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--text-muted);
}

.legal-content h2 {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 4px;
}

.legal-content h3 {
    font-size: 0.875rem;
    color: var(--text);
    margin: 16px 0 6px;
}

.legal-content p {
    margin-bottom: 8px;
}

.legal-content strong {
    color: var(--text);
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-card {
    background: var(--surface);
    border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
    padding: 24px 20px;
    width: 100%;
    max-width: 480px;
    padding-bottom: calc(24px + var(--safe-bottom));
}

.modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.modal-sub {
    font-size: 0.825rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.modal-input {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
    -webkit-appearance: none;
    appearance: none;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.modal-btn {
    flex: 1;
    padding: 13px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
}

.modal-btn--primary {
    background: var(--primary);
    color: white;
}

.modal-btn--secondary {
    background: var(--surface-hover);
    color: var(--text);
}

.modal-btn--danger {
    background: var(--danger);
    color: white;
}

.modal-btn:active {
    opacity: 0.85;
}


/* Global Loader */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.global-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.loader-icon {
    width: 48px;
    height: 48px;
    color: var(--primary);
    animation: loader-spin 2s linear infinite;
}

.loader-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: 0.5px;
}

.loader-subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
}

@keyframes loader-spin {
    100% {
        transform: rotate(360deg);
    }
}

.alarm-select-cb {
    display: none;
    margin-right: 12px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #ef4444;
}

.alarm-edit-mode .alarm-select-cb {
    display: block;
    animation: slideInCb 0.2s ease-out forwards;
}

@keyframes slideInCb {
    from {
        opacity: 0;
        transform: translateX(-10px) scale(0.8);
    }

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

.alarm-edit-mode .alarm-item {
    padding-left: 8px;
}

/* Blue Dot Animation */
.user-blue-dot-wrapper {
    position: relative;
}

.user-blue-dot {
    width: 14px;
    height: 14px;
    background-color: #007aff;
    border: 2px solid white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

.user-blue-dot-pulse {
    width: 14px;
    height: 14px;
    background-color: #007aff;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    animation: blueDotPulse 2s infinite ease-out;
}

@keyframes blueDotPulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(3.5);
        opacity: 0;
    }
}

@keyframes buttonPulseBlue {
    0% {
        background: rgba(0, 180, 216, 0.1);
        border-color: rgba(0, 180, 216, 0.3);
        box-shadow: 0 0 0 rgba(0, 180, 216, 0);
    }

    50% {
        background: rgba(0, 180, 216, 0.4);
        border-color: rgba(0, 180, 216, 0.8);
        box-shadow: 0 0 12px rgba(0, 180, 216, 0.6);
    }

    100% {
        background: rgba(0, 180, 216, 0.1);
        border-color: rgba(0, 180, 216, 0.3);
        box-shadow: 0 0 0 rgba(0, 180, 216, 0);
    }
}

.pulse-button-blue {
    animation: buttonPulseBlue 2.5s infinite ease-in-out;
}

/* ── Notes Feature ── */
.notes-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border);
}

[data-theme="dark"] .notes-card {
    background: var(--bg);
}

.notes-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

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

.notes-card-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notes-pin {
    font-size: 1.2rem;
}

.notes-card-preview {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notes-card-date {
    font-size: 0.75rem;
    color: var(--text-subtle);
    text-align: right;
}

.note-color-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.note-color-dot.active {
    transform: scale(1.2);
    border-color: var(--text);
}

.notes-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.notes-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* Map Container Dark Background */
[data-theme="dark"] .leaflet-container {
    background: #0f172a !important;
}

/* ── Service Assistant Setup ── */
.setup-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border);
}

.setup-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.setup-section-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.setup-form-group {
    margin-bottom: 12px;
}

.setup-form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-subtle);
    margin-bottom: 4px;
    font-weight: 600;
}

.setup-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
}

.setup-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.setup-input[type="number"]::-webkit-inner-spin-button,
.setup-input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.setup-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.setup-subsection-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.setup-component-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setup-component-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
}

.setup-component-item:hover {
    background: var(--surface-hover);
}

.setup-component-item input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    background-color: var(--bg);
    margin-right: 12px;
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-subtle);
    border-radius: 4px;
    display: inline-grid;
    place-content: center;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.setup-component-item input[type="checkbox"]::before {
    content: "";
    width: 12px;
    height: 12px;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    background-color: #ffffff;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.setup-component-item input[type="checkbox"]:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.setup-component-item input[type="checkbox"]:checked::before {
    transform: scale(1);
}

[data-theme="dark"] .setup-component-item input[type="checkbox"]:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

[data-theme="dark"] .setup-component-item input[type="checkbox"]:checked::before {
    background-color: var(--bg);
}

/* Hide spin buttons for number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.setup-component-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setup-component-name {
    font-weight: 600;
    color: var(--text);
    font-size: 0.95rem;
}

.setup-component-limit {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s, transform 0.1s;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-primary:active {
    opacity: 0.85;
    transform: scale(0.98);
}

.btn-secondary {
    background-color: var(--surface-hover);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s, transform 0.1s;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-secondary:active {
    opacity: 0.85;
    transform: scale(0.98);
}

[data-theme="dark"] .btn-primary,
[data-theme="dark"] .modal-btn--primary {
    background-color: var(--primary);
    color: #0f172a;
    /* high contrast dark text */
}

[data-theme="dark"] .btn-primary:active,
[data-theme="dark"] .modal-btn--primary:active {
    background-color: #7dd3fc;
    /* Tailwind sky-300 for active state */
}

/* ═══════════════════════════════════════════════
   SERVICE ASSISTANT — New UI Components
═══════════════════════════════════════════════ */

/* Service Assistant Empty State */
.sa-empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 280px !important;
    width: auto !important;
    display: inline-block !important;
}

.sa-empty-state-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 280px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: inline-block !important;
}

/* Small devices specific fix */
@media (max-width: 375px) {
    .sa-empty-state-title {
        font-size: 0.95rem;
        max-width: 200px !important;
    }
    .sa-empty-state-subtitle {
        font-size: 0.75rem;
        max-width: 200px !important;
    }
}

@media (max-width: 320px) {
    .sa-empty-state-title {
        font-size: 0.85rem;
        max-width: 180px !important;
    }
    .sa-empty-state-subtitle {
        font-size: 0.7rem;
        max-width: 180px !important;
    }
}

/* Focus Mode (Fullscreen) - Hide UI elements for map focus */
body.focus-mode #top-bar,
body.focus-mode #bottom-nav,
body.focus-mode .bottom-sheet,
body.focus-mode .side-sheet,
body.focus-mode .sheet-overlay,
body.focus-mode #pwa-install-banner {
    display: none !important;
}

/* Hide individual FAB buttons except fullscreen */
body.focus-mode #btn-theme-toggle,
body.focus-mode #btn-recenter,
body.focus-mode #btn-locate {
    display: none !important;
}

body.focus-mode #map {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1 !important;
}

/* In focus mode: hide refresh, keep only locate + layer toggle */
body.focus-mode #map-refresh-control {
    display: none !important;
}

/* Position the leaflet topright container snug to top-right */
body.focus-mode .leaflet-top.leaflet-right {
    top: 0 !important;
    right: 0 !important;
}

/* Locate button: top-bar hidden so reduce margin-top */
body.focus-mode #map-locate-control {
    margin-top: 12px !important;
    margin-right: 12px !important;
}

/* Layer toggle sits right below locate with small gap */
body.focus-mode #map-layer-control {
    margin-top: 8px !important;
    margin-right: 12px !important;
}

/* Show fullscreen button in focus mode as exit button */
body.focus-mode #btn-fullscreen {
    display: flex !important;
    position: fixed !important;
    top: 12px !important;
    left: 12px !important;
    z-index: 9999 !important;
}

/* Odometer Card */
.sa-odometer-card {
    background: var(--surface);
    padding: 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sa-odometer-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.sa-odometer-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.sa-odometer-value span.sa-km {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 2px;
}

.sa-odometer-updated {
    font-size: 0.72rem;
    color: var(--success);
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.sa-odometer-updated::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}

.sa-update-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.sa-update-btn svg {
    width: 14px;
    height: 14px;
}

.sa-update-btn:active {
    opacity: 0.8;
}

[data-theme="dark"] .sa-update-btn {
    color: #0f172a;
}

/* Stats Row */
.sa-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--border);
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

.sa-stat-item {
    background: var(--surface);
    padding: 10px 8px;
    text-align: center;
}

.sa-stat-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sa-stat-val {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

/* Vehicle Info Card */
.sa-vehicle-card {
    background: var(--surface);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.sa-vehicle-info {
    flex: 1;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    min-width: 0;
}

.sa-vehicle-field {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.sa-vehicle-field-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sa-vehicle-field-val {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sa-edit-btn {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    transition: background 0.15s;
}

.sa-edit-btn svg {
    width: 13px;
    height: 13px;
}

.sa-edit-btn:active {
    opacity: 0.7;
}

/* Summary Grid */
.sa-summary-section {
    padding: 12px 16px 8px;
    flex-shrink: 0;
}

.sa-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}

.sa-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.sa-summary-item {
    background: var(--surface);
    border-radius: 12px;
    padding: 12px 8px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.sa-summary-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.sa-summary-icon svg {
    width: 18px;
    height: 18px;
}

.sa-summary-count {
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text);
}

.sa-summary-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-align: center;
}

.sa-summary-bar {
    width: 100%;
    height: 3px;
    border-radius: 2px;
    margin-top: 6px;
}

.sa-summary-item--safe .sa-summary-icon {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
}

.sa-summary-item--safe .sa-summary-bar {
    background: #22c55e;
}

.sa-summary-item--soon .sa-summary-icon {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

.sa-summary-item--soon .sa-summary-bar {
    background: #f59e0b;
}

.sa-summary-item--danger .sa-summary-icon {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.sa-summary-item--danger .sa-summary-bar {
    background: #ef4444;
}

.sa-summary-item--total .sa-summary-icon {
    background: rgba(99, 102, 241, 0.12);
    color: #6366f1;
}

.sa-summary-item--total .sa-summary-bar {
    background: #6366f1;
}

/* Alert Banner */
.sa-alert-banner {
    margin: 0 16px 12px;
    background: rgba(0, 180, 216, 0.08);
    border: 1px solid rgba(0, 180, 216, 0.2);
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.sa-alert-banner:active {
    background: rgba(0, 180, 216, 0.15);
}

.sa-alert-banner.hidden {
    display: none;
}

.sa-alert-icon {
    color: var(--primary);
    flex-shrink: 0;
}

.sa-alert-icon svg {
    width: 18px;
    height: 18px;
}

.sa-alert-text {
    flex: 1;
}

.sa-alert-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary);
}

.sa-alert-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.sa-alert-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
}

.sa-alert-arrow svg {
    width: 14px;
    height: 14px;
}

/* Filter Tabs */
.sa-filter-tabs {
    display: flex;
    gap: 0;
    padding: 0 16px 12px;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
}

.sa-filter-tabs::-webkit-scrollbar {
    display: none;
}

.sa-filter-tab {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.sa-filter-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

[data-theme="dark"] .sa-filter-tab.active {
    color: #0f172a;
}

.sa-filter-tab:not(.active):active {
    background: var(--surface-hover);
}

/* Component Cards */
.sa-component-card {
    background: var(--surface);
    border-radius: 0;
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.sa-component-card:first-child {
    border-top: 1px solid var(--border);
}

.sa-comp-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 22px;
}

.sa-comp-body {
    flex: 1;
    min-width: 0;
}

.sa-comp-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.sa-comp-interval {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.sa-comp-progress-wrap {
    background: var(--surface-hover);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 3px;
}

.sa-comp-progress {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sa-comp-km-text {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.sa-comp-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.sa-status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
}

.sa-status-badge--safe {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

[data-theme="dark"] .sa-status-badge--safe {
    background: rgba(34, 197, 94, 0.18);
    color: #4ade80;
}

.sa-status-badge--soon {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

[data-theme="dark"] .sa-status-badge--soon {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
}

.sa-status-badge--danger {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
    animation: pulseBadge 2s ease-in-out infinite;
}

[data-theme="dark"] .sa-status-badge--danger {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

@keyframes pulseBadge {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.sa-comp-arrow {
    color: var(--text-subtle);
}

.sa-comp-arrow svg {
    width: 14px;
    height: 14px;
}

/* Component Detail Actions */
.sa-mark-done-btn {
    background: none;
    border: 1px solid currentColor;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.sa-mark-done-btn:active {
    opacity: 0.7;
}

/* Header action buttons */
.sa-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sa-header-icon-btn {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.15s;
    flex-shrink: 0;
}

.sa-header-icon-btn svg {
    width: 16px;
    height: 16px;
}

.sa-header-icon-btn:active {
    opacity: 0.7;
}

.sa-history-btn {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
}

.sa-history-btn svg {
    width: 14px;
    height: 14px;
}

.sa-history-btn:active {
    opacity: 0.7;
}