:root {
    color-scheme: light;
    --bg: #f3f6fb;
    --panel: #ffffff;
    --border: #d9e1ee;
    --text: #132238;
    --muted: #5b6b83;
    --primary: #2f6fed;
    --primary-soft: #eaf1ff;
    --danger: #d74747;
    --success: #177a47;
    --shadow: 0 8px 24px rgba(16, 32, 64, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

a {
    color: inherit;
}

input[type="number"],
input[type="text"],
input[type="color"],
textarea,
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    padding: 10px 12px;
    color: var(--text);
}

button,
.button-link,
.upload-button {
    border: 0;
    border-radius: 12px;
    padding: 10px 14px;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover,
.button-link:hover,
.upload-button:hover {
    transform: translateY(-1px);
    opacity: 0.96;
}

.secondary {
    background: #dbe5f7;
    color: var(--text);
}

.danger {
    background: var(--danger);
}

.page-shell {
    width: min(1600px, calc(100vw - 40px));
    margin: 0 auto;
    padding: 24px 0 36px;
}

.hero {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.hero h1 {
    margin: 0 0 6px;
    font-size: clamp(28px, 3vw, 40px);
}

.hero p {
    margin: 0;
    color: var(--muted);
}

.layout {
    display: grid;
    grid-template-columns: 1.05fr 1.25fr 0.9fr;
    gap: 16px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 18px;
    min-width: 0;
}

.panel h2 {
    margin: 0 0 12px;
    font-size: 22px;
}

.field-label,
.status-line,
.muted {
    color: var(--muted);
}

.compact-head {
    margin-bottom: 8px;
}

.account-panel {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f8fbff;
    padding: 12px;
    margin-bottom: 12px;
}

.account-switch-row,
.account-create-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.account-create-row {
    margin-top: 8px;
}

.account-switch-row select,
.account-create-row input {
    min-height: 38px;
    border-radius: 10px;
}

.account-switch-row button,
.account-create-row button,
.account-actions button {
    min-height: 38px;
    border-radius: 10px;
    padding: 8px 12px;
    white-space: nowrap;
}

.account-actions {
    justify-content: flex-start;
}

/* ── 管理员重置面板 ───────────────────────────────────────── */

.admin-reset-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
}

.admin-reset-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.admin-reset-row select {
    flex: 1 1 0;
    min-width: 0;
    min-height: 36px;
    border-radius: 10px;
}

.admin-reset-row input {
    flex: 1 1 0;
    min-width: 0;
    min-height: 36px;
    border-radius: 10px;
}

/* ── 侧边栏链接组 ─────────────────────────────────────────── */

.sidebar-link-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

.sidebar-link-group:first-of-type {
    border-top: none;
}

.sidebar-group-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-link-group .button-link,
.sidebar-link-group .upload-button {
    justify-content: center;
    padding: 10px 14px;
    font-size: 13px;
    border-radius: 10px;
}

.sidebar-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.sidebar-row .button-link,
.sidebar-row .upload-button {
    width: 100%;
}

/* ── 爬虫控制面板 ─────────────────────────────────────────── */

.crawler-panel {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f8fbff;
    padding: 10px 12px;
    margin-bottom: 12px;
}

.crawler-buttons {
    display: flex;
    gap: 8px;
}

.crawler-mode-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 36px;
    border-radius: 10px;
    padding: 6px 0;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.crawler-mode-btn.is-active {
    background: var(--primary);
    color: #fff;
}

.crawler-mode-btn.is-active.secondary {
    background: var(--primary);
}

.hint-list {
    margin: 0 0 14px;
    padding-left: 20px;
    color: var(--muted);
}

.search-row,
.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar.compact {
    margin-top: 12px;
}

.search-row input {
    flex: 1 1 260px;
}

.search-filter-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

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

.search-filter-head .field-label {
    margin: 0;
}

.search-regulation-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.search-regulation-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.search-regulation-chip:hover {
    transform: translateY(-1px);
    border-color: var(--primary);
}

.search-regulation-chip.is-active {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

.search-regulation-chip input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.search-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 34px;
    padding: 8px 10px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: #f8fbff;
    color: var(--text);
}

.search-filter-toggle input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.status-line {
    margin: 12px 0 10px;
    min-height: 1.2em;
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stack-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.stat-card {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 14px;
    min-width: 110px;
    text-align: center;
}

.stat-link {
    color: inherit;
}

.stat-link:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.stat-card .value {
    display: block;
    font-size: 24px;
    font-weight: 700;
}

.deck-admin-layout,
.deck-detail-layout {
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
    gap: 16px;
}

.admin-layout {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

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

.deck-admin-panel,
.deck-summary-panel,
.deck-cards-panel {
    min-width: 0;
}

.deck-manage-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
    align-content: start;
}

.deck-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.deck-manage-card,
.deck-card-row {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    padding: 12px;
}

.deck-manage-head,
.deck-summary-head {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.deck-manage-card {
    cursor: default;
    min-width: 0;
}

.deck-meta {
    min-width: 0;
}

.deck-count {
    display: inline-block;
    margin-top: 2px;
}

.deck-description {
    margin: 6px 0 0;
    color: var(--muted);
    line-height: 1.4;
}

.deck-actions {
    display: grid;
    grid-template-columns: 1.45fr 0.95fr 0.7fr;
    gap: 10px;
    margin-top: 10px;
}

.deck-actions > * {
    width: 100%;
    min-width: 0;
}

.deck-actions > .deck-detail-link {
    min-width: 0;
}

.deck-actions > .edit-deck {
    min-width: 0;
}

.deck-actions > .delete-deck {
    min-width: 0;
    padding-inline: 10px;
    font-size: 13px;
}

.deck-manage-card.dragging {
    opacity: 0.5;
}

.deck-manage-card.drag-over-before {
    box-shadow: inset 0 3px 0 var(--primary);
}

.deck-manage-card.drag-over-after {
    box-shadow: inset 0 -3px 0 var(--primary);
}

.deck-order-handle {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #f5f7fb;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    cursor: grab;
    user-select: none;
}

.deck-order-handle:active {
    cursor: grabbing;
}

.deck-color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    flex: 0 0 auto;
}

.deck-color-swatch.large {
    width: 36px;
    height: 36px;
}

.deck-basic-energy-panel {
    margin-top: 18px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.deck-check-panel {
    margin-top: 18px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.deck-check-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.deck-check-item {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f9fbfe;
    padding: 8px 10px;
}

.deck-check-item.is-pass {
    border-color: rgba(23, 122, 71, 0.22);
    background: #f3fbf7;
}

.deck-check-item.is-warning,
.deck-check-item.is-error {
    border-color: rgba(170, 103, 8, 0.24);
    background: #fff8ed;
}

.deck-check-label {
    font-size: 12px;
    font-weight: 800;
    color: #30445f;
    white-space: nowrap;
}

.deck-check-message {
    min-width: 0;
    font-size: 13px;
    line-height: 1.35;
}

.deck-basic-energy-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
}

.deck-basic-energy-item {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) 58px;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 10px;
    background: #f9fbfe;
}

.deck-basic-energy-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 12px;
}

.deck-basic-energy-name {
    font-weight: 600;
    min-width: 0;
}

.deck-basic-energy-input {
    width: 58px;
    min-width: 58px;
    padding: 7px 6px;
    text-align: center;
    border-radius: 10px;
}

.deck-basic-energy-actions {
    margin-top: 12px;
}

.deck-sections-layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

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

.deck-sections-full {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.deck-sections-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.deck-section-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    padding: 12px;
}

.deck-section-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.deck-card-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.deck-card-line {
    padding: 8px 10px;
    border-radius: 12px;
    background: #f8fafc;
}

.deck-card-line.dragging {
    opacity: 0.55;
}

.deck-card-line.drag-over-before {
    box-shadow: inset 0 2px 0 var(--primary);
}

.deck-card-line.drag-over-after {
    box-shadow: inset 0 -2px 0 var(--primary);
}

.deck-card-line.is-backup {
    background: #fff5eb;
}

.deck-card-mainline {
    display: grid;
    grid-template-columns: 28px 90px 24px 32px minmax(0, 1fr) 52px 44px;
    gap: 6px;
    align-items: center;
}

.deck-card-reorder-handle,
.deck-card-reorder-placeholder {
    width: 28px;
    min-width: 28px;
    height: 28px;
    min-height: 28px;
}

.deck-card-reorder-handle {
    padding: 0;
    border-radius: 9px;
    background: #eef3fb;
    color: var(--muted);
    font-size: 13px;
    line-height: 1;
    cursor: grab;
}

.deck-card-reorder-handle:active {
    cursor: grabbing;
}

.deck-card-reorder-placeholder {
    display: inline-block;
}

.deck-card-action-trigger,
.deck-card-action-placeholder {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
}

.deck-card-action-trigger {
    padding: 0;
    border-radius: 10px;
    font-size: 18px;
    line-height: 1;
}

.deck-card-action-placeholder {
    display: inline-block;
}

.deck-card-code {
    font-size: 12px;
}

.deck-card-name {
    font-weight: 600;
    min-width: 0;
    word-break: break-word;
}

.deck-card-rarity,
.deck-card-quantity {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
}

.deck-card-rarity {
    border: 1px solid rgba(19, 34, 56, 0.08);
    background: #fff;
    color: #425466;
}

.deck-card-rarity.is-empty {
    background: #f2f4f7;
    color: transparent;
}

.deck-card-quantity {
    background: #132238;
    color: #fff;
}

.deck-meta {
    min-width: 0;
}

.deck-name {
    display: block;
    font-size: 18px;
}

.deck-count,
.deck-description {
    color: var(--muted);
}

.deck-description {
    margin: 6px 0 0;
}

.deck-actions {
    margin-top: 12px;
}

.deck-summary-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.deck-summary-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: 12px;
    font-size: 13px;
}

.deck-card-main {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
}

.deck-card-code {
    font-size: 16px;
    font-weight: 700;
}

.deck-card-name {
    font-weight: 600;
}

.deck-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.result-list,
.deck-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 67vh;
    overflow-y: auto;
    padding-right: 4px;
}

