* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    overflow: hidden;
    height: 100vh;
}

/* Menu Bar */
#menu-bar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    padding: 8px 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.menu-item {
    padding: 6px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.menu-item:hover {
    background-color: #e0e0e0;
}

/* Dropdowns */
.dropdown {
    position: fixed;
    top: 40px;
    left: 0;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    z-index: 1001;
    min-width: 180px;
}

.dropdown.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

#toast-container {
    position: fixed;
    top: 54px;
    right: 16px;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    min-width: 260px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 14px;
    border-radius: 10px;
    color: #1f2937;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.4);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
    font-size: 13px;
    line-height: 1.35;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast-info {
    border-color: rgba(59, 130, 246, 0.45);
    background: linear-gradient(180deg, rgba(239, 246, 255, 0.98), rgba(240, 249, 255, 0.98));
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-warn {
    border-color: rgba(245, 158, 11, 0.55);
    background: linear-gradient(180deg, rgba(255, 251, 235, 0.98), rgba(255, 247, 237, 0.98));
}

.toast-error {
    border-color: rgba(239, 68, 68, 0.55);
    background: linear-gradient(180deg, rgba(254, 242, 242, 0.98), rgba(255, 237, 237, 0.98));
}

.toast-fatal {
    color: #fff;
    border-color: rgba(127, 29, 29, 0.85);
    background: linear-gradient(180deg, rgba(127, 29, 29, 0.98), rgba(69, 10, 10, 0.98));
}

.toast-success {
    border-color: rgba(34, 197, 94, 0.55);
    background: linear-gradient(180deg, rgba(240, 253, 244, 0.98), rgba(236, 253, 245, 0.98));
}

.dropdown-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: #f0f0f0;
}

.dropdown-divider {
    height: 1px;
    background-color: #ddd;
    margin: 4px 0;
}

/* Map */
#map {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Panels */
.panel {
    position: fixed;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    transition: transform 0.3s ease-in-out;
}

.panel.hidden {
    display: none !important;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    background-color: #fafafa;
    border-radius: 8px 8px 0 0;
}

.panel-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 24px;
    height: 24px;
    line-height: 1;
}

.close-btn:hover {
    color: #333;
}

.panel-content {
    padding: 16px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
}

/* Left Panel - Route */
.left-panel {
    top: 50px;
    left: -320px;
    width: 300px;
    max-height: calc(100vh - 60px);
}

.left-panel.open {
    transform: translateX(320px);
}

/* Right Panel - Marker Types */
.right-panel {
    top: 50px;
    right: -320px;
    width: 300px;
    max-height: calc(100vh - 60px);
}

.right-panel.open {
    transform: translateX(-320px);
}

/* Bottom Panel - Statistics */
.bottom-panel {
    bottom: -300px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    max-width: 90vw;
}

.bottom-panel.open {
    transform: translateX(-50%) translateY(-300px);
}

/* Top Panel - Chart */
.top-panel {
    top: auto;
    bottom: 20px;
    left: 20px;
    width: 420px;
    height: 30vh;
    min-height: 220px;
    max-height: 340px;
    max-width: 90vw;
    border-radius: 12px;
    transform: none;
    display: block;
}

.top-panel.open {
    transform: none;
}

.top-panel .panel-content {
    height: calc(100% - 50px);
    display: flex;
    flex-direction: column;
}

/* Directions Panel */
.directions-panel {
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 500px;
    max-width: 90vw;
    max-height: calc(100vh - 60px);
    display: none;
}

.directions-panel.open {
    display: block;
}

/* OSM Inspector */
.osm-inspector-panel {
    right: 20px;
    bottom: 20px;
    width: 390px;
    max-width: 90vw;
    max-height: 55vh;
}

.osm-inspector-panel .panel-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.osm-inspector-empty {
    color: #64748b;
    font-size: 13px;
    line-height: 1.45;
    padding: 12px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
}

.osm-inspector-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: auto;
}

.osm-inspector-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.osm-inspector-title {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}

.osm-inspector-subtitle {
    font-size: 12px;
    color: #64748b;
}

.osm-inspector-section h4 {
    font-size: 13px;
    margin-bottom: 8px;
    color: #334155;
}

.osm-inspector-section p,
.osm-inspector-section li {
    font-size: 12px;
    color: #374151;
    line-height: 1.45;
}

.osm-inspector-section ul {
    padding-left: 18px;
    margin: 0;
}

.osm-inspector-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.osm-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #334155;
    font-size: 11px;
}

.osm-inspector-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.osm-inspector-table th,
.osm-inspector-table td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}

.osm-inspector-table th {
    width: 38%;
    color: #475569;
    font-weight: 600;
}

