/*
 * map.boostfit.app — Modern Design System
 * Zero dependencies, system fonts, instant render
 */
:root {
    --bg: #090d14;
    --bg-elevated: #111720;
    --bg-card: #161c28;
    --bg-glass: rgba(17, 23, 32, 0.88);
    --border: #202837;
    --border-light: #2a3348;
    --text: #e2e8f0;
    --text-dim: #64748b;
    --text-muted: #475569;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.25);
    --green: #22c55e;
    --green-glow: rgba(34, 197, 94, 0.2);
    --yellow: #eab308;
    --red: #ef4444;
    --purple: #8b5cf6;
    --orange: #f97316;
    --radius: 10px;
    --radius-sm: 7px;
    --radius-xs: 5px;
    --shadow: 0 2px 8px rgba(0,0,0,0.25);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.45);
    --shadow-glow: 0 0 20px var(--accent-glow);
    --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    height: 100%; background: var(--bg); color: var(--text);
    font-family: var(--font); font-size: 13px; line-height: 1.5;
    -webkit-font-smoothing: antialiased; overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent); color: #fff; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========== Login ========== */
.login-page {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, #1a2744 0%, #090d14 60%);
}
.login-container { width: 100%; max-width: 400px; padding: 24px; }
.login-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; padding: 44px 36px;
    box-shadow: var(--shadow-lg), 0 0 60px rgba(59,130,246,0.06);
    animation: fadeUp 0.4s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.login-icon { text-align: center; margin-bottom: 16px; font-size: 44px; }
