:root {
    --ink: #18202a;
    --muted: #617084;
    --line: #f1d7c8;
    --paper: #fffaf5;
    --panel: #ffffff;
    --brand: #e95716;
    --brand-dark: #c93d12;
    --brand-deep: #a73514;
    --accent: #ff8b2c;
    --rose: #fff0eb;
    --cyan: #fff4df;
    --lilac: #f7edf0;
    --mint: #fff7ea;
    --cream: #fff1da;
    --blue: #eef6f8;
    --shadow: 0 18px 50px rgb(174 77 23 / 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgb(255 250 245 / 0.96), rgb(255 253 250 / 0.98)),
        radial-gradient(circle at top left, rgb(244 104 28 / 0.1), transparent 36rem);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
    font: inherit;
}

.page-header {
    padding: 18px 0;
}

.topbar,
.layout {
    width: min(1440px, 100%);
    margin: 0 auto;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 clamp(16px, 3vw, 40px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.brand img {
    width: 54px;
    height: 54px;
    object-fit: contain;
    border-radius: 50%;
}

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

.brand strong {
    font-size: 1.05rem;
}

.brand small {
    color: var(--muted);
    margin-top: 2px;
}

.panel-kicker {
    margin: 0 0 8px;
    color: var(--brand-dark);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.total-card {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 16px;
}

.total-card span,
.total-card small {
    display: block;
}

.total-card strong {
    display: block;
    margin: 8px 0 4px;
    font-size: 1.8rem;
    line-height: 1;
}

.layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 22px;
    padding: 0 clamp(16px, 3vw, 40px) 44px;
    align-items: start;
}

.summary-panel,
.sheet-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.summary-panel {
    position: sticky;
    top: 18px;
    padding: 20px;
}

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

.summary-head h2 {
    margin: 0;
}

.summary-head .panel-kicker {
    color: var(--brand);
}

.ghost-button,
.primary-button,
.secondary-button,
.quick-actions button {
    min-height: 40px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}

.ghost-button {
    padding: 7px 12px;
}

.primary-button {
    width: 100%;
    margin-top: 16px;
    border-color: var(--brand);
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    font-weight: 700;
}

.secondary-button {
    width: 100%;
    margin-top: 10px;
    border-color: var(--brand);
    background: #fff;
    color: var(--brand-dark);
    font-weight: 700;
}

.total-card {
    margin: 18px 0;
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
}

.selected-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 43vh;
    overflow: auto;
}

.selected-list li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.selected-list b {
    display: block;
    font-size: 0.95rem;
}

.selected-list small,
.empty-selected,
.price-note {
    color: var(--muted);
}

.selected-list button {
    width: 30px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.empty-selected {
    margin: 22px 0;
    line-height: 1.7;
}

.price-note {
    margin: 14px 0 0;
    font-size: 0.84rem;
    line-height: 1.6;
}

.sheet-panel {
    padding: clamp(16px, 2vw, 24px);
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 220px;
    gap: 14px;
    margin-bottom: 14px;
}

.search-box,
.category-box {
    display: grid;
    gap: 7px;
}

.search-box span,
.category-box span {
    color: var(--brand-dark);
    font-size: 0.86rem;
    font-weight: 700;
}

.search-box input,
.category-box select {
    width: 100%;
    height: 46px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 0 13px;
    color: var(--ink);
}

.quick-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.quick-actions button {
    padding: 0 13px;
}

.quick-actions span {
    color: var(--muted);
    margin-left: auto;
}

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

.category-section {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.category-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid rgb(174 77 23 / 0.13);
}

.category-title h2 {
    margin: 0;
    font-size: 1.05rem;
}

.category-title span {
    color: rgb(24 32 42 / 0.7);
    font-size: 0.9rem;
}

.item-list {
    display: grid;
}

.item-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    min-height: 54px;
    padding: 10px 12px;
    border-top: 1px solid rgb(174 77 23 / 0.12);
    cursor: pointer;
}

.item-row:first-child {
    border-top: 0;
}

.item-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
}

.item-name {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    min-width: 0;
    line-height: 1.45;
}

.item-name span {
    overflow-wrap: anywhere;
}

.item-price {
    color: #111827;
    font-weight: 800;
    white-space: nowrap;
}

.category-section[data-tone="rose"] .category-title,
.category-section[data-tone="rose"] .item-row {
    background: var(--rose);
}

.category-section[data-tone="cyan"] .category-title,
.category-section[data-tone="cyan"] .item-row {
    background: var(--cyan);
}

.category-section[data-tone="lilac"] .category-title,
.category-section[data-tone="lilac"] .item-row {
    background: var(--lilac);
}

.category-section[data-tone="mint"] .category-title,
.category-section[data-tone="mint"] .item-row {
    background: var(--mint);
}

.category-section[data-tone="cream"] .category-title,
.category-section[data-tone="cream"] .item-row {
    background: var(--cream);
}

.category-section[data-tone="blue"] .category-title,
.category-section[data-tone="blue"] .item-row {
    background: var(--blue);
}

.item-row:has(input:checked) {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
    background: #fff8ef !important;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    pointer-events: none;
    padding: 10px 16px;
    border-radius: 8px;
    color: #fff;
    background: rgb(24 32 42 / 0.92);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

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

/* 浮动合计 —— 桌面宽屏与手机竖屏常驻右下角 */
.floating-total {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 40;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 9px 15px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    box-shadow: 0 10px 24px rgb(174 77 23 / 0.34);
    cursor: pointer;
    line-height: 1;
    transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.floating-total:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgb(174 77 23 / 0.42);
}

.floating-total-amount {
    font-size: 1rem;
    font-weight: 800;
}

.floating-total-count {
    padding-left: 9px;
    border-left: 1px solid rgb(255 255 255 / 0.45);
    font-size: 0.74rem;
    opacity: 0.92;
}

.floating-total.is-empty {
    opacity: 0.55;
    box-shadow: 0 6px 16px rgb(174 77 23 / 0.2);
}

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

    .summary-panel {
        position: static;
        order: 2;
    }
}

@media (max-width: 760px) {
    .page-header {
        padding-top: 12px;
    }

    .topbar {
        align-items: flex-start;
    }

    .brand img {
        width: 46px;
        height: 46px;
    }
    .toolbar,
    .category-grid {
        grid-template-columns: 1fr;
    }

    .quick-actions span {
        width: 100%;
        margin-left: 0;
    }

    .floating-total {
        right: 14px;
        bottom: 14px;
        padding: 8px 13px;
        gap: 8px;
    }

    .floating-total-amount {
        font-size: 0.95rem;
    }

    .floating-total-count {
        padding-left: 8px;
        font-size: 0.7rem;
    }

    /* 窄屏下让 toast 上移，避开右下角浮动合计 */
    .toast {
        bottom: 64px;
    }

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