:root {
    --bg: #f6f7f2;
    --surface: #ffffff;
    --surface-soft: #eef3ec;
    --ink: #1d2528;
    --muted: #697579;
    --line: #dce3dd;
    --sidebar: #14201e;
    --accent: #0f766e;
    --accent-strong: #0b5f59;
    --warn: #b7791f;
    --danger: #b42318;
    --info: #315f9c;
    --shadow: 0 16px 40px rgba(29, 37, 40, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.5 Arial, Helvetica, sans-serif;
}

a {
    color: var(--accent-strong);
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    padding: 10px 11px;
    outline: none;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 700;
}

label input,
label select,
label textarea {
    color: var(--ink);
    font-weight: 400;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

td small {
    display: block;
    color: var(--muted);
    margin-top: 2px;
}

.app-shell {
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--sidebar);
    color: #eaf1ec;
    display: flex;
    flex-direction: column;
    padding: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 6px 22px;
}

.brand-logo {
    width: 118px;
    height: 46px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    padding: 7px;
    flex: 0 0 auto;
}

.brand strong,
.brand small {
    display: block;
}

.brand small,
.sidebar-footer span {
    color: #a9b8b2;
}

.nav {
    display: grid;
    gap: 6px;
}

.nav a,
.sidebar-footer a {
    border-radius: 6px;
    color: #eaf1ec;
    padding: 10px 12px;
}

.nav a:hover,
.sidebar-footer a:hover {
    background: rgba(255, 255, 255, 0.09);
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 8px;
    padding-top: 18px;
}

.main {
    padding: 28px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 22px;
}

.topbar h1,
.login-card h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.15;
}

.kicker {
    margin: 0 0 5px;
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.top-actions {
    color: var(--muted);
}

.panel,
.metric,
.login-card,
.globe-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 18px;
    margin-bottom: 18px;
}

.panel.wide {
    max-width: 1120px;
}

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

.panel-head h2,
.map-copy h2 {
    margin: 0;
    font-size: 18px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric {
    padding: 16px;
    display: grid;
    gap: 5px;
}

.metric span,
.metric small,
.muted {
    color: var(--muted);
}

.metric strong {
    font-size: 26px;
    line-height: 1.1;
}

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 0.72fr);
    gap: 18px;
}

.globe-panel {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 18px;
    padding: 18px;
    margin-bottom: 18px;
    overflow: hidden;
}

.map-copy p {
    color: var(--muted);
    margin-bottom: 0;
}

.globe-layout {
    display: grid;
    grid-template-columns: minmax(300px, 520px) minmax(220px, 0.42fr);
    gap: 18px;
    align-items: center;
}

.globe-stage {
    position: relative;
    width: min(100%, 520px);
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: 50%;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.globe-stage.is-dragging {
    cursor: grabbing;
}

.globe-svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.globe-aura {
    fill: rgba(20, 99, 137, 0.18);
    filter: url("#globeGlow");
}

.globe-ocean {
    fill: url("#globeOcean");
}

.globe-grid {
    fill: none;
    stroke: rgba(255, 255, 255, 0.18);
    stroke-width: 1;
}

.globe-land {
    fill: rgba(193, 221, 177, 0.82);
    stroke: rgba(255, 255, 255, 0.38);
    stroke-width: 1.4;
    stroke-linejoin: round;
}

.globe-route {
    fill: none;
    stroke: #f3bd33;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 12 16;
    filter: drop-shadow(0 0 7px rgba(243, 189, 51, 0.9));
    animation: route-flow 1.8s linear infinite;
}

.globe-rim {
    fill: none;
    stroke: rgba(255, 255, 255, 0.74);
    stroke-width: 2;
}

.pin-pulse {
    fill: rgba(243, 189, 51, 0.24);
    stroke: rgba(255, 255, 255, 0.62);
    stroke-width: 1;
    animation: pin-pulse 1.9s ease-in-out infinite;
}

.pin-dot {
    fill: #f3bd33;
    stroke: #fff;
    stroke-width: 2;
}

.globe-pin.origin .pin-dot {
    fill: #e11d48;
}

.globe-pin.origin .pin-pulse {
    fill: rgba(225, 29, 72, 0.28);
}

.pin-label {
    fill: #fff;
    stroke: rgba(20, 32, 30, 0.65);
    stroke-width: 2;
    paint-order: stroke;
    font-size: 13px;
    font-weight: 800;
}

.globe-hint {
    position: absolute;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--accent-strong);
    padding: 6px 11px;
    font-size: 12px;
    font-weight: 800;
    box-shadow: var(--shadow);
}

.route-list {
    display: grid;
    gap: 10px;
    max-height: 430px;
    overflow: auto;
    padding-right: 3px;
}

.route-card {
    display: grid;
    gap: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 11px;
    color: var(--ink);
}

.route-card span {
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 800;
}

.route-card small {
    color: var(--muted);
}

.route-card:hover {
    border-color: rgba(15, 118, 110, 0.45);
    box-shadow: 0 8px 24px rgba(15, 118, 110, 0.1);
}

@keyframes route-flow {
    to {
        stroke-dashoffset: -56;
    }
}

