@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* === DESIGN TOKENS === */
:root, [data-theme="dark"] {
    --bg: #0f1117;
    --text: #e8eaed;
    --text-muted: rgba(232,234,237,0.65);
    --text-subtle: rgba(232,234,237,0.45);
    --text-ghost: rgba(232,234,237,0.28);
    --surface: #141620;
    --surface-1: #191c28;
    --surface-2: #1e2230;
    --surface-3: #252938;
    --border: rgba(232,234,237,0.08);
    --border-strong: rgba(232,234,237,0.14);
    --main: #3b82f6;
    --main-light: #60a5fa;
    --main-soft: rgba(59,130,246,0.12);
    --glass-blur: 24px;
    --glass-tint: rgba(15,17,23,0.8);
    --glass-border: rgba(232,234,237,0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.16);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.22);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.28);
}

[data-theme="light"] {
    --bg: #f8f9fc;
    --text: #1a1d26;
    --text-muted: rgba(26,29,38,0.65);
    --text-subtle: rgba(26,29,38,0.45);
    --text-ghost: rgba(26,29,38,0.28);
    --surface: #ffffff;
    --surface-1: #f1f3f7;
    --surface-2: #e8ebf0;
    --surface-3: #dde1e8;
    --border: rgba(26,29,38,0.08);
    --border-strong: rgba(26,29,38,0.14);
    --glass-tint: rgba(248,249,252,0.85);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }

/* === APP SHELL === */
.app-shell { display: flex; flex-direction: column; height: 100vh; background: var(--bg); }

/* === TOPBAR === */
.topbar {
    display: flex; align-items: center;
    height: 48px; padding: 0 16px;
    background: var(--glass-tint); backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--border);
    flex-shrink: 0; z-index: 100;
    position: relative; gap: 4px;
}
.topbar-left {
    display: flex; align-items: center; gap: 2px;
    flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none;
}
.topbar-left::-webkit-scrollbar { display: none; }
.topbar-right {
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.topbar::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(59,130,246,0.3), rgba(59,130,246,0.5), rgba(59,130,246,0.3), transparent);
}

/* topbar-left and topbar-right defined above */

.topbar-logo {
    width: 34px; height: 34px; border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--main), var(--main-light));
    display: flex; align-items: center; justify-content: center;
    margin-right: 12px; box-shadow: var(--shadow-sm), 0 0 12px rgba(59,130,246,0.3);
    overflow: hidden;
}
.topbar-logo img { width: 100%; height: 100%; object-fit: contain; }
.logo-text, .logo-glyph { color: white; font-weight: 800; font-size: 16px; }

.topbar-item {
    padding: 6px 16px; height: 34px; border-radius: var(--radius-md);
    font-size: 13px; font-weight: 500; color: var(--text-muted);
    text-decoration: none; display: flex; align-items: center;
    border: 1px solid transparent; transition: all 120ms ease;
    background: transparent; cursor: pointer; font-family: inherit;
    white-space: nowrap; flex-shrink: 0;
}
.topbar-item:hover { color: var(--text); background: var(--surface-1); }
.topbar-item.active {
    color: white; background: linear-gradient(135deg, var(--main), var(--main-light));
    font-weight: 600; border-color: rgba(59,130,246,0.3);
    box-shadow: var(--shadow-sm), 0 0 12px rgba(59,130,246,0.25);
}

.topbar-user { font-size: 13px; color: var(--text-muted); margin-right: 8px; }
.topbar-user-btn {
    display: flex; align-items: center; gap: 6px; background: none; border: none;
    color: var(--text-muted); cursor: pointer; padding: 4px 8px;
    border-radius: var(--radius-md); transition: all 120ms;
}
.topbar-user-btn:hover { background: var(--surface-1); color: var(--text); }
.topbar-user-avatar {
    width: 28px; height: 28px; border-radius: 50%; background: var(--main);
    color: white; font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.topbar-user-name { font-size: 13px; font-weight: 500; }
.topbar-dropdown {
    position: absolute; top: 100%; right: 0; z-index: 500; margin-top: 4px;
    width: 220px; background: var(--glass-tint); backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); padding: 4px 0; overflow: hidden;
}
.topbar-dropdown-header { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.topbar-dropdown-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 14px;
    font-size: 13px; cursor: pointer; color: var(--text-muted);
}
.topbar-dropdown-item i { width: 16px; text-align: center; font-size: 12px; }
.topbar-dropdown-item:hover { background: var(--surface-2); color: var(--text); }
.topbar-dropdown-item.logout:hover { color: #ef4444; }
.topbar-dropdown-sep { height: 1px; background: var(--border); margin: 4px 0; }
.dropdown-backdrop { position: fixed; inset: 0; z-index: 499; }
.topbar-plan {
    font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-full);
    background: var(--main-soft); color: var(--main); letter-spacing: 0.04em;
}
.topbar-btn {
    width: 34px; height: 34px; border-radius: var(--radius-md);
    border: none; background: transparent; color: var(--text-muted);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 120ms ease;
}
.topbar-btn:hover { background: var(--surface-1); color: var(--text); }

/* === MAIN CONTENT === */
.main-content { flex: 1; overflow: hidden; position: relative; }

/* === WIDGET GRID === */
.widget-grid {
    position: relative;
    height: 100%;
    padding: 0;
    --grid-gap: 8px;
    --grid-pad: 8px;
}
.widget-grid-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 150; }

/* === WIDGET FRAME === */
.widget-frame {
    position: absolute;
    background: var(--glass-tint); backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-sm); transition: box-shadow 200ms ease, left 200ms ease, top 200ms ease, width 200ms ease, height 200ms ease;
}
.widget-frame:hover { box-shadow: var(--shadow-md); }

.widget-maximized {
    position: fixed !important; inset: 56px 8px 8px 8px; z-index: 50;
    grid-column: unset !important; grid-row: unset !important;
}

.widget-header {
    display: flex; align-items: center; gap: 6px;
    padding: 2px 8px; height: 20px; flex-shrink: 0;
    background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
    border-bottom: 1px solid var(--border);
    cursor: grab;
}
.widget-header:active { cursor: grabbing; }
.widget-drag-handle { color: var(--text-ghost); font-size: 9px; padding: 0 2px; }
.widget-header .widget-ctrl-btn { cursor: pointer; opacity: 0; transition: opacity 150ms; }
.widget-header:hover .widget-ctrl-btn { opacity: 1; }
.widget-title { font-size: 11px; font-weight: 600; color: var(--text-ghost); flex: 1; }
.widget-header:hover .widget-title { color: var(--text-muted); }
.widget-controls { display: flex; gap: 2px; }
.widget-ctrl-btn {
    width: 26px; height: 26px; border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-ghost); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 11px;
    transition: all 120ms ease;
}
.widget-ctrl-btn:hover { background: var(--surface-2); color: var(--text); }
.widget-close-btn:hover { color: #ef4444; }
.widget-body { flex: 1; overflow: hidden; min-height: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
/* Dropdown portal: rendered outside widget overflow context */
.dropdown-portal {
    position: fixed; z-index: 600;
    background: var(--glass-tint); backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); padding: 6px;
    max-height: 260px; overflow-y: auto;
}
.widget-resize-handle {
    position: absolute; bottom: 0; right: 0; width: 24px; height: 24px;
    cursor: nwse-resize; opacity: 0; transition: opacity 150ms;
    z-index: 99999; pointer-events: all;
}
.widget-resize-handle::after {
    content: ''; position: absolute; bottom: 3px; right: 3px;
    width: 8px; height: 8px; border-right: 2px solid var(--text-ghost);
    border-bottom: 2px solid var(--text-ghost);
}
.widget-frame:hover .widget-resize-handle { opacity: 1; }
.widget-dragging { opacity: 0.6; pointer-events: none; transition: none; user-select: none; }
.widget-grid.is-dragging { user-select: none; cursor: grabbing; }
.widget-grid.is-dragging * { user-select: none; }
.widget-resizing { opacity: 0.8; transition: none; user-select: none; }
.widget-ghost {
    background: var(--main-soft); border: 2px dashed var(--main);
    border-radius: var(--radius-lg); opacity: 0.4;
}

/* === WIDGET FAB === */
.widget-add-fab {
    position: fixed; bottom: 20px; right: 20px; width: 48px; height: 48px;
    border-radius: var(--radius-full); border: none;
    background: linear-gradient(135deg, var(--main), var(--main-light));
    color: white; font-size: 18px; cursor: pointer;
    box-shadow: var(--shadow-lg), 0 0 20px rgba(59,130,246,0.3);
    display: flex; align-items: center; justify-content: center;
    transition: all 150ms ease; z-index: 200;
}
.widget-add-fab:hover { transform: scale(1.08) translateY(-2px); box-shadow: var(--shadow-lg), 0 0 30px rgba(59,130,246,0.4); }

/* === WIDGET DRAWER === */
.widget-drawer-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    z-index: 300; display: flex; justify-content: flex-end;
}
.widget-drawer {
    width: 380px; height: 100%; background: var(--glass-tint); backdrop-filter: blur(var(--glass-blur));
    border-left: 1px solid var(--glass-border); display: flex; flex-direction: column;
    animation: slideIn 250ms cubic-bezier(0.16,1,0.3,1);
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.widget-drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.widget-drawer-header h3 { font-size: 16px; font-weight: 700; }

.widget-drawer-search { padding: 12px 20px; }
.widget-drawer-search input {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-md); background: var(--surface-1); color: var(--text);
    font-size: 13px; outline: none;
}
.widget-drawer-search input:focus { border-color: var(--main); }

