:root {
    --bg-main: #2a2a2a;
    --bg-header: #ffffff;
    --text-primary: #121212;
    --text-secondary: #555555;
    --accent-color: #ff4500;
    --btn-bg: #e0e0e0;
    --btn-border: #cccccc;
    --btn-text: #333333;
    --btn-active: #d0d0d0;
    --status-ok: #008800;
    --map-filter: none;
    --paper-bg: #f8f8f8;
    --paper-line: #d5d5d5;
}

body.dark-mode {
    --bg-main: #0a0a0a;
    --bg-header: #000000;
    --text-primary: #e0e0e0;
    --text-secondary: #aaaaaa;
    --btn-bg: #333333;
    --btn-border: #555555;
    --btn-text: #ffffff;
    --btn-active: #555555;
    --status-ok: #00ff00;
    --map-filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
    --paper-bg: #1e1e1e;
    --paper-line: #333333;
}

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

.navbar { 
    background: var(--bg-header); 
    display: flex; 
    flex-direction: column;
    border-bottom: 3px solid var(--accent-color); 
    z-index: 1000;
    position: relative;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
}

.brand { 
    margin: 0; 
    font-size: 1.4rem; 
    color: var(--accent-color); 
    font-weight: 900;
    letter-spacing: 1px;
}

.btn-compact {
    display: none;
    align-items: center;
    gap: 5px;
    background: #e0e0e0;
    border: 2px solid #ccc;
    padding: 8px 15px;
    font-weight: bold;
    font-size: 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    color: #333;
}
.btn-compact:active { background: #d0d0d0; }

.status { 
    font-size: 0.9rem; 
    color: var(--status-ok); 
    font-family: monospace;
    font-weight: bold;
}
.status.alert { color: #cc0000; }

.gloves-optimized {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 10px;
    background: rgba(0,0,0,0.05);
}

body.dark-mode .gloves-optimized { background: rgba(255,255,255,0.05); }

.btn-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--btn-bg);
    color: var(--btn-text);
    border: 2px solid var(--btn-border);
    padding: 12px 5px;
    font-size: 0.9rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    touch-action: manipulation;
}

.btn-large .material-icons { font-size: 22px; margin-bottom: 4px; }
.btn-large:active { background: var(--btn-active); transform: scale(0.98); }

.btn-sos { background: #cc0000; color: white; border-color: #aa0000; font-size: 1.1rem; }
.btn-sos:active { background: #ff0000; }

main { height: calc(100vh - 110px); position: relative; }

.view-panel {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
}
.view-panel.active { display: block; }

#map { width: 100%; height: 100%; background-color: var(--bg-main); }

body.dark-mode .leaflet-layer,
body.dark-mode .leaflet-control-zoom-in,
body.dark-mode .leaflet-control-zoom-out,
body.dark-mode .leaflet-control-attribution {
    filter: var(--map-filter);
}

.leaflet-routing-container { display: none !important; }

#roadbookView {
    display: none;
    height: 100%;
    background: var(--bg-main);
}
#roadbookView.active { display: block; }

.split-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    height: 100%;
    padding: 15px;
    gap: 15px;
    box-sizing: border-box;
}

.roadbook-pane {
    height: 100%;
    overflow-y: auto;
    background: var(--paper-bg);
    border: 2px solid #dddddd;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    position: relative;
    scroll-behavior: smooth;
}

.roadbook-paper {
    min-height: 100%;
    position: relative;
    padding: 0 45px;
}

.roadbook-paper::before, .roadbook-paper::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    width: 35px;
    background-color: rgba(0,0,0,0.04);
    background-image: radial-gradient(circle, var(--bg-main) 6px, transparent 7px);
    background-size: 35px 35px;
    z-index: 2;
}
.roadbook-paper::before { left: 0; border-right: 2px dashed var(--paper-line); }
.roadbook-paper::after { right: 0; border-left: 2px dashed var(--paper-line); }

.roadbook-empty {
    text-align: center;
    padding: 80px;
    color: var(--text-secondary);
    font-size: 1.2rem;
    font-weight: bold;
}

.rb-item {
    display: grid;
    grid-template-columns: 140px 100px 1fr 100px;
    align-items: center;
    border-bottom: 2px solid var(--paper-line);
    padding: 25px 10px;
    color: var(--text-primary);
    transition: background-color 0.3s ease;
}

.rb-item.active-step {
    background-color: rgba(255, 69, 0, 0.12);
    border-left: 6px solid var(--accent-color);
}

.rb-tulip { text-align: center; display: flex; justify-content: center; align-items: center; }
.rb-tulip .material-icons { font-size: 48px; color: var(--text-primary); }

.speed-sign {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 110px;
    height: 110px;
    border: 24px solid var(--text-primary);
    border-radius: 50%;
    font-size: 5.5rem;
    font-weight: 900;
    box-sizing: border-box;
    line-height: 1;
    padding-top: 4px;
}

.rb-dist { text-align: left; padding-left: 10px; }
.rb-dist .rb-label { font-size: 0.85rem; color: #555555; font-weight: bold; text-transform: uppercase; display: block; }
.rb-dist .rb-val { font-size: 1.8rem; font-weight: 900; display: inline-block; }
.rb-dist .rb-unit { font-size: 1rem; font-weight: bold; display: inline-block; margin-left: 3px; }

.rb-info { font-size: 1.2rem; font-weight: bold; padding-left: 10px; line-height: 1.3; }

.rb-extra { text-align: right; font-size: 0.9rem; font-weight: bold; color: #333; }
.rb-badge {
    display: inline-block;
    background: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
}

.map-pane {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
    border: 3px solid var(--accent-color);
    border-radius: 6px;
    overflow: hidden;
}

.pane-title {
    background: #000;
    color: var(--accent-color);
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 900;
    letter-spacing: 1px;
}

#globalRouteMap {
    flex-grow: 1;
    width: 100%;
}