.result-item,
.deck-item,
.inventory-card,
.deck-breakdown {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fcfdff;
    padding: 12px;
}

.result-item {
    cursor: pointer;
}

.result-item.active {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.result-title {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
}

.badges,
.inventory-pill-row,
.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.badge,
.inventory-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #edf2fb;
    color: #30445f;
    font-size: 13px;
}

.detail-inline-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
    margin-top: 12px;
}

.detail-inline-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.deck-card-modal-card {
    width: min(820px, 100%);
}

.deck-card-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.deck-card-modal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.deck-card-modal-summary {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.deck-card-modal-inline-form {
    grid-template-columns: minmax(0, 1fr) auto;
}

.deck-card-modal-ops {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.deck-card-modal-plan-hint {
    margin: 0;
    padding: 8px 10px;
    border-radius: 12px;
    background: #f7faff;
    color: var(--muted);
    font-size: 12px;
}

.deck-card-modal-action-groups {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.deck-card-modal-action-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fbfcff;
}

.deck-card-modal-action-title {
    font-size: 12px;
    font-weight: 700;
    color: #30445f;
}

.deck-card-modal-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.deck-card-modal-action-row {
    justify-content: flex-start;
    flex-wrap: wrap;
}

/* ── 卡牌详情弹窗 ─────────────────────────────────────────── */

.deck-card-info-btn {
    width: 24px;
    min-width: 24px;
    height: 24px;
    min-height: 24px;
    padding: 0;
    border-radius: 999px;
    background: #e0e7ff;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.card-detail-popup-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.empty-state {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 28px;
    text-align: center;
    color: var(--muted);
}

.back-link {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.holdings-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.holdings-hero-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.holdings-hero-toolbar {
    margin-top: 0;
}

.holdings-note {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    color: var(--muted);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.holdings-note-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 280px;
    min-width: 0;
}

.deck-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    flex: 1 1 280px;
}

.deck-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #f8fbff;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
}

.deck-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    border: 1px solid rgba(19, 34, 56, 0.2);
    flex: none;
}

