:root {
    color-scheme: light;
    --panel: #ffffff;
    --panel-soft: #f5f7fb;
    --ink: #162033;
    --muted: #64748b;
    --line: #d9e1ee;
    --brand: #0d7c66;
    --brand-dark: #075846;
    --accent: #1d4ed8;
    --warn: #b45309;
    --danger: #b91c1c;
    --shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
    color: var(--ink);
    background: #dfe9f4;
}

button,
input {
    font: inherit;
}

.transport-shell {
    display: grid;
    grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
    min-height: 100vh;
    overflow: hidden;
}

.transport-shell.is-panel-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
}

.transport-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    height: 100vh;
    padding: 18px;
    overflow: auto;
    background: var(--panel);
    border-right: 1px solid var(--line);
    box-shadow: 8px 0 24px rgba(15, 23, 42, 0.08);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 2;
}

.transport-shell.is-panel-collapsed .transport-panel {
    padding: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateX(-18px);
    pointer-events: none;
}

.transport-header {
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    gap: 12px;
    align-items: center;
}

.transport-header h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.25;
    letter-spacing: 0;
}

.transport-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.back-link,
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--ink);
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
}

.back-link:hover,
.icon-btn:hover,
.map-tool-btn:hover {
    color: var(--brand-dark);
    border-color: rgba(13, 124, 102, 0.35);
}

