* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overscroll-behavior-y: none;
    overscroll-behavior-x: none;
    /* Hide scrollbar for Chrome, Safari and Opera */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE and Edge */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    background-color: #ffffff;
    color: #000000;
    font-size: 14px;
}

/* 标题栏 */
.header {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    padding: 6px 12px;
    border-bottom: none;
    position: sticky;
    top: 0;
    z-index: 100;
    margin: 0;
}

.header-content {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 4px;
}

.header-menu {
    margin-left: auto;
}

.header-menu {
    position: relative;
}

.header-menu-trigger {
    font-size: 18px;
    line-height: 1;
    padding: 1px 6px;
    border: 1px solid rgba(0,0,0,0.3);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    color: #000;
    letter-spacing: 1px;
}

.header-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 130px;
    overflow: hidden;
}

.header-menu-dropdown.open {
    display: block;
}

.header-menu-item {
    display: block;
    width: 100%;
    padding: 8px 14px;
    text-align: left;
    font-size: 13px;
    background: none;
    border: none;
    cursor: pointer;
    color: #000000;
    text-decoration: none;
    white-space: nowrap;
}

.header-menu-item:hover {
    background: rgba(0,0,0,0.06);
}

.header-menu-item:disabled,
.header-menu-item.is-disabled {
    color: rgba(0,0,0,0.35);
    cursor: not-allowed;
}
.header-menu-item:disabled:hover,
.header-menu-item.is-disabled:hover { background: none; }

.header-menu-user {
    padding: 8px 14px 6px;
    font-size: 12px;
    color: rgba(0,0,0,0.4);
    white-space: nowrap;
}

.header-menu-divider {
    height: 1px;
    background: #eee;
    margin: 2px 0;
}

.header h1 {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: #000000;
    letter-spacing: 1px;
}

.session-info-text {
    font-size: 12px;
    color: rgba(0, 0, 0, 0.9);
    white-space: nowrap;
}

/* 控制区 */
.controls {
    background: #ffffff;
    padding: 5px 12px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 99;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    margin: 0;
    box-shadow: none;
    overflow-x: auto;
}

.tabs {
    display: flex;
    gap: 3px;
}

.tab-btn {
    padding: 4px 10px;
    border: 1px solid rgba(0,0,0,0.08);
    background: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-weight: 500;
    color: rgba(0,0,0,0.5);
}

.tab-btn:hover {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
}

.tab-btn.active {
    background: #f5f5f5;
    color: #000;
    border-color: rgba(0,0,0,0.12);
    box-shadow: none;
}

.tab-count {
    font-size: 10px;
    opacity: 0.7;
    margin-left: 2px;
}

.filter-group, .sort-group {
    display: flex;
    gap: 3px;
}

.filter-btn, .sort-btn {
    padding: 4px 10px;
    border: 1px solid rgba(0,0,0,0.08);
    background: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    white-space: nowrap;
    color: rgba(0,0,0,0.5);
    font-weight: 500;
}

.filter-btn:hover, .sort-btn:hover {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
}

.filter-btn.active, .sort-btn.active {
    background: #f5f5f5;
    color: #000;
    border-color: rgba(0,0,0,0.12);
    box-shadow: none;
}

.filter-btn:disabled, .sort-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #ffffff;
}

.filter-btn:disabled.active, .sort-btn:disabled.active {
    background: #f0f0f0;
    border-color: #3a3a3c;
}

.search-group {
    flex: 1;
    min-width: 120px;
}

.search-input {
    width: 100%;
    padding: 4px 10px;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 6px;
    font-size: 12px;
    background: #ffffff;
    color: #000000;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.arrangement-controls {
    display: none;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
    flex-shrink: 0;
    white-space: nowrap;
    min-width: fit-content;
    width: auto;
}

.arrangement-controls[style*="display: block"],
.arrangement-controls[style*="display:flex"] {
    display: flex !important;
}

.arrangement-controls > * {
    flex-shrink: 0;
    flex-grow: 0;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 3px;
    background: #ffffff;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
    flex-grow: 0;
    white-space: nowrap;
    width: auto;
    min-width: auto;
}

.zoom-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    background: #ffffff;
    color: rgba(0,0,0,0.5);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.zoom-btn:hover {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
    transform: scale(1.05);
}

.zoom-btn:active {
    transform: scale(0.95);
}

.zoom-level {
    min-width: 45px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: rgba(0,0,0,0.7);
    padding: 0 6px;
    user-select: none;
}

.add-hanger-btn {
    padding: 4px 10px;
    background: #ffffff;
    color: rgba(0,0,0,0.5);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: none;
    flex-shrink: 0;
    flex-grow: 0;
    width: auto;
    min-width: auto;
}

.add-hanger-btn:hover {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
}

.export-btn {
    padding: 4px 10px;
    background: #ffffff;
    color: rgba(0,0,0,0.5);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: none;
    flex-shrink: 0;
    flex-grow: 0;
    width: auto;
    min-width: auto;
}

.export-btn:hover {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
}

.export-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 卡片展示区 */
.main-content {
    padding: 8px 0;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 1px;
}

/* Double size for inventory and live tabs */
#cardView {
    padding-left: 6px;
    padding-right: 6px;
}
#cardView .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(196px, calc(50% - 3px)), 1fr));
    column-gap: 6px;
    row-gap: 3px;
}

.card {
    width: 60px;
    height: 56px;
    background: #ffffff;
    color: #111;
    border-radius: 4px;
    padding: 2px;
    position: relative;
    cursor: pointer;
    transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1px;
    border: 1px solid rgba(0,0,0,0.12);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    /* Prevent long-press image preview on mobile */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Double size cards for inventory and live tabs */
#cardView .card {
    width: 100%;
    height: 164px;
    padding: 5px;
    gap: 3px;
    border-radius: 9px;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #cbd5e0;
}

/*
 * The arrangement canvas can itself be scaled. Transforming a child card on
 * hover makes Chromium rebuild the shared canvas layer, which softens covers
 * and can flash every card on Windows. Keep the visual highlight without
 * moving or scaling the card; HTML drag-and-drop is unaffected.
 */
.arrangement-view .card {
    transition: box-shadow 0.1s ease-out, border-color 0.1s ease-out;
}

.arrangement-view .card:hover,
.arrangement-view .card:active {
    transform: none !important;
}

.card:active {
    transform: scale(0.98);
}

.selectable-card {
    cursor: pointer !important;
    transition: all 0.2s ease;
}

.selectable-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15) !important;
    border-color: rgba(0, 0, 0, 0.3) !important;
}

.live-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 4px;
    height: 4px;
    background-color: #e53935;
    border-radius: 50%;
    z-index: 10;
}

.card-right-tags {
    position: absolute;
    bottom: 3px;
    right: 1px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    z-index: 10;
}

