:root {
    --bg: #eef2ec;
    --panel: #ffffff;
    --ink: #20231f;
    --muted: #687064;
    --line: #d8dfd3;
    --green: #2f7d4f;
    --green-dark: #1f5c38;
    --amber: #c88f2d;
    --red: #b63e35;
    --blue: #276b8f;
    --tile: #fbfcf8;
    --shadow: 0 10px 26px rgba(31, 38, 29, 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;
}

.pack-shell {
    width: min(1480px, 100%);
    margin: 0 auto;
    padding: 14px;
}

.pack-topbar,
.quick-links,
.language-tabs,
.zone-head,
.action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.pack-topbar {
    margin-bottom: 12px;
}

.quick-links {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.quick-links a,
.btn,
.language-tabs button,
.mode-tabs button,
.category-strip button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 900;
    text-decoration: none;
}

.quick-links a {
    padding: 8px 11px;
    border: 1px solid var(--line);
    color: var(--green);
    background: var(--panel);
}

.language-tabs {
    flex-wrap: wrap;
}

.language-tabs button {
    border: 1px solid var(--line);
    padding: 8px 11px;
    color: var(--ink);
    background: var(--panel);
    cursor: pointer;
}

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

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

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

h1,
h2,
h3 {
    margin: 0;
}

h1 {
    font-size: 30px;
    line-height: 1.1;
}

h2 {
    font-size: 22px;
}

.station-grid {
    display: grid;
    gap: 12px;
}

.control-panel,
.product-zone,
.entry-panel,
.recent-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.control-panel,
.entry-panel,
.recent-panel {
    display: grid;
    gap: 12px;
    padding: 12px;
}

.product-zone {
    display: grid;
    gap: 12px;
    padding: 12px;
}

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

input,
select,
button {
    font: inherit;
}

input,
select {
    width: 100%;
    min-height: 46px;
    padding: 10px 11px;
    border: 1px solid #c7d0c1;
    border-radius: 8px;
    color: var(--ink);
    background: #ffffff;
    font-weight: 800;
}

.location-hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
}

.mode-tabs,
.category-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mode-tabs button,
.category-strip button {
    border: 1px solid var(--line);
    padding: 9px 11px;
    color: var(--ink);
    background: #f6f8f3;
    cursor: pointer;
}

.mode-tabs button.is-active,
.category-strip button.is-active {
    border-color: var(--green);
    color: #ffffff;
    background: var(--green);
}

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

.product-pager {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 2px 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.product-pager::-webkit-scrollbar {
    display: none;
}

.product-pager span,
.product-pager button {
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    text-align: center;
}

.product-pager button {
    flex: 0 0 auto;
    min-width: 42px;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #f6f8f3;
    cursor: pointer;
}

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

.product-tile {
    min-height: 132px;
    display: grid;
    grid-template-rows: 62px minmax(0, 1fr);
    grid-auto-rows: auto;
    gap: 6px;
    padding: 10px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: var(--tile);
    color: var(--ink);
    text-align: center;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px var(--line);
}

.product-tile.has-detail {
    grid-template-rows: 62px minmax(0, 1fr) auto;
}

.product-tile img,
.product-image-placeholder {
    width: 100%;
    height: 62px;
    border-radius: 7px;
    object-fit: cover;
    background: #e7ece2;
}

.product-image-placeholder {
    display: grid;
    place-items: center;
    color: var(--green);
    font-size: 24px;
    font-weight: 900;
}

.product-tile strong {
    align-self: center;
    overflow-wrap: anywhere;
    font-size: clamp(16px, 1.55vw, 22px);
    line-height: 1.18;
}

.product-tile span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.product-tile.is-selected {
    border-color: var(--amber);
    background: #fff7e7;
    box-shadow: 0 0 0 3px rgba(200, 143, 45, 0.2);
}

.selected-product {
    min-height: 92px;
    display: grid;
    gap: 5px;
    padding: 12px;
    border-radius: 8px;
    background: #f7f8f4;
}

.selected-product span,
.selected-product em {
    color: var(--muted);
    font-size: 13px;
    font-style: normal;
    font-weight: 900;
}

.selected-product strong {
    font-size: 24px;
    line-height: 1.18;
}

.scale-display {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: end;
    padding: 14px;
    border-radius: 8px;
    color: #ffffff;
    background: #263126;
}

.scale-display span {
    grid-column: 1 / -1;
    color: #cbd5c8;
    font-size: 13px;
    font-weight: 900;
}

.calc-history {
    grid-column: 1 / -1;
    min-height: 30px;
    overflow-x: auto;
    white-space: nowrap;
    color: #aebfac;
    font-size: 16px;
    font-weight: 900;
    scrollbar-width: none;
}

.calc-history::-webkit-scrollbar {
    display: none;
}

.scale-display strong {
    min-width: 0;
}

.scale-display input {
    min-height: 60px;
    border: 0;
    padding: 0;
    color: #ffffff;
    background: transparent;
    font-size: 40px;
    font-weight: 900;
    text-align: right;
}

.scale-display small {
    padding-bottom: 10px;
    color: #dce8d7;
    font-size: 19px;
    font-weight: 900;
}

.scale-display em {
    grid-column: 1 / -1;
    justify-self: end;
    color: #f8d287;
    font-size: 24px;
    font-style: normal;
    font-weight: 900;
}

.tare-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(128px, 0.72fr);
    gap: 8px;
}