.deck-legend-name {
    white-space: nowrap;
}

.holdings-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.holdings-section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 16px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.section-title {
    margin: 0;
    font-size: 20px;
}

.section-count {
    color: var(--muted);
}

.group-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.group-block {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.group-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.group-title {
    margin: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex-wrap: wrap;
}

.group-title-text {
    min-width: 0;
    word-break: break-word;
}

.group-attribute-markers {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.attribute-marker {
    display: inline-block;
    font-size: 15px;
    line-height: 1;
}

.group-count {
    color: var(--muted);
    white-space: nowrap;
}

.group-records {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.record-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 8px 10px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    position: relative;
}

.record-top-row,
.record-bottom-row {
    display: grid;
    gap: 4px;
}

.record-top-row {
    grid-template-columns: minmax(112px, 1.5fr) repeat(3, minmax(0, 0.68fr)) minmax(0, 1.2fr);
    align-items: center;
    padding-right: 18px;
}

.record-quantity-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.record-bottom-row {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 0.85fr);
}

.record-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.record-field span {
    font-size: 10px;
    color: var(--muted);
    white-space: nowrap;
}

.record-field strong {
    font-size: 12px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-code-value {
    font-size: 10px;
    overflow: visible;
    text-overflow: clip;
}

.record-strong-field strong {
    font-size: 14px;
}

.record-free-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    justify-self: start;
}

.record-free-field {
    gap: 1px;
}

.record-deck-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.record-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.record-action-btn {
    padding: 3px 6px;
    font-size: 10px;
}

.record-delete-btn {
    padding: 2px 6px;
    min-height: auto;
}

.record-delete-icon {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 16px;
    height: 16px;
    min-height: 0;
    padding: 0;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    z-index: 1;
}

.quantity-editor {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px 30px;
    align-items: center;
    gap: 4px;
    min-width: 0;
    padding: 0 5px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: #f8fbff;
}

.record-top-editor {
    grid-template-columns: fit-content(14px) 38px 22px;
    gap: 2px;
    padding: 0 3px;
    justify-self: start;
    width: fit-content;
}

.quantity-editor.record-free-editor {
    grid-template-columns: 32px 16px;
    gap: 2px;
    width: fit-content;
    padding: 0;
    border: 0;
    background: transparent;
}

.record-quantity-row .quantity-editor {
    grid-template-columns: 28px 14px;
    gap: 1px;
    width: fit-content;
    max-width: 100%;
    justify-self: center;
    padding: 0 2px;
}

.quantity-editor.free {
    background: #edf2fb;
}

.quantity-editor-label {
    font-size: 3px;
    font-weight: 150;
    line-height: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.record-top-editor .quantity-editor-label {
    max-width: 14px;
}

.record-top-editor .quantity-input {
    width: 100%;
}

.record-free-editor .quantity-editor-label-hidden {
    display: none;
}

.quantity-editor-label-hidden {
    font-size: 0;
}

.record-quantity-row .quantity-editor-label-hidden {
    display: none;
}

.quantity-editor .quantity-input {
    width: 50%;
    min-width: 0;
    height: 18px;
    border-radius: 4px;
    padding: 0 4px;
    font-size: 11px;
    line-height: 1;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text);
    appearance: textfield;
    -moz-appearance: textfield;
}

.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.record-quantity-row .quantity-input {
    width: 100%;
    height: 16px;
    padding: 0 2px;
    border-color: transparent;
    background: var(--editor-bg, rgba(255, 255, 255, 0.95));
    color: var(--editor-text, var(--text));
    font-size: 10px;
}

.record-free-editor .quantity-input {
    width: 100%;
    height: 16px;
    padding: 0 2px;
    font-size: 10px;
    border-color: var(--border);
    background: #fff;
    color: var(--text);
}

.record-quantity-row .quantity-apply-btn {
    width: 100%;
    height: 14px;
    padding: 0;
    min-height: 0;
    background: var(--editor-bg, #dbe5f7);
    color: var(--editor-text, var(--text));
    font-size: 6px;
    border-radius: 3px;
}

.record-free-editor .quantity-apply-btn {
    width: 100%;
    height: 14px;
    min-height: 0;
    padding: 0;
    background: #dbe5f7;
    color: var(--text);
    font-size: 6px;
    border-radius: 3px;
}

.quantity-editor .quantity-apply-btn {
    height: 18px;
    padding: 0 4px;
    min-width: 0;
    font-size: 9px;
    border-radius: 4px;
}

.deck-pill {
    display: inline-flex;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #f8fbff;
    color: #30445f;
    font-size: 11px;
    white-space: nowrap;
    justify-content: center;
    padding: 3px 8px;
    font-weight: 700;
}


.deck-pill.free {
    background: #f8fbff;
}

.record-value {
    font-size: 15px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
    gap: 8px;
}

.mini-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 10px;
    border-radius: 12px;
    background: #f7faff;
    min-width: 0;
}

.mini-stat span {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-stat strong {
    font-size: 15px;
    line-height: 1.1;
    word-break: break-word;
}

.deck-stat {
    min-width: 0;
}

.empty-table {
    text-align: center;
    color: var(--muted);
    padding: 18px 12px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: #fafcff;
}

.inventory-table-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.inventory-table-note {
    align-items: center;
}

.inventory-rarity-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inventory-table-filters {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
}

.inventory-filter-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) minmax(130px, 0.7fr) minmax(130px, 0.7fr) auto auto auto;
    gap: 10px;
    align-items: end;
}