@keyframes pin-pulse {
    0%,
    100% {
        opacity: 0.58;
        transform: scale(1);
        transform-origin: center;
    }
    50% {
        opacity: 0.96;
        transform: scale(1.16);
    }
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

.filters {
    grid-template-columns: minmax(220px, 1fr) 220px 180px auto;
    align-items: end;
    margin-bottom: 16px;
}

.span-2 {
    grid-column: span 2;
}

.stack {
    display: grid;
    gap: 14px;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 39px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    padding: 9px 13px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn.primary:hover {
    background: var(--accent-strong);
}

.btn.ghost {
    background: var(--surface-soft);
}

.btn.tiny {
    min-height: 31px;
    padding: 6px 9px;
    font-size: 12px;
}

.btn.danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.row-actions {
    display: flex;
    gap: 6px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 800;
    background: #eef0f1;
    color: var(--ink);
}

.badge-active,
.badge-delivered,
.badge-payment_received {
    background: #dff3e5;
    color: #17613a;
}

.badge-passive,
.badge-planned {
    background: #edf1f5;
    color: #4d6072;
}

.badge-blocked,
.badge-cancelled,
.badge-payable {
    background: #fee4df;
    color: var(--danger);
}

.badge-loading,
.badge-receivable {
    background: #fff1d6;
    color: var(--warn);
}

.badge-on_route,
.badge-payment_sent {
    background: #dbeafe;
    color: var(--info);
}

.activity-list {
    display: grid;
    gap: 10px;
}

.activity {
    display: grid;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    color: var(--ink);
}

.activity span {
    color: var(--accent-strong);
    font-weight: 800;
}

.activity small {
    color: var(--muted);
}

.checkbox-grid,
.permissions {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.checkbox-grid legend,
.permission-group legend {
    color: var(--ink);
    font-weight: 800;
}

.checkbox-grid label,
.permission-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-weight: 600;
}

.checkbox-grid input,
.permission-group input {
    width: auto;
}

.permissions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.permission-group {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    display: grid;
    gap: 9px;
}

.hint-box,
.danger-zone,
.empty-state {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 14px;
    margin-top: 14px;
}

.danger-zone {
    background: #fff7f5;
    border-color: #f4b8ae;
}

.flash {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-weight: 800;
}

.flash.success {
    background: #dff3e5;
    color: #17613a;
}

.flash.error {
    background: #fee4df;
    color: var(--danger);
}

.empty-state {
    text-align: center;
    padding: 44px 18px;
}

.empty-cell {
    color: var(--muted);
    text-align: center;
}

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(120deg, rgba(15, 118, 110, 0.12), transparent 44%),
        var(--bg);
}

.login-card {
    width: min(460px, 100%);
    padding: 28px;
    display: grid;
    gap: 24px;
}

.login-logo {
    width: min(260px, 100%);
    height: 68px;
    object-fit: contain;
    justify-self: start;
}

.small {
    font-size: 12px;
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

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

    .metrics-grid,
    .two-col,
    .globe-panel {
        grid-template-columns: 1fr 1fr;
    }

    .globe-layout {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 760px) {
    .main {
        padding: 18px;
    }

    .topbar,
    .panel-head,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .nav,
    .metrics-grid,
    .two-col,
    .globe-panel,
    .globe-layout,
    .filters,
    .form-grid,
    .permissions,
    .checkbox-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }

    .globe-stage {
        min-height: 220px;
    }
}

/* 2026-06-21 polish: compact logo and minimal route map */
.brand {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 8px;
    padding: 6px 0 22px;
}

.brand-logo {
    display: block;
    width: 208px;
    max-width: 100%;
    height: auto;
    max-height: 82px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    padding: 10px;
}

.brand > span {
    padding-left: 4px;
}

.brand > span strong {
    font-size: 13px;
}

.login-card {
    overflow: hidden;
}

.login-logo {
    display: block;
    width: 250px;
    max-width: 100%;
    height: auto;
    max-height: 90px;
    object-fit: contain;
    justify-self: start;
}

.route-map-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 18px;
    padding: 18px;
    margin-bottom: 18px;
    overflow: hidden;
}

.route-map-layout {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) minmax(220px, 300px);
    gap: 16px;
    align-items: stretch;
}

.route-map-stage {
    min-width: 0;
    min-height: 320px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7fbfa;
    overflow: hidden;
}

.route-map-svg {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 320px;
}

.map-bg {
    fill: url("#mapBg");
}

.map-grid {
    fill: none;
    stroke: rgba(105, 117, 121, 0.14);
    stroke-width: 1;
}

.map-land {
    fill: #d5e4d4;
    stroke: #ffffff;
    stroke-width: 1.3;
    stroke-linejoin: round;
}

.map-route {
    fill: none;
    stroke: #0f766e;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-dasharray: 8 11;
    animation: route-flow 1.6s linear infinite;
}

.map-route-dot {
    fill: #e3b341;
    stroke: #fff;
    stroke-width: 1.5;
}

.map-point {
    cursor: pointer;
}

.point-ring {
    fill: rgba(15, 118, 110, 0.16);
    stroke: rgba(15, 118, 110, 0.5);
    stroke-width: 1.3;
}

.point-dot {
    fill: #0f766e;
    stroke: #fff;
    stroke-width: 2;
}

.map-point.origin .point-ring {
    fill: rgba(225, 29, 72, 0.13);
    stroke: rgba(225, 29, 72, 0.52);
}

.map-point.origin .point-dot {
    fill: #e11d48;
}

.point-label {
    fill: var(--ink);
    stroke: #fff;
    stroke-width: 4;
    paint-order: stroke;
    font-size: 13px;
    font-weight: 800;
}

.route-map-panel .route-list {
    max-height: 320px;
}

.globe-panel,
.globe-stage,
.globe-svg {
    max-width: 100%;
}

@media (max-width: 1100px) {
    .route-map-panel,
    .route-map-layout {
        grid-template-columns: 1fr;
    }

    .brand-logo {
        width: 190px;
    }
}

@media (max-width: 760px) {
    .login-logo {
        width: 220px;
    }

    .route-map-stage,
    .route-map-svg {
        min-height: 260px;
    }
}
