:root {
    --bg: #f5f7f4;
    --panel: #ffffff;
    --ink: #20231f;
    --muted: #687064;
    --line: #dfe4da;
    --green: #2f7d4f;
    --blue: #276b8f;
    --red: #b63e35;
    --amber: #b98322;
    --shadow: 0 10px 28px 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;
}

.app-shell {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 18px 14px 88px;
}

.topbar,
.quick-links,
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

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

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

.quick-links a,
.btn {
    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);
}

.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: 21px;
}

h3 {
    font-size: 18px;
}

.notice-card,
.action-card,
.batch-section,
.batch-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.notice-card {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
    padding: 14px;
    border-left: 5px solid var(--blue);
}

.notice-card span {
    color: var(--muted);
    line-height: 1.55;
}

.action-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 14px;
}

.action-card,
.batch-section {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.stack-form,
.form-grid,
.batch-list,
.output-list {
    display: grid;
    gap: 10px;
}

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

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

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

textarea {
    resize: vertical;
}

.btn {
    border: 0;
    padding: 10px 12px;
    color: #ffffff;
    background: var(--green);
    cursor: pointer;
}

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

.btn.compact {
    min-height: 38px;
}

.tag-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 38px;
}

.tag-chip {
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 10px;
    background: #f7f8f4;
    color: var(--ink);
    cursor: pointer;
    font-weight: 900;
}

.tag-chip:hover {
    border-color: var(--green);
    color: var(--green);
    background: #e8f3ed;
}

.empty-tags {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.scale-panel {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7f8f4;
}

.scale-panel span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
}

.scale-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 88px;
    gap: 8px;
}

.scale-input-row input {
    min-height: 58px;
    font-size: 28px;
    font-weight: 900;
}

.package-preview {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7f8f4;
    color: var(--green);
    font-weight: 900;
}

.batch-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border-left: 5px solid var(--green);
}

.batch-card.status-planned {
    border-left-color: var(--blue);
}

.batch-card.status-slaughtering,
.batch-card.status-packing {
    border-left-color: var(--amber);
}

.batch-card.status-completed {
    opacity: 0.72;
}

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

.status-pill,
.metric-pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 9px;
    border-radius: 8px;
    background: #e8f3ed;
    color: var(--green);
    font-size: 12px;
    font-weight: 900;
}

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

.batch-meta div {
    min-width: 0;
    padding: 9px;
    border-radius: 8px;
    background: #f7f8f4;
}

.batch-meta dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.batch-meta dd {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
    font-weight: 900;
}

.output-card {
    display: grid;
    gap: 4px;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
}

.output-card small {
    color: var(--muted);
    line-height: 1.45;
}

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

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

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

.record-row div,
.report-row div,
.detail-row div {
    min-width: 0;
}

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

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

.record-row.status-canceled,
.detail-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;
}

.report-title {
    margin-top: 4px;
    font-size: 17px;
}

.detail-row code {
    max-width: 42%;
    overflow-wrap: anywhere;
    color: var(--blue);
    font-weight: 900;
}

.empty-state {
    padding: 14px;
    border: 1px dashed #c8d1c0;
    border-radius: 8px;
    color: var(--muted);
    background: #fbfcfa;
    text-align: center;
}

.egg-shell {
    max-width: 860px;
}

.egg-station-panel,
.egg-step,
.egg-summary-grid article,
.egg-record-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.egg-station-panel {
    display: grid;
    gap: 14px;
    padding: 14px;
}

.egg-step {
    display: grid;
    gap: 10px;
    padding: 14px;
}

.big-toggle,
.quick-qty,
.egg-product-grid,
.egg-qty-row,
.egg-slot-grid,
.egg-summary-grid,
.egg-record-list {
    display: grid;
    gap: 10px;
}

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

.big-toggle button,
.quick-qty button,
.egg-product-card,
.egg-qty-row button {
    min-height: 64px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7f8f4;
    color: var(--ink);
    cursor: pointer;
    font-size: 22px;
    font-weight: 950;
}

.big-toggle button.is-active,
.egg-product-card.is-active {
    border-color: var(--green);
    background: var(--green);
    color: #fff;
}

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

.egg-product-card {
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 8px;
    padding: 12px;
    text-align: center;
}

.egg-product-card span {
    font-size: 15px;
    color: inherit;
    opacity: .78;
}

.egg-qty-row {
    grid-template-columns: 84px minmax(0, 1fr) 84px;
}

.egg-qty-row input {
    min-height: 76px;
    text-align: center;
    font-size: 36px;
    font-weight: 950;
}

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