.inventory-filter-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.inventory-filter-field span,
.inventory-filter-check {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.inventory-filter-field input,
.inventory-filter-field select {
    min-height: 36px;
    border-radius: 10px;
    padding: 7px 10px;
}

.inventory-filter-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    white-space: nowrap;
}

.inventory-filter-check input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.inventory-filter-reset {
    min-height: 36px;
    border-radius: 10px;
    padding: 7px 12px;
    white-space: nowrap;
}

.inventory-rarity-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    font-size: 12px;
    color: var(--text);
    font-weight: 600;
}

.inventory-rarity-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    border: 1px solid rgba(19, 34, 56, 0.16);
    flex: none;
}

.inventory-table-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.inventory-table-section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 16px;
}

.inventory-table-scroll {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
}

.inventory-grid {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.inventory-grid th,
.inventory-grid td {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 4px 6px;
    font-size: 10px;
    text-align: center;
    white-space: nowrap;
    background: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inventory-grid thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #f8fbff;
    font-weight: 700;
    padding: 6px 6px;
}

.inventory-grid thead tr:first-child th {
    background: #edf3ff;
    font-size: 11px;
}

.inventory-grid tr th:first-child,
.inventory-grid tr td:first-child {
    border-left: 0;
}

.inventory-grid thead tr:first-child th:first-child {
    border-top-left-radius: 16px;
}

.inventory-grid thead tr:first-child th:last-child {
    border-top-right-radius: 16px;
}

.inventory-grid tbody tr:nth-child(even) td {
    background: #fcfdff;
}

.inventory-grid tbody tr:last-child td:first-child {
    border-bottom-left-radius: 16px;
}

.inventory-grid tbody tr:last-child td:last-child {
    border-bottom-right-radius: 16px;
}

.sticky-name {
    position: sticky;
    left: 0;
    z-index: 2;
}

.inventory-grid thead .sticky-name {
    z-index: 4;
}

.inventory-name-head {
    min-width: 190px;
}

.inventory-slot-head {
    min-width: 248px;
}

.inventory-name-cell {
    min-width: 190px;
    max-width: 190px;
    text-align: left;
    vertical-align: top;
    background: #f8fbff;
}

.inventory-name-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.inventory-name-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
}