.suit-tag {
    position: absolute;
    bottom: 0;
    right: 0;
    background: rgba(255,255,255,0.9);
    color: #000;
    font-size: 5px;
    font-weight: bold;
    padding: 0 1px;
    border-radius: 1px;
    line-height: 1.3;
    z-index: 10;
}

/* Double size live indicator for inventory and live tabs */
#cardView .live-indicator {
    top: auto;
    bottom: 5px;
    right: 5px;
    width: 9px;
    height: 9px;
}

#cardView .card-right-tags {
    right: 6px;
}

#cardView .suit-tag {
    bottom: 2px;
    right: 2px;
    font-size: 8px;
    padding: 0 2px;
    border-radius: 2px;
}

.arrangement-view .suit-tag {
    font-size: 4px;
}

.card-highlight {
    border: 2px solid #faad14 !important;
    box-shadow: 0 0 3px rgba(250, 173, 20, 0.6) !important;
    background: #fffbe6 !important;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 12px rgba(250, 173, 20, 0.6);
    }
    50% {
        box-shadow: 0 0 20px rgba(250, 173, 20, 0.8);
    }
}

.card-highlight:hover {
    transform: translateY(-2px) scale(1.05) !important;
}

.card-found-highlight {
    border: 3px solid #30d158 !important;
    box-shadow: 0 0 20px rgba(48, 209, 88, 0.8) !important;
    background: #f6ffed !important;
    animation: found-pulse 0.5s ease-in-out 3;
    z-index: 100 !important;
}

@keyframes found-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(48, 209, 88, 0.8);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 30px rgba(48, 209, 88, 1);
    }
}

.card-image {
    width: 100%;
    background: #ffffff;
    border-radius: 3px;
    object-fit: cover;
    object-position: center;
    flex-shrink: 0;
    /* Prevent long-press image preview on mobile */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none; /* Prevent direct interaction with image */
}

/* Double size image for inventory and live tabs */
#cardView .card-image {
    height: 113px;
    border-radius: 6px;
}

.card-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1px;
    margin: 0;
}

.card-info--new {
    background: #e53935 !important;
    color: #000 !important;
    border-radius: 2px;
}

.card-info--new .card-name,
.card-info--new .card-id {
    color: #000 !important;
}

/* Double size info spacing for inventory and live tabs */
#cardView .card-info {
    gap: 3px;
}

.card-name {
    font-size: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

/* Double size text for inventory and live tabs */
#cardView .card-name {
    font-size: 10px;
}

.card-id {
    font-size: 6px;
    color: rgba(0,0,0,0.55);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Double size text for inventory and live tabs */
#cardView .card-id {
    font-size: 9px;
}

.card-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 4px;
    font-weight: 700;
    gap: 2px;
    margin: 0;
}

/* Double size stats for inventory and live tabs */
#cardView .card-stats {
    font-size: 9px;
    gap: 3px;
}

.card-stats-left {
    display: flex;
    gap: 1px;
    flex: 1;
    align-items: center;
}

/* Double size gap for inventory and live tabs */
#cardView .card-stats-left {
    gap: 3px;
}

.separator {
    color: #ccc;
}

#cardView.tab--inventory .show-count,
#cardView.tab--inventory .sales-count,
#cardView.tab--inventory .separator {
    display: none;
}

.show-count {
    color: #111;
}

.sales-count {
    color: rgba(0, 0, 0, 0.65);
}

.stock-count {
    color: #2e7d32;
}

.stock-count.is-negative {
    color: #c0392b;
    font-weight: 600;
}

.stock-count-neg {
    color: #c0392b;
    font-weight: 600;
}

/* Card info in addCardGrid modal - positioned at top with black background */
#addCardGrid .card-info {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 2px 4px;
    margin: 0;
    font-size: 7px;
    z-index: 1;
}

#addCardGrid .card-name,
#addCardGrid .card-id {
    color: white;
}

/* Card stats in addCardGrid modal - positioned at bottom with black background */
#addCardGrid .selectable-card {
    position: relative;
}

#addCardGrid .card-stats {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(247, 243, 243, 0.75);
    color: rgb(18, 17, 17);
    padding: 2px 4px;
    margin: 0;
    font-size: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#addCardGrid .card-stats-left {
    display: flex;
    gap: 2px;
    align-items: center;
}

#addCardGrid .separator {
    color: rgba(0, 0, 0, 0.5);
}

#addCardGrid .show-count,
#addCardGrid .sales-count,
#addCardGrid .stock-count:not(.is-negative) {
    color: rgb(11, 11, 11);
}

/* Card in hanger-grid */
.hanger-grid .card {
    position: relative;
}

/* Card info in hanger-grid - positioned at top with black gradient */
.hanger-grid .card-info {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.85), rgba(255,255,255,0.6));
    color: #000;
    padding: 2px 4px;
    margin: 0;
    font-size: 7px;
    z-index: 1;
}

.hanger-grid .card-name {
    color: #000;
}
.hanger-grid .card-id {
    color: rgba(0,0,0,0.75);
}

.hanger-grid .card-stats {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(255,255,255,0.85), rgba(255,255,255,0.6));
    color: #000;
    padding: 2px 4px;
    margin: 0;
    font-size: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hanger-grid .card-stats-left {
    display: flex;
    gap: 2px;
    align-items: center;
}

.hanger-grid .separator {
    color: rgba(0, 0, 0, 0.45);
}

.hanger-grid .show-count,
.hanger-grid .sales-count {
    color: #000;
}
.hanger-grid .stock-count:not(.is-negative) {
    color: #000;
}


/* Double size presale tag for inventory and live tabs */
#cardView .presale-tag {
    padding: 1px 1px;
    border-radius: 2px;
    font-size: 6px;
}

.presale-tag.presale {
    background: linear-gradient(135deg, #90cdf4 0%, #63b3ed 100%);
    color: #1a365d;
}

.presale-tag.available {
    background: linear-gradient(135deg, #9ae6b4 0%, #68d391 100%);
    color: #22543d;
}

.card-menu-btn {
    position: absolute;
    top: 1px;
    right: 1px;
    background: rgba(255, 255, 255, 0.8);
    border: none;
    border-radius: 2px;
    padding: 1px 3px;
    cursor: pointer;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}

/* Double size menu button for inventory and live tabs */
#cardView .card-menu-btn {
    top: 3px;
    right: 3px;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 18px;
}

.card:hover .card-menu-btn {
    opacity: 1;
}

.card-menu-dropdown {
    position: absolute;
    top: 20px;
    right: 1px;
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    z-index: 100;
    min-width: 80px;
}

#cardView .card-menu-dropdown {
    top: 29px;
    right: 3px;
    min-width: 100px;
}

.card-menu-dropdown.show {
    display: flex;
}

.card-menu-item {
    background: #ffffff;
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

#cardView .card-menu-item {
    padding: 7px 13px;
    font-size: 13px;
}

