:root {
    --bg: #0b0f14;
    --panel: #111826;
    --panel2: #0f1520;
    --border: #243042;
    --text: #e8edf5;
    --muted: #9fb0c6;
    --accent: #5aa7ff;
    --route: #ff4b4b;
    --ok: #30d158;
    --err: #ff5a7a;
    --warn: #ffcc66;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    background: rgba(11, 15, 20, 0.92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    object-fit: cover;
    opacity: 0.9;
}

.title {
    font-size: 18px;
    font-weight: 650;
}

.sub {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.atlas-shell {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(0, 700px) minmax(24px, 1fr);
    gap: 20px;
    align-items: stretch;
    min-height: calc(100vh - 81px);
    padding: 12px;
}

.atlas-visual {
    position: relative;
    min-height: calc(100vh - 105px);
    overflow: hidden;
    border-right: 1px solid rgba(255,255,255,0.04);
}

.atlas-animation {
    position: sticky;
    top: 101px;
    display: grid;
    place-items: center;
    height: calc(100vh - 105px);
    min-height: 500px;
    isolation: isolate;
}

.atlas-glow {
    position: absolute;
    width: min(70vh, 440px);
    aspect-ratio: 1;
    border-radius: 999px;
    background:
        radial-gradient(circle, rgba(90,167,255,0.24) 0 18%, rgba(90,167,255,0.08) 42%, transparent 70%),
        radial-gradient(circle at 50% 62%, rgba(48,209,88,0.12), transparent 52%);
    filter: blur(10px);
    opacity: 0.55;
    transform: translateY(-18px);
    z-index: -2;
}

.atlas-orbit {
    position: relative;
    display: grid;
    place-items: center;
    width: min(58vh, 360px);
    aspect-ratio: 1;
}

.atlas-orbit::before,
.atlas-orbit::after {
    content: "";
    position: absolute;
    inset: 10%;
    border: 1px solid rgba(90,167,255,0.22);
    border-top-color: rgba(90,167,255,0.62);
    border-right-color: rgba(90,167,255,0.08);
    border-radius: 999px;
    opacity: 0.38;
    animation: orbitActive 5s linear infinite;
}

.atlas-orbit::after {
    inset: 18%;
    border-color: rgba(48,209,88,0.18);
    border-bottom-color: rgba(48,209,88,0.56);
    border-left-color: rgba(48,209,88,0.06);
    animation-duration: 7s;
    animation-direction: reverse;
}

.atlas-figure {
    width: 34%;
    height: 34%;
    object-fit: contain;
    opacity: 0.5;
    filter: drop-shadow(0 0 24px rgba(90,167,255,0.22));
    animation: atlasBreathe 4s ease-in-out infinite;
}

.route-lines {
    position: absolute;
    width: 58%;
    height: 42%;
    border-left: 4px solid var(--route);
    border-bottom: 4px solid var(--route);
    border-radius: 42% 0 46% 30%;
    transform: rotate(-18deg);
    opacity: 0.72;
    box-shadow: 0 0 18px rgba(255,75,75,0.35);
}

.atlas-node {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 18px rgba(90,167,255,0.75);
    animation: nodeFlash 1.8s ease-in-out infinite;
}

.atlas-node.one {
    top: 24%;
    left: 24%;
}

.atlas-node.two {
    top: 36%;
    right: 20%;
    animation-delay: 0.35s;
}

.atlas-node.three {
    right: 32%;
    bottom: 24%;
    animation-delay: 0.7s;
}

.card,
.report-card,
.chart-panel,
.visual-panel,
.project-hero,
.route-card,
.data-grid article,
#panel-waypoints article,
#panel-planner article {
    background: linear-gradient(180deg, var(--panel), var(--panel2));
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

.card {
    grid-column: 2;
    align-self: start;
    width: min(700px, 100%);
    margin: 4px auto 0;
    padding: 28px;
}

h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
}