.inventory-group-reorder {
    display: flex;
    flex-direction: row;
    gap: 3px;
}

.inventory-group-move-btn {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    padding: 0;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: #f7faff;
    color: var(--primary);
    font-size: 10px;
    line-height: 1;
}

.inventory-group-move-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.inventory-name-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.inventory-name-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.inventory-name-meta strong {
    font-size: 13px;
    line-height: 1.15;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inventory-attribute-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: none;
}

.inventory-edit-btn {
    width: 12px;
    height: 12px;
    min-width: 12px;
    min-height: 12px;
    padding: 0;
    flex: none;
    border-radius: 999px;
    background: var(--danger);
    box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(215, 71, 71, 0.16);
}

.inventory-edit-btn:hover {
    transform: scale(1.05);
}

.inventory-attribute-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    border: 1px solid rgba(19, 34, 56, 0.18);
}

.inventory-code-cell,
.inventory-number-cell {
    font-variant-numeric: tabular-nums;
}

.inventory-mini-cell {
    width: 28px;
    min-width: 28px;
    max-width: 28px;
    padding-left: 0;
    padding-right: 0;
}

.inventory-regulation-cell {
    width: 20px;
    min-width: 20px;
    max-width: 20px;
}

.inventory-code-cell {
    width: 72px;
    min-width: 72px;
    max-width: 72px;
}

.inventory-number-cell {
    width: 28px;
    min-width: 28px;
    max-width: 28px;
}

.inventory-tone-cell {
    font-weight: 700;
}

.inventory-deck-cell {
    font-weight: 700;
}

.inventory-empty-cell {
    background: #f8fafc;
    min-width: 28px;
}

.inventory-modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 20px;
}

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

.inventory-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(19, 34, 56, 0.48);
}

.inventory-modal-card {
    position: relative;
    z-index: 1;
    width: min(980px, 100%);
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 24px 80px rgba(9, 20, 41, 0.24);
    border: 1px solid rgba(255, 255, 255, 0.6);
    display: flex;
    flex-direction: column;
    padding: 18px;
    gap: 14px;
}

.inventory-modal-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}

.inventory-modal-head h2 {
    margin: 0 0 4px;
    font-size: 24px;
}

.inventory-modal-subtitle {
    margin: 0;
}