.login-title { font-size: 22px; font-weight: 700; color: #fff; margin-bottom: 2px; text-align: center; letter-spacing: -0.4px; }
.login-subtitle { font-size: 13px; color: var(--text-dim); margin-bottom: 28px; text-align: center; }
.login-error {
    background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.25);
    color: var(--red); padding: 10px 16px; border-radius: var(--radius-sm);
    margin-bottom: 18px; font-size: 12px; text-align: center;
}
.login-form label { display: block; font-size: 12px; font-weight: 500; color: var(--text-dim); margin-bottom: 6px; }
.login-form input {
    width: 100%; padding: 11px 14px; background: var(--bg); border: 1px solid var(--border);
    color: var(--text); border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 20px;
    transition: var(--transition); font-family: var(--font);
}
.login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.login-form button {
    width: 100%; padding: 12px; background: var(--accent); color: #fff;
    border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
    cursor: pointer; transition: var(--transition); font-family: var(--font);
}
.login-form button:hover { background: #2563eb; transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }

/* ========== App Shell ========== */
.app-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.app-header {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-glass); border-bottom: 1px solid var(--border);
    padding: 0 18px; height: 50px; gap: 16px; flex-shrink: 0;
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo {
    width: 28px; height: 28px; background: linear-gradient(135deg, var(--accent), var(--purple));
    border-radius: 7px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px;
}
.header-title { font-size: 14px; font-weight: 600; color: #fff; letter-spacing: -0.3px; }
.header-badge {
    background: rgba(59,130,246,0.1); color: var(--accent); padding: 2px 9px;
    border-radius: 8px; font-size: 10px; font-weight: 500; border: 1px solid rgba(59,130,246,0.18);
}
.header-center { flex: 1; display: flex; justify-content: center; }
.stats-bar { display: flex; gap: 22px; align-items: center; }
.stat-item { font-size: 11px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.stat-value { color: #fff; font-weight: 600; font-size: 13px; }
.stat-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.stat-dot.green { background: var(--green); box-shadow: 0 0 6px var(--green-glow); }
.stat-dot.blue { background: var(--accent); box-shadow: 0 0 6px var(--accent-glow); }
.header-right { display: flex; gap: 6px; }

.app-layout { display: flex; flex: 1; overflow: hidden; }

/* ========== Buttons ========== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 7px 14px; border: 1px solid var(--border); background: var(--bg-elevated);
    color: var(--text); border-radius: var(--radius-sm); cursor: pointer;
    font-size: 11px; font-weight: 500; transition: var(--transition); white-space: nowrap;
    font-family: var(--font);
}
.btn:hover { background: var(--bg-card); border-color: var(--border-light); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #2563eb; border-color: #2563eb; box-shadow: var(--shadow-glow); }
.btn-outline { background: transparent; border-color: var(--border); }
.btn-ghost { background: transparent; border: none; color: var(--text-dim); padding: 6px 10px; }
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.btn-sm { padding: 5px 10px; font-size: 11px; border-radius: var(--radius-xs); }
.btn-close {
    background: none; border: none; color: var(--text-dim); font-size: 18px;
    cursor: pointer; width: 28px; height: 28px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center; transition: var(--transition);
}
.btn-close:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.flex-1 { flex: 1; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }

/* ========== Map Panel ========== */
.map-panel { flex: 1; position: relative; min-width: 0; background: var(--bg); }
#map { width: 100%; height: 100%; z-index: 1; }

/* Map floating controls */
.map-ctrls {
    position: absolute; top: 14px; right: 14px; z-index: 1000;
    display: flex; flex-direction: column; gap: 4px;
}
.map-ctrl-btn {
    width: 34px; height: 34px; background: var(--bg-glass); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-dim); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; backdrop-filter: blur(12px); transition: var(--transition);
    box-shadow: var(--shadow);
}
.map-ctrl-btn:hover { background: var(--bg-card); color: var(--text); border-color: var(--border-light); }
.map-ctrl-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--shadow-glow); }

/* Search bar */
.map-search {
    position: absolute; top: 14px; left: 14px; z-index: 1000;
    max-width: 500px; width: calc(100% - 200px);
}
.search-box {
    display: flex; align-items: center; background: var(--bg-glass);
    border: 1px solid var(--border); border-radius: 12px;
    padding: 2px; backdrop-filter: blur(16px); box-shadow: var(--shadow);
    transition: var(--transition);
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-box input {
    flex: 1; background: transparent; border: none; color: var(--text);
    padding: 10px 16px; font-size: 13px; outline: none; font-family: var(--font);
    min-width: 0;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box .s-divider { width: 1px; height: 22px; background: var(--border); }
.search-box select {
    background: transparent; border: none; color: var(--text-dim);
    padding: 8px 10px; font-size: 11px; outline: none; font-family: var(--font);
    cursor: pointer; max-width: 130px; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='4'%3E%3Cpath d='M0 0l4 4 4-4' fill='%2364748b'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center;
    padding-right: 22px;
}
.search-box button {
    background: var(--accent); border: none; color: #fff; padding: 8px 16px;
    border-radius: 10px; font-size: 11px; font-weight: 600; cursor: pointer;
    transition: var(--transition); font-family: var(--font); margin: 2px;
}
.search-box button:hover { background: #2563eb; }

/* Legend overlay */
.map-legend {
    position: absolute; bottom: 56px; right: 14px; z-index: 1000;
    background: var(--bg-glass); border: 1px solid var(--border);
    border-radius: 12px; padding: 14px; backdrop-filter: blur(16px);
    box-shadow: var(--shadow-lg); font-size: 11px; min-width: 180px;
    max-height: 300px; overflow-y: auto; display: none;
}
.map-legend.visible { display: block; }
.map-legend h4 { font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; letter-spacing: 0.8px; }
.legend-item { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; border-radius: 4px; transition: var(--transition); }
.legend-item:hover { background: rgba(255,255,255,0.03); }
.legend-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.legend-count { color: var(--text-muted); font-size: 10px; }

/* Info bar */
.map-info {
    position: absolute; bottom: 12px; left: 14px; right: 14px; z-index: 1000;
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-glass); border: 1px solid var(--border);
    border-radius: 10px; padding: 8px 14px; backdrop-filter: blur(12px);
    box-shadow: var(--shadow); font-size: 11px; color: var(--text-dim);
}
.map-info .coords { font-family: var(--font-mono); font-size: 10px; }
.map-info .badge { background: var(--accent); color: #fff; padding: 2px 10px; border-radius: 7px; font-weight: 600; font-size: 10px; }

/* ========== Sidebar ========== */
.sidebar {
    width: 420px; background: var(--bg-elevated); border-left: 1px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0;
    transition: width 0.25s ease;
}
.sidebar.collapsed { width: 0; border-left: none; }
.sidebar-inner { flex: 1; overflow-y: auto; overflow-x: hidden; }
.sidebar-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
    background: var(--bg-glass); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 5;
}
.sidebar-head h2 { font-size: 13px; font-weight: 600; letter-spacing: -0.2px; }
.sidebar-head .head-actions { display: flex; gap: 4px; }

.panel {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.panel-label {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: 8px; display: flex; align-items: center;
    gap: 8px; letter-spacing: 0.8px;
}
.panel-label .count { margin-left: auto; font-size: 10px; color: var(--text-dim); }

.input-row { display: flex; gap: 8px; }
.input-row input, .input-row select {
    flex: 1; background: var(--bg); border: 1px solid var(--border);
    color: var(--text); border-radius: var(--radius-xs); padding: 8px 12px;
    font-size: 12px; outline: none; transition: var(--transition); font-family: var(--font);
}
.input-row input:focus, .input-row select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.input-row input::placeholder { color: var(--text-muted); }

/* Progress */
.progress-wrap { margin-top: 8px; }
.progress-bar {
    height: 3px; background: var(--bg); border-radius: 2px; overflow: hidden;
}
.progress-fill {
    height: 100%; background: linear-gradient(90deg, var(--accent), var(--purple));
    width: 0%; transition: width 0.4s ease; border-radius: 2px;
}
.progress-text { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* Run list */
.run-list { max-height: 160px; overflow-y: auto; }
.run-item {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.03); font-size: 11px; border-radius: var(--radius-xs);
}
.run-item:hover { background: rgba(255,255,255,0.02); }
.run-status {
    padding: 1px 7px; border-radius: 4px; font-size: 9px; font-weight: 600; text-transform: uppercase; flex-shrink: 0;
}
.run-status.completed { background: rgba(34,197,94,0.12); color: var(--green); }
.run-status.error { background: rgba(239,68,68,0.12); color: var(--red); }
.run-status.running { background: rgba(234,179,8,0.12); color: var(--yellow); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.run-detail { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-time { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }

/* Marker table */
.marker-table-wrap { max-height: 340px; overflow-y: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.marker-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.marker-table thead { position: sticky; top: 0; z-index: 2; }
.marker-table th {
    text-align: left; padding: 7px 10px; background: var(--bg);
    font-weight: 600; font-size: 9px; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.marker-table td { padding: 6px 10px; border-bottom: 1px solid rgba(255,255,255,0.03); font-size: 11px; }
.marker-table tbody tr { transition: var(--transition); }
.marker-table tbody tr:hover { background: rgba(59,130,246,0.04); }
.clickable { cursor: pointer; color: var(--accent); font-weight: 500; }
.clickable:hover { text-decoration: underline; }
.marker-actions { display: flex; gap: 2px; }
.marker-actions button {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 13px; padding: 2px 5px; border-radius: 4px;
}
.marker-actions button:hover { color: var(--text); background: rgba(255,255,255,0.06); }

/* Empty states */
.empty-state { text-align: center; padding: 28px 16px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 28px; margin-bottom: 8px; opacity: 0.5; }
.empty-state p { font-size: 11px; }
.loading-text { color: var(--text-muted); font-size: 11px; padding: 10px; text-align: center; }

/* ========== Modals ========== */
.modal {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(6px);
    display: none; align-items: center; justify-content: center;
}
.modal.show { display: flex; animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.modal-box {
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: 16px; padding: 28px; max-width: 540px; width: 92%;
    max-height: 82vh; overflow-y: auto; position: relative;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5); animation: fadeUp 0.25s ease;
}
.modal-box h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; letter-spacing: -0.2px; }
.modal-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-field .mlabel { font-size: 9px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 2px; }
.modal-field .mvalue { font-size: 13px; color: var(--text); }
.modal-props { margin-top: 16px; }
.modal-props h4 { font-size: 11px; font-weight: 600; margin-bottom: 8px; color: var(--text-dim); }
.props-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.props-table td { padding: 3px 8px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.props-table td:first-child { color: var(--text-muted); width: 130px; }
.modal-actions { margin-top: 18px; display: flex; gap: 8px; }

/* ========== Toasts ========== */
.toasts {
    position: fixed; bottom: 20px; right: 20px; z-index: 99999;
    display: flex; flex-direction: column-reverse; gap: 6px;
}
.toast {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 16px; box-shadow: var(--shadow-lg);
    display: flex; align-items: center; gap: 8px; font-size: 12px;
    animation: slideIn 0.25s ease; max-width: 360px;
}
@keyframes slideIn { from{opacity:0;transform:translateX(30px)} to{opacity:1;transform:translateX(0)} }
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-msg { flex: 1; }

/* ========== Leaflet overrides ========== */
.leaflet-container { background: var(--bg) !important; font-family: var(--font) !important; }
.leaflet-control-attribution { background: var(--bg-glass) !important; color: var(--text-muted) !important; font-size: 9px !important; padding: 2px 6px !important; border-radius: 4px !important; }
.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important; color: var(--text) !important;
    border: 1px solid var(--border) !important; border-radius: 12px !important;
    box-shadow: var(--shadow-lg) !important;
}
.leaflet-popup-tip { background: var(--bg-card) !important; }
.leaflet-popup-close-button { color: var(--text-dim) !important; top: 8px !important; right: 10px !important; }
.leaflet-popup-content { margin: 10px 16px !important; font-size: 12px !important; line-height: 1.5 !important; }
.leaflet-popup-content strong { font-size: 13px; display: block; margin-bottom: 2px; }
.popup-cat {
    display: inline-block; padding: 1px 7px; border-radius: 4px;
    font-size: 10px; font-weight: 600; margin: 4px 0;
}

/* MarkerCluster */
.marker-cluster-small { background: rgba(59,130,246,0.18) !important; }
.marker-cluster-small div { background: var(--accent) !important; color: #fff !important; font-family: var(--font) !important; }
.marker-cluster-medium { background: rgba(59,130,246,0.22) !important; }
.marker-cluster-medium div { background: var(--accent) !important; color: #fff !important; }
.marker-cluster-large { background: rgba(59,130,246,0.28) !important; }
.marker-cluster-large div { background: var(--accent) !important; color: #fff !important; }
.marker-cluster { border-radius: 50% !important; }
.marker-cluster div { border-radius: 50% !important; font-weight: 600 !important; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    .sidebar { width: 100%; max-height: 42vh; border-left: none; border-top: 1px solid var(--border); }
    .sidebar.collapsed { max-height: 0; }
    .map-panel { height: 58vh; flex: none; }
    .header-center { display: none; }
    .map-search { width: calc(100% - 28px); left: 14px; }
    .search-box select { display: none; }
    .search-box .s-divider { display: none; }
    .map-ctrls { top: 50px; right: 8px; }
    .map-legend { bottom: 48px; right: 8px; max-height: 180px; }
}

/* Tooltip */
[data-tip] { position: relative; }
[data-tip]:hover::after {
    content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%;
    transform: translateX(-50%); background: var(--bg-elevated); color: var(--text);
    padding: 4px 10px; border-radius: 6px; font-size: 10px; white-space: nowrap;
    border: 1px solid var(--border); pointer-events: none; z-index: 10000;
}