.osm-inspector-raw {
    margin: 0;
    padding: 10px;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 11px;
    line-height: 1.4;
    overflow: auto;
    max-height: 220px;
}

/* Markers List */
#markers-list {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.marker-insert-slot {
    position: relative;
    height: 10px;
    margin: 0 4px;
    border-radius: 999px;
    transition: height 0.16s ease, margin 0.16s ease, opacity 0.16s ease;
    cursor: pointer;
}

.marker-insert-slot.marker-insert-slot-tail {
    margin-bottom: 0;
}

.marker-insert-slot:hover,
.marker-insert-slot.active {
    height: 32px;
    margin: 2px 4px;
}

.marker-insert-line {
    position: absolute;
    left: 12px;
    right: 12px;
    top: 50%;
    height: 2px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(74, 144, 164, 0.08), rgba(74, 144, 164, 0.65), rgba(74, 144, 164, 0.08));
    opacity: 0;
    transition: opacity 0.16s ease;
}

.marker-insert-button {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 26px;
    height: 26px;
    transform: translate(-50%, -50%) scale(0.85);
    border: 1px solid rgba(74, 144, 164, 0.4);
    border-radius: 50%;
    background: #fff;
    color: #4a90a4;
    font-size: 18px;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    opacity: 0;
    transition: opacity 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.marker-insert-slot:hover .marker-insert-line,
.marker-insert-slot.active .marker-insert-line {
    opacity: 1;
}

.marker-insert-slot:hover .marker-insert-button,
.marker-insert-slot.active .marker-insert-button {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.marker-insert-slot:hover .marker-insert-button {
    box-shadow: 0 4px 12px rgba(74, 144, 164, 0.18);
}

.route-style-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    margin-bottom: 12px;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 4px;
}

.route-style-control label {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.route-style-control input[type="color"] {
    width: 42px;
    height: 30px;
    padding: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
}

.route-style-control input[type="number"] {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    font-size: 13px;
    text-align: right;
}

.route-style-control.stacked {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    gap: 12px;
}

.route-style-control select {
    width: auto;
    min-width: 140px;
    padding: 7px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    font-size: 13px;
}

.route-style-control.stacked select {
    flex: 0 0 auto;
}

.routing-diagnostics {
    padding: 10px;
    margin-bottom: 12px;
    border: 1px solid #f3c46b;
    border-radius: 4px;
    background-color: #fff8e5;
    color: #4f3b11;
    font-size: 12px;
}

.routing-diagnostics strong {
    display: block;
    margin-bottom: 6px;
}

.routing-diagnostics ul {
    margin: 0;
    padding-left: 18px;
}

.marker-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 4px;
    cursor: move;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.2s ease;
}

.marker-item:hover {
    background-color: #f0f0f0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

#markers-list.dragging .marker-item {
    position: relative;
}

.marker-item[draggable="true"] {
    user-select: none;
}

.marker-item .marker-info {
    flex: 1;
}

.marker-item .marker-name {
    font-weight: 500;
    font-size: 14px;
}

.marker-item .marker-type {
    font-size: 12px;
    color: #666;
}

.marker-item .marker-actions {
    display: flex;
    gap: 8px;
}

.marker-item button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    padding: 4px;
}

.marker-item button:hover {
    color: #333;
}

/* Marker Types List */
#marker-types-list {
    margin-bottom: 16px;
}

.marker-type-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 4px;
    margin-bottom: 8px;
}

.marker-type-item .type-info {
    flex: 1;
}

.marker-type-item .type-name {
    font-weight: 500;
    font-size: 14px;
}

.marker-type-item .type-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 10px;
}

.marker-type-item .type-actions {
    display: flex;
    gap: 8px;
}

.marker-type-item button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    padding: 4px;
}

.marker-type-item button:hover {
    color: #333;
}

/* Statistics */
#stats-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-box {
    background-color: #f9f9f9;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid #eee;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

#daily-stats {
    margin-top: 16px;
}

.day-stat {
    background-color: #f9f9f9;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid #eee;
    margin-bottom: 8px;
}

.day-stat h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

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

.day-stat .day-stat-item {
    font-size: 12px;
    color: #666;
}

.day-stat .day-stat-value {
    font-weight: 600;
    color: #333;
}

/* Chart */
#elevation-chart {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin-bottom: 16px;
}

/* Directions */
#directions-list {
    margin-bottom: 16px;
}

.direction-item {
    padding: 12px;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 4px;
    margin-bottom: 8px;
}

.direction-item .direction-text {
    font-size: 14px;
    color: #333;
    margin-bottom: 8px;
}

.direction-item .direction-note {
    font-size: 13px;
    color: #666;
    font-style: italic;
    padding: 8px;
    background-color: #fff;
    border-left: 3px solid #ddd;
    margin-top: 8px;
}