.inventory-modal-close-icon {
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    font-size: 24px;
    line-height: 1;
}

.inventory-modal-status {
    margin: 0;
}

.inventory-modal-table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 16px;
}

.inventory-modal-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
}

.inventory-modal-table th,
.inventory-modal-table td {
    padding: 5px 4px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    text-align: center;
    background: #fff;
    font-size: 11px;
}

.inventory-modal-table th {
    white-space: normal;
    line-height: 1.15;
}

.inventory-modal-table td {
    white-space: nowrap;
}

.inventory-modal-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f7faff;
}

.inventory-modal-input {
    min-width: 38px;
    width: 38px;
    max-width: 38px;
    padding: 4px 2px;
    border-radius: 8px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.inventory-modal-order-head,
.inventory-modal-order-cell {
    width: 34px;
    min-width: 34px;
    max-width: 34px;
    padding-left: 3px;
    padding-right: 3px;
}

.inventory-modal-reorder {
    display: flex;
    align-items: center;
    justify-content: center;
}

.inventory-modal-drag-handle,
.inventory-modal-drag-placeholder {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 16px;
    line-height: 1;
}

.inventory-modal-drag-handle {
    border: 1px solid var(--border);
    background: #f7faff;
    color: var(--primary);
    cursor: grab;
    user-select: none;
    transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.inventory-modal-drag-handle:hover {
    background: #eef4ff;
    border-color: rgba(37, 99, 235, 0.28);
}

.inventory-modal-drag-handle:active {
    cursor: grabbing;
    transform: scale(0.96);
}

.inventory-modal-drag-placeholder {
    color: var(--muted);
}

.inventory-modal-table tbody tr.dragging {
    opacity: 0.42;
}

.inventory-modal-table tbody tr.drag-over-top td {
    box-shadow: inset 0 3px 0 #2563eb;
}

.inventory-modal-table tbody tr.drag-over-bottom td {
    box-shadow: inset 0 -3px 0 #2563eb;
}

.inventory-modal-code-cell {
    width: 66px;
    min-width: 66px;
    max-width: 66px;
}

.inventory-modal-name-cell {
    width: 84px;
    min-width: 84px;
    max-width: 84px;
    text-align: left;
    white-space: normal;
    word-break: break-word;
}

.inventory-modal-rarity-cell {
    width: 34px;
    min-width: 34px;
    max-width: 34px;
    font-weight: 700;
}

.inventory-modal-regulation-cell {
    width: 18px;
    min-width: 18px;
    max-width: 18px;
}

.inventory-modal-qty-head,
.inventory-modal-qty-cell {
    width: 62px;
    min-width: 62px;
    max-width: 62px;
    padding-left: 2px;
    padding-right: 2px;
}

.inventory-modal-delete-head,
.inventory-modal-delete-cell {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
}

.inventory-modal-delete-btn {
    width: 100%;
    min-width: 0;
    padding: 4px 0;
    border-radius: 8px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.inventory-modal-delete-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.inventory-modal-actions {
    justify-content: flex-end;
}

body.modal-open {
    overflow: hidden;
}

.card-title {
    margin: 0 0 8px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

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

.card-grid .value {
    margin-top: 4px;
    font-weight: 600;
    word-break: break-word;
}

.inventory-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 120px auto;
    gap: 10px;
    align-items: end;
}

.mono {
    font-family: Consolas, "Courier New", monospace;
}

.success-text {
    color: var(--success);
}

.warning-text {
    color: #aa6708;
}

/* ── 分组排序按钮 ── */

.sort-groups-btn {
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: #f7faff;
    color: var(--primary);
    cursor: pointer;
    transition: background 0.15s;
}

.sort-groups-btn:hover {
    background: #e8f0fe;
}

/* ── 卡组弹窗 Delta 行 ── */

.deck-card-modal-delta-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.deck-card-modal-delta-row input {
    width: 70px;
    text-align: center;
}
.delta-step-btn {
    width: 32px;
    height: 32px;
    font-size: 16px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.deck-card-modal-dual-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.deck-card-modal-column {
    min-width: 0;
}

.danger-btn {
    background: #dc2626;
    color: #fff;
    border: 1px solid #b91c1c;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.danger-btn:hover {
    background: #b91c1c;
}

.deck-card-modal-topbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
    padding: 0 4px;
}

/* ── 排序弹窗 ── */

.sort-groups-modal-card {
    max-width: 500px;
    width: 90vw;
}

.sort-groups-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 4px 0;
}

.sort-group-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: grab;
    transition: background 0.15s, transform 0.12s, box-shadow 0.15s;
    user-select: none;
}

.sort-group-item:hover {
    background: #f7faff;
}

.sort-group-item.dragging {
    opacity: 0.4;
    background: #e8f0fe;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.sort-group-item.drag-over {
    border-color: var(--primary);
    background: #eef4ff;
    box-shadow: 0 0 0 2px var(--primary);
    transform: scale(1.02);
}

.sort-group-drag-handle {
    font-size: 18px;
    color: var(--muted);
    line-height: 1;
    flex-shrink: 0;
}

.sort-group-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sort-group-count {
    flex-shrink: 0;
    font-size: 12px;
    color: var(--muted);
}

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

    .deck-admin-layout,
    .deck-detail-layout {
        grid-template-columns: 1fr;
    }

    .result-list,
    .deck-list {
        max-height: 420px;
    }

    .inventory-layout,
    .card-grid,
    .form-row {
        grid-template-columns: 1fr;
    }

    .deck-sections-grid {
        grid-template-columns: 1fr;
    }

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

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

    .inventory-filter-grid {
        grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(130px, 0.6fr));
    }
}

