#app {
    --map-ink: #20324a;
    --map-muted: #718096;
    --map-primary: #003399;
    --map-primary-dark: #002b85;
    --map-border: #e2e8f0;
    --map-soft: #f5f8fc;
    display: flex;
    min-height: 620px;
    height: calc(100vh - 230px);
    flex-direction: column;
    margin: 0 0 1.25rem;
    padding: 0 clamp(0.75rem, 1.5vw, 1.25rem);
    color: var(--map-ink);
    font-family: Arial, sans-serif;
}

#app .map-toolbar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem clamp(1rem, 2vw, 1.5rem);
    border: 1px solid var(--map-border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 16px rgba(32, 50, 74, 0.055);
}

#app .map-toolbar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
}

#app .map-toolbar-heading {
    display: flex;
    min-width: 250px;
    align-items: center;
    gap: 0.75rem;
}

#app .map-title-icon {
    display: inline-flex;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #edf5fc;
    color: var(--map-primary);
    font-size: 1.15rem;
}

#app .map-toolbar-heading strong {
    display: block;
    color: var(--map-ink);
    font-size: 1.05rem;
    font-weight: 750;
}

#app .map-subtitle {
    display: block;
    margin-top: 0.2rem;
    color: var(--map-muted);
    font-size: 0.76rem;
}

#app .map-toolbar-info {
    display: flex;
    min-width: 0;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.75rem 1.25rem;
    margin-left: auto;
}

#app .map-filter-panel {
    padding: 0.8rem 0.9rem 0.9rem;
    border: 1px solid #e8edf4;
    border-radius: 11px;
    background: #f8fbff;
}

#app .map-filter-heading {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.35rem 0.65rem;
    margin-bottom: 0.65rem;
}

#app .map-filter-heading strong {
    color: var(--map-primary-dark);
    font-size: 0.8rem;
    font-weight: 750;
}

#app .map-filter-heading strong i {
    margin-right: 0.2rem;
}

#app .map-filter-heading span {
    color: var(--map-muted);
    font-size: 0.7rem;
}

#app .map-filters {
    display: grid;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    grid-template-columns: minmax(240px, 2.1fr) minmax(145px, 1fr) minmax(180px, 1.35fr) minmax(135px, 0.9fr) minmax(150px, 1fr);
    align-items: end;
    gap: 0.75rem;
}

#app .map-filters > legend {
    float: none;
    width: auto;
    height: 0;
    padding: 0;
}

#app .map-filters.has-date {
    grid-template-columns: minmax(220px, 2fr) minmax(135px, 0.95fr) minmax(160px, 1.2fr) minmax(125px, 0.85fr) minmax(140px, 0.95fr) minmax(145px, 0.95fr);
}

#app .map-filter {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.3rem;
}

#app .map-filter label {
    margin: 0;
    color: #53657a;
    font-size: 0.72rem;
    font-weight: 700;
}

#app .map-search-control {
    position: relative;
    display: flex;
    min-height: 38px;
    align-items: center;
}

#app .map-search-control > i {
    position: absolute;
    left: 0.75rem;
    color: var(--map-muted);
    pointer-events: none;
}

#app .map-search-control input,
#app .map-filter > input,
#app .map-filter > select,
#app .map-filter .k-picker,
#app .map-filter .k-dropdownlist,
#app .map-filter .k-combobox {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    padding: 0.45rem 0.7rem;
    border: 1px solid #d8e1ec;
    border-radius: 8px;
    background: #fff;
    color: var(--map-ink);
    font-size: 0.8rem;
}

#app .map-search-control input {
    padding-left: 2.15rem;
}

#app .map-filter .k-picker,
#app .map-filter .k-dropdownlist,
#app .map-filter .k-combobox {
    padding: 0;
}

#app .map-filter .k-input-inner,
#app .map-filter .k-input {
    background: #fff !important;
    color: var(--map-ink) !important;
    font-size: 0.8rem;
}