.widget-drawer-list { flex: 1; overflow-y: auto; padding: 0 20px 20px; }
.widget-drawer-category h4 {
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text-subtle); padding: 12px 0 8px;
}
.widget-drawer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.widget-drawer-item {
    padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md);
    cursor: pointer; text-align: center; transition: all 120ms ease;
}
.widget-drawer-item:hover { background: var(--surface-1); border-color: var(--main); transform: translateY(-1px); }
.widget-drawer-icon { font-size: 20px; color: var(--main); margin-bottom: 6px; }
.widget-drawer-name { display: block; font-size: 12px; font-weight: 600; }
.widget-drawer-size { display: block; font-size: 10px; color: var(--text-ghost); margin-top: 2px; }

/* === MAP CONTAINER === */
.map-widget-wrapper { position: relative; width: 100%; height: 100%; }
.map-container { width: 100%; height: 100%; min-height: 200px; }

/* === MAP TYPE BAR (top-left) === */
.map-type-bar {
    position: absolute; top: 8px; left: 8px; z-index: 10;
    display: flex; gap: 2px; padding: 3px;
    background: var(--glass-tint); backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}
.map-type-btn {
    width: 30px; height: 30px; border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 12px;
    transition: all 120ms ease;
}
.map-type-btn:hover { background: var(--surface-2); color: var(--text); }
.map-type-btn.active { background: var(--main); color: white; }

/* === MAP TOOLBAR (top-right) === */
.map-toolbar {
    position: absolute; top: 8px; right: 8px; z-index: 10;
    display: flex; gap: 4px; padding: 4px;
    background: var(--glass-tint); backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}
.map-tool-btn {
    width: 30px; height: 30px; border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 12px;
    transition: all 120ms ease;
}
.map-tool-btn:hover { background: var(--surface-2); color: var(--text); }
.map-tool-btn.active { background: var(--main); color: white; }
.map-tool-sep { width: 1px; background: var(--border); margin: 2px 0; }

/* === MAP TREE FILTER === */
.map-tree-filter {
    position: absolute; top: 50px; right: 8px; z-index: 10;
    width: 220px; max-height: 300px; overflow-y: auto;
    background: var(--glass-tint); backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); padding: 4px 0;
}
.map-tree-header { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.map-tree-item {
    display: flex; align-items: center; gap: 4px;
    padding: 5px 10px; cursor: pointer; font-size: 12px;
    transition: background 80ms;
}
.map-tree-item:hover { background: var(--surface-2); }
.map-tree-item.selected { background: var(--main-soft); color: var(--main); }

/* === MAP MARKERS === */
.map-marker { position: relative; cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.map-marker__icon {
    font-size: 20px; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
}
.map-marker__dot {
    width: 14px; height: 14px; border-radius: var(--radius-full);
    background: var(--marker-color, var(--main));
    border: 2px solid white;
    box-shadow: 0 0 8px color-mix(in srgb, var(--marker-color, var(--main)), transparent 40%);
}
.map-marker__label {
    position: absolute; top: -24px; left: 50%; transform: translateX(-50%);
    padding: 2px 8px; border-radius: var(--radius-sm);
    background: var(--surface); border: 1px solid var(--border);
    font-size: 11px; font-weight: 600; white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

/* === LOGIN EXTRAS === */
.login-divider {
    display: flex; align-items: center; gap: 12px; margin: 16px 0;
    color: var(--text-ghost); font-size: 12px;
}
.login-divider::before, .login-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}
.sso-buttons { display: flex; gap: 10px; }
.sso-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--surface-1); color: var(--text); font-size: 13px; font-weight: 500;
    text-decoration: none; cursor: pointer; transition: all 120ms ease;
}
.sso-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.sso-btn-active, .sso-btn-active:hover { border-color: var(--main); background: rgba(59,130,246,0.1); color: var(--main); }
.login-footer { text-align: center; margin-top: 16px; }
.login-link {
    background: none; border: none; color: var(--main); font-size: 13px;
    cursor: pointer; text-decoration: underline;
}
.login-link:hover { opacity: 0.8; }
.login-success {
    padding: 10px 14px; margin-bottom: 16px; border-radius: var(--radius-md);
    background: rgba(0,201,142,0.1); color: #00c98e; font-size: 13px;
    border: 1px solid rgba(0,201,142,0.2);
}

/* === ASSET PANEL === */
.asset-panel { display: flex; flex-direction: column; height: 100%; }

.asset-search-bar {
    display: flex; align-items: center; gap: 8px; padding: 8px;
    border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.asset-search-bar i { color: var(--text-ghost); font-size: 13px; margin-left: 4px; }
.asset-search-bar input {
    flex: 1; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--surface-1); color: var(--text); font-size: 13px; outline: none;
}
.asset-search-bar input:focus { border-color: var(--main); }
.asset-search-bar select {
    padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--surface-1); color: var(--text); font-size: 12px; outline: none;
    max-width: 140px;
}

.asset-list { flex: 1; overflow-y: auto; }

.asset-count {
    padding: 6px 12px; font-size: 11px; color: var(--text-ghost);
    border-top: 1px solid var(--border); text-align: center; flex-shrink: 0;
}