p {
    margin: 4px 0 20px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

button,
.actions a,
.menu-link {
    padding: 8px 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text);
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    text-decoration: none;
}

button:hover,
.actions a:hover,
.menu-link:hover {
    border-color: rgba(90,167,255,0.5);
}

input {
    width: min(220px, 100%);
    padding: 9px 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text);
    border-radius: 10px;
    outline: none;
}

select {
    width: min(320px, 100%);
    padding: 9px 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text);
    border-radius: 10px;
    outline: none;
}

select option {
    color: #111;
}

input:focus {
    border-color: rgba(90,167,255,0.6);
}

.dropzone {
    display: grid;
    place-items: center;
    min-height: 190px;
    margin-top: 20px;
    padding: 40px 18px;
    background: rgba(255,255,255,0.03);
    border: 2px dashed var(--border);
    border-radius: 12px;
    color: var(--muted);
    text-align: center;
    cursor: pointer;
}

.file-input {
    display: block;
    width: min(320px, 100%);
    margin-top: 16px;
}

.upload-actions,
.actions,
.planner-controls,
.section-title,
.report-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.menu-button {
    width: 42px;
    height: 38px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
}

.settings-menu {
    position: fixed;
    top: 64px;
    right: 14px;
    z-index: 1200;
    display: none;
    width: min(380px, calc(100vw - 28px));
    max-height: calc(100vh - 82px);
    overflow: auto;
    padding: 16px;
    background: linear-gradient(180deg, var(--panel), var(--panel2));
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 16px 36px rgba(0,0,0,0.42);
}

.settings-menu.is-open {
    display: grid;
    gap: 18px;
}

.settings-menu.nav-menu {
    width: min(300px, calc(100vw - 28px));
}

.settings-menu.nav-menu.is-open {
    gap: 12px;
}

.nav-menu nav {
    display: grid;
    gap: 8px;
}

.nav-menu .menu-link {
    display: block;
}

.menu-link.is-active {
    color: var(--text);
    border-color: rgba(90,167,255,0.5);
    background: rgba(90,167,255,0.16);
}

.progress-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
    place-items: center;
    padding: 18px;
    background: rgba(4, 7, 11, 0.76);
    backdrop-filter: blur(7px);
}

.progress-overlay.is-visible {
    display: grid;
}

.progress-card {
    width: min(480px, 100%);
    padding: 20px;
    background: linear-gradient(180deg, var(--panel), var(--panel2));
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 42px rgba(0,0,0,0.46);
}

.progress-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
}

.progress-head p {
    margin-bottom: 0;
}

.progress-elapsed {
    min-height: 16px;
    margin-top: 6px;
}

.progress-head strong {
    color: var(--accent);
    font-size: 22px;
    font-variant-numeric: tabular-nums;
}

.progress-track {
    height: 9px;
    margin: 18px 0;
    overflow: hidden;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 999px;
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--ok));
    border-radius: inherit;
    transition: width 0.45s ease;
}

.progress-overlay.is-waiting .progress-track span {
    background:
        linear-gradient(90deg, transparent, rgba(255,255,255,0.34), transparent),
        linear-gradient(90deg, var(--accent), var(--ok));
    background-size: 80px 100%, 100% 100%;
    animation: progressWaiting 1.1s linear infinite;
}

.progress-steps {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.progress-steps li {
    position: relative;
    padding: 8px 10px 8px 30px;
    color: var(--muted);
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    font-size: 12px;
}

.progress-steps li::before {
    content: "";
    position: absolute;
    left: 10px;
    top: 50%;
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: rgba(255,255,255,0.18);
    transform: translateY(-50%);
}

.progress-steps li.is-active {
    color: var(--text);
    border-color: rgba(90,167,255,0.45);
}

.progress-steps li.is-active::before {
    background: var(--accent);
    box-shadow: 0 0 14px rgba(90,167,255,0.72);
}

.progress-steps li.is-done {
    color: rgba(232,237,245,0.72);
}

.progress-steps li.is-done::before {
    background: var(--ok);
}

.progress-close {
    display: none;
    width: 100%;
    margin-top: 14px;
}

.progress-close.is-visible {
    display: block;
}

.settings-menu section {
    display: grid;
    gap: 10px;
}

.form-stack {
    display: grid;
    gap: 10px;
}

.form-stack button,
.form-stack .menu-link {
    width: 100%;
    text-align: center;
}

.form-stack label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
}

