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

body.is-modal-open { overflow: hidden; }

.quote-shell {
    width: min(1760px, 100%);
    margin: 0 auto;
    padding: 18px 14px 90px;
}

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

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

.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: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 14px;
    background: var(--panel);
    color: var(--green);
    cursor: pointer;
    font-size: 16px;
    font-weight: 950;
    text-decoration: none;
}

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

.btn.small {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 14px;
}

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

h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-size: 42px; line-height: 1.05; }
h2 { margin: 0; font-size: 22px; }

.notice-card,
.quote-panel,
.product-panel,
.quote-list-card,
.quote-product-card,
.share-dialog,
.public-quote-sheet,
.error-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(--green);
}

.notice-card span {
    color: var(--muted);
    font-weight: 800;
    line-height: 1.5;
}

.quote-layout {
    display: grid;
    grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.quote-panel,
.product-panel {
    min-width: 0;
    padding: 14px;
}

.quote-form,
.quote-list,
.product-panel,
.quote-product-card,
.share-dialog {
    display: grid;
    gap: 12px;
}

.form-grid,
.product-tools,
.price-grid,
.quote-price-row {
    display: grid;
    gap: 10px;
}

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

.product-tools {
    grid-template-columns: minmax(220px, 1fr) minmax(140px, 160px) minmax(96px, 120px);
    align-items: end;
}

.product-tools > *,
.quote-product-card > *,
.price-grid,
.quote-price-row,
.product-check,
.summary-card {
    min-width: 0;
}

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

input,
select,
textarea {
    width: 100%;
    min-height: 46px;
    border: 1px solid #cbd8c8;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 16px;
    font-weight: 850;
}

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

.toggle-row {
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
}

.toggle-row small {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.toggle-row input {
    width: 22px;
    height: 22px;
    min-height: 22px;
}

.quote-list-card {
    margin-top: 14px;
    padding: 12px;
}

.quote-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    align-items: stretch;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
    padding: 6px;
}

.quote-card.is-active {
    border-color: var(--green);
    box-shadow: inset 4px 0 0 var(--green);
}

.quote-card-main {
    min-width: 0;
    border: 0;
    padding: 12px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
}

.quote-link-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: 0 6px 6px;
}

.quote-link-actions a,
.quote-link-actions button:not(.icon-dot) {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 10px;
    background: #fff;
    color: var(--green);
    cursor: pointer;
    font-size: 14px;
    font-weight: 950;
    text-decoration: none;
}

.quote-link-actions a:hover,
.quote-link-actions button:not(.icon-dot):hover {
    border-color: var(--green);
    background: #eef7f0;
}

.quote-card-main strong,
.quote-card-main span,
.quote-card-main small {
    display: block;
}

.quote-card-main strong { font-size: 17px; }
.quote-card-main span { margin-top: 3px; font-size: 20px; font-weight: 950; }
.quote-card-main small { margin-top: 5px; color: var(--muted); font-weight: 850; }

.icon-dot {
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    font-size: 22px;
    font-weight: 950;
    line-height: 1;
}

.summary-card {
    min-height: 64px;
    display: grid;
    align-content: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
}

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

.summary-card strong {
    font-size: 30px;
    line-height: 1;
}

.quote-product-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.quote-product-card {
    grid-template-columns: minmax(190px, 1.35fr) minmax(170px, 0.85fr) minmax(112px, 0.5fr) minmax(230px, 1.05fr);
    align-items: center;
    padding: 10px 12px;
    border-left: 5px solid transparent;
}

.quote-product-card.is-selected {
    border-color: var(--green);
    background: #fbfffb;
}

.product-check {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    color: var(--ink);
}

.product-check input {
    width: 22px;
    height: 22px;
    min-height: 22px;
    margin-top: 3px;
}

.product-check strong,
.product-check small {
    display: block;
}

.product-check strong {
    font-size: 18px;
    line-height: 1.2;
}

.product-check small {
    margin-top: 3px;
    color: var(--muted);
    font-weight: 850;
}

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

.price-grid div {
    padding: 7px 8px;
    border-radius: 8px;
    background: var(--soft);
}

.price-grid span,
.customer-price.is-empty {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
}

.price-grid b {
    display: block;
    margin-top: 2px;
    font-size: 16px;
}

.customer-price {
    min-height: 38px;
    border: 1px solid #c8decf;
    border-radius: 8px;
    background: #edf7f0;
    color: var(--green);
    cursor: pointer;
    padding: 0 10px;
    font-weight: 950;
}

.customer-price.is-empty {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 10px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #fff;
}

.quote-price-row {
    grid-template-columns: minmax(0, 1fr) 120px;
    align-items: end;
    gap: 8px;
}

.item-note {
    grid-column: 1 / -1;
    min-height: 40px;
}

.empty-card {
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #fff;
    font-weight: 900;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(20, 28, 22, .36);
}

.modal-backdrop[hidden] {
    display: none;
}

.share-dialog {
    width: min(560px, 100%);
    padding: 16px;
}

.icon-btn {
    width: 48px;
    height: 48px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    font-size: 30px;
    line-height: 1;
}

.share-result {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
}

.share-result p {
    margin: 0;
    overflow-wrap: anywhere;
    font-weight: 850;
}

.public-quote-body {
    background: #eef1eb;
}

.public-quote-sheet {
    width: min(920px, calc(100% - 24px));
    margin: 18px auto;
    padding: 24px;
}

.public-quote-head,
.public-quote-customer,
.public-quote-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.quote-meta {
    display: grid;
    align-content: start;
    justify-items: end;
    gap: 4px;
    color: var(--muted);
    font-weight: 900;
}

.quote-meta strong {
    color: var(--ink);
    font-size: 20px;
}

.public-quote-customer {
    margin: 18px 0;
    padding: 14px;
    border-radius: 8px;
    background: var(--soft);
}

.public-quote-customer div {
    display: grid;
    gap: 4px;
}

.public-quote-customer span {
    color: var(--muted);
    font-weight: 900;
}

.public-quote-customer strong {
    font-size: 22px;
}

.public-note {
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-weight: 850;
    line-height: 1.65;
}

.public-quote-table {
    width: 100%;
    border-collapse: collapse;
}

.public-quote-table th,
.public-quote-table td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.public-quote-table th {
    background: #edf4eb;
    color: var(--muted);
    font-weight: 950;
}

.num {
    text-align: right !important;
    white-space: nowrap;
}

.public-quote-footer {
    align-items: center;
    margin-top: 20px;
    color: var(--muted);
    font-weight: 850;
}

@media (max-width: 1180px) {
    .quote-layout { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .quote-shell { padding: 14px 10px 80px; }
    .quote-topbar { flex-wrap: wrap; }
    .quick-links { width: 100%; justify-content: flex-start; }
    h1 { font-size: 34px; }
    .product-tools { grid-template-columns: 1fr; }
    .quote-product-grid { grid-template-columns: 1fr; gap: 12px; }
    .quote-product-card {
        grid-template-columns: 1fr;
        align-items: stretch;
        padding: 12px;
    }
    .product-check {
        align-items: start;
    }
    .price-grid {
        gap: 10px;
    }
}

@media (max-width: 560px) {
    .form-grid,
    .price-grid,
    .quote-price-row,
    .public-quote-head,
    .public-quote-customer,
    .public-quote-footer,
    .share-actions {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }
    .quote-meta { justify-items: start; }
}

@media print {
    body { background: #fff; }
    .public-quote-sheet {
        width: 100%;
        margin: 0;
        border: 0;
        box-shadow: none;
    }
    .no-print { display: none !important; }
}
