:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Header */
.app-header {
    padding: 1.25rem 1.5rem 0.5rem;
}
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}
.version {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    vertical-align: middle;
}
.app-header p {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.github-link {
    color: var(--text-muted);
    transition: color 0.15s;
}
.github-link:hover { color: var(--text); }

/* Wizard step indicators */
.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 1.5rem 1rem;
    max-width: 600px;
    margin: 0 auto;
}
.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
}
.step:not(.completed):not(.active) {
    pointer-events: none;
    opacity: 0.5;
}
.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.step.active .step-number {
    background: var(--primary);
    color: white;
}
.step.completed .step-number {
    background: var(--success);
    color: white;
}
.step.completed:hover .step-number {
    filter: brightness(0.85);
}
.step-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}
.step.active .step-label {
    color: var(--primary);
}
.step.completed .step-label {
    color: var(--success);
}
.step-connector {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 0.25rem;
    min-width: 30px;
    max-width: 60px;
    align-self: flex-start;
    margin-top: 15px;
}

/* Panels */
.wizard-panel {
    display: none;
    max-width: 700px;
    margin: 0 auto;
    padding: 0 1rem 2rem;
}
.wizard-panel.active {
    display: block;
}
.panel-content {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 2rem;
}
.panel-content-full {
    padding: 0;
}
.panel-content h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* Form elements */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
    color: var(--text);
}
.form-group input[type="date"],
.form-group input[type="time"],
.form-group input[type="number"],
.form-group input[type="text"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--surface);
    transition: border-color 0.15s;
}
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}
input[type="range"] {
    width: 100%;
    margin-top: 0.25rem;
}
.range-value {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 0.6rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
    background: var(--border);
    color: var(--text);
}
.btn-secondary:hover { background: #d1d5db; }
.btn-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}
.wizard-nav {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Location search */
.location-section {
    margin-bottom: 1.5rem;
}
.location-section h3 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}
.search-row {
    position: relative;
}
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.search-results.hidden { display: none; }
.search-result-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover {
    background: #eff6ff;
}
.location-coord {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    min-height: 1.2em;
}

/* Map picker */
.map-pick-area {
    margin-top: 1rem;
}
.map-pick-area p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.picker-map {
    height: 250px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* Conditions */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}
.error {
    padding: 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    color: var(--danger);
    margin-top: 1rem;
}
.hidden { display: none !important; }
.conditions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.condition-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.condition-card h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.condition-card .big-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}
.condition-card .detail {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}
.summary-card {
    grid-column: 1 / -1;
}
.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}
.summary-row:last-child { border-bottom: none; }
.summary-row .label { color: var(--text-muted); }

/* Traffic light */
.traffic-light {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}
.traffic-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border);
}
.traffic-dot.active-green { background: var(--success); box-shadow: 0 0 6px var(--success); }
.traffic-dot.active-yellow { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.traffic-dot.active-red { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.traffic-label { font-weight: 600; font-size: 0.9rem; }

/* Chart */
.chart-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    height: 180px;
}
.chart-container h3 {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}
.chart-container canvas {
    max-height: 130px;
}

/* Full map (step 4) */
.map-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    min-height: 500px;
    margin: 0 1rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}
.map-top-bar {
    flex-shrink: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.map-top-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.map-top-row h2 {
    font-size: 1rem;
    margin: 0;
    white-space: nowrap;
}
.map-cards-row {
    display: flex;
    gap: 0.5rem;
}
.map-cards-row .map-summary-card {
    flex: 1;
    min-width: 0;
}
.map-top-nav {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}
.map-legend { display: flex; gap: 0.75rem; font-size: 0.8rem; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 0.3rem; }
.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.legend-dot.start { background: var(--success); }
.legend-dot.end { background: var(--danger); }
.legend-dot.waypoint { background: var(--primary); }
.map-summary-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-size: 0.85rem;
}
.map-summary-card h4 {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}
.map-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.2rem 0;
}
.advice-card {
    border-left: 3px solid var(--success);
}
.advice-card.caution { border-left-color: var(--warning); }
.advice-card.danger { border-left-color: var(--danger); }
.advice-card h4 { margin-bottom: 0.25rem; }
.advice-text { font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; }
.waypoint-hint { text-align: center; padding: 0.5rem; background: rgba(37,99,235,0.08); border-radius: 8px; margin-bottom: 0.5rem; }
.waypoint-hint small { color: #2563eb; }
.full-map {
    flex: 1;
    min-height: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .map-layout {
        height: auto;
    }
    .map-cards-row {
        flex-direction: column;
    }
    .full-map {
        height: 50vh;
    }
}
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.modal.hidden { display: none; }
.modal-content { background: var(--surface); border-radius: var(--radius); width: 90%; max-width: 600px; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 1.1rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }
.modal-tabs { display: flex; border-bottom: 1px solid var(--border); }
.modal-tab { flex: 1; padding: 0.6rem; background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-size: 0.85rem; color: var(--text-muted); }
.modal-tab.active { border-bottom-color: var(--primary); color: var(--primary); font-weight: 600; }
.export-pane { padding: 1rem 1.25rem; flex: 1; overflow: auto; }
.export-pane.hidden { display: none; }
.export-pane textarea { width: 100%; min-height: 300px; font-family: monospace; font-size: 0.8rem; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; resize: vertical; background: var(--bg); color: var(--text); }
.modal-content .btn-primary { margin: 0 1.25rem 1rem; }

@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
    .conditions-grid { grid-template-columns: 1fr; }
    .wizard-steps { gap: 0; }
    .step-label { display: none; }
}