.direction-item .direction-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* Buttons */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn.primary {
    background-color: #4a90a4;
    color: #fff;
}

.btn.primary:hover {
    background-color: #3a7a8e;
}

.btn.secondary {
    background-color: #e0e0e0;
    color: #333;
}

.btn.secondary:hover {
    background-color: #d0d0d0;
}

.btn.danger {
    background-color: #e74c3c;
    color: #fff;
}

.btn.danger:hover {
    background-color: #c0392b;
}

/* Export Page */
.page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff;
    z-index: 2000;
}

.page.hidden {
    display: none;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    border-bottom: 1px solid #ddd;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.page-content {
    padding: 32px;
    max-width: 1200px;
    margin: 0 auto;
}

.export-section {
    margin-bottom: 0;
}

.export-modal-content {
    width: min(760px, calc(100vw - 32px));
}

.export-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.export-section .btn {
    width: 100%;
    justify-content: center;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: #fff;
    padding: 24px;
    border-radius: 8px;
    width: 400px;
    max-width: 90vw;
}

.modal-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #333;
}

.modal-content input,
.modal-content textarea,
.modal-content select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 14px;
}

.modal-content textarea {
    min-height: 100px;
    resize: vertical;
}

.modal-content label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #333;
}

.modal-content > div {
    margin-bottom: 16px;
}

#download-progress {
    margin-top: 16px;
}

#progress-bar {
    width: 100%;
    height: 20px;
}

#progress-text {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: #666;
}

.modal-content .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.settings-modal {
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(4px);
}

.settings-modal-content {
    width: min(860px, calc(100vw - 32px));
    max-height: min(760px, calc(100vh - 48px));
    overflow: auto;
    padding: 0;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.settings-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px 18px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #f8fafc, #eef6f8);
}

.settings-header h3 {
    margin-bottom: 0;
    font-size: 22px;
}

.settings-kicker {
    margin-bottom: 4px;
    color: #4a90a4;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    padding: 20px;
}

.modal-content .settings-grid,
.modal-content .settings-header,
.modal-content .settings-actions {
    margin-bottom: 0;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #ffffff;
}

.settings-section h4 {
    margin: 4px 2px 2px;
    color: #0f172a;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.modal-content .settings-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    min-height: 62px;
    margin-bottom: 0;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #f8fafc;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.modal-content .settings-row:hover {
    border-color: rgba(74, 144, 164, 0.45);
    background: #f1f8fa;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(74, 144, 164, 0.12);
}

.modal-content .settings-row strong {
    display: block;
    color: #111827;
    font-size: 13px;
    line-height: 1.2;
}

.modal-content .settings-row small {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.35;
}

.modal-content .switch-input {
    position: absolute;
    width: 1px;
    height: 1px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #ddd;
}

.modal-body {
    margin-bottom: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid #ddd;
}

.modal-body .form-group {
    margin-bottom: 16px;
}

.modal-body .form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

.modal-body .form-group select,
.modal-body .form-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.modal-body .warning {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 12px;
    margin-top: 16px;
}

.modal-body .warning p {
    margin: 0 0 8px 0;
    color: #856404;
}

.modal-body .warning ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
    color: #856404;
}

.modal-body .warning li {
    margin-bottom: 4px;
}

.modal-content .switch-input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.modal-content .switch {
    position: relative;
    flex-shrink: 0;
    width: 52px;
    height: 30px;
    border-radius: 999px;
    background: #64748b;
    box-shadow: inset 0 1px 4px rgba(15, 23, 42, 0.2);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.modal-content .switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #f1f5f9;
    border: 1px solid rgba(15, 23, 42, 0.15);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.3);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease;
}

.modal-content .switch-input:checked + .switch {
    background: #0d9488;
    box-shadow: inset 0 1px 4px rgba(13, 148, 136, 0.4);
}

.modal-content .switch-input:checked + .switch::after {
    transform: translateX(22px);
    background: #ffffff;
    border-color: rgba(13, 148, 136, 0.3);
}

.modal-content .switch-input:focus-visible + .switch {
    outline: 3px solid rgba(74, 144, 164, 0.35);
    outline-offset: 3px;
}

.settings-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.settings-actions .btn {
    width: 100%;
    justify-content: center;
}

.settings-radio {
    width: 22px;
    height: 22px;
    accent-color: #4a90a4;
    cursor: pointer;
    margin: 0;
}

.settings-select {
    min-width: 220px;
    max-width: 100%;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    font-size: 0.95em;
    cursor: pointer;
}

.settings-info {
    margin: 4px 0 12px;
    padding: 10px 12px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9em;
    color: #334155;
}

.settings-info.warn {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #78350f;
}