@media (max-width: 1200px) {
    .group-records {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .record-top-row {
        grid-template-columns: minmax(112px, 1.3fr) repeat(2, minmax(0, 0.7fr)) minmax(0, 0.75fr);
    }
}

@media (max-width: 900px) {
    .group-records {
        grid-template-columns: 1fr;
    }

    .deck-manage-list,
    .deck-basic-energy-list {
        grid-template-columns: 1fr;
    }

    .deck-card-mainline {
        grid-template-columns: 28px 80px 22px 28px minmax(0, 1fr) 48px 40px;
        gap: 4px;
    }

    .deck-card-modal-grid {
        grid-template-columns: 1fr;
    }

    .record-top-row {
        grid-template-columns: 1fr;
    }

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

    .inventory-table-note {
        align-items: flex-start;
    }

    .inventory-filter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .inventory-name-head,
    .inventory-name-cell {
        min-width: 166px;
        max-width: 166px;
    }

    .inventory-modal {
        padding: 12px;
    }

    .inventory-modal-card {
        max-height: calc(100vh - 24px);
        padding: 14px;
    }
}

@media (max-width: 640px) {
    .deck-card-mainline {
        grid-template-columns: 28px 80px 22px 28px minmax(0, 1fr);
        align-items: start;
        gap: 4px;
    }

    .deck-card-rarity,
    .deck-card-quantity,
    .deck-card-code {
        min-width: 0;
    }

    .detail-inline-form,
    .deck-card-modal-inline-form {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .deck-basic-energy-item {
        grid-template-columns: 48px minmax(0, 1fr) 54px;
    }

    .record-quantity-row {
        grid-template-columns: 1fr;
    }

    .record-bottom-row {
        grid-template-columns: 1fr;
    }

    .holdings-hero-actions {
        align-items: flex-start;
    }

    .deck-legend {
        justify-content: flex-start;
    }

    .inventory-rarity-legend {
        gap: 6px;
    }

    .inventory-rarity-item {
        width: 100%;
        justify-content: flex-start;
    }

    .inventory-filter-grid {
        grid-template-columns: 1fr;
    }

    .inventory-name-wrap {
        flex-direction: row;
        gap: 6px;
    }

    .inventory-name-head,
    .inventory-name-cell {
        min-width: 148px;
        max-width: 148px;
    }

    .inventory-grid th,
    .inventory-grid td,
    .inventory-modal-table th,
    .inventory-modal-table td {
        padding: 5px 5px;
        font-size: 10px;
    }

    .inventory-slot-head {
        min-width: 224px;
    }

    .inventory-mini-cell,
    .inventory-number-cell,
    .inventory-empty-cell {
        width: 24px;
        min-width: 24px;
        max-width: 24px;
    }

    .inventory-regulation-cell {
        width: 18px;
        min-width: 18px;
        max-width: 18px;
    }

    .inventory-code-cell {
        width: 64px;
        min-width: 64px;
        max-width: 64px;
    }

    .inventory-modal-input {
        min-width: 32px;
        width: 32px;
        max-width: 32px;
        padding: 5px 2px;
    }

    .inventory-modal-order-head,
    .inventory-modal-order-cell,
    .inventory-modal-rarity-cell,
    .inventory-modal-regulation-cell,
    .inventory-modal-qty-head,
    .inventory-modal-qty-cell,
    .inventory-modal-delete-head,
    .inventory-modal-delete-cell {
        width: 56px;
        min-width: 56px;
        max-width: 56px;
    }

    .inventory-modal-code-cell {
        width: 60px;
        min-width: 60px;
        max-width: 60px;
    }

    .inventory-modal-name-cell {
        width: 74px;
        min-width: 74px;
        max-width: 74px;
    }

    .inventory-modal-head {
        flex-direction: column;
    }

    .inventory-modal-actions {
        justify-content: stretch;
    }

    .inventory-modal-actions button {
        flex: 1 1 auto;
    }
}

/* ── 卡牌图片 ─────────────────────────────────────────────── */

.card-image-wrap {
    flex: 0 0 auto;
    width: 80px;
    min-height: 112px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f6fb;
    border: 1px solid var(--border);
}

.card-image {
    width: 100%;
    height: auto;
    display: block;
}

.card-detail-header {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.card-detail-header .card-image-wrap {
    width: 160px;
    min-height: 224px;
    border-radius: 12px;
}

.card-detail-info {
    flex: 1 1 0;
    min-width: 0;
    align-self: center;
}

.result-main {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.result-info {
    flex: 1 1 0;
    min-width: 0;
}

@media (max-width: 640px) {
    .card-detail-header {
        flex-direction: column;
        align-items: stretch;
    }

    .card-detail-header .card-image-wrap {
        width: 120px;
        min-height: 168px;
        align-self: center;
    }

    .card-detail-info {
        align-self: flex-start;
    }

    .result-main .card-image-wrap {
        width: 60px;
        min-height: 84px;
    }
}

/* ── 通用弹窗遮罩 ─────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(19, 34, 56, 0.48);
    display: grid;
    place-items: center;
    padding: 20px;
}

.modal-card {
    position: relative;
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 24px 80px rgba(9, 20, 41, 0.24);
    padding: 24px;
    width: 100%;
}

/* ── 退标弹窗 ──────────────────────────────────────────────── */

.retire-modal-card {
    max-width: 620px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 18px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #6b7280;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 6px;
}
.modal-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 6px 0;
    color: #132238;
}

.retire-desc {
    color: #6b7280;
    font-size: 14px;
    margin: 0 0 16px 0;
}

.retire-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.retire-label {
    font-weight: 600;
    font-size: 14px;
    color: #374151;
}

.retire-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 15px;
    background: #fff;
    color: #111827;
    outline: none;
    appearance: auto;
}
.retire-select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.retire-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    user-select: none;
}
.retire-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #6366f1;
    flex-shrink: 0;
}
.retire-current-regulations {
    margin: 4px 0 0 26px;
    font-size: 13px;
    color: #6b7280;
}