#app .map-filter .k-combobox .k-input-button {
    border-left: 1px solid #d8e1ec !important;
    background: #f8fbff !important;
}

#app .map-search-control input:focus,
#app .map-filter > input:focus,
#app .map-filter > select:focus,
#app .map-filter .k-picker:focus-within,
#app .map-filter .k-dropdownlist:focus-within,
#app .map-filter .k-combobox:focus-within {
    outline: none;
    border-color: #8ba9d8 !important;
    box-shadow: 0 0 0 0.18rem rgba(0, 51, 153, 0.12);
}

#app .map-filter-date > input {
    padding: 0.4rem 0.6rem;
}

#app .map-toolbar-meta {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

#app .map-count,
#app .map-status {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border: 1px solid #d9e4f2;
    border-radius: 999px;
    background: #f5f8fc;
    color: #53657a;
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
}

#app .map-status-loading {
    border-color: #d9e1ea;
    background: #f3f5f8;
    color: #53657a;
}

#app .map-count {
    border-color: #c8ddf4;
    background: #eaf4ff;
    color: #145b9a;
}

#app .map-status {
    border-color: #c7e5d2;
    background: #eaf7ef;
    color: #247344;
}

#app .map-status.map-status-error {
    border-color: #f1caca;
    background: #fff0f0;
    color: #ad2828;
}

#app .legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem 0.85rem;
    color: #53657a;
    font-size: 0.73rem;
}

#app .legend > span {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

#app .dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 0.35rem;
    border-radius: 50%;
}

#app .blue {
    background: #2563eb;
}

#app .purple {
    background: #9333ea;
}

#app .green {
    background: #16a34a;
}

#app .orange {
    background: #f59e0b;
}

#app .kpis {
    display: grid;
    grid-template-columns: repeat(6, minmax(130px, 1fr));
    gap: 0.65rem;
    margin: 0.8rem 0;
}

#app .kpi {
    display: flex;
    min-width: 0;
    min-height: 66px;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--map-border);
    border-radius: 11px;
    background: #fff;
    color: var(--map-ink);
    cursor: pointer;
    text-align: left;
    transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

#app .kpi:hover {
    border-color: #bfd0e8;
    background: #fbfdff;
    box-shadow: 0 4px 12px rgba(32, 50, 74, 0.07);
    transform: translateY(-1px);
}

#app .kpi.is-active {
    border-color: #8ba9d8;
    background: #edf5fc;
    box-shadow: inset 0 0 0 1px rgba(0, 51, 153, 0.08);
}

#app .kpi:focus-visible {
    outline: 3px solid rgba(0, 51, 153, 0.25);
    outline-offset: 2px;
}

#app .kpi-icon {
    display: inline-flex;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #edf5fc;
    color: var(--map-primary);
    font-size: 1rem;
}

#app .kpi.alert .kpi-icon {
    background: #fff2e5;
    color: #a45100;
}

#app .kpi-copy {
    display: block;
    min-width: 0;
}

#app .kpi b {
    display: block;
    color: var(--map-ink);
    font-size: 1.15rem;
    line-height: 1.15;
}

#app .kpi small {
    display: block;
    margin-top: 0.2rem;
    color: var(--map-muted);
    font-size: 0.7rem;
    line-height: 1.2;
}

#app .map-last-update {
    align-self: center;
    color: var(--map-muted);
    font-size: 0.72rem;
    text-align: right;
}

#app .layout {
    display: grid;
    min-height: 0;
    flex: 1;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    gap: 0.75rem;
}

#app .map-canvas-panel,
#app .map-orders-panel {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--map-border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 16px rgba(32, 50, 74, 0.05);
}

#app #map {
    width: 100%;
    height: 100%;
    min-height: 340px;
}

#app .map-orders-panel {
    display: flex;
    flex-direction: column;
}