/* === V3 CARD (Asset item) === */
.v3-card {
    position: relative; padding: 10px 12px 10px 18px;
    border-bottom: 1px solid var(--border); cursor: pointer;
    transition: background 120ms ease;
}
.v3-card::before {
    content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px;
    border-radius: var(--radius-full); background: var(--state-color, #6b7280);
    box-shadow: 0 0 6px color-mix(in srgb, var(--state-color, transparent), transparent 50%);
}
.v3-card:hover { background: var(--surface-1); }
.v3-card.selected { background: rgba(59,130,246,0.08); }
.v3-card.selected::before { background: var(--main); box-shadow: 0 0 12px rgba(59,130,246,0.3); }

.v3-card__top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.v3-card__icon {
    width: 28px; height: 28px; border-radius: var(--radius-sm); flex-shrink: 0;
    background: var(--surface-2); display: flex; align-items: center; justify-content: center;
    font-size: 14px;
}
.v3-card__dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
    margin: 0 9px 0 0;
    box-shadow: 0 0 6px color-mix(in srgb, var(--state-color, #3b82f6), transparent 40%);
}
.v3-card__plate {
    font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 4px;
    background: #FAD607; color: #333; border: 1.5px solid #333; letter-spacing: 0.5px;
}
.v3-card__name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.v3-status {
    display: inline-flex; padding: 1px 8px; border-radius: var(--radius-full);
    font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; flex-shrink: 0;
}
.v3-status--moving { background: rgba(0,201,142,0.1); color: #00c98e; }
.v3-status--stopped { background: rgba(239,68,68,0.1); color: #ef4444; }
.v3-status--idle { background: rgba(245,158,11,0.1); color: #f59e0b; }
.v3-status--sleep { background: rgba(59,130,246,0.1); color: #3b82f6; }

.v3-card__time { font-size: 11px; color: var(--text-ghost); margin-left: auto; white-space: nowrap; }
.v3-card__meta { display: flex; gap: 10px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.v3-card__meta span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.v3-card__meta i { font-size: 10px; opacity: 0.7; }
.v3-card__location { font-size: 11px; color: var(--text-subtle); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v3-card { position: relative; }
.v3-card__menu-btn {
    position: absolute; bottom: 6px; right: 6px;
    width: 24px; height: 24px; border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-ghost); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 12px;
    opacity: 0; transition: opacity 120ms;
}
.v3-card:hover .v3-card__menu-btn { opacity: 1; }
.v3-card__menu-btn:hover { background: var(--surface-2); color: var(--text); }

/* === STATUS BAR WIDGET === */
.status-bar-widget {
    display: flex; align-items: center; gap: 20px; padding: 0 16px;
    height: 100%; font-size: 12px; color: var(--text-subtle);
}
.status-bar-widget > div { display: flex; align-items: center; gap: 6px; }
.status-dot { width: 7px; height: 7px; border-radius: var(--radius-full); }
.status-dot.connected { background: #00c98e; box-shadow: 0 0 6px rgba(0,201,142,0.4); animation: pulse 2s infinite; }
.status-dot.disconnected { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,0.4); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.status-credits { margin-left: auto; }

/* === LOGIN PAGE === */
.login-page {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: var(--bg); overflow-y: auto; padding: 40px 0;
}
.login-card {
    width: 400px; padding: 40px; border-radius: var(--radius-xl);
    background: var(--glass-tint); backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border); box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-glyph {
    display: inline-flex; align-items: center; justify-content: center;
    width: 56px; height: 56px; border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--main), var(--main-light));
    color: white; font-weight: 800; font-size: 24px; margin-bottom: 12px;
    box-shadow: 0 0 24px rgba(59,130,246,0.3);
}
.login-logo h1 { font-size: 22px; font-weight: 700; }
.login-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.login-field { margin-bottom: 16px; }
.login-field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.login-field input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--surface-1); color: var(--text); font-size: 14px; outline: none;
    transition: border-color 120ms;
}
.login-field input:focus { border-color: var(--main); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }

.login-error {
    padding: 10px 14px; margin-bottom: 16px; border-radius: var(--radius-md);
    background: rgba(239,68,68,0.1); color: #ef4444; font-size: 13px;
    border: 1px solid rgba(239,68,68,0.2);
}

.login-btn {
    width: 100%; padding: 12px; border: none; border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--main), var(--main-light));
    color: white; font-size: 14px; font-weight: 600; cursor: pointer;
    box-shadow: var(--shadow-sm), 0 0 16px rgba(59,130,246,0.2);
    transition: all 150ms ease;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md), 0 0 24px rgba(59,130,246,0.3); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* === LAYOUT ADD BUTTON === */
.topbar-add-layout { opacity: 0.5; font-size: 12px; }
.topbar-add-layout:hover { opacity: 1; }

/* === LAYOUT MENU === */
.layout-menu-overlay {
    position: fixed; inset: 0; z-index: 200; display: flex; justify-content: center; padding-top: 56px;
    background: rgba(0,0,0,0.3); backdrop-filter: blur(2px);
}
.layout-menu {
    width: 360px; max-height: 400px; overflow-y: auto;
    background: var(--glass-tint); backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); padding: 16px;
    animation: fadeDown 200ms ease;
}
@keyframes fadeDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.layout-menu h4 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.layout-menu-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    border-radius: var(--radius-md); cursor: pointer; transition: all 120ms ease;
    margin-bottom: 4px;
}
.layout-menu-item:hover { background: var(--surface-1); }
.layout-menu-item.pinned { opacity: 0.5; }
.layout-menu-item > i:first-child { font-size: 16px; color: var(--main); width: 24px; text-align: center; }
.layout-menu-name { font-size: 13px; font-weight: 600; }
.layout-menu-desc { font-size: 11px; color: var(--text-subtle); }

/* === LIVE REPORT WIDGETS === */
/* === LIVE REPORT HEADER === */
.lr-header-bar {
    display: flex; align-items: center; gap: 12px; padding: 6px 12px; height: 100%;
}
.lr-picker-btn {
    display: flex; align-items: center; gap: 6px; background: none;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 5px 12px; cursor: pointer; color: var(--text); font-size: 13px; font-weight: 500;
    white-space: nowrap;
}
.lr-picker-btn:hover { background: var(--surface-2); }
.lr-picker-dropdown {
    position: absolute; top: 100%; left: 0; z-index: 600; margin-top: 4px;
    width: 250px; max-height: 260px; overflow-y: auto;
    background: var(--glass-tint); backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); padding: 6px;
}
.lr-picker-option {
    display: flex; align-items: center; gap: 6px; padding: 5px 8px;
    font-size: 12px; cursor: pointer; border-radius: var(--radius-sm);
}
.lr-picker-option:hover { background: var(--surface-2); }
.lr-picker-option.selected { background: var(--main-soft); color: var(--main); }
.lr-date-picker { display: flex; align-items: center; gap: 4px; }
.lr-date-btn {
    width: 26px; height: 26px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-1); color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 10px;
}
.lr-date-btn:hover { background: var(--surface-2); color: var(--text); }
.lr-date-input {
    padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-1); color: var(--text); font-size: 12px;
}