.retire-step1-footer,
.retire-step2-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.retire-step2-footer {
    justify-content: space-between;
}

.retire-card-list-header {
    padding: 8px 0;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 4px;
}

.retire-select-all {
    font-weight: 600;
}

.retire-card-list {
    flex: 1;
    overflow-y: auto;
    max-height: 420px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.retire-card-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.retire-card-row:hover {
    background: #f9fafb;
}
.retire-card-row input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: #6366f1;
    flex-shrink: 0;
}

.retire-card-name {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    color: #132238;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.retire-card-code {
    font-size: 12px;
    color: #6b7280;
    font-family: ui-monospace, monospace;
    flex-shrink: 0;
}

.retire-card-rarity {
    font-size: 12px;
    color: #9ca3af;
    flex-shrink: 0;
    min-width: 20px;
    text-align: center;
}

.retire-card-qty {
    font-weight: 700;
    font-size: 14px;
    color: #374151;
    flex-shrink: 0;
    min-width: 36px;
    text-align: right;
}

.retire-card-location {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    font-size: 11px;
}

.retire-loc-free {
    background: #ecfdf5;
    color: #059669;
    padding: 2px 7px;
    border-radius: 6px;
    font-weight: 600;
}

.retire-loc-deck {
    padding: 2px 7px;
    border-radius: 6px;
    font-weight: 600;
}

.retire-selected-count {
    font-size: 14px;
    color: #6b7280;
}

.button-link.danger {
    background: #dc2626;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 9px 20px;
    border-radius: 10px;
    font-weight: 600;
    transition: background 0.15s;
}
.button-link.danger:hover {
    background: #b91c1c;
}