.egg-slot-input {
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7f8f4;
}

.egg-slot-input span {
    color: var(--muted);
    font-size: 14px;
    font-weight: 950;
}

.egg-slot-input input {
    min-height: 56px;
    text-align: center;
    font-size: 28px;
    font-weight: 950;
}

.egg-total-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-radius: 8px;
    background: #e8f3ed;
    color: var(--green);
}

.egg-total-panel span {
    font-weight: 950;
}

.egg-total-panel strong {
    color: var(--ink);
    font-size: 30px;
}

.egg-existing-panel {
    padding: 12px 14px;
    border: 1px solid #d8c58a;
    border-radius: 8px;
    background: #fff9e7;
    color: #85651c;
    font-size: 15px;
    font-weight: 900;
    line-height: 1.45;
}

.egg-auto-batch,
.egg-save-status {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7f8f4;
    color: var(--muted);
    font-size: 16px;
    font-weight: 900;
    line-height: 1.45;
}

.egg-auto-batch strong {
    display: block;
    color: var(--ink);
    font-size: 22px;
}

.egg-batch-select-wrap {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.egg-batch-select-wrap[hidden] {
    display: none;
}

.egg-save-status {
    text-align: center;
}

.egg-save-status.is-saving {
    color: #9a6d12;
    background: #fff9e7;
}

.egg-save-status.is-saved {
    color: var(--green);
    background: #e8f3ed;
}

.egg-save-status.is-error {
    color: #b84036;
    background: #fff1ef;
}

.quick-qty {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.egg-submit {
    min-height: 72px;
    font-size: 26px;
}

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

.egg-summary-grid article {
    min-height: 102px;
    display: grid;
    align-content: center;
    padding: 16px;
}

.egg-summary-grid span {
    font-size: 36px;
    font-weight: 950;
}

.egg-summary-grid p {
    margin: 6px 0 0;
    color: var(--muted);
    font-weight: 900;
}

.egg-record-list {
    margin-top: 4px;
}

.egg-record-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
}

.egg-record-card p,
.egg-record-card small {
    margin: 6px 0 0;
    color: var(--muted);
    font-weight: 850;
}

.egg-record-card .egg-record-qty {
    color: var(--ink);
    font-size: 26px;
    font-weight: 950;
}

.egg-slot-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.egg-slot-summary span {
    padding: 5px 8px;
    border-radius: 999px;
    background: #f7f8f4;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.egg-record-card span {
    padding: 7px 10px;
    border-radius: 999px;
    background: #e8f3ed;
    color: var(--green);
    font-weight: 950;
    white-space: nowrap;
}

.egg-chart-section {
    margin-top: 14px;
}

.egg-chart-panel {
    height: 340px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
}

.egg-chart-panel canvas {
    width: 100%;
    height: 100%;
}

.chart-note {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 850;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 18px;
    z-index: 30;
    transform: translate(-50%, 16px);
    max-width: min(460px, calc(100% - 28px));
    padding: 12px 14px;
    border-radius: 8px;
    background: #1f2a22;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

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

@media (min-width: 760px) {
    .app-shell {
        padding: 26px 24px 96px;
    }

    .action-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }

    .action-card:nth-child(3) {
        grid-column: 1 / -1;
    }

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

    .batch-card {
        grid-template-columns: minmax(220px, 0.9fr) minmax(460px, 1.5fr) minmax(220px, 0.8fr);
        align-items: start;
    }

    .batch-meta {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .production-data-grid {
        grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
        align-items: start;
    }

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

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

@media (max-width: 640px) {
    .egg-summary-grid {
        grid-template-columns: 1fr;
    }

    .egg-product-grid {
        grid-template-columns: 1fr;
    }

    .egg-slot-grid {
        grid-template-columns: 1fr;
    }

    .egg-record-card {
        display: grid;
    }

    .egg-chart-panel {
        height: 300px;
    }
}

@media print {
    body.printing-production-report {
        background: #ffffff;
    }

    body.printing-production-report .topbar,
    body.printing-production-report .notice-card,
    body.printing-production-report .action-grid,
    body.printing-production-report .batch-section,
    body.printing-production-report .production-data-grid > article:first-child,
    body.printing-production-report .toast {
        display: none !important;
    }

    body.printing-production-report .app-shell {
        width: 100%;
        padding: 0;
    }

    body.printing-production-report .production-data-grid {
        display: block;
        margin: 0;
    }

    body.printing-production-report .production-data-grid > article {
        display: grid !important;
        border: 0;
        box-shadow: none;
    }
}