.search-zone {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.search-box {
    display: grid;
    grid-template-columns: 20px 1fr;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 0 12px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.search-box i {
    color: var(--muted);
}

.search-box input {
    width: 100%;
    min-width: 0;
    height: 42px;
    color: var(--ink);
    background: transparent;
    border: 0;
    outline: 0;
}

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

.search-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 42px;
    padding: 0 14px;
    color: #fff;
    background: var(--brand);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

#transportClearBtn {
    width: 42px;
    padding: 0;
    color: var(--ink);
    background: var(--panel-soft);
    border: 1px solid var(--line);
}

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

.summary-grid div {
    min-width: 0;
    padding: 10px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.summary-grid strong {
    display: block;
    font-size: 22px;
    line-height: 1.1;
}

.summary-grid span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.status-strip {
    padding: 12px;
    color: var(--muted);
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13px;
}

.status-strip.is-error {
    color: var(--danger);
    background: #fff1f2;
    border-color: #fecdd3;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 700;
}

.section-title small {
    min-width: 24px;
    color: var(--muted);
    text-align: right;
}

.result-panel,
.batch-panel {
    min-height: 0;
}

.batch-panel {
    flex: 1;
}

.result-list,
.batch-list {
    display: grid;
    gap: 8px;
}

.result-card,
.batch-card {
    width: 100%;
    min-width: 0;
    padding: 12px;
    text-align: left;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
}

.result-card:hover,
.batch-card:hover,
.batch-card.is-active {
    border-color: rgba(13, 124, 102, 0.5);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.vessel-title {
    min-width: 0;
    overflow: hidden;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.route-text,
.meta-text {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.batch-order-nos {
    margin-top: 6px;
    color: #334155;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 7px;
    color: var(--accent);
    background: #eff6ff;
    border-radius: 999px;
    font-size: 12px;
}

.badge.warn {
    color: var(--warn);
    background: #fff7ed;
}

.badge.danger {
    color: var(--danger);
    background: #fff1f2;
}

.map-stage {
    position: relative;
    min-width: 0;
    min-height: 100vh;
    padding: 22px;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 24%, rgba(13, 124, 102, 0.16), transparent 28%),
        radial-gradient(circle at 78% 70%, rgba(29, 78, 216, 0.14), transparent 30%),
        #dfe9f4;
}

.map-toolbar {
    position: absolute;
    top: 22px;
    left: 22px;
    display: flex;
    gap: 8px;
    z-index: 1200;
}

.map-basemap {
    position: relative;
}

.basemap-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    min-width: 132px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(217, 225, 238, 0.95);
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
    z-index: 1300;
}

.basemap-menu[hidden] {
    display: none;
}

.basemap-option {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 7px 9px;
    color: #334155;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
}

.basemap-option:hover {
    background: rgba(241, 245, 249, 0.9);
}

.basemap-option.is-active {
    background: rgba(236, 253, 245, 0.95);
    border-color: rgba(13, 124, 102, 0.42);
    color: #075846;
    font-weight: 600;
}

.basemap-swatch {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    border: 1px solid rgba(15, 23, 42, 0.18);
    flex: 0 0 auto;
    background-size: cover;
    background-position: center;
}

.basemap-swatch-positron {
    background-color: #e8ecef;
    background-image: linear-gradient(135deg, #dfe4e8 0%, #eef1f3 55%, #c9d3da 100%);
}

.basemap-swatch-voyager {
    background-color: #e7eef0;
    background-image: linear-gradient(135deg, #cfe3d8 0%, #f3ede0 55%, #bcd2e6 100%);
}

.basemap-swatch-ocean {
    background-color: #14324f;
    background-image: linear-gradient(135deg, #0b2545 0%, #1d4e79 55%, #2a6f97 100%);
}

.basemap-swatch-satellite {
    background-color: #3a3f33;
    background-image: linear-gradient(135deg, #2b2f25 0%, #4b5240 55%, #6b6450 100%);
}

.basemap-swatch-relief {
    background-color: #b9a07a;
    background-image: linear-gradient(135deg, #c9b48c 0%, #a98c63 55%, #8a7a5c 100%);
}


.map-refresh-clock {
    position: absolute;
    top: 22px;
    right: 84px;
    min-height: 34px;
    padding: 8px 11px;
    color: #334155;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(217, 225, 238, 0.9);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
    font-size: 12px;
    line-height: 1.4;
    z-index: 1200;
}

.map-side-tools {
    position: absolute;
    top: 78px;
    right: 22px;
    display: grid;
    gap: 8px;
    z-index: 1200;
}

.map-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 12px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(217, 225, 238, 0.9);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
    cursor: pointer;
}

.map-icon-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    color: #334155;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(217, 225, 238, 0.9);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
    cursor: pointer;
}

.map-icon-tool:hover,
.map-icon-tool.is-active {
    color: #075846;
    border-color: rgba(13, 124, 102, 0.42);
    background: rgba(236, 253, 245, 0.94);
}

.map-icon-tool.is-filtering {
    color: #b45309;
    border-color: rgba(245, 158, 11, 0.52);
    background: rgba(255, 247, 237, 0.96);
}

.transport-map {
    position: relative;
    width: 100%;
    height: calc(100vh - 44px);
    min-height: 560px;
    overflow: hidden;
    background: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.map-legend {
    position: absolute;
    left: 16px;
    bottom: 16px;
    display: grid;
    grid-template-columns: repeat(2, max-content);
    gap: 7px 12px;
    padding: 10px 12px;
    color: #334155;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(217, 225, 238, 0.9);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
    font-size: 12px;
    line-height: 1.25;
    z-index: 1180;
}

.map-legend div {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--brand);
    box-shadow: 0 0 0 3px rgba(13, 124, 102, 0.14);
}

.legend-dot.warn {
    background: var(--warn);
    box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.14);
}

.legend-dot.danger {
    background: var(--danger);
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.14);
}

.legend-line {
    width: 24px;
    height: 0;
    border-top: 3px solid rgba(29, 78, 216, 0.9);
    border-radius: 999px;
}

.transport-map .leaflet-container,
.leaflet-container.transport-map {
    width: 100%;
    height: 100%;
    background: #e2e8f0;
    font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.leaflet-control-attribution {
    font-size: 11px;
}

.leaflet-popup-content {
    min-width: 220px;
    margin: 12px;
    font-size: 13px;
}

.leaflet-route-overlay,
.leaflet-label-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.transport-map .leaflet-overlay-pane {
    z-index: 420;
}

.transport-map .leaflet-marker-pane {
    z-index: 700;
}

.transport-map .leaflet-popup-pane {
    z-index: 900;
}

.leaflet-route-overlay {
    z-index: 430;
}

.offline-world-map-layer {
    background: #d8e3e7;
    user-select: none;
}

.leaflet-label-layer {
    z-index: 760;
}

.leaflet-port-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.route-path-halo {
    display: none;
}

.route-path-halo.is-active {
    display: none;
}

.transport-vessel-icon {
    overflow: visible;
    background: transparent;
    border: 0;
}

.transport-marker {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: #fff;
    background: var(--brand);
    border: 2px solid rgba(255, 255, 255, 0.95);
    border-radius: 999px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
    transform: translate(var(--marker-offset-x, 0), var(--marker-offset-y, 0));
}

.transport-marker::after {
    position: absolute;
    inset: -8px;
    border: 1px solid rgba(13, 124, 102, 0.42);
    border-radius: inherit;
    content: "";
}

.transport-marker.is-warn {
    background: var(--warn);
}

.transport-marker.is-danger {
    background: var(--danger);
}

.transport-marker.is-active {
    width: 42px;
    height: 42px;
    background: #f97316;
}

.transport-marker.is-flashing {
    animation: transport-marker-flash 0.7s ease-in-out 3;
}

.transport-marker span {
    font-size: 12px;
    font-weight: 800;
}

@keyframes transport-marker-flash {
    0%,
    100% {
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
        transform: translate(var(--marker-offset-x, 0), var(--marker-offset-y, 0)) scale(1);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(249, 115, 22, 0.22), 0 14px 30px rgba(15, 23, 42, 0.28);
        transform: translate(var(--marker-offset-x, 0), var(--marker-offset-y, 0)) scale(1.12);
    }
}

.lane-label-wrap {
    position: absolute;
    pointer-events: none;
}

.lane-label {
    display: inline-flex;
    align-items: center;
    width: max-content;
    max-width: 180px;
    min-height: 24px;
    padding: 4px 8px;
    color: #fff;
    background: rgba(47, 102, 216, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 5px;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.26);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    transform: translate(10px, -12px);
}

.lane-label-end {
    background: rgba(29, 78, 216, 0.92);
}

.lane-label-wrap.is-active .lane-label {
    background: rgba(249, 115, 22, 0.94);
    box-shadow: 0 8px 20px rgba(249, 115, 22, 0.28);
}

.port-label-wrap {
    transform: translate(10px, -26px);
    z-index: 1;
}

.port-label-wrap.end {
    transform: translate(12px, 8px);
}

.route-port-label-start {
    transform: translate(10px, -30px);
}

.route-port-label-end {
    transform: translate(12px, 10px);
}

.port-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: max-content;
    max-width: 150px;
    min-height: 23px;
    padding: 3px 8px;
    color: #1f2937;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.46);
    border-radius: 5px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.15;
    white-space: nowrap;
}

.port-label span {
    color: #0d7c66;
    font-size: 11px;
}

.port-label-end span {
    color: #c2410c;
}

.port-label-wrap.is-active .port-label {
    border-color: rgba(249, 115, 22, 0.66);
    box-shadow: 0 10px 22px rgba(249, 115, 22, 0.2);
}

.static-map-fallback {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.world-map-image,
.route-layer,
.marker-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.world-map-image {
    object-fit: fill;
    user-select: none;
    pointer-events: none;
}

.route-layer {
    pointer-events: none;
    z-index: 2;
}

.marker-layer {
    z-index: 5;
}

.route-path {
    fill: none;
    stroke: #38bdf8;
    stroke-width: 3.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 12 10;
    animation: routeFlow 1.1s linear infinite;
    filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.55));
}

.route-path.is-active {
    stroke: #fbbf24;
    stroke-width: 4.2;
    stroke-dasharray: 12 10;
    animation-duration: 0.8s;
    filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.6));
}

@keyframes routeFlow {
    to {
        stroke-dashoffset: -22;
    }
}

.route-port {
    fill: #ffffff;
    stroke: #0d7c66;
    stroke-width: 3;
    filter: drop-shadow(0 3px 5px rgba(15, 23, 42, 0.24));
}

.route-port.route-port-end {
    stroke: #f97316;
}

.route-port.is-active {
    fill: #fff7ed;
    stroke-width: 3.4;
}

.ship-marker {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: #fff;
    background: var(--brand);
    border: 2px solid rgba(255, 255, 255, 0.95);
    border-radius: 999px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
    transform: translate(-50%, -50%) translate(var(--marker-offset-x, 0), var(--marker-offset-y, 0));
    cursor: pointer;
}

.ship-marker::after {
    position: absolute;
    inset: -8px;
    border: 1px solid rgba(13, 124, 102, 0.42);
    border-radius: inherit;
    content: "";
}

.ship-marker.is-warn {
    background: var(--warn);
}

.ship-marker.is-danger {
    background: var(--danger);
}

.ship-marker.is-active {
    width: 42px;
    height: 42px;
    background: #f97316;
    z-index: 4;
}

.ship-marker span {
    font-size: 12px;
    font-weight: 800;
}

.map-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #475569;
    background: rgba(237, 242, 247, 0.82);
    pointer-events: none;
    z-index: 4;
}