.menu-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.app-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 12px;
    min-height: calc(100vh - 65px);
    padding: 12px;
}

.project-sidebar {
    position: sticky;
    top: 77px;
    align-self: start;
    height: calc(100vh - 89px);
    overflow: auto;
    padding: 16px;
    background: linear-gradient(180deg, var(--panel), var(--panel2));
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

.sidebar-section + .sidebar-section {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.sidebar-head span {
    color: var(--muted);
    font-size: 12px;
}

.tree {
    display: grid;
    gap: 10px;
}

.tree details {
    padding: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
}

.tree summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 650;
}

.tree a,
.tree-empty {
    display: block;
    margin: 8px 0 0 18px;
    padding: 7px 9px;
    color: var(--muted);
    border-radius: 8px;
    font-size: 12px;
    text-decoration: none;
}

.tree summary .project-link {
    display: inline-flex;
    margin: 0;
    padding: 4px 6px;
    color: var(--text);
}

.tree a:hover,
.tree a.is-active {
    color: var(--text);
    background: rgba(90,167,255,0.16);
}

.workspace {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(0, 700px) minmax(24px, 1fr);
    gap: 20px;
}

.project-workspace {
    display: grid;
    gap: 14px;
    align-self: start;
}

.project-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px;
}

.project-hero p,
.route-card p {
    margin-bottom: 0;
}

.project-route-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.route-card {
    display: grid;
    gap: 16px;
    padding: 18px;
}

.route-card-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
}

.route-card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.route-card-actions form {
    margin: 0;
}

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--text);
    line-height: 1;
    text-decoration: none;
}

.route-card-icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-button-danger {
    color: var(--err);
}

.danger-button {
    color: var(--err);
}

.route-edit-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(150px, 190px) auto;
    gap: 8px;
    align-items: end;
}

.route-edit-form label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 11px;
}

.route-edit-form input {
    width: 100%;
}

.route-edit-form[hidden] {
    display: none;
}

.report-edit-form {
    margin: 12px 0 4px;
}

.route-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.route-metrics span {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
}

.route-metrics small {
    color: var(--muted);
    font-size: 11px;
}

.route-metrics strong {
    font-size: 13px;
}

.project-upload-card {
    grid-column: auto;
    width: 100%;
    margin: 0;
}

.tool-card {
    grid-column: auto;
    width: min(760px, 100%);
    margin: 0;
}

.tool-overview-grid .route-card {
    min-height: 112px;
}

.combine-preview-card {
    width: 100%;
}

.combine-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 16px 0;
}

.combine-summary article {
    display: grid;
    gap: 5px;
    padding: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
}

.combine-summary span {
    color: var(--muted);
    font-size: 11px;
}

.combine-summary strong {
    font-size: 14px;
}

.raspberry-progress {
    height: 10px;
    overflow: hidden;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 999px;
}

.raspberry-progress div {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--ok));
    border-radius: inherit;
    transition: width 0.25s ease;
}

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

.status-chip {
    padding: 5px 9px;
    color: var(--muted);
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.status-chip[data-status="running"],
.status-chip[data-status="queued"] {
    color: var(--accent);
    border-color: rgba(90,167,255,0.34);
}

.status-chip[data-status="done"] {
    color: var(--ok);
    border-color: rgba(48,209,88,0.34);
}

.status-chip[data-status="error"],
.status-chip[data-status="cancelled"] {
    color: var(--err);
    border-color: rgba(255,90,122,0.34);
}

.route-preview {
    height: 230px;
    margin: 14px 0;
    overflow: hidden;
    background:
        linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
        #0f1520;
    background-size: 32px 32px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
}

.route-preview svg {
    width: 100%;
    height: 100%;
}

.route-preview polyline {
    fill: none;
    stroke: var(--route);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 8px rgba(255,75,75,0.35));
}