.settings-info.ok {
    background: #ecfdf5;
    border-color: #6ee7b7;
    color: #065f46;
}

/* Responsive */
@media (max-width: 768px) {
    #menu-bar {
        max-width: 100vw;
        overflow-x: auto;
    }

    .settings-grid {
        grid-template-columns: 1fr;
        padding: 14px;
    }

    .settings-header {
        padding: 18px 16px 14px;
    }

    .settings-modal-content {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 28px);
    }

    .left-panel,
    .right-panel {
        width: 250px;
    }

    .bottom-panel,
    .top-panel {
        width: 90vw;
    }

    .top-panel {
        height: 32vh;
        min-height: 210px;
    }

    #stats-container {
        grid-template-columns: 1fr;
    }

    .day-stat .day-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Offline Maps Page */
.offline-maps-page {
    padding: 80px 32px 32px;
    max-width: 1200px;
    margin: 0 auto;
}

.offline-maps-page .page-header {
    text-align: center;
    margin-bottom: 40px;
}

.offline-maps-page .page-header h1 {
    font-size: 32px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.offline-maps-page .page-header p {
    font-size: 16px;
    color: #666;
}

.region-selector {
    background-color: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 32px;
}

.selector-level {
    margin-bottom: 16px;
}

.selector-level label {
    display: block;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
}

.selector-level select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background-color: #fff;
}

.map-types-section {
    background-color: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 32px;
}

.map-types-section h2 {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 24px;
}

.map-type-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.map-type-card {
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    transition: box-shadow 0.2s;
}

.map-type-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.map-type-card .card-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.map-type-card h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.map-type-card p {
    font-size: 14px;
    color: #666;
    margin-bottom: 16px;
}

.map-type-card .download-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
}

.map-type-card .size-estimate {
    font-size: 14px;
    font-weight: 600;
    color: #4a90a4;
}

.download-progress-section {
    background-color: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 32px;
}

.download-progress-section h2 {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 24px;
}

.progress-container {
    margin-bottom: 16px;
}

#download-progress-bar {
    width: 100%;
    height: 24px;
    margin-bottom: 8px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #666;
}

.downloaded-maps-section {
    background-color: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.downloaded-maps-section h2 {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 24px;
}

#downloaded-maps-list {
    margin-bottom: 16px;
    min-height: 60px;
}

/* Map Manager Page Styles */
.map-manager-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.page-header {
    margin-bottom: 30px;
    text-align: center;
}

.page-header h1 {
    color: #4a90a4;
    margin-bottom: 10px;
}

.page-header p {
    color: #666;
}

.offline-mode-section {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    text-align: center;
}

.toggle-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    width: 50px;
    height: 26px;
    background: #ccc;
    border-radius: 13px;
    position: relative;
    margin-right: 12px;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.toggle-label input:checked + .toggle-slider {
    background: #4a90a4;
}

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

.toggle-description {
    color: #666;
    font-size: 14px;
}

.region-selection-section,
.download-status-section,
.downloaded-regions-section {
    margin-bottom: 30px;
}

.region-selection-section h2,
.download-status-section h2,
.downloaded-regions-section h2 {
    color: #4a90a4;
    margin-bottom: 15px;
    border-bottom: 2px solid #4a90a4;
    padding-bottom: 8px;
}

.filter-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-controls input,
.filter-controls select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.filter-controls input {
    flex: 1;
}

.regions-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
}

.region-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.region-item:last-child {
    border-bottom: none;
}

.region-info h3 {
    margin: 0 0 5px 0;
    color: #333;
}

.region-path {
    margin: 0;
    color: #666;
    font-size: 13px;
}

.download-btn {
    background: #4a90a4;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.download-btn:hover:not(:disabled) {
    background: #3a7a8e;
}

.download-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.download-status-list {
    max-height: 300px;
    overflow-y: auto;
}

.status-item {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-item.completed {
    background: #e8f5e9;
}

.status-item.error {
    background: #ffebee;
}

.status-info h4 {
    margin: 0 0 5px 0;
    color: #333;
}

.status-stage {
    margin: 0;
    color: #666;
    font-size: 13px;
}

.status-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #4a90a4;
    transition: width 0.3s;
}

.progress-text {
    font-size: 12px;
    color: #666;
    min-width: 40px;
    text-align: right;
}

.downloaded-regions-list {
    max-height: 300px;
    overflow-y: auto;
}

.downloaded-region-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    margin-bottom: 10px;
}

.downloaded-region-item h4 {
    margin: 0;
    color: #333;
}

.delete-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.delete-btn:hover {
    background: #c0392b;
}

.loading,
.error {
    text-align: center;
    padding: 20px;
    color: #666;
}

.error {
    color: #e74c3c;
}