.card-menu-item:last-child {
    border-bottom: none;
}

.card-menu-item:hover {
    background: #f0f0f0;
}

.card-menu-item.delete {
    color: #ff4d4f;
}

.card-menu-item.debug {
    color: rgba(0, 0, 0, 0.7);
}

.card-delete-btn {
    position: absolute;
    top: 14px;
    right: 1px;
    background: #ff4d4f;
    color: #000;
    border: none;
    border-radius: 2px;
    padding: 1px 4px;
    cursor: pointer;
    font-size: 8px;
    display: none;
}

/* Double size delete button for inventory and live tabs */
#cardView .card-delete-btn {
    top: 29px;
    right: 3px;
    border-radius: 4px;
    padding: 3px 9px;
    font-size: 13px;
}

.card-delete-btn.show {
    display: block;
}

/* 空槽位样式 */
.empty-slot {
    width: 60px;
    height: 56px;
    background: rgba(0, 0, 0, 0.02);
    border: 1px dashed rgba(0,0,0,0.15);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-slot:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.empty-slot-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.empty-slot-plus {
    font-size: 24px;
    font-weight: 300;
    color: #a0aec0;
    transition: all 0.3s ease;
}

.empty-slot:hover .empty-slot-plus {
    color: rgba(0, 0, 0, 0.7);
    transform: scale(1.2);
}

/* 拖拽状态样式 */
.card[draggable="true"] {
    cursor: grab;
}

.card[draggable="true"]:active {
    cursor: grabbing;
}

.card.dragging {
    opacity: 0.3;
    transform: scale(0.95);
    cursor: grabbing;
}

.touch-drag-ghost {
    border-radius: 6px;
    overflow: hidden;
    transition: none;
}

/* Drop target highlight */
.slot-drop-target {
    outline: 2px dashed rgba(255, 255, 255, 0.3);
    outline-offset: -2px;
    background: rgba(255, 255, 255, 0.06) !important;
    border-radius: 4px;
}

/* Poof animation when card is removed by dragging out */
.card-poof {
    animation: poof 0.3s ease-out forwards;
    pointer-events: none;
}

@keyframes poof {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    30% {
        opacity: 0.7;
        transform: scale(1.08) rotate(2deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.3) rotate(-5deg);
    }
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    padding: 12px;
}

.page-btn {
    padding: 6px 12px;
    border: 1px solid rgba(0,0,0,0.08);
    background: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: rgba(0,0,0,0.5);
    font-weight: 500;
    transition: all 0.2s ease;
}

.page-btn:hover {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
}

.page-btn.active {
    background: #f5f5f5;
    color: #000;
    border-color: rgba(0,0,0,0.12);
}

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

/* 加载指示器 */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    gap: 12px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-size: 14px;
    color: rgba(0,0,0,0.4);
    font-weight: 500;
}

/* 排款画布 */
.arrangement-view {
    height: calc(100dvh - 50px);
    min-height: 400px;
    background: #ffffff;
    position: relative;
    overflow: auto;
    margin: -8px 0;
    width: 100%;
    /* Show scrollbar for arrangement view */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #c0c0c0 #f0f0f0; /* Firefox */
    /* Allow only panning, disable browser zoom (custom pinch-zoom handled by JS) */
    touch-action: pan-x pan-y;
    overscroll-behavior: contain;
}

/* Webkit scrollbar styles for arrangement view */
.arrangement-view::-webkit-scrollbar {
    width: 12px;
    height: 12px;
    display: block; /* Override global hide */
}

.arrangement-view::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 10px;
}

.arrangement-view::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 10px;
    border: 2px solid #f0f0f0;
}

.arrangement-view::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

.canvas {
    min-width: 100%;
    min-height: 100%;
    position: relative;
    cursor: grab;
    background: #ffffff;
}

.canvas:active {
    cursor: grabbing;
}

.hanger {
    position: absolute;
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 4px;
    padding: 33px 1px 1px 1px;
    min-width: 186px;
    user-select: none;
    -webkit-user-select: none;
    content-visibility: auto;
    contain-intrinsic-size: 200px 160px;
}

.hanger.dragging {
    opacity: 0.6;
    cursor: move;
}


.hanger-focused {
    border: 3px solid #30d158 !important;
    box-shadow: 0 0 20px rgba(48, 209, 88, 0.5) !important;
    animation: hanger-pulse 0.6s ease-in-out 2;
    z-index: 50 !important;
}

@keyframes hanger-pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(48, 209, 88, 0.5);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 30px rgba(48, 209, 88, 0.8);
        transform: scale(1.02);
    }
}

.hanger-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
    background: #f0f0f0;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    cursor: move;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.hanger-title {
    font-size: 12px;
    font-weight: 500;
}

.hanger-header-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
}

.hanger-add-btn {
    background: transparent;
    color: #000000;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 3px;
    line-height: 1;
    transition: all 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.hanger-add-btn:hover {
    background: rgba(255,255,255,0.1);
    transform: scale(1.1);
}

.hanger-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    color: #000000;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.hanger-menu-dropdown {
    position: absolute;
    top: 24px;
    right: 8px;
    background: #ffffff;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 10;
    display: none;
    overflow: hidden;
}

.hanger-menu-dropdown.show {
    display: flex;
    flex-direction: column;
}

.hanger-menu-dropdown button {
    border: none;
    background: #ffffff;
    padding: 6px 16px;
    font-size: 12px;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}

.hanger-menu-dropdown button:hover {
    background: #f0f0f0;
}

.hanger-lock-btn {
    color: #fa8c16;
}

.hanger-edit-btn {
    color: rgba(0, 0, 0, 0.7);
}

.hanger-delete-btn {
    color: #ff4d4f;
}

.hanger--locked .hanger-header {
    cursor: default;
}

.hanger-lock-icon {
    font-size: 10px;
}

.hanger-grid {
    display: grid;
    gap: 2px;
    margin-top: 16px;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

/* Sidebar mode for multi-select (right side) */
.modal.modal-sidebar {
    background: rgba(0, 0, 0, 0.2);
    justify-content: flex-end;
    align-items: stretch;
}

.modal.modal-sidebar .modal-content {
    width: 450px;
    max-width: 450px;
    height: 100%;
    border-radius: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.modal.modal-sidebar .modal-content h3 {
    flex-shrink: 0;
}

.modal.modal-sidebar .modal-content .form-group,
.modal.modal-sidebar .modal-content .modal-filter-group,
.modal.modal-sidebar .modal-content .capacity-info {
    flex-shrink: 0;
}

.modal.modal-sidebar .modal-content #addCardGrid {
    flex: 1;
    overflow-y: auto;
    max-height: none !important;
}

.modal.modal-sidebar .modal-actions {
    flex-shrink: 0;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.modal-content {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    position: relative;
}

.modal-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    font-size: 20px;
    line-height: 32px;
    text-align: center;
    cursor: pointer;
    color: rgba(0,0,0,0.5);
    z-index: 10;
    padding: 0;
}

.modal-close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #000000;
}