.combine-map-shell {
    display: grid;
    gap: 10px;
    margin: 14px 0;
}

.combine-map {
    height: 360px;
    width: 100%;
    overflow: hidden;
    background: #0f1520;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18);
}

.combine-map .leaflet-control-zoom a {
    background: rgba(15,21,32,0.94);
    border-bottom-color: rgba(255,255,255,0.14);
    color: var(--text);
}

.combine-map .leaflet-control-attribution {
    background: rgba(255,255,255,0.88);
    color: #1d2635;
}

.combine-map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    color: var(--muted);
    font-size: 12px;
}

.combine-map-legend span {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.legend-line {
    display: inline-block;
    width: 34px;
    height: 0;
    border-top: 4px solid #31d37b;
    border-radius: 999px;
}

.legend-line-source {
    border-color: #31d37b;
    box-shadow: 0 0 8px rgba(49,211,123,0.35);
}

.legend-line-missing {
    border-color: #ff4d5f;
    border-top-style: dashed;
    box-shadow: 0 0 8px rgba(255,77,95,0.35);
}

.trim-line-muted {
    border-color: #8da0b8;
    box-shadow: none;
    opacity: 0.8;
}

.simplify-line-original {
    border-color: #8da0b8;
    box-shadow: none;
    opacity: 0.85;
}

.trim-panel {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.trim-values {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 12px;
}

.trim-values strong {
    color: var(--text);
}

.trim-range {
    position: relative;
    height: 46px;
    user-select: none;
    touch-action: none;
}

.trim-range-track,
.trim-range-selection {
    position: absolute;
    top: 19px;
    height: 8px;
    border-radius: 999px;
}

.trim-range-track {
    right: 0;
    left: 0;
    background: rgba(141,160,184,0.28);
}

.trim-range-selection {
    background: linear-gradient(90deg, #31d37b, #68e3aa);
    box-shadow: 0 0 14px rgba(49,211,123,0.28);
}

.trim-handle {
    position: absolute;
    top: 8px;
    width: 22px;
    height: 30px;
    padding: 0;
    transform: translateX(-50%);
    background: #f7fbff;
    border: 2px solid #31d37b;
    border-radius: 6px;
    box-shadow: 0 8px 18px rgba(0,0,0,0.28);
    cursor: ew-resize;
}

.trim-handle::after {
    content: "";
    position: absolute;
    top: 7px;
    bottom: 7px;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    background: rgba(12,20,31,0.38);
    box-shadow: -4px 0 rgba(12,20,31,0.24), 4px 0 rgba(12,20,31,0.24);
}

.combine-route-row {
    cursor: pointer;
}

.combine-route-row:hover td,
.combine-route-row.is-active td {
    background: rgba(90,167,255,0.09);
}

.combine-route-row.is-active td {
    box-shadow: inset 0 1px 0 rgba(90,167,255,0.24), inset 0 -1px 0 rgba(90,167,255,0.24);
}

.combine-direction-label {
    display: inline-flex;
    min-width: 76px;
}

.row-tools {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.row-tools .icon-button {
    width: 30px;
    height: 30px;
    padding: 0;
}

.login-shell {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 420px));
    justify-content: center;
    gap: 18px;
    min-height: calc(100vh - 65px);
    padding: 12vh 12px 24px;
}

.check-row {
    display: flex !important;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px;
}

.check-row input {
    width: auto;
}

.upload-actions {
    margin-top: 14px;
}

.report-head,
.section-title {
    justify-content: space-between;
}

.status {
    min-height: 18px;
    margin: 14px 0;
    color: var(--muted);
    font-size: 12px;
}

.status.ok {
    color: var(--ok);
}

.status.error {
    color: var(--err);
}

.overview-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin: 8px 0 14px;
}

.overview-toolbar label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
}