.tare-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.tare-open {
    width: 100%;
    min-height: 46px;
    justify-content: space-between;
}

.tare-now {
    min-height: 46px;
}

.tare-open strong {
    color: var(--amber);
    font-size: 18px;
}

.tare-presets .tare-preset {
    min-width: 94px;
    min-height: 86px;
    display: grid;
    grid-template-rows: 34px auto auto;
    justify-items: center;
    gap: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    color: var(--ink);
    background: #ffffff;
    font-weight: 900;
    cursor: pointer;
}

.tare-icon {
    position: relative;
    width: 42px;
    height: 30px;
    border: 3px solid #8d795d;
    border-top-width: 6px;
    border-radius: 5px 5px 3px 3px;
    background: #ead8b8;
}

.tare-icon::before,
.tare-icon::after,
.tare-icon i {
    content: "";
    position: absolute;
    display: block;
}

.tare-icon::before {
    top: -8px;
    left: 6px;
    width: 15px;
    height: 9px;
    border-left: 3px solid #8d795d;
    border-top: 3px solid #8d795d;
    transform: skewX(-20deg);
}

.tare-icon::after {
    right: 6px;
    bottom: 5px;
    left: 6px;
    height: 3px;
    border-radius: 999px;
    background: rgba(141, 121, 93, 0.55);
}

.tare-icon i {
    top: 5px;
    left: 50%;
    width: 3px;
    height: 20px;
    background: rgba(141, 121, 93, 0.55);
}

.tare-preset.box-b .tare-icon {
    width: 36px;
    height: 26px;
    background: #dfcba7;
}

.tare-preset.box-c .tare-icon {
    width: 31px;
    height: 23px;
    background: #d6bd92;
}

.tare-presets strong {
    font-size: 13px;
    line-height: 1.2;
    text-align: center;
}

.tare-presets small,
.empty-inline {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.floating-panel {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 14px;
    background: rgba(12, 18, 13, 0.38);
}

.floating-panel.is-open {
    display: flex;
}

.floating-card {
    width: min(480px, 100%);
    display: grid;
    gap: 12px;
    padding: 14px;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 24px 70px rgba(20, 28, 21, 0.28);
}

.floating-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.floating-head strong {
    font-size: 18px;
}

.icon-button {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink);
    background: #f7f8f4;
    font-size: 24px;
    font-weight: 900;
    cursor: pointer;
}

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

.keypad button {
    min-height: 58px;
    border: 0;
    border-radius: 8px;
    color: #ffffff;
    background: #e97862;
    font-size: 23px;
    font-weight: 900;
    cursor: pointer;
}