.modal-content.modal-large {
    max-width: 800px;
}

/* Debug data modal */
.debug-data-container {
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 4px;
    padding: 12px;
    max-height: 500px;
    overflow: auto;
    overscroll-behavior: contain;
    margin-bottom: 12px;
}

.debug-data-container pre {
    margin: 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: rgba(0,0,0,0.8);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.modal-content h3 {
    margin-bottom: 16px;
    font-size: 16px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: rgba(0,0,0,0.5);
}

.form-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 4px;
    font-size: 14px;
    background: #ffffff;
    color: #000000;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* 弹窗内的过滤按钮组 */
.modal-filter-group {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px;
    background: #ffffff;
    border-radius: 8px;
}

.modal-filter-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(0,0,0,0.08);
    background: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-weight: 500;
    color: rgba(0,0,0,0.5);
}

.modal-filter-btn:hover {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
}

.modal-filter-btn.active {
    background: #f5f5f5;
    color: #000;
    border-color: rgba(0,0,0,0.12);
    box-shadow: none;
}

/* 排序组 */
.modal-sort-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px;
    background: #ffffff;
    border-radius: 8px;
}

.modal-sort-group label {
    font-size: 13px;
    font-weight: 500;
    color: rgba(0,0,0,0.7);
    margin: 0;
}

.sort-select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid rgba(0,0,0,0.08);
    background: #ffffff;
    border-radius: 6px;
    font-size: 13px;
    color: rgba(0,0,0,0.7);
    cursor: pointer;
    transition: all 0.3s ease;
}

.sort-select:hover {
    border-color: #cbd5e0;
}

.sort-select:focus {
    outline: none;
    border-color: rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

/* 容量信息 */
.capacity-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin: 0 8px 12px 8px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    font-size: 13px;
    color: rgba(0, 0, 0, 0.7);
    transition: all 0.3s ease;
}

.capacity-info.capacity-full {
    background: #ffffff;
    border-color: rgba(250, 140, 22, 0.35);
    color: #fa8c16;
}

.capacity-info strong {
    font-size: 15px;
    font-weight: 700;
    color: #000;
}

.capacity-remaining {
    color: #30d158;
}

.capacity-info.capacity-full .capacity-remaining,
.capacity-info.capacity-full strong {
    color: #fa8c16;
}

/* 卡片详情弹窗 */
.modal-content.modal-card-detail {
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
}

#cardDetailModal .modal-close-btn {
    top: 10px;
    right: 10px;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.12);
    color: rgba(0, 0, 0, 0.72);
    font-size: 28px;
    line-height: 1;
    border-radius: 24px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

#cardDetailModal .modal-close-btn:hover,
#cardDetailModal .modal-close-btn:focus-visible {
    background: rgba(0, 0, 0, 0.14);
    color: #000;
    outline: none;
}

.card-detail-body {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
}

.card-detail-image {
    flex-shrink: 0;
    width: 200px;
    height: 200px;
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-detail-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.card-detail-image img:hover {
    opacity: 0.85;
    transform: scale(1.02);
}

.card-detail-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.detail-label {
    font-weight: 600;
    color: rgba(0,0,0,0.5);
    min-width: 80px;
    flex-shrink: 0;
}

.detail-value {
    color: #000000;
    flex: 1;
    word-break: break-word;
}

/* 套装组件标签页 */
#cardDetailSuitTabs {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.suit-tabs-nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.suit-tab-btn {
    padding: 4px 14px;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 16px;
    background: #ffffff;
    color: rgba(0,0,0,0.5);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suit-tab-btn:hover {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
}

.suit-tab-btn.active {
    background: #f5f5f5;
    color: #000;
    border-color: rgba(0,0,0,0.12);
}

.suit-tab-panel { display: none; }
.suit-tab-panel.active { display: block; }

.suit-tab-panel h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #000000;
}

/* SKU列表 */
.card-detail-sku-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.card-detail-sku-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #000000;
}

.sku-table-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 4px;
}

.sku-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.sku-table thead {
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 1;
}

.sku-table th {
    padding: 8px 12px;
    text-align: center;
    font-weight: 600;
    color: rgba(0,0,0,0.7);
    border-bottom: 2px solid rgba(255,255,255,0.08);
    white-space: nowrap;
}

.sku-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: #000000;
    text-align: center;
}

.sku-table tbody tr:hover {
    background: #ffffff;
}

.sku-table tbody tr:last-child td {
    border-bottom: none;
}

/* 移动端适配 */
@media (max-width: 600px) {
    .card-detail-body {
        flex-direction: column;
        gap: 16px;
    }

    .card-detail-image {
        width: 100%;
        height: 250px;
    }

    .detail-label {
        min-width: 70px;
    }
}

/* 多选卡片样式 */
.card-selected {
    position: relative;
}

/* card-selected in addCardModal keeps same look as other cards */
#addCardGrid .card-selected {
    border: 1px solid rgba(0,0,0,0.08) !important;
    background: #ffffff !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
}

.card-selected::after {
    content: '✓';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.5);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 6px;
    font-weight: bold;
    z-index: 10;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Double size checkmark for inventory and live tabs */
#cardView .card-selected::after {
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    font-size: 12px;
}

/* Move check marks below card-info in addCardModal */
#addCardGrid .card-selected::after,
#addCardGrid .card-in-hanger::after {
    top: 14px;
}

/* Card assigned to another hanger — only check mark differs */
.card-in-hanger {
    position: relative;
}

.card-in-hanger::after {
    content: '✓';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #f5222d;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 6px;
    font-weight: bold;
    z-index: 10;
}

/* Tag showing card is on other hanger(s) */
.other-hanger-tag {
    background: #ff9800;
    color: white;
    padding: 0 3px;
    border-radius: 2px;
    font-size: 8px;
    font-weight: bold;
    line-height: 1.4;
}