.report-shell {
    width: 100%;
    margin: 0 auto;
    padding: 0;
}

.report-card {
    padding: 24px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(120px, 1fr));
    gap: 10px;
    margin: 18px 0;
}

.summary-grid article {
    padding: 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
}

.summary-grid span {
    display: block;
    color: var(--muted);
    font-size: 11px;
}

.summary-grid strong {
    display: block;
    margin-top: 5px;
    font-size: 15px;
}

.tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin: 18px 0 14px;
    padding: 4px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
}

.tab-button {
    border-color: transparent;
    border-radius: 8px;
}

.tab-button[aria-selected="true"] {
    background: rgba(90,167,255,0.18);
    border-color: rgba(90,167,255,0.45);
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
}

.overview-visual-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.visual-panel {
    display: grid;
    grid-template-rows: auto minmax(360px, 1fr);
    gap: 12px;
    min-height: 430px;
    padding: 16px;
}

.map-section {
    min-height: 360px;
    overflow: hidden;
    background: #0f1520;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
}

#map {
    width: 100%;
    height: 100%;
}

#route3d {
    position: relative;
    min-height: 360px;
    overflow: hidden;
    background: #0f1520;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    color: var(--muted);
}

#route3d canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.cached-report-image {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.map-legend {
    display: grid;
    gap: 5px;
    padding: 9px 10px;
    background: rgba(11, 15, 20, 0.86);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 10px;
    color: var(--text);
    font-size: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.28);
}

.map-legend span {
    display: flex;
    align-items: center;
    gap: 7px;
}

.map-legend i {
    display: inline-block;
    width: 22px;
    height: 8px;
    border-radius: 999px;
}

.external-map-popup .leaflet-popup-content-wrapper,
.external-map-popup .leaflet-popup-tip {
    background: #121a28;
    border: 1px solid rgba(255,255,255,0.16);
    color: var(--text);
    box-shadow: 0 16px 36px rgba(0,0,0,0.34);
}

.external-map-popup .leaflet-popup-content {
    display: grid;
    gap: 8px;
    margin: 13px 14px;
    font-size: 13px;
}

.external-map-popup .leaflet-popup-close-button {
    color: var(--muted);
}

.external-map-popup span,
.external-map-popup small {
    color: var(--muted);
}

.map-popup-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.map-popup-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 11px;
    border: 1px solid rgba(90,167,255,0.55);
    border-radius: 8px;
    background: rgba(90,167,255,0.16);
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.chart-panel,
.visual-panel,
#panel-waypoints article,
#panel-planner article {
    padding: 16px;
}

.chart-panel canvas {
    width: 100%;
    height: 300px;
    max-height: 300px;
}

.table-wrap {
    overflow-x: auto;
}

.google-waypoint-import {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 10px;
    align-items: end;
    margin: 10px 0 14px;
}

.google-waypoint-import label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.google-waypoint-import input {
    min-width: 0;
}

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

th,
td {
    padding: 9px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-weight: 650;
}

td input {
    width: 100%;
    min-width: 96px;
}

.icon-action {
    width: auto;
    color: var(--err);
}

.waypoint-order-cell {
    width: 48px;
}

.drag-handle {
    width: 34px;
    min-height: 30px;
    padding: 0;
    cursor: grab;
    color: var(--text);
    border-color: rgba(90,167,255,0.45);
    background: rgba(90,167,255,0.14);
}

.drag-handle:active {
    cursor: grabbing;
}

#waypointTable tr.is-dragging {
    opacity: 0.48;
}

