:root {
    --bg: #f5f7f2;
    --panel: #ffffff;
    --ink: #20231f;
    --muted: #697066;
    --line: #dfe5d8;
    --green: #2f7d4f;
    --blue: #2b6f95;
    --orange: #bd7a24;
    --red: #b6453c;
    --shadow: 0 12px 28px rgba(28, 35, 27, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", Arial, sans-serif;
}

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

button {
    cursor: pointer;
}

.delivery-shell {
    width: min(1260px, 100%);
    margin: 0 auto;
    padding: 18px 14px 84px;
}

.delivery-topbar,
.tool-strip,
.pane-head,
.card-head,
.detail-head,
.head-actions,
.detail-actions,
.route-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.head-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.delivery-topbar {
    align-items: flex-start;
    margin-bottom: 16px;
}

.eyebrow,
p,
h1,
h2,
h3 {
    margin-top: 0;
}

.eyebrow {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

h1 {
    margin-bottom: 0;
    font-size: 32px;
    line-height: 1.1;
}

h2,
h3 {
    margin-bottom: 0;
}

.quick-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.quick-links a,
.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border: 1px solid var(--green);
    border-radius: 8px;
    background: var(--green);
    color: #ffffff;
    text-decoration: none;
    font-weight: 900;
}

.btn.ghost,
.quick-links a {
    border-color: var(--line);
    background: var(--panel);
    color: var(--green);
}

.btn.warning {
    border-color: #e0c08c;
    background: #fff7e8;
    color: #9b5d12;
}

.btn.danger {
    border-color: #e1b8b4;
    background: #fff5f4;
    color: var(--red);
}

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

.summary-grid article,
.tool-strip,
.delivery-list-pane,
.delivery-detail {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.summary-grid article {
    padding: 14px;
}

.summary-grid span {
    display: block;
    font-size: 28px;
    font-weight: 950;
}

.summary-grid p {
    margin-bottom: 0;
    color: var(--muted);
    font-weight: 800;
}

.tool-strip {
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding: 12px;
}

.filter-tabs,
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: end;
}

.filter-tabs button {
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8faf6;
    color: var(--ink);
    font-weight: 900;
}

.filter-tabs button.is-active {
    border-color: var(--green);
    background: var(--green);
    color: #ffffff;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 11px;
    border: 1px solid #cbd5c3;
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
}

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

.delivery-workspace {
    display: grid;
    grid-template-columns: minmax(320px, .95fr) minmax(0, 1.35fr);
    gap: 14px;
    align-items: start;
}

.delivery-list-pane,
.delivery-detail {
    min-height: 420px;
    padding: 14px;
}

.delivery-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.delivery-card {
    display: grid;
    gap: 10px;
    padding: 13px;
    border: 1px solid var(--line);
    border-left: 6px solid var(--blue);
    border-radius: 8px;
    background: #ffffff;
    text-align: left;
}

.delivery-card:hover {
    border-color: var(--green);
}

.delivery-card.is-active {
    border-color: var(--green);
    box-shadow: inset 0 0 0 2px rgba(47, 125, 79, .15);
}

.delivery-card.status-delivered {
    border-left-color: var(--green);
}

.delivery-card.status-completed {
    border-left-color: var(--muted);
    opacity: .82;
}

.card-head {
    align-items: flex-start;
}

.date-chip,
.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 4px 9px;
    border-radius: 8px;
    background: #edf3e8;
    color: var(--green);
    font-size: 13px;
    font-weight: 900;
}

.status-pill {
    background: #eef4f8;
    color: var(--blue);
}

.delivery-card h3 {
    margin: 4px 0 0;
    font-size: 19px;
}

.delivery-card p,
.card-meta,
.empty-panel span,
.note-text {
    color: var(--muted);
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13px;
    font-weight: 800;
}

.detail-head {
    align-items: flex-start;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.detail-head h2 {
    margin: 4px 0;
    font-size: 26px;
}

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

.facts-grid div,
.route-panel,
.detail-block,
.empty-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9faf6;
}

.facts-grid div {
    padding: 11px;
}

dt {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

dd {
    margin: 4px 0 0;
    font-size: 18px;
    font-weight: 950;
    word-break: break-word;
}

.route-panel,
.detail-block {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
    padding: 12px;
}

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

.route-form label:last-child {
    grid-column: 1 / -1;
}

.ship-items {
    display: grid;
    gap: 8px;
}

.ship-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    background: #ffffff;
}

.ship-item span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

.item-money {
    font-weight: 950;
}

.note-text {
    margin-bottom: 0;
    line-height: 1.55;
    white-space: pre-wrap;
}

.route-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
}

.empty-panel {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    min-height: 320px;
    padding: 22px;
    text-align: center;
}

.empty-state {
    padding: 14px;
    border: 1px dashed #cfd8c8;
    border-radius: 8px;
    color: var(--muted);
    background: #fbfcf8;
    font-weight: 800;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 18px;
    z-index: 30;
    transform: translateX(-50%) translateY(20px);
    max-width: min(460px, calc(100vw - 28px));
    padding: 12px 16px;
    border-radius: 8px;
    background: #20231f;
    color: #ffffff;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
    font-weight: 850;
}

.toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 900px) {
    .delivery-topbar,
    .tool-strip {
        display: grid;
    }

    .quick-links {
        justify-content: flex-start;
    }

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

    .delivery-workspace {
        grid-template-columns: 1fr;
    }

    .facts-grid,
    .route-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .delivery-shell {
        padding-inline: 10px;
    }

    h1 {
        font-size: 28px;
    }

    .summary-grid {
        gap: 8px;
    }

    .summary-grid article {
        padding: 11px;
    }

    .summary-grid span {
        font-size: 24px;
    }

    .filter-row,
    .filter-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .search-box {
        grid-column: 1 / -1;
    }

    .route-actions .btn {
        width: 100%;
    }
}