/* Check badge showing hanger name on cards in modal */
.card-check-badge {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    color: white;
    font-size: 7px;
    font-weight: bold;
    text-align: center;
    padding: 2px 2px;
    z-index: 10;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-check-badge.badge-current {
    background: rgba(24, 144, 255, 0.9);
}

.card-check-badge.badge-other {
    background: rgba(245, 34, 45, 0.9);
}

.selectable-card {
    transition: all 0.2s ease;
}

.selectable-card:hover:not(.card-in-other-hanger) {
    transform: scale(1.03);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.card-in-other-hanger {
    opacity: 0.5;
    cursor: not-allowed !important;
}

.card-in-other-hanger:hover {
    opacity: 0.7;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #f5f5f5;
    color: #000;
    border: 1px solid rgba(0,0,0,0.12);
}

.btn-primary:hover {
    background: #ffffff;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #ffffff;
    color: rgba(0,0,0,0.5);
    border: 1px solid rgba(0,0,0,0.08);
}

.btn-secondary:hover {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
}

/* 拖拽效果 */
.dragging {
    opacity: 0.5;
}

.drag-over {
    border: 2px dashed rgba(255, 255, 255, 0.3);
}

/* 卡片移除状态 - 长按后准备移除 */
.card-removing {
    animation: card-remove 0.3s ease-out forwards;
    border: 2px solid #f56565 !important;
    box-shadow: 0 8px 24px rgba(245, 101, 101, 0.6) !important;
}

@keyframes card-remove {
    0% {
        transform: scale(1.05);
        opacity: 1;
    }
    50% {
        transform: scale(1.1) rotate(5deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(0.8) rotate(-5deg);
        opacity: 0;
    }
}

/* ==================== Image Viewer Modal ==================== */
.image-viewer-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.image-viewer-modal.show {
    display: block;
}

.image-viewer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

.image-viewer-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.image-viewer-close {
    position: absolute;
    top: 20px;
    right: 30px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 40px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    transition: all 0.3s ease;
    z-index: 10002;
}

.image-viewer-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(0, 0, 0, 0.5);
    transform: rotate(90deg);
}

.image-viewer-controls {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 25px;
    z-index: 10002;
}

.image-viewer-controls .zoom-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.image-viewer-controls .zoom-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(0, 0, 0, 0.5);
}

.image-viewer-controls .zoom-level {
    color: white;
    min-width: 60px;
    text-align: center;
    font-size: 14px;
}

.image-viewer-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    position: relative;
}

.image-viewer-container img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    transition: transform 0.3s ease;
    cursor: grab;
}

.image-viewer-container img:active {
    cursor: grabbing;
}

/* ========================================
   Import Progress Modal Styles
   ======================================== */

.import-progress-stages {
    margin: 20px 0;
    padding: 0;
}

.import-stage {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin: 8px 0;
    border-radius: 8px;
    background: #ffffff;
    opacity: 0.4;
    transition: all 0.3s ease;
}

.import-stage.active {
    opacity: 1;
    background: #f0f0f0;
    font-weight: 600;
    color: #000;
}

.import-stage.complete {
    opacity: 1;
    background: rgba(48, 209, 88, 0.1);
    color: rgba(0,0,0,0.7);
}

.import-stage.error {
    opacity: 1;
    background: rgba(255, 69, 58, 0.1);
    color: #ff453a;
}

.stage-icon {
    font-size: 20px;
    margin-right: 12px;
    min-width: 24px;
    text-align: center;
}

.stage-text {
    flex: 1;
    font-size: 14px;
}

.import-progress-bar {
    width: 100%;
    height: 8px;
    background: #ffffff;
    border-radius: 4px;
    overflow: hidden;
    margin: 20px 0;
}

.import-progress-fill {
    height: 100%;
    background: #30d158;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.import-progress-fill.indeterminate {
    background: linear-gradient(90deg, #2ab04a 0%, #5fe38a 50%, #2ab04a 100%);
    background-size: 200% 100%;
    animation: importBarShimmer 1.2s linear infinite;
    transition: none;
}

@keyframes importBarShimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.import-error-message {
    padding: 12px 16px;
    margin-top: 16px;
    background: rgba(255, 69, 58, 0.1);
    color: #c62828;
    border-radius: 8px;
    border-left: 4px solid #c62828;
    font-size: 14px;
    line-height: 1.5;
}

.import-success-message {
    padding: 12px 16px;
    margin-top: 16px;
    background: rgba(48, 209, 88, 0.1);
    color: #2e7d32;
    border-radius: 8px;
    border-left: 4px solid #4CAF50;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-line;
}

/* Dashboard Styles */
.dashboard-modal-content {
    background: #ffffff;
    border-radius: 12px;
    width: 95%;
    max-width: 1400px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid rgba(255,255,255,0.08);
    gap: 8px 16px;
}

.dashboard-nav-tabs {
    display: flex;
    gap: 4px;
    flex: 0 0 100%;
    order: 3;
}

.dashboard-nav-tab {
    padding: 6px 16px;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 6px;
    background: #ffffff;
    cursor: pointer;
    font-size: 13px;
    color: rgba(0,0,0,0.5);
    transition: all 0.2s ease;
}

.dashboard-nav-tab.active {
    background: #f5f5f5;
    color: #000;
    border-color: rgba(0,0,0,0.12);
}

.dashboard-nav-tab:hover:not(.active) {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
}

.dashboard-header h2 {
    margin: 0;
    color: #000000;
    font-size: 24px;
}

.dashboard-close-btn {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: rgba(0,0,0,0.5);
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.dashboard-close-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #000000;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.dashboard-stat-card {
    background: #ffffff;
    color: rgba(0,0,0,0.7);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.08);
}

.dashboard-stat-card:nth-child(2) {
    background: #ffffff;
}

.dashboard-stat-card:nth-child(3) {
    background: #ffffff;
}

.dashboard-stat-card:nth-child(4) {
    background: #ffffff;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
}

.dashboard-section {
    margin-bottom: 24px;
}

.dashboard-section h3 {
    margin: 0 0 16px 0;
    color: #000000;
    font-size: 20px;
}

.dashboard-table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.08);
}

.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}

.dashboard-table thead {
    background: #ffffff;
}

.dashboard-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: rgba(0,0,0,0.5);
    border-bottom: 2px solid rgba(255,255,255,0.08);
    white-space: nowrap;
}

.dashboard-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.dashboard-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

.dashboard-table tbody tr:last-child td {
    border-bottom: none;
}

.dashboard-btn-small {
    padding: 6px 12px;
    font-size: 12px;
    border: 1px solid rgba(0,0,0,0.08);
    background: #ffffff;
    color: rgba(0,0,0,0.5);
    border-radius: 4px;
    cursor: pointer;
    margin-right: 8px;
    transition: all 0.2s ease;
}

.dashboard-btn-small:hover {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
}

.dashboard-btn-danger {
    border-color: #f44336;
    background: #f44336;
}

.dashboard-btn-danger:hover {
    background: #d32f2f;
    border-color: #d32f2f;
}