.keypad .op-key {
    background: #c8a23b;
}

.keypad .equal-key {
    background: var(--green);
}

.keypad .backspace-key {
    position: relative;
    background: var(--red);
}

.keypad .backspace-key span {
    display: inline-block;
    transform: translateY(-1px);
    font-size: 26px;
    line-height: 1;
}

.keypad .clear-key {
    background: #f7f8f4;
    color: var(--ink);
    border: 1px solid var(--line);
}

.label-preview,
.print-label {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.label-preview {
    display: grid;
    gap: 6px;
    padding: 12px;
}

.label-preview p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.label-preview strong {
    font-size: 22px;
}

.label-preview span {
    font-size: 28px;
    font-weight: 900;
}

.label-preview small,
.label-preview code {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.btn {
    border: 0;
    padding: 10px 12px;
    cursor: pointer;
}

.btn.primary {
    flex: 1;
    min-height: 58px;
    color: #ffffff;
    background: var(--green);
    font-size: 17px;
}

.btn.secondary,
.btn.ghost {
    border: 1px solid var(--line);
    color: var(--ink);
    background: #f7f8f4;
}

.btn.danger {
    width: 100%;
    color: #ffffff;
    background: var(--red);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

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

.data-grid {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

.record-list,
.report-panel,
.template-form {
    display: grid;
    gap: 8px;
}

.template-form textarea {
    width: 100%;
    min-height: 120px;
    padding: 10px 11px;
    border: 1px solid #c7d0c1;
    border-radius: 8px;
    color: var(--ink);
    background: #ffffff;
    font: inherit;
    font-weight: 800;
}

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

.template-row {
    width: 100%;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}

.record-row,
.report-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcf8;
}

.record-row small,
.report-row small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.record-row span {
    color: var(--green);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.record-row.status-canceled {
    opacity: 0.62;
}

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

.report-summary div {
    display: grid;
    gap: 5px;
    padding: 10px;
    border-radius: 8px;
    background: #f7f8f4;
}

.report-summary span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.report-summary strong {
    font-size: 22px;
}

.print-label {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 12px;
    min-height: 118px;
    padding: 12px;
}

.print-label p {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.print-label h3 {
    margin-bottom: 6px;
    font-size: 23px;
}

.print-label strong {
    font-size: 30px;
}

.label-barcode {
    min-width: 190px;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 6px;
    border-left: 1px dashed var(--line);
    padding-left: 12px;
}

.barcode-svg {
    width: 176px;
    max-width: 100%;
    height: 46px;
}

.label-barcode span {
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0;
}

.label-barcode small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.empty-state {
    padding: 18px;
    border: 1px dashed #c7d0c1;
    border-radius: 8px;
    color: var(--muted);
    background: #fbfcf8;
    text-align: center;
    font-weight: 900;
}

.toast {
    position: fixed;
    right: 14px;
    bottom: 18px;
    left: 14px;
    z-index: 20;
    transform: translateY(16px);
    opacity: 0;
    pointer-events: none;
    padding: 13px 16px;
    border-radius: 8px;
    color: #ffffff;
    background: #263126;
    text-align: center;
    transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (min-width: 860px) {
    .station-grid {
        grid-template-columns: 260px minmax(0, 1fr) 330px;
        align-items: start;
    }

    .control-panel,
    .entry-panel {
        position: sticky;
        top: 12px;
    }

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

@media (min-width: 1080px) {
    .data-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1180px) {
    .product-pad {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media print {
    body {
        background: #ffffff;
    }

    .pack-topbar,
    .station-grid,
    .recent-panel .zone-head,
    .toast {
        display: none !important;
    }

    .pack-shell {
        width: 100%;
        padding: 0;
    }

    .recent-panel {
        border: 0;
        box-shadow: none;
        padding: 0;
    }

    .label-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 8mm;
    }

    .print-label {
        break-inside: avoid;
        min-height: 42mm;
        box-shadow: none;
    }
}