#app .map-orders-heading {
    padding: 0.9rem 1rem 0.75rem;
    border-bottom: 1px solid var(--map-border);
    background: #fbfdff;
}

#app .map-orders-heading h2 {
    margin: 0;
    color: var(--map-primary-dark);
    font-size: 0.92rem;
    font-weight: 750;
}

#app .map-orders-heading h2 i {
    margin-right: 0.25rem;
}

#app .map-panel-hint {
    display: block;
    margin-top: 0.25rem;
    color: var(--map-muted);
    font-size: 0.7rem;
}

#app #panel {
    min-height: 0;
    flex: 1;
    overflow: auto;
    overscroll-behavior: contain;
}

#app .item {
    padding: 0.85rem 0.95rem;
    border-bottom: 1px solid #edf1f6;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease;
}

#app .item:hover,
#app .item:focus-visible {
    border-left-color: var(--map-primary);
    outline: none;
    background: #f3f7fc;
}

#app .item.alert {
    border-left-color: #e67e22;
}

#app .item > b {
    color: var(--map-ink);
    font-size: 0.84rem;
}

#app .muted {
    margin-top: 0.25rem;
    color: var(--map-muted);
    font-size: 0.72rem;
    line-height: 1.5;
}

#app .badge {
    display: inline-block;
    margin: 0.2rem 0.2rem 0 0;
    padding: 0.18rem 0.45rem;
    border: 1px solid #f2d5b8;
    border-radius: 999px;
    background: #fff2e5;
    color: #a45100;
    font-size: 0.64rem;
    font-weight: 700;
}

#app .info h3 {
    margin: 0 0 0.5rem;
    color: var(--map-primary-dark);
    font-size: 1rem;
}

#app .info hr {
    border: 0;
    border-top: 1px solid var(--map-border);
}

@media (max-width: 1200px) {
    #app .kpis {
        grid-template-columns: repeat(3, minmax(130px, 1fr));
    }

    #app .map-filters,
    #app .map-filters.has-date {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    #app .map-filter-search,
    #app .map-filter-traffic {
        grid-column: span 2;
    }
}

@media (max-width: 850px) {
    #app {
        height: auto;
        min-height: 0;
    }

    #app .map-toolbar-top {
        align-items: flex-start;
        flex-direction: column;
    }

    #app .map-toolbar-info {
        width: 100%;
        justify-content: space-between;
        margin-left: 0;
    }

    #app .map-toolbar-meta {
        margin-left: 0;
    }

    #app .legend {
        margin-left: 0;
    }

    #app .map-filters,
    #app .map-filters.has-date {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #app .map-filter-search {
        grid-column: 1 / -1;
    }

    #app .map-filter-traffic {
        grid-column: auto;
    }

    #app .layout {
        grid-template-columns: minmax(0, 1fr);
    }

    #app .map-canvas-panel {
        min-height: 55vh;
    }

    #app #map {
        height: 55vh;
        min-height: 360px;
    }

    #app .map-orders-panel {
        max-height: 42vh;
    }
}

@media (max-width: 575.98px) {
    #app .map-toolbar {
        padding: 0.9rem;
    }

    #app .map-toolbar-heading {
        min-width: 0;
    }

    #app .map-toolbar-info {
        align-items: flex-start;
        flex-direction: column;
    }

    #app .map-toolbar-meta {
        flex-wrap: wrap;
    }

    #app .map-filter-panel {
        padding: 0.75rem;
    }

    #app .map-filters,
    #app .map-filters.has-date {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.65rem;
    }

    #app .map-filter-search,
    #app .map-filter-traffic {
        grid-column: auto;
    }

    #app .legend {
        gap: 0.4rem 0.65rem;
    }

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

    #app .kpi {
        min-height: 60px;
        padding: 0.55rem;
    }

    #app .map-last-update {
        grid-column: 1 / -1;
        text-align: left;
    }
}