.dashboard-btn-back {
    padding: 8px 16px;
    font-size: 14px;
    border: 1px solid rgba(0,0,0,0.08);
    background: #ffffff;
    color: rgba(0,0,0,0.5);
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.dashboard-btn-back:hover {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
}

.dashboard-products-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.dashboard-products-header h3 {
    margin: 0;
}

.dashboard-product-tabs {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.dashboard-tab-btn {
    padding: 6px 14px;
    border: 1px solid rgba(0,0,0,0.08);
    background: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-weight: 500;
    color: rgba(0,0,0,0.5);
}

.dashboard-tab-btn:hover {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
}

.dashboard-tab-btn.active {
    background: #f5f5f5;
    color: #000;
    border-color: rgba(0,0,0,0.12);
    box-shadow: none;
}

.dashboard-tab-btn span {
    font-size: 11px;
    opacity: 0.8;
    margin-left: 4px;
}

.sort-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(0,0,0,0.5);
    font-size: 12px;
    padding: 2px 4px;
    margin-left: 4px;
}

.sort-btn:hover {
    color: rgba(0, 0, 0, 0.85);
}

/* ===== Generic danger button ===== */

.btn-danger {
    flex: none;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid #e53935;
    background: transparent;
    color: #e53935;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}

.btn-danger:hover {
    background: rgba(255, 69, 58, 0.15);
}

/* ===== Arrangement History ===== */

.save-arrangement-btn,
.history-arrangement-btn,
.undo-btn,
.redo-btn {
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.08);
    background: #ffffff;
    color: rgba(0,0,0,0.5);
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.undo-btn:disabled,
.redo-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.save-arrangement-btn:hover,
.history-arrangement-btn:hover {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
}

.save-arrangement-btn.dirty {
    background: #ff9800;
    color: #000;
    font-weight: 600;
}

.save-arrangement-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* History list inside modal */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 60vh;
    max-height: 60dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 0;
}

.history-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 6px;
    background: #ffffff;
}

.history-list-item--latest {
    border-color: rgba(0, 0, 0, 0.2);
    background: #f0f0f0;
}

.history-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item-label {
    font-size: 13px;
    font-weight: 500;
}

.history-item-meta {
    font-size: 11px;
    color: rgba(0,0,0,0.4);
}

.history-item-actions {
    display: flex;
    gap: 6px;
}

.history-list-item--selected {
    border-color: #ff453a;
    background: rgba(255, 69, 58, 0.12);
}

.history-checkbox {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-right: 8px;
    cursor: pointer;
}

.history-multi-select-btn {
    margin-bottom: 8px;
    font-size: 12px;
    padding: 4px 12px;
}

.history-batch-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 8px;
    font-size: 13px;
}

.history-batch-bar .btn-danger {
    font-size: 12px;
    padding: 4px 12px;
}

.history-batch-bar .btn-secondary {
    font-size: 12px;
    padding: 4px 12px;
}

.history-loading,
.history-empty {
    text-align: center;
    color: rgba(0,0,0,0.4);
    padding: 20px;
    font-size: 13px;
}

/* Readonly banner shown above canvas during history view */
.arrangement-readonly-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    padding: 3px 8px;
    font-size: 11px;
    color: rgba(0,0,0,0.5);
    position: sticky;
    top: 0;
    z-index: 10;
}

.arrangement-readonly-banner .btn-secondary {
    flex: none;
    padding: 1px 7px;
    font-size: 11px;
    line-height: 1.6;
    border-radius: 4px;
}

/* Hanger in read-only mode — no pointer interactions */
.hanger--readonly {
    pointer-events: none;
}

.hanger--readonly .hanger-header {
    pointer-events: auto;
    cursor: default;
}

.hanger--readonly .card:not(.empty-slot) {
    pointer-events: auto;
    cursor: pointer;
}

/* Readonly empty slot */
.empty-slot--readonly {
    background: #ffffff;
    border: 1px dashed #ddd;
}

/* Toast notification */
.arrangement-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #000000;
    color: #ffffff;
    padding: 12px 26px;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.2);
    z-index: 9999;
    pointer-events: none;
}

.arrangement-toast--error {
    background: #000000;
    color: #ff6b6b;
    box-shadow: 0 6px 24px rgba(0,0,0,0.35), 0 2px 8px rgba(229,57,53,0.3);
}

/* Arrangement change notification — top center */
#arrangementChangeNotif {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    color: rgba(0,0,0,0.7);
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.08);
    font-size: 13px;
    z-index: 9999;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    max-width: 280px;
}

/* History panel tabs */
.history-panel-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.history-tab-btn {
    padding: 4px 14px;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 4px;
    background: #ffffff;
    cursor: pointer;
    font-size: 13px;
    color: rgba(0,0,0,0.5);
    transition: all 0.2s ease;
}

.history-tab-btn:hover {
    background: #f0f0f0;
    color: rgba(0,0,0,0.7);
}

.history-tab-btn.active {
    background: #f5f5f5;
    color: #000;
    border-color: rgba(0,0,0,0.12);
}

/* Ops log table */
.ops-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.ops-table th, .ops-table td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    text-align: left;
}

.ops-table th {
    background: #ffffff;
    font-weight: 600;
    color: rgba(0,0,0,0.6);
}