#waypointTable tr.is-drag-over {
    background: rgba(90,167,255,0.14);
    outline: 1px solid rgba(90,167,255,0.55);
}

.day-plan {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.manual-planner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.manual-plan-column {
    min-width: 0;
    overflow: hidden;
    border: 1px solid rgba(111, 178, 255, 0.16);
    background: linear-gradient(180deg, rgba(21, 31, 48, 0.96), rgba(13, 20, 32, 0.92));
    border-radius: 8px;
    box-shadow: 0 16px 34px rgba(0,0,0,0.20);
}

.manual-plan-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px 11px;
    border-bottom: 1px solid rgba(111, 178, 255, 0.12);
    background: rgba(255,255,255,0.025);
    color: var(--text);
    font-weight: 700;
}

.manual-day-title {
    display: grid;
    min-width: 0;
    gap: 3px;
    line-height: 1.2;
}

.manual-day-title strong {
    color: var(--text);
    font-size: 15px;
}

.manual-day-title small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.manual-day-remove {
    border: 1px solid rgba(255, 90, 122, 0.35);
    background: rgba(255, 90, 122, 0.1);
    color: var(--text);
    padding: 4px 8px;
    border-radius: 8px;
    flex: 0 0 auto;
}

.manual-day-note {
    display: grid;
    gap: 6px;
    padding: 12px 14px 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.manual-day-note textarea {
    min-height: 70px;
    width: 100%;
    padding: 10px 11px;
    border: 1px solid rgba(111, 178, 255, 0.20);
    border-radius: 8px;
    outline: none;
    background: rgba(4, 10, 18, 0.36);
    color: var(--text);
    font: inherit;
    font-weight: 400;
    line-height: 1.45;
    overflow: hidden;
    resize: none;
}

.manual-day-note textarea::placeholder {
    color: rgba(159,176,198,0.72);
}

.manual-day-note textarea:focus {
    border-color: rgba(90,167,255,0.60);
    box-shadow: 0 0 0 3px rgba(90,167,255,0.12);
}

.manual-drop-zone {
    display: grid;
    gap: 8px;
    min-height: 94px;
    padding: 12px 14px 14px;
}

.planning-leg-card {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    cursor: grab;
    border: 1px solid rgba(111, 178, 255, 0.28);
    background: rgba(12, 22, 38, 0.78);
    border-radius: 8px;
    padding: 10px;
}

.planning-leg-card:active {
    cursor: grabbing;
}

.planning-leg-card.is-dragging {
    opacity: 0.48;
}

.planning-leg-card.is-drop-before {
    border-top-color: rgba(90,167,255,0.95);
    box-shadow: inset 0 2px 0 rgba(90,167,255,0.85);
}

.planning-leg-card.is-drop-after {
    border-bottom-color: rgba(90,167,255,0.95);
    box-shadow: inset 0 -2px 0 rgba(90,167,255,0.85);
}

.planning-leg-handle {
    width: 28px;
    min-height: 30px;
    padding: 0;
    cursor: grab;
    color: var(--text);
    border-color: rgba(90,167,255,0.45);
    background: rgba(90,167,255,0.14);
}

.planning-leg-handle:active {
    cursor: grabbing;
}

.planning-leg-content {
    display: grid;
    min-width: 0;
    gap: 4px;
}

.planning-leg-card span,
.manual-plan-empty {
    color: var(--muted);
    font-size: 0.86rem;
}

.manual-drop-zone.is-drop-active {
    background: rgba(90,167,255,0.05);
}

.manual-plan-empty {
    padding: 11px 12px;
    border: 1px dashed rgba(111, 178, 255, 0.22);
    border-radius: 8px;
    background: rgba(90,167,255,0.035);
    text-align: center;
}

.day-plan > div {
    padding: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
}

.day-plan .day-plan-card {
    display: grid;
    gap: 8px;
}

.day-plan-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.day-plan-edit {
    border: 1px solid rgba(111, 178, 255, 0.45);
    background: rgba(111, 178, 255, 0.12);
    color: var(--text);
    padding: 5px 10px;
    border-radius: 8px;
}

.day-plan-waypoints {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.day-plan-waypoints span {
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.05);
    border-radius: 999px;
    padding: 4px 8px;
}

.day-plan-totals {
    color: var(--muted);
}

.day-plan-legs {
    display: grid;
    gap: 6px;
}

.day-plan-legs div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.08);
    color: var(--muted);
}