.map-empty i {
    font-size: 44px;
    color: var(--brand);
}

.map-empty.is-hidden {
    display: none;
}

.detail-drawer {
    position: absolute;
    right: 40px;
    bottom: 40px;
    width: min(430px, calc(100% - 80px));
    max-height: calc(100vh - 80px);
    overflow: auto;
    padding: 18px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 1300;
}

.drawer-close {
    position: absolute;
    top: 12px;
    right: 12px;
}

.detail-drawer h2 {
    margin: 0 46px 8px 0;
    font-size: 18px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 0;
}

.detail-grid div,
.order-row {
    min-width: 0;
    padding: 10px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.detail-grid span,
.order-row span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.detail-grid strong,
.order-row strong {
    display: block;
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.order-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

@media (max-width: 980px) {
    .transport-shell,
    .transport-shell.is-panel-collapsed {
        grid-template-columns: 1fr;
        overflow: auto;
    }

    .transport-panel {
        height: auto;
        max-height: none;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .transport-shell.is-panel-collapsed .transport-panel {
        display: none;
    }

    .map-stage {
        min-height: 620px;
        padding: 14px;
    }

    .transport-map {
        height: 620px;
        min-height: 620px;
    }
}

@media (max-width: 560px) {
    .transport-panel {
        padding: 12px;
    }

    .search-zone {
        grid-template-columns: 1fr;
    }

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

    .map-toolbar {
        left: 14px;
        right: 14px;
        flex-wrap: wrap;
    }

    .map-refresh-clock {
        top: 64px;
        right: 14px;
        max-width: calc(100% - 28px);
    }

    .map-side-tools {
        top: 112px;
        right: 14px;
    }

    .map-legend {
        right: 14px;
        left: 14px;
        grid-template-columns: repeat(2, minmax(0, max-content));
        justify-content: start;
    }

    .map-tool-btn {
        flex: 1;
        min-width: 0;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-drawer {
        right: 14px;
        bottom: 14px;
        width: calc(100% - 28px);
    }
}