/* ===== Metrics (销售报表) ===== */
.metrics-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.m-btn {
    padding: 6px 14px; border: 1px solid rgba(0,0,0,0.12); border-radius: 8px;
    background: #f8f9fa; cursor: pointer; font-size: 13px; color: #000;
}
.m-btn:hover { background: #eef0f2; }
.m-btn.on { background: #0a84ff; border-color: #0a84ff; color: #fff; }
.m-btn-group { display: inline-flex; }
.m-btn-group .m-btn { border-radius: 0; border-right-width: 0; }
.m-btn-group .m-btn:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.m-btn-group .m-btn:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-right-width: 1px; }
.m-search {
    padding: 8px 12px; border: 1px solid rgba(0,0,0,0.12); border-radius: 8px;
    font-size: 14px; flex: 1; min-width: 200px; background: #fff; color: #000;
}
.m-search:focus { outline: none; border-color: rgba(0,0,0,0.3); }
.m-select {
    padding: 8px 12px; border: 1px solid rgba(0,0,0,0.12); border-radius: 8px;
    font-size: 14px; background: #fff; color: #000; cursor: pointer;
}
.m-select:focus { outline: none; border-color: rgba(0,0,0,0.3); }
.m-date {
    padding: 7px 8px; border: 1px solid rgba(0,0,0,0.12); border-radius: 8px;
    font-size: 13px; background: #fff; color: #000;
}
.m-date:focus { outline: none; border-color: rgba(0,0,0,0.3); }
.m-info { font-size: 13px; color: rgba(0,0,0,0.5); margin-left: auto; white-space: nowrap; }
.m-table-wrap {
    background: #ffffff; border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    overflow: auto; max-height: calc(90vh - 180px); max-height: calc(90dvh - 180px); border: 1px solid rgba(0,0,0,0.08);
    overscroll-behavior: contain;
}
.m-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.m-table th {
    position: sticky; top: 0; background: #f8f9fa; border-bottom: 1px solid rgba(0,0,0,0.08);
    padding: 10px 12px; text-align: left; font-weight: 600; color: rgba(0,0,0,0.7);
    white-space: nowrap; z-index: 1; cursor: pointer; user-select: none;
}
.m-table th:hover { background: #eef0f2; }
.m-table th.sort-asc::after { content: ' ▲'; color: #0a84ff; font-size: 10px; }
.m-table th.sort-desc::after { content: ' ▼'; color: #0a84ff; font-size: 10px; }
.m-table th.num, .m-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.m-table td {
    padding: 8px 12px; border-bottom: 1px solid rgba(0,0,0,0.05); color: rgba(0,0,0,0.8);
    max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.m-table tr:hover td { background: rgba(0,0,0,0.03); }
.m-table th:nth-child(1), .m-table td:nth-child(1) { min-width: 180px; width: 180px; }
.m-table th:nth-child(2), .m-table td:nth-child(2) { width: 1%; white-space: nowrap; }
.m-empty { text-align: center; padding: 40px; color: rgba(0,0,0,0.3); }
.m-bar { position: relative; height: 20px; background: rgba(0,0,0,0.04); border-radius: 10px; min-width: 140px; overflow: hidden; }
.m-bar-fill { position: absolute; inset: 0 auto 0 0; background: #8ba3b5; border-radius: 10px; transition: width .3s ease; }
.m-bar-label { position: relative; z-index: 1; display: block; text-align: center; line-height: 20px; font-size: 11px; font-weight: 500; color: rgba(0,0,0,0.72); letter-spacing: 0.2px; }
.m-row-clickable { cursor: pointer; }
.m-row-clickable.expanded td { background: rgba(10,132,255,0.04); }
.m-name-link { color: #0a84ff; cursor: pointer; }
.m-name-link:hover { text-decoration: underline; }
#cardDetailModal { z-index: 1100; }

#metricsModal .m-table-wrap { scrollbar-width: none; -ms-overflow-style: none; }
#metricsModal .m-table-wrap::-webkit-scrollbar { width: 0; height: 0; display: none; }

#metricsModal .dashboard-header { margin-bottom: 10px; padding-bottom: 8px; }
#metricsModal .metrics-title-group { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
#metricsModal .metrics-toolbar { margin-top: -15px; margin-bottom: 10px; }

/* 订单流转 pie chart */
#metricsModal .m-flow-chart {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
    padding: 24px 12px;
}
#metricsModal .m-pie-wrap { position: relative; width: 240px; height: 240px; }
#metricsModal .m-pie {
    width: 100%; height: 100%;
    border-radius: 50%;
    background: #fff;
    overflow: hidden;
}
#metricsModal .m-pie svg { display: block; width: 100%; height: 100%; cursor: pointer; }
#metricsModal .m-pie-slice { transition: opacity 0.15s ease, transform 0.15s ease; transform-origin: center; transform-box: fill-box; }
#metricsModal .m-pie-slice path,
#metricsModal .m-pie-slice circle { stroke: #fff; stroke-width: 0.012; }
#metricsModal .m-pie:hover .m-pie-slice:not(.is-active) { opacity: 0.55; }
#metricsModal .m-pie-slice.is-active { transform: scale(1.04); }
#metricsModal .m-pie-legend .legend-item { padding: 4px 8px; border-radius: 6px; transition: background 0.15s ease; cursor: default; }
#metricsModal .m-pie-legend .legend-item.is-active { background: #f3f5f8; }
#metricsModal .m-pie-center {
    position: absolute;
    inset: 60px;
    background: #fff;
    border-radius: 50%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center;
    color: rgba(0,0,0,0.7);
    font-size: 12px;
    line-height: 1.4;
}
#metricsModal .m-pie-center .pie-total { font-size: 22px; font-weight: 600; color: #000; }
#metricsModal .m-pie-legend { display: flex; flex-direction: column; gap: 8px; min-width: 200px; }
#metricsModal .m-pie-legend .legend-item {
    display: flex; align-items: center; gap: 10px;
    font-size: 13px; color: rgba(0,0,0,0.8);
}
#metricsModal .m-pie-legend .legend-swatch {
    width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0;
}
#metricsModal .m-pie-legend .legend-name { flex: 1; }
#metricsModal .m-pie-legend .legend-val { color: rgba(0,0,0,0.5); font-variant-numeric: tabular-nums; }

/* 订单趋势 line chart */
#metricsModal .m-trend-chart {
    padding: 16px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#metricsModal .m-trend-svg-wrap {
    position: relative;
    width: 100%;
    height: 360px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 10px;
    overflow: hidden;
}
#metricsModal .m-trend-svg-wrap svg { display: block; width: 100%; height: 100%; }
#metricsModal .m-trend-grid line { stroke: rgba(0,0,0,0.06); stroke-width: 1; }
#metricsModal .m-trend-axis text { font-size: 11px; fill: rgba(0,0,0,0.45); }
#metricsModal .m-trend-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#metricsModal .m-trend-area { fill-opacity: 0.08; stroke: none; }
#metricsModal .m-trend-dot { stroke: #fff; stroke-width: 1.5; }
#metricsModal .m-trend-hover-line { stroke: rgba(0,0,0,0.2); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
#metricsModal .m-trend-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(255,255,255,0.98);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    padding: 8px 10px;
    font-size: 12px;
    color: rgba(0,0,0,0.85);
    white-space: nowrap;
    transition: opacity 0.1s ease;
}
#metricsModal .m-trend-tooltip .tt-date { color: rgba(0,0,0,0.55); margin-bottom: 4px; font-size: 11px; }
#metricsModal .m-trend-tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
#metricsModal .m-trend-tooltip .tt-swatch { width: 8px; height: 8px; border-radius: 2px; }
#metricsModal .m-trend-tooltip .tt-val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 500; }
#metricsModal .m-trend-legend { display: flex; gap: 18px; justify-content: center; font-size: 13px; color: rgba(0,0,0,0.75); }
#metricsModal .m-trend-legend .legend-item { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; padding: 2px 6px; border-radius: 6px; transition: opacity 0.15s ease, background 0.15s ease; user-select: none; -webkit-tap-highlight-color: transparent; }
/* Only apply :hover styles on devices with a real pointer — otherwise iOS
 * treats the first tap as a pseudo-hover, swallowing it before the click
 * handler runs (which made "second tap to uncheck" feel broken). */
@media (hover: hover) {
    #metricsModal .m-trend-legend .legend-item:hover { background: #f3f5f8; }
}
#metricsModal .m-trend-legend.is-isolated .legend-item:not(.is-active) { opacity: 0.35; }
#metricsModal .m-trend-legend .legend-item.is-active { background: #f3f5f8; }
#metricsModal .m-trend-legend .legend-swatch { width: 14px; height: 4px; border-radius: 2px; }