@keyframes atlasBreathe {
    0%,
    100% {
        transform: translateY(0) scale(0.99);
    }

    50% {
        transform: translateY(-8px) scale(1.01);
    }
}

@keyframes orbitActive {
    0% {
        opacity: 0.2;
        transform: rotate(0deg) scale(0.98);
    }

    50% {
        opacity: 0.55;
        transform: rotate(180deg) scale(1.03);
    }

    100% {
        opacity: 0.2;
        transform: rotate(360deg) scale(0.98);
    }
}

@keyframes nodeFlash {
    0%,
    100% {
        opacity: 0;
        transform: scale(0.6);
    }

    45% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes progressWaiting {
    0% {
        background-position: -80px 0, 0 0;
    }

    100% {
        background-position: 480px 0, 0 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .atlas-figure,
    .atlas-orbit::before,
    .atlas-orbit::after,
    .atlas-node {
        animation: none !important;
    }
}

@media (max-width: 980px) {
    .app-layout,
    .atlas-shell {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .project-sidebar {
        position: relative;
        top: auto;
        height: auto;
        max-height: 320px;
    }

    .workspace,
    .login-shell {
        grid-template-columns: 1fr;
    }

    .project-route-grid {
        grid-template-columns: 1fr;
    }

    .atlas-visual {
        min-height: 260px;
        border-right: 0;
        border-bottom: 1px solid rgba(255,255,255,0.04);
    }

    .atlas-animation {
        position: relative;
        top: auto;
        height: 260px;
        min-height: 260px;
    }

    .atlas-orbit {
        width: min(260px, 72vw);
    }

    .card {
        grid-column: 1;
        padding: 18px;
    }

    .summary-grid,
    .overview-visual-grid,
    .charts-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    button,
    input,
    .actions a,
    .menu-link {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .row-tools .icon-button {
        width: 34px;
    }

    .tabs,
    .summary-grid,
    .overview-visual-grid,
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .overview-toolbar,
    .overview-toolbar label {
        align-items: stretch;
        flex-direction: column;
        width: 100%;
    }

    .project-hero,
    .route-card-head,
    .route-edit-form {
        align-items: stretch;
        flex-direction: column;
    }

    .route-edit-form {
        display: flex;
    }

    .google-waypoint-import {
        grid-template-columns: 1fr;
    }

    .route-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .combine-summary {
        grid-template-columns: 1fr;
    }
}

@media print {
    @page {
        size: A4 landscape;
        page-orientation: landscape;
        margin: 8mm;
    }

    body {
        background: #fff;
        color: #111;
        font-size: 8px;
        line-height: 1.25;
    }

    .topbar,
    .no-print {
        display: none !important;
    }

    .report-shell,
    .report-card {
        padding: 0;
        width: 100%;
        box-shadow: none;
        border: 0;
        background: #fff;
    }

    .app-layout {
        display: block;
        min-height: auto;
        padding: 0;
    }

    .report-head {
        margin-bottom: 2mm;
    }

    .report-head h2 {
        font-size: 12px;
        line-height: 1.1;
    }

    .report-head p {
        margin: 1mm 0 0;
        color: #444;
        font-size: 8px;
    }

    .summary-grid {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 3mm;
        margin: 0 0 3mm;
    }

    .summary-grid article,
    .chart-panel,
    .visual-panel,
    #panel-waypoints article,
    #panel-planner article {
        border-color: #ddd;
        background: #fff;
        color: #111;
        box-shadow: none;
        break-inside: avoid;
    }

    .summary-grid article {
        padding: 2mm;
        border-radius: 5px;
    }

    .summary-grid span,
    .summary-grid strong {
        font-size: 8px;
    }

    .summary-grid strong {
        margin-top: 2px;
        font-size: 9px;
    }

    .tab-panel {
        display: block;
    }

    #panel-overview {
        display: grid;
        grid-template-rows: auto auto minmax(0, 1fr) auto;
        gap: 0;
        page-break-after: always;
        break-after: page;
    }

    .map-section,
    #route3d {
        min-height: 0;
        height: 80mm;
        break-inside: avoid;
    }

    #map,
    #route3d canvas {
        width: 100% !important;
        height: 100% !important;
    }

    .has-cached-report-images .has-cached-report-image .cached-report-image {
        display: block;
    }

    .has-cached-report-images .map-section.has-cached-report-image #map,
    .has-cached-report-images #route3d.has-cached-report-image canvas,
    .has-cached-report-images .chart-panel.has-cached-report-image canvas {
        display: none !important;
    }

    .overview-visual-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 3mm;
        min-height: 87mm;
        align-items: stretch;
    }

    .visual-panel {
        grid-template-rows: auto minmax(0, 80mm);
        min-height: 0;
        gap: 1.5mm;
        padding: 2mm;
        overflow: hidden;
    }

    .charts-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 3mm;
        margin-top: 3mm;
    }

    .chart-panel {
        padding: 2mm;
        overflow: hidden;
    }

    .chart-panel canvas {
        height: 52mm !important;
        max-height: 52mm;
    }

    .chart-panel .cached-report-image {
        height: 52mm;
        max-height: 52mm;
    }

    .visual-panel h2,
    .chart-panel h2,
    #panel-waypoints h2,
    #panel-planner h2 {
        font-size: 10px;
        line-height: 1.1;
        margin-bottom: 1.5mm;
    }

    #panel-planner {
        page-break-before: auto;
        break-before: auto;
    }

    #panel-planner,
    #panel-waypoints {
        margin-top: 0;
    }

    #panel-planner article,
    #panel-waypoints article {
        padding: 6px 0;
        border: 0;
    }

    #panel-planner .section-title,
    #panel-waypoints .section-title {
        margin-bottom: 5px;
    }

    .manual-planner {
        display: none !important;
    }

    .day-plan {
        display: grid;
        grid-template-columns: 1fr;
        gap: 2mm;
        margin-top: 2mm;
    }

    .day-plan > div {
        border-color: #ddd;
        background: #fff;
        box-shadow: none;
        break-inside: avoid;
    }

    .day-plan > div {
        padding: 2.5mm 3mm;
        border-radius: 5px;
    }

    .manual-day-remove,
    .planning-leg-handle,
    .day-plan-edit,
    .google-waypoint-import {
        display: none !important;
    }

    .day-plan .day-plan-card {
        display: grid;
        grid-template-columns: 0.75fr 1.25fr 1.3fr 2.1fr;
        gap: 3mm;
        align-items: start;
    }

    .day-plan-title {
        display: block;
    }

    .day-plan-title strong {
        font-size: 10px;
    }

    .day-plan-totals {
        color: #333;
    }

    .day-plan-waypoints {
        display: block;
    }

    .day-plan-waypoints span {
        display: inline;
        padding: 0;
        border: 0;
        background: transparent;
    }

    .day-plan-waypoints span:not(:last-child)::after {
        content: ", ";
    }

    .day-plan-legs {
        display: none !important;
    }

    table {
        font-size: 8px;
    }

    th,
    td {
        padding: 4px 3px;
        white-space: normal;
        border-bottom-color: #ddd;
    }

    td input {
        min-width: 0;
        padding: 0;
        border: 0;
        background: transparent;
        color: #111;
    }

    .leaflet-control-container {
        display: none;
    }
}