.lr-kpis {
    display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; height: 100%;
    align-content: center;
}
.lr-kpi {
    background: var(--glass-tint); border: 1px solid var(--glass-border);
    border-radius: var(--radius-md); padding: 5px 10px; position: relative; overflow: hidden;
    display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
}
.lr-kpi::before {
    content: ''; position: absolute; inset: 0; border-radius: inherit;
    background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent 50%); pointer-events: none;
}
.lr-kpi__label { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-subtle); white-space: nowrap; }
.lr-kpi__value { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.lr-empty-msg { padding: 20px; text-align: center; color: var(--text-ghost); font-size: 13px; }

/* === TIMELINE WIDGET === */
.lr-timeline-widget { padding: 12px; height: 100%; display: flex; flex-direction: column; justify-content: center; }
.lr-timeline-legend { display: flex; gap: 16px; margin-bottom: 8px; font-size: 12px; color: var(--text-muted); }
.lr-legend-item { display: flex; align-items: center; gap: 6px; }
.lr-legend-dot { width: 10px; height: 10px; border-radius: var(--radius-full); display: inline-block; }
.lr-timeline-bar {
    position: relative; height: 28px; border-radius: var(--radius-md);
    background: var(--surface-2); border: 1px solid var(--border); overflow: hidden;
}
.lr-timeline-seg { position: absolute; top: 0; height: 100%; min-width: 2px; }
.lr-timeline-ticks {
    display: flex; justify-content: space-between; font-size: 11px; color: var(--text-ghost); margin-top: 4px;
}

/* === ALERTS WIDGET === */
.lr-alerts-widget { padding: 8px; overflow-y: auto; height: 100%; }
.lr-alert-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border-radius: var(--radius-md); border: 1px solid var(--border);
    margin-bottom: 6px; cursor: pointer; transition: all 120ms ease;
    position: relative; overflow: hidden;
}
.lr-alert-item::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--alert-color, var(--main));
}
.lr-alert-item:hover { background: var(--surface-1); }
.alert--speed { --alert-color: #ef4444; }
.alert--idle { --alert-color: #f59e0b; }
.alert--drive { --alert-color: #3b82f6; }
.lr-alert-badge {
    font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: var(--radius-full);
    background: var(--surface-2); white-space: nowrap; flex-shrink: 0;
}
.lr-alert-body { flex: 1; min-width: 0; }
.lr-alert-detail { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-alert-time { font-size: 11px; color: var(--text-subtle); }

/* === ONSITE WIDGET === */
.lr-onsite-widget { padding: 8px; overflow-y: auto; height: 100%; }
.lr-onsite-item {
    display: flex; gap: 12px; padding: 10px; position: relative;
}
.lr-onsite-item::before {
    content: ''; position: absolute; left: 20px; top: -8px; bottom: -8px; width: 2px;
    background: repeating-linear-gradient(to bottom, var(--text-ghost) 0px, var(--text-ghost) 6px, transparent 6px, transparent 12px);
}
.lr-onsite-item:first-child::before { top: 16px; }
.lr-onsite-item:last-child::before { bottom: 16px; }
.lr-onsite-pin {
    width: 24px; height: 24px; border-radius: var(--radius-full); flex-shrink: 0;
    background: var(--surface-2); border: 1px solid var(--border); position: relative; z-index: 2;
    display: flex; align-items: center; justify-content: center;
}
.lr-onsite-pin::after {
    content: ''; width: 10px; height: 10px; border-radius: var(--radius-full); background: var(--main);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}
.lr-onsite-body { flex: 1; }
.lr-onsite-name { font-size: 13px; font-weight: 600; }
.lr-onsite-meta { font-size: 12px; color: var(--text-subtle); margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; }

/* === SCORING WIDGET === */
.lr-scoring-widget { padding: 16px; height: 100%; }
.lr-scores { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; justify-content: center; }
.lr-score { text-align: center; }
.lr-score__ring {
    width: 72px; height: 72px; border-radius: var(--radius-full);
    background: conic-gradient(var(--color) calc(var(--score) * 10%), var(--surface-2) 0);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 800; position: relative;
}
.lr-score__ring::before {
    content: ''; position: absolute; inset: 6px; border-radius: var(--radius-full); background: var(--bg);
}
.lr-score__ring span { position: relative; z-index: 1; }
.lr-score__bar { width: 80px; height: 8px; border-radius: var(--radius-full); background: var(--surface-2); overflow: hidden; }
.lr-score__fill {
    height: 100%; border-radius: var(--radius-full);
    width: calc(var(--score) * 10%); background: var(--color);
}
.lr-score__label { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* === JOURNEY WIDGETS === */
.journey-panel { display: flex; flex-direction: column; height: 100%; }

.journey-header {
    padding: 10px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
    display: flex; flex-direction: column; gap: 8px;
}
.journey-device-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; position: relative; }
.journey-device-btn {
    display: flex; align-items: center; gap: 2px; background: none; border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 4px 10px; cursor: pointer;
    color: var(--text); font-size: 13px; font-weight: 600;
}
.journey-device-btn:hover { background: var(--surface-2); }
.journey-device-dropdown {
    position: absolute; top: 100%; left: 0; z-index: 600; margin-top: 4px;
    width: 240px; max-height: 250px; overflow-y: auto;
    background: var(--glass-tint); backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); padding: 6px;
}
.journey-device-option {
    display: flex; align-items: center; gap: 6px; padding: 5px 8px;
    font-size: 12px; cursor: pointer; border-radius: var(--radius-sm);
}
.journey-device-option:hover { background: var(--surface-2); }
.journey-device-option.selected { background: var(--main-soft); color: var(--main); }
.v3-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.journey-date-picker { display: flex; align-items: center; gap: 6px; }
.journey-date-btn {
    width: 28px; height: 28px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-1); color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 11px;
    transition: all 120ms ease;
}
.journey-date-btn:hover { background: var(--surface-2); color: var(--text); }
.journey-date-input {
    flex: 1; padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-1); color: var(--text); font-size: 13px; outline: none;
    font-family: inherit;
}
.journey-date-input:focus { border-color: var(--main); }

.journey-summary {
    display: flex; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.journey-stat { text-align: center; flex: 1; }
.journey-stat-val { display: block; font-size: 16px; font-weight: 700; }
.journey-stat-lbl { font-size: 10px; color: var(--text-subtle); text-transform: uppercase; letter-spacing: 0.04em; }

.journey-list { flex: 1; overflow-y: auto; padding: 4px; }

.journey-item {
    display: flex; gap: 10px; padding: 10px; margin-bottom: 4px;
    border-radius: var(--radius-md); border: 1px solid var(--border);
    cursor: pointer; transition: all 120ms ease; position: relative;
}
.journey-item:hover { background: var(--surface-1); }
.journey-item.selected { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.3); }
.journey-item.private { border-left: 3px solid #8b5cf6; }

.journey-item-times {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    width: 44px; flex-shrink: 0; font-size: 12px; font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.journey-time-start { color: #00c98e; }
.journey-time-end { color: #ef4444; }
.journey-time-line {
    width: 2px; flex: 1; min-height: 16px;
    background: repeating-linear-gradient(to bottom, var(--text-ghost) 0px, var(--text-ghost) 4px, transparent 4px, transparent 8px);
}

.journey-item-body { flex: 1; min-width: 0; }
.journey-item-addr {
    font-size: 12px; display: flex; align-items: center; gap: 6px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-bottom: 2px;
}
.journey-start-addr { color: var(--text); }
.journey-end-addr { color: var(--text-muted); }

.journey-item-stats {
    display: flex; gap: 10px; margin-top: 6px; font-size: 11px; color: var(--text-subtle);
    flex-wrap: wrap;
}
.journey-item-stats span { display: inline-flex; align-items: center; gap: 4px; }
.journey-item-stats i { font-size: 10px; }

.journey-type-badge {
    font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: var(--radius-full);
    text-transform: uppercase; letter-spacing: 0.03em;
}
.journey-type-badge.business { background: rgba(59,130,246,0.1); color: #3b82f6; }
.journey-type-badge.private { background: rgba(139,92,246,0.1); color: #8b5cf6; }

.journey-item-score {
    width: 36px; height: 36px; border-radius: var(--radius-full);
    background: var(--surface-2); border: 2px solid var(--score-color);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; flex-shrink: 0; align-self: center;
}

/* === FENCE WIDGETS === */
.fence-panel, .driver-panel { display: flex; flex-direction: column; height: 100%; }
.fence-header, .driver-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.fence-add-btn {
    padding: 4px 10px; border: 1px solid var(--main); border-radius: var(--radius-sm);
    background: transparent; color: var(--main); font-size: 12px; cursor: pointer;
    transition: all 120ms ease;
}
.fence-add-btn:hover { background: var(--main); color: white; }

.fence-add-form { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.fence-input {
    padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-1); color: var(--text); font-size: 13px; outline: none; width: 100%;
}
.fence-input:focus { border-color: var(--main); }
.fence-add-row { display: flex; gap: 4%; }
.fence-save-btn {
    padding: 8px; border: none; border-radius: var(--radius-sm);
    background: var(--main); color: white; font-size: 13px; font-weight: 600; cursor: pointer;
}
.fence-save-btn:hover { opacity: 0.9; }

.fence-list, .driver-list { flex: 1; overflow-y: auto; padding: 4px; }
.fence-item, .driver-item {
    display: flex; align-items: center; gap: 10px; padding: 10px;
    border-bottom: 1px solid var(--border); transition: background 120ms;
}
.fence-item:hover, .driver-item:hover { background: var(--surface-1); }

.fence-color-dot { width: 12px; height: 12px; border-radius: var(--radius-full); flex-shrink: 0; }
.fence-item-body, .driver-item-body { flex: 1; min-width: 0; }
.fence-item-name, .driver-item-name { font-size: 13px; font-weight: 600; }
.fence-item-meta, .driver-item-meta { font-size: 11px; color: var(--text-subtle); display: flex; gap: 8px; }
.fence-delete-btn {
    width: 28px; height: 28px; border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-ghost); cursor: pointer; font-size: 12px;
    display: flex; align-items: center; justify-content: center;
}
.fence-delete-btn:hover { background: rgba(239,68,68,0.1); color: #ef4444; }

.driver-avatar {
    width: 32px; height: 32px; border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--main), var(--main-light, #60a5fa));
    color: white; font-weight: 700; font-size: 14px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.driver-item-meta i { font-size: 10px; margin-right: 3px; }

/* === SETTINGS WIDGET === */
.settings-panel { padding: 16px; overflow-y: auto; height: 100%; }
.settings-section { margin-bottom: 20px; }
.settings-section-title {
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text-subtle); margin-bottom: 10px; padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.settings-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; font-size: 13px;
}
.settings-label { color: var(--text-muted); }
.settings-value { font-weight: 500; display: flex; align-items: center; gap: 6px; }
.settings-color-swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); }
.plan-badge {
    font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-full);
    background: rgba(59,130,246,0.1); color: var(--main);
}
.settings-perms { display: flex; flex-wrap: wrap; gap: 6px; }
.settings-perm-badge {
    font-size: 11px; padding: 3px 8px; border-radius: var(--radius-full);
    background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}

/* === ALERTS FEED === */
.alerts-feed { padding: 8px; overflow-y: auto; height: 100%; }
.alert-feed-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: var(--radius-sm); margin-bottom: 4px; transition: background 120ms;
}
.alert-feed-item:hover { background: var(--surface-1); }
.alert-feed-icon {
    width: 28px; height: 28px; border-radius: var(--radius-full);
    display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0;
}
.alert-feed-item.speed .alert-feed-icon { background: rgba(239,68,68,0.1); color: #ef4444; }
.alert-feed-item.idle .alert-feed-icon { background: rgba(245,158,11,0.1); color: #f59e0b; }
.alert-feed-item.info .alert-feed-icon { background: rgba(59,130,246,0.1); color: #3b82f6; }
.alert-feed-body { flex: 1; min-width: 0; }
.alert-feed-title { font-size: 13px; font-weight: 500; }
.alert-feed-detail { font-size: 11px; color: var(--text-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-feed-time { font-size: 11px; color: var(--text-ghost); white-space: nowrap; }

/* === DRAG & DROP === */
.widget-dragging { opacity: 0.8; box-shadow: var(--shadow-lg) !important; transition: none !important; cursor: grabbing; }
.widget-ghost {
    border: 2px dashed var(--main); border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--main), transparent 92%); opacity: 0.5;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .topbar-left { overflow-x: auto; scrollbar-width: none; }
    .topbar-left::-webkit-scrollbar { display: none; }
    .topbar-item { font-size: 12px; padding: 4px 10px; }
    .topbar-user-name { display: none; }
}

/* === FLEET EFFICIENCY === */
.fleet-panel { padding: 16px; height: 100%; overflow-y: auto; }
.fleet-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.fleet-card {
    padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--surface-1); transition: all 120ms ease;
}
.fleet-card:hover { background: var(--surface-2); }
.fleet-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.fleet-card-name { font-size: 14px; font-weight: 600; }
.fleet-card-score {
    width: 40px; height: 40px; border-radius: var(--radius-full);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 800; border: 2px solid;
}
.fleet-card-bars { display: flex; flex-direction: column; gap: 6px; }
.fleet-bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.fleet-bar-label { width: 50px; color: var(--text-muted); }
.fleet-bar-track { flex: 1; height: 6px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; }
.fleet-bar-fill { height: 100%; border-radius: var(--radius-full); transition: width 500ms ease; }
.fleet-bar-val { width: 28px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* === COMMANDS === */
.commands-panel { padding: 12px; height: 100%; display: flex; flex-direction: column; }
.commands-device { font-size: 13px; font-weight: 600; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.commands-list { flex: 1; overflow-y: auto; }
.command-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: var(--radius-sm); cursor: pointer; transition: background 120ms;
}
.command-item:hover { background: var(--surface-1); }
.command-icon { width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--main); }
.command-name { font-size: 13px; font-weight: 500; }
.command-desc { font-size: 11px; color: var(--text-subtle); }

/* === SETTINGS TABS === */
.settings-tabs { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.settings-tab {
    padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius-full);
    background: transparent; color: var(--text-muted); font-size: 12px; font-weight: 500; cursor: pointer;
    transition: all 120ms ease;
}
.settings-tab:hover { background: var(--surface-1); color: var(--text); }
.settings-tab.active {
    background: linear-gradient(135deg, var(--main), var(--main-light, #60a5fa));
    color: white; border-color: transparent;
}
.settings-section-header { display: flex; align-items: center; justify-content: space-between; }
.settings-edit-row {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.settings-edit-row label { width: 140px; font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.settings-edit-row input, .settings-edit-row select {
    flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-1); color: var(--text); font-size: 13px; outline: none;
}
.settings-edit-row input:focus, .settings-edit-row select:focus { border-color: var(--main); }
.settings-actions { padding: 12px 0; display: flex; align-items: center; gap: 12px; }
.settings-save-btn {
    padding: 8px 20px; border: none; border-radius: var(--radius-sm);
    background: var(--main); color: white; font-size: 13px; font-weight: 600; cursor: pointer;
}
.settings-save-btn:hover { opacity: 0.9; }
.settings-save-msg { font-size: 12px; color: #00c98e; }
.user-list { margin-top: 8px; }
.fence-cancel-btn {
    padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: transparent; color: var(--text-muted); font-size: 13px; cursor: pointer;
}
.fence-cancel-btn:hover { background: var(--surface-1); }

/* === REPORT WIZARD === */
.report-wizard { padding: 12px; height: 100%; overflow-y: auto; display: flex; flex-direction: column; }
.report-wizard-header { margin-bottom: 10px; }
.report-type-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.report-type-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; transition: all 120ms ease;
}
.report-type-item:hover { background: var(--surface-1); }
.report-type-item.selected { border-color: var(--main); background: rgba(59,130,246,0.05); }
.report-type-icon { font-size: 16px; color: var(--main); width: 24px; text-align: center; }
.report-type-name { font-size: 13px; font-weight: 600; }
.report-type-desc { font-size: 11px; color: var(--text-subtle); }
.report-config { border-top: 1px solid var(--border); padding-top: 10px; }
.report-result { margin-top: 10px; max-height: 200px; overflow: auto; }
.report-result pre {
    font-size: 11px; font-family: 'JetBrains Mono', monospace; color: var(--text-muted);
    background: var(--surface-1); padding: 10px; border-radius: var(--radius-sm);
    white-space: pre-wrap; word-break: break-all;
}

/* === CAMERA WIDGET === */
.camera-panel { height: 100%; display: flex; flex-direction: column; }
.camera-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.camera-device-name { font-size: 13px; font-weight: 600; }
.camera-channels { font-size: 11px; color: var(--text-subtle); }
.camera-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 8px; flex: 1; }
.camera-channel {
    border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden;
    display: flex; flex-direction: column;
}
.camera-placeholder {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: var(--surface-1); color: var(--text-ghost); font-size: 13px; gap: 6px; min-height: 120px;
}
.camera-placeholder i { font-size: 24px; }
.camera-channel-controls {
    display: flex; gap: 4px; padding: 6px; border-top: 1px solid var(--border); justify-content: center;
}
.camera-btn {
    width: 28px; height: 28px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: transparent; color: var(--text-muted); cursor: pointer; font-size: 11px;
    display: flex; align-items: center; justify-content: center;
}
.camera-btn:hover { background: var(--surface-2); color: var(--main); }

/* === TOAST NOTIFICATIONS === */
.toast-container {
    position: fixed; bottom: 16px; right: 16px; z-index: 600;
    display: flex; flex-direction: column; gap: 8px; max-width: 380px;
    pointer-events: none;
}
.toast-item {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
    border-radius: var(--radius-md); border: 1px solid var(--border);
    background: var(--glass-tint); backdrop-filter: blur(var(--glass-blur));
    box-shadow: var(--shadow-lg); min-width: 300px;
    animation: toastSlideIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto; position: relative; overflow: hidden;
}
.toast-item.toast-removing {
    animation: toastSlideOut 250ms ease forwards;
}
.toast-border {
    position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 4px 0 0 4px;
}
.toast-border-success { background: #00c98e; }
.toast-border-error { background: #ef4444; }
.toast-border-warning { background: #f59e0b; }
.toast-border-info { background: #3b82f6; }
@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(60px) scale(0.95); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(60px); }
}
.toast-icon { font-size: 16px; margin-top: 2px; margin-left: 6px; }
.toast-success .toast-icon { color: #00c98e; }
.toast-error .toast-icon { color: #ef4444; }
.toast-warning .toast-icon { color: #f59e0b; }
.toast-info .toast-icon { color: #3b82f6; }
.toast-body { flex: 1; }
.toast-title { font-size: 13px; font-weight: 600; }
.toast-message { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.toast-close {
    background: transparent; border: none; color: var(--text-ghost); cursor: pointer;
    font-size: 11px; padding: 4px; border-radius: var(--radius-sm); transition: all 120ms;
}
.toast-close:hover { color: var(--text); background: var(--surface-2); }

/* === LOADING SPINNER === */
.loading-spinner {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; padding: 32px; width: 100%; height: 100%; min-height: 80px;
}
.loading-dots {
    display: flex; gap: 6px; align-items: center;
}
.loading-dot {
    width: 8px; height: 8px; border-radius: var(--radius-full);
    background: var(--main); animation: loadingPulse 1.4s ease-in-out infinite;
}
.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes loadingPulse {
    0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.1); }
}
.loading-message {
    font-size: 12px; color: var(--text-muted); font-weight: 500;
}

/* === AUDIT LOG === */
.audit-panel { display: flex; flex-direction: column; height: 100%; }
.audit-header {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
    padding: 10px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; gap: 6px;
}
.audit-list { flex: 1; overflow-y: auto; padding: 4px; }
.audit-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: var(--radius-sm); transition: background 120ms;
}
.audit-item:hover { background: var(--surface-1); }
.audit-icon { width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--main); }
.audit-body { flex: 1; }
.audit-action { font-size: 13px; font-weight: 500; }
.audit-detail { font-size: 11px; color: var(--text-subtle); }
.audit-time { font-size: 11px; color: var(--text-ghost); white-space: nowrap; }

/* === ACCOUNT LIST === */
.account-list { margin-top: 8px; }

/* === HEATMAP CONTROLS === */
.heatmap-controls { display: flex; gap: 6px; padding: 8px; align-items: center; height: 100%; flex-wrap: wrap; }

/* === EXPORT PANEL === */
.export-panel { height: 100%; display: flex; flex-direction: column; }

/* === SUBSCRIPTION === */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.plan-card {
    padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--surface-1); transition: all 120ms ease;
}
.plan-card.current { border-color: var(--main); box-shadow: 0 0 12px rgba(59,130,246,0.15); }
.plan-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.plan-price { font-size: 14px; color: var(--main); font-weight: 600; margin-bottom: 10px; }
.plan-features { list-style: none; padding: 0; margin: 0; }
.plan-features li { font-size: 12px; padding: 3px 0; color: var(--text-muted); }
.plan-desc { font-size: 12px; color: var(--text-subtle); }

/* === TACHO === */
.tacho-panel { padding: 12px; height: 100%; overflow-y: auto; }
.tacho-header { margin-bottom: 8px; }
.tacho-device { font-size: 13px; font-weight: 600; padding: 8px 0; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.tacho-actions { display: flex; flex-direction: column; gap: 6px; }
.tacho-driver-hours { margin-top: 8px; }

/* === MOBILE RESPONSIVE === */
@media (max-width: 768px) {
    /* --- Topbar: hamburger-friendly, scrollable tabs --- */
    .topbar { height: 48px; padding: 0 8px; gap: 2px; }
    .topbar-left { gap: 1px; }
    .topbar-item { padding: 6px 10px; font-size: 12px; min-height: 44px; }
    .topbar-user-name { display: none; }
    .topbar-user-btn { padding: 4px; }
    .topbar-btn { width: 44px; height: 44px; }
    .topbar-plan { display: none; }

    /* --- Widget grid: single column stack --- */
    .widget-grid {
        display: flex !important; flex-direction: column; gap: 8px;
        padding: 8px; overflow-y: auto; height: 100%;
    }
    .widget-frame {
        position: relative !important; left: auto !important; top: auto !important;
        width: 100% !important; height: auto !important; min-height: 200px;
        flex-shrink: 0;
    }
    .widget-maximized {
        position: fixed !important; inset: 48px 0 0 0; z-index: 50;
        min-height: unset; border-radius: 0;
    }
    .widget-add-fab { bottom: 12px; right: 12px; width: 48px; height: 48px; font-size: 18px; }

    /* --- Asset table: horizontal scroll, sticky first column --- */
    .asset-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .asset-table-wrap table { min-width: 600px; }
    .asset-table-wrap th:first-child,
    .asset-table-wrap td:first-child {
        position: sticky; left: 0; z-index: 2;
        background: var(--surface);
    }

    /* --- Context menus: full-width bottom sheet --- */
    .context-overlay { display: flex; align-items: flex-end; justify-content: center; }
    .context-menu {
        position: relative !important; left: auto !important; top: auto !important;
        width: 100%; max-width: 100%; min-width: unset;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 8px 8px 24px; /* extra bottom padding for safe area */
        animation: sheetUp 250ms ease;
    }
    @keyframes sheetUp {
        from { opacity: 0; transform: translateY(100%); }
        to { opacity: 1; transform: translateY(0); }
    }
    .context-item { min-height: 44px; padding: 10px 16px; font-size: 14px; }

    /* --- Modals: full-width on mobile --- */
    .modal-panel { width: 100% !important; max-width: 100% !important; max-height: 90vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; margin-top: auto; }
    .modal-overlay { align-items: flex-end; }

    /* --- Toast: bottom centre, full width --- */
    .toast-container { bottom: 60px; right: 8px; left: 8px; max-width: none; }
    .toast-item { min-width: unset; }

    /* --- Typography & touch targets --- */
    body { font-size: 15px; }
    button, a, .context-item, .topbar-item, .topbar-dropdown-item,
    .admin-card, .tree-node, .lr-picker-option {
        min-height: 44px;
    }
    .topbar-dropdown-item { padding: 10px 14px; font-size: 14px; min-height: 44px; display: flex; align-items: center; }
    .topbar-dropdown { width: 260px; }

    /* --- Widget drawer: full-screen on mobile --- */
    .widget-drawer { width: 100% !important; max-width: 100% !important; }

    /* --- Layout menu --- */
    .layout-menu { width: 100%; max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
    .layout-menu-overlay { align-items: flex-end; }
}

/* Tablet-specific adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .topbar-user-name { display: none; }
    .topbar-plan { font-size: 9px; }
    .admin-tree { width: 300px; }
}

/* === ADMIN PANEL === */
.admin-panel { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.admin-section { flex: 1; overflow-y: auto; padding: 8px 12px; }
.admin-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}
.admin-toolbar h3 { font-size: 14px; font-weight: 600; }
.admin-form {
    padding: 12px; margin-bottom: 12px;
    border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--surface-1);
}
.admin-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
@media (max-width: 768px) { .admin-form-grid { grid-template-columns: 1fr; } }
.admin-list { display: flex; flex-direction: column; gap: 6px; }
.admin-card {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--surface); transition: background 120ms;
}
.admin-card:hover { background: var(--surface-1); }
.admin-card-color {
    width: 6px; height: 36px; border-radius: var(--radius-full); flex-shrink: 0;
}
.admin-card-dot {
    width: 10px; height: 10px; border-radius: var(--radius-full); flex-shrink: 0;
}
.admin-card-body { flex: 1; min-width: 0; }
.admin-card-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-card-meta { font-size: 11px; color: var(--text-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* === ADMIN PAGE === */
.admin-page { height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.admin-body { flex: 1; display: flex; overflow: hidden; }

.admin-tree {
    width: 420px; flex-shrink: 0; display: flex; flex-direction: column;
    border-right: 1px solid var(--border); background: var(--surface);
}
.admin-tree-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.admin-tree-header h3 { font-size: 14px; font-weight: 600; }
.admin-tree-list { flex: 1; overflow-y: auto; padding: 4px 0; }

.admin-properties { flex: 1; overflow-y: auto; }
.admin-props-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.admin-props-header h3 { font-size: 18px; font-weight: 700; margin-right: 8px; display: inline; }
.admin-props-body { padding: 12px 20px; overflow-y: auto; flex: 1; }

/* Asset split view: data source list (left) + detail (right) */
.admin-asset-split {
    display: flex; flex: 1; min-height: 0; overflow: hidden;
}
.admin-asset-ds-list {
    width: 200px; flex-shrink: 0; border-right: 1px solid var(--border);
    display: flex; flex-direction: column; overflow-y: auto;
}
.admin-asset-ds-detail {
    flex: 1; display: flex; flex-direction: column; overflow-y: auto;
}
.admin-ds-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px;
    cursor: pointer; border-bottom: 1px solid var(--border); transition: background 80ms;
}
.admin-ds-item:hover { background: var(--surface-1); }
.admin-ds-item.selected { background: var(--main-soft); }

/* Tree nodes */
.tree-node {
    display: flex; align-items: center; gap: 6px; min-height: 32px;
    cursor: pointer; transition: background 100ms; user-select: none;
    padding-right: 8px;
}
.tree-node:hover { background: var(--surface-1); }
.tree-node.selected { background: color-mix(in srgb, var(--main), transparent 88%); }

.tree-node-expand { width: 16px; flex-shrink: 0; text-align: center; color: var(--text-ghost); }
.tree-node-icon { font-size: 13px; flex-shrink: 0; }
.tree-node-label { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.tree-node-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 1; }
.tree-node.drag-over { background: color-mix(in srgb, var(--main), transparent 80%); border-radius: var(--radius-sm); }
.tree-node-meta { display: flex; gap: 6px; font-size: 10px; color: var(--text-ghost); margin-left: auto; flex-shrink: 0; }

/* Tree device nodes */
.tree-device { opacity: 0.8; }
.tree-device:hover { opacity: 1; }
.tree-device-dot {
    width: 8px; height: 8px; border-radius: var(--radius-full); flex-shrink: 0;
    box-shadow: 0 0 4px currentColor;
}

/* Context menu */
.context-overlay { position: fixed; inset: 0; z-index: 400; }
.context-menu {
    position: fixed; z-index: 401; min-width: 200px;
    background: var(--glass-tint); backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); padding: 4px;
    animation: fadeDown 150ms ease;
}
.context-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    border-radius: var(--radius-sm); font-size: 13px; cursor: pointer;
    transition: background 100ms;
}
.context-item:hover { background: var(--surface-1); }
.context-item i { width: 16px; text-align: center; font-size: 12px; color: var(--text-muted); }
.context-item.danger { color: #ef4444; }
.context-item.danger i { color: #ef4444; }
.context-divider { height: 1px; background: var(--border); margin: 4px 8px; }

/* Tree user nodes */
.tree-user { padding-top: 2px; padding-bottom: 2px; }
.tree-user.disabled { opacity: 0.5; }
.tree-user-avatar {
    width: 22px; height: 22px; border-radius: var(--radius-full); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: white; background: var(--main);
}
.tree-user-email { font-size: 10px; color: var(--text-ghost); margin-left: 4px; }
.tree-user-badges { display: flex; gap: 3px; margin-left: auto; flex-shrink: 0; }

/* Tree badges */
.tree-badge {
    font-size: 9px; font-weight: 600; padding: 1px 5px; border-radius: var(--radius-full);
    text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap;
}
.tree-badge.plan { background: rgba(59,130,246,0.1); color: #3b82f6; }
.tree-badge.role { background: var(--surface-2); color: var(--text-muted); }
.tree-badge.code { background: var(--surface-2); color: var(--text-subtle); font-family: monospace; letter-spacing: 1px; }
.tree-badge.pending { background: rgba(245,158,11,0.1); color: #f59e0b; }
.tree-badge.sso { background: rgba(139,92,246,0.1); color: #8b5cf6; }

/* Drag drop zones */
.tree-drop-zone { transition: background 150ms; border-radius: var(--radius-sm); }
.tree-drop-zone.drag-over { background: color-mix(in srgb, var(--main), transparent 85%); }
[draggable="true"] { cursor: grab; }
[draggable="true"]:active { cursor: grabbing; opacity: 0.6; }

/* Invite code display */
.invite-code-display {
    font-family: monospace; font-size: 24px; font-weight: 700; letter-spacing: 4px;
    color: var(--main); padding: 12px; text-align: center;
    background: var(--surface-1); border: 1px dashed var(--border);
    border-radius: var(--radius-md);
}

/* Inheritance badges */
.inherit-badge {
    font-size: 9px; font-weight: 600; padding: 1px 6px; border-radius: var(--radius-full);
    text-transform: uppercase; letter-spacing: 0.03em; margin-left: 6px;
}
.inherit-badge.own { background: rgba(0,201,142,0.1); color: #00c98e; }
.inherit-badge.inherited { background: rgba(59,130,246,0.1); color: #3b82f6; }

@media (max-width: 768px) {
    .admin-body { flex-direction: column; }
    .admin-tree { width: 100%; height: 40%; border-right: none; border-bottom: 1px solid var(--border); }
    .admin-properties { min-height: 60%; }
    .admin-props-header { padding: 12px 14px; }
    .admin-props-body { padding: 10px 14px; }
    .admin-asset-split { flex-direction: column; }
    .admin-asset-ds-list { width: 100%; height: 120px; border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; overflow-x: auto; overflow-y: hidden; }
    .admin-ds-item { white-space: nowrap; border-bottom: none; border-right: 1px solid var(--border); }
}

/* === ASSET TREE SELECTOR === */
.asset-group-bar { padding: 4px 8px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.asset-group-toggle {
    width: 100%; display: flex; align-items: center; gap: 8px;
    padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-1); color: var(--text); font-size: 12px; cursor: pointer;
    font-family: inherit;
}
.asset-group-toggle:hover { background: var(--surface-2); }

.asset-tree-dropdown {
    max-height: 250px; overflow-y: auto; border-bottom: 1px solid var(--border);
    background: var(--surface); padding: 2px 0;
}
.asset-tree-item {
    display: flex; align-items: center; gap: 0; padding: 2px 4px;
    font-size: 12px; transition: background 100ms;
}
.asset-tree-item.selected { background: color-mix(in srgb, var(--main), transparent 88%); }

/* Expand button — big enough to click easily */
.tree-expand-btn {
    width: 24px; height: 24px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border: none; background: transparent; color: var(--text-ghost);
    cursor: pointer; border-radius: var(--radius-sm); font-size: 9px;
}
.tree-expand-btn:hover { background: var(--surface-2); color: var(--text); }
.tree-expand-btn.small { width: 20px; height: 20px; font-size: 8px; }
.tree-expand-spacer { width: 24px; flex-shrink: 0; }
.tree-expand-spacer.small { width: 20px; }

/* Select area — fills remaining space */
.tree-select-area {
    display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0;
    padding: 4px 8px; border-radius: var(--radius-sm); cursor: pointer;
}
.tree-select-area:hover { background: var(--surface-1); }

/* === SEARCH RESULTS DROPDOWN === */
.asset-search-bar { position: relative; }
.asset-search-results {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
    background: var(--glass-tint); backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border); border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-lg); max-height: 200px; overflow-y: auto;
}
.asset-search-item {
    padding: 8px 12px; font-size: 12px; cursor: pointer; transition: background 100ms;
    display: flex; align-items: center;
}
.asset-search-item:hover { background: var(--surface-1); }

/* === MODALS === */
/* === DRAGGABLE DIALOG === */
.dialog-backdrop { position: fixed; inset: 0; z-index: 600; background: rgba(0,0,0,0.3); }
.dialog-window {
    position: fixed; z-index: 601;
    background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; max-height: 85vh;
    animation: dialogIn 200ms ease;
}
.dialog-titlebar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; cursor: grab;
    background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    user-select: none;
}
.dialog-titlebar:active { cursor: grabbing; }
.dialog-title { font-size: 14px; font-weight: 600; }
.dialog-close {
    width: 28px; height: 28px; border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-ghost); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.dialog-close:hover { background: rgba(239,68,68,0.15); color: #ef4444; }

.dialog-tabs-wrap {
    display: flex; align-items: stretch; flex-shrink: 0;
    border-bottom: 1px solid var(--border); background: var(--surface-1);
}
.dialog-tab-arrow {
    width: 24px; flex-shrink: 0; border: none; background: var(--surface-1);
    color: var(--text-ghost); cursor: pointer; display: flex;
    align-items: center; justify-content: center; font-size: 10px;
}
.dialog-tab-arrow:hover { background: var(--surface-2); color: var(--text); }
.dialog-tabs {
    display: flex; gap: 0; overflow-x: auto; flex: 1;
    scrollbar-width: none;
}
.dialog-tabs::-webkit-scrollbar { display: none; }
.dialog-tab {
    padding: 8px 14px; font-size: 12px; font-weight: 500;
    border: none; background: none; color: var(--text-muted);
    cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent;
    transition: all 120ms;
}
.dialog-tab:hover { color: var(--text); background: var(--surface-2); }
.dialog-tab.active { color: var(--main); border-bottom-color: var(--main); }

.dialog-body { flex: 1; overflow-y: auto; padding: 16px; min-height: 0; }
.dialog-resize-handle {
    position: absolute; bottom: 0; right: 0; width: 18px; height: 18px;
    cursor: nwse-resize;
}
.dialog-resize-handle::after {
    content: ''; position: absolute; bottom: 4px; right: 4px;
    width: 10px; height: 10px;
    border-right: 2px solid var(--text-ghost);
    border-bottom: 2px solid var(--text-ghost);
    opacity: 0.5;
}
.dialog-footer {
    display: flex; align-items: center; justify-content: flex-end; gap: 10px;
    padding: 10px 16px; border-top: 1px solid var(--border);
}

/* Tracker Settings fields */
.ts-section { margin-bottom: 20px; }
.ts-section-title { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.ts-field {
    display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.ts-field > label { width: 140px; flex-shrink: 0; font-size: 12px; color: var(--text-muted); text-align: right; }
.ts-field > input, .ts-field > select {
    flex: 1; max-width: 250px; padding: 6px 10px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-1); color: var(--text); font-size: 13px;
}
.ts-field > input:read-only { opacity: 0.6; }
.ts-value { font-size: 13px; }
.ts-hint { font-size: 11px; color: var(--text-ghost); margin-bottom: 10px; }
.ts-empty { font-size: 12px; color: var(--text-ghost); padding: 12px 0; }
.ts-check { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.ts-check input[type="checkbox"] { accent-color: var(--main); }
/* Image upload zone */
.img-upload-zone {
    display: flex; flex-direction: column; gap: 4px;
    padding: 8px; border: 2px dashed var(--border); border-radius: var(--radius-md);
    transition: border-color 150ms, background 150ms;
}
.img-upload-zone:hover { border-color: var(--main); background: var(--main-soft); }
.img-upload-label {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-1); color: var(--text-muted); font-size: 12px;
    cursor: pointer; width: fit-content; transition: all 120ms;
}
.img-upload-label:hover { background: var(--surface-2); color: var(--text); border-color: var(--main); }

/* Masked text input (looks like password but doesn't trigger browser save) */
.masked-input { -webkit-text-security: disc; text-security: disc; }

.ts-lock { color: var(--text-ghost); font-size: 11px !important; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
.ts-inherit-hint {
    font-size: 10px; font-weight: 400; color: var(--text-ghost); margin-left: 8px;
    font-style: italic;
}
.ts-inherit-hint:empty { display: none; }
.ts-io-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.ts-io-row input { padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-1); color: var(--text); font-size: 12px; }
.ts-io-type { width: 70px; flex-shrink: 0; font-weight: 500; color: var(--text-muted); }
.ts-ooh-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ts-ooh-day { width: 80px; flex-shrink: 0; font-size: 12px; font-weight: 500; }
.ts-ooh-row input { padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-1); color: var(--text); font-size: 12px; }
.ts-notes { width: 100%; min-height: 120px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-1); color: var(--text); font-size: 13px; resize: vertical; }
.ts-btn-sm { padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-1); color: var(--text-muted); font-size: 12px; cursor: pointer; }
.ts-btn-sm:hover { background: var(--surface-2); color: var(--text); }
/* Accordion sections */
.ts-acc { margin-bottom: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ts-acc > summary {
    padding: 8px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
    background: var(--surface-1); color: var(--text-muted); list-style: none;
    display: flex; align-items: center; gap: 6px;
}
.ts-acc > summary::-webkit-details-marker { display: none; }
.ts-acc > summary::before { content: '\f054'; font-family: 'Font Awesome 6 Pro','Font Awesome 6 Free'; font-weight: 900; font-size: 9px; transition: transform 150ms; }
.ts-acc[open] > summary::before { transform: rotate(90deg); }
.ts-acc > :not(summary) { padding: 10px 12px; }

/* IO blocks */
.ts-io-block { padding: 10px 0; border-bottom: 1px solid var(--border); }
.ts-io-block:last-child { border-bottom: none; }
.ts-io-heading { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.ts-unit { font-size: 12px; color: var(--text-ghost); white-space: nowrap; }

/* Reminder rows */
/* Icon selector grid */
.ts-icon-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
    gap: 4px; margin-top: 8px;
}
.ts-icon-item {
    width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; font-size: 18px; color: var(--text-muted);
    transition: all 120ms;
}
.ts-icon-item:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.ts-icon-item.selected { background: var(--main-soft); color: var(--main); border-color: var(--main); }
.ts-dot-preview { background: #00c98e; }

/* Apply-to-many tree */
.apply-tree-row {
    display: flex; align-items: center; gap: 2px; padding: 1px 8px;
}
.apply-tree-row.device { padding: 1px 8px; }
.apply-tree-node-check, .apply-tree-device-check {
    display: flex; align-items: center; gap: 4px; flex: 1;
    font-size: 12px; cursor: pointer; padding: 3px 4px;
    border-radius: var(--radius-sm);
}
.apply-tree-node-check:hover, .apply-tree-device-check:hover { background: var(--surface-2); }
.apply-tree-node-check input, .apply-tree-device-check input { accent-color: var(--main); flex-shrink: 0; }
.apply-tree-node-check span:first-of-type { font-weight: 500; }
.apply-tree-device-check span:last-child { color: var(--text-muted); }

.ts-reminder-row {
    display: flex; align-items: center; gap: 8px; padding: 8px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 6px;
}

.ts-btn-save { padding: 7px 20px; border: none; border-radius: var(--radius-sm); background: var(--main); color: white; font-size: 13px; font-weight: 500; cursor: pointer; }
.ts-btn-save:hover { filter: brightness(1.1); }
.ts-save-msg { font-size: 12px; }

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    z-index: 500; display: flex; align-items: center; justify-content: center;
}
.modal-panel {
    width: 500px; max-height: 80vh;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; overflow: hidden;
    animation: dialogIn 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes dialogIn { from { opacity: 0; transform: scale(0.95) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 16px 20px; overflow-y: auto; }

/* === Journey map visualisation icons (shared between Leaflet + Google) === */
.chi-journey-icon { background:none !important; border:none !important; }
.chi-arrow {
    width:20px; height:20px; display:flex; align-items:center; justify-content:center;
    font-size:14px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
.chi-heartbeat {
    width:22px; height:22px; border-radius:50%; background:#ef4444; color:#fff;
    display:flex; align-items:center; justify-content:center; font-size:11px;
    box-shadow:0 2px 5px rgba(0,0,0,0.4); border:2px solid #fff;
}
.chi-flag {
    width:24px; height:24px; display:flex; align-items:center; justify-content:center;
    font-size:18px; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
}
.chi-flag-start { color:#00c98e; }
.chi-flag-end { color:#1f2937; }

/* === Journey classifier (pro/enterprise only) === */
.journey-classify {
    display:flex; gap:4px; margin-top:6px;
}
.jc-btn {
    flex:1; padding:4px 6px; font-size:10px; font-weight:500;
    background:var(--surface-2); color:var(--text-muted);
    border:1px solid var(--border); border-radius:12px; cursor:pointer;
    transition: all 0.15s;
}
.jc-btn:hover { background:var(--surface-3); color:var(--text); }
.jc-btn.active.business { background:#3b82f6; color:#fff; border-color:#3b82f6; }
.jc-btn.active.personal { background:#f59e0b; color:#fff; border-color:#f59e0b; }
.jc-btn.active.unclassified { background:var(--surface-3); color:var(--text); border-color:var(--border-strong); }
.journey-type-badge.unclassified { background:var(--surface-3); color:var(--text-muted); }

/* === Leaflet device marker (the circled icon badge) — global so every caller of chicaneLeaflet.init gets it === */
.leaflet-device-marker { background: none !important; border: none !important; }
.ldm-wrap {
    width: 32px; height: 32px; border-radius: 50%;
    border: 2px solid #3b82f6;
    background: var(--surface-1);
    display: flex; align-items: center; justify-content: center;
    position: relative;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.ldm-icon { z-index: 2; position: relative; }
.ldm-pulse {
    position: absolute; width: 100%; height: 100%;
    border-radius: 50%; opacity: 0;
    display: none;
}
@keyframes ldmPulse {
    0%   { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(2); opacity: 0; }
}
.ldm-pulse { animation: ldmPulse 0.8s ease-out forwards; }

/* === Mobile layout override — single full-viewport widget, no chrome === */
/* Applies at ALL viewports so the mobile layout looks right even on a desktop
   preview. The viewport-aware switcher in Dashboard.razor handles when it's active. */
.widget-grid.layout-mobile {
    display: flex !important;
    flex-direction: column;
    padding: 0 !important;
    gap: 0 !important;
    height: 100% !important;
    overflow: hidden !important;
}
.widget-grid.layout-mobile .widget-frame {
    position: relative !important;
    left: auto !important; top: auto !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    flex: 1 1 auto !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    z-index: auto !important;
}
.widget-grid.layout-mobile .widget-header,
.widget-grid.layout-mobile .widget-resize-handle { display: none !important; }
.widget-grid.layout-mobile .widget-body { border-radius: 0; }