@media (max-width: 600px) {
    #dashboardModal .dashboard-modal-content { padding: 12px; width: 100%; max-height: 90vh; max-height: 90dvh; border-radius: 0; }
    #dashboardModal .dashboard-header { margin-bottom: 10px; padding-bottom: 8px; gap: 6px; }
    #dashboardModal .dashboard-header h2 { font-size: 16px; margin: 0; }
    #dashboardModal .dashboard-nav-tabs { gap: 4px; flex-wrap: wrap; }
    #dashboardModal .dashboard-nav-tab { padding: 6px 10px; font-size: 12px; }
    #dashboardModal .dashboard-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
    #dashboardModal .dashboard-stat-card { padding: 10px 12px; }
    #dashboardModal .dashboard-stat-card .stat-value { font-size: 20px; }
    #dashboardModal .dashboard-stat-card .stat-label { font-size: 11px; }
    #dashboardModal .dashboard-section { margin-bottom: 12px; }
    #dashboardModal .dashboard-section h3 { font-size: 14px; margin: 0 0 8px; }
    #dashboardModal .dashboard-table { font-size: 11px; }
    #dashboardModal .dashboard-table th,
    #dashboardModal .dashboard-table td { padding: 6px 4px; }
    #dashboardModal .dashboard-table-container { max-height: calc(90vh - 260px); max-height: calc(90dvh - 260px); overscroll-behavior: contain; }
    #dashboardModal .db-toolbar { gap: 6px !important; margin-bottom: 10px !important; }
    #dashboardModal .db-toolbar select,
    #dashboardModal .db-toolbar input,
    #dashboardModal .db-toolbar button { padding: 6px 8px !important; font-size: 12px !important; min-width: 0 !important; }
    #dashboardModal #dbInfo { display: none; }
    #metricsModal .dashboard-modal-content { padding: 12px; width: 100%; max-height: 90vh; max-height: 90dvh; border-radius: 0; }
    #metricsModal .dashboard-header { margin-bottom: 6px; padding-bottom: 6px; }
    #metricsModal .metrics-toolbar { gap: 6px; margin-bottom: 6px; }
    #metricsModal .m-btn { padding: 6px 8px; font-size: 12px; }
    #metricsModal .m-select { padding: 6px 8px; font-size: 12px; }
    #metricsModal .m-search { padding: 6px 8px; font-size: 12px; min-width: 0; flex: 1 1 120px; }
    #metricsModal .m-info { display: none; }
    #metricsModal .m-table { font-size: 11px; table-layout: fixed; width: 100%; }
    #metricsModal .m-table th { padding: 6px 4px; font-size: 11px; }
    #metricsModal .m-table td { padding: 5px 4px; max-width: none; }
    #metricsModal .m-bar { min-width: 0; height: 16px; }
    #metricsModal .m-bar-label { line-height: 16px; font-size: 10px; }
    #metricsModal .m-table-wrap { max-height: calc(90vh - 140px); max-height: calc(90dvh - 140px); overflow-x: hidden; }
    /* Phone: fit all 6 columns in viewport — proportional widths */
    #metricsModal .m-table th:nth-child(1), #metricsModal .m-table td:nth-child(1) { width: 28%; min-width: 0; }
    #metricsModal .m-table th:nth-child(2), #metricsModal .m-table td:nth-child(2) { width: 18%; }
    #metricsModal .m-table th:nth-child(3), #metricsModal .m-table td:nth-child(3) { width: 13%; }
    #metricsModal .m-table th:nth-child(4), #metricsModal .m-table td:nth-child(4) { width: 11%; }
    #metricsModal .m-table th:nth-child(5), #metricsModal .m-table td:nth-child(5) { width: 18%; }
    #metricsModal .m-table th:nth-child(6), #metricsModal .m-table td:nth-child(6) { width: 12%; }
}
.m-detail-row td { padding: 18px 22px; background: #fbfbfc; border-bottom: 1px solid rgba(0,0,0,0.05); max-width: none; white-space: normal; }
.m-stacked { display: flex; height: 26px; border-radius: 13px; overflow: hidden; width: 100%; }
.m-stacked-seg { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.95); min-width: 0; transition: flex-basis .3s ease; border-right: 1px solid rgba(255,255,255,0.35); letter-spacing: 0.2px; }
.m-stacked-seg:last-child { border-right: 0; }
.m-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: rgba(0,0,0,0.62); }
.m-legend-item { display: inline-flex; align-items: center; gap: 7px; }
.m-legend-swatch { width: 10px; height: 10px; border-radius: 3px; }
.m-loading { font-size: 12px; color: rgba(0,0,0,0.4); }
.m-metric-cell { cursor: pointer; }
.m-metric-cell:hover { background: rgba(10,132,255,0.05); }
.m-detail-title { font-size: 12px; color: rgba(0,0,0,0.55); margin-bottom: 10px; font-weight: 500; }
.m-channel-list { display: flex; flex-direction: column; gap: 6px; }
.m-channel-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.m-channel-name { flex: 0 0 140px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: rgba(0,0,0,0.7); }
.m-channel-bar { flex: 1; height: 16px; background: rgba(0,0,0,0.04); border-radius: 8px; overflow: hidden; }
.m-channel-bar-fill { height: 100%; border-radius: 8px; transition: width .3s ease; }
.m-channel-val { flex: 0 0 auto; color: rgba(0,0,0,0.6); font-variant-numeric: tabular-nums; }

/* ===== 选款 (style selection) ===== */
.tab-btn-xuankuan { margin-left: 4px; }
.xuankuan-controls { display: flex; gap: 8px; align-items: center; }
.card-selected-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #22c55e;
    color: #fff;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    font-weight: bold;
    z-index: 3;
    display: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.card.card-xuankuan .card-selected-badge { display: block; }
.card.card-xuankuan { outline: 2px solid #22c55e; outline-offset: -2px; }
#cardDetailXuankuanBtn.is-selected { background: #22c55e; border-color: #22c55e; color: #fff; }

/* ===== 创建日期筛选（紧凑弹出） ===== */
.date-filter-group { position: relative; display: flex; align-items: center; }
.date-filter-btn { padding: 3px 8px; border: 1px solid #ddd; border-radius: 6px; background: #fff; font-size: 14px; line-height: 1.4; cursor: pointer; }
.date-filter-btn.active { border-color: #22c55e; background: #eafff1; }
.date-filter-popover { display: none; position: fixed; z-index: 10050; background: #fff; border: 1px solid #ddd; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.15); padding: 10px; min-width: 210px; }
.date-filter-popover.open { display: block; }
.dfp-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; color: #555; }
.dfp-row span { width: 30px; flex: 0 0 auto; }
.dfp-row input { flex: 1; padding: 4px 6px; border: 1px solid #ddd; border-radius: 6px; font-size: 12px; min-width: 0; }
.dfp-actions { display: flex; gap: 8px; }
.dfp-btn { flex: 1; padding: 5px; border: 1px solid #ddd; border-radius: 6px; background: #f5f5f5; font-size: 12px; cursor: pointer; }
.dfp-btn-primary { background: #22c55e; border-color: #22c55e; color: #fff; }
