* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
}

.hidden { display: none !important; }

/* Login / Account Selection Screen */
.login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-box {
    background: linear-gradient(135deg, #16213e, #0f3460);
    border: 2px solid #e94560;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    font-size: 1.5rem;
    color: #ffcc00;
    margin-bottom: 0.5rem;
}

.login-box h2 {
    font-size: 1.1rem;
    color: #aaa;
    margin-bottom: 1.5rem;
    font-weight: normal;
}

/* Login form */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.login-form input {
    padding: 0.7rem 0.9rem;
    border-radius: 6px;
    border: 1px solid #444;
    background: #1a1a2e;
    color: #eee;
    font-size: 0.95rem;
}

.btn-login {
    padding: 0.7rem;
    background: #e94560;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
}

.btn-login:hover {
    background: #ff6b81;
}

.login-error {
    color: #e94560;
    font-size: 0.85rem;
    margin-top: 0.3rem;
}

.account-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.account-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.account-select-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    background: #1a1a2e;
    border: 1px solid #444;
    border-radius: 8px;
    color: #eee;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.account-select-btn:hover {
    background: #2a2a4e;
    border-color: #ffcc00;
}

.account-delete-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid #666;
    border-radius: 6px;
    color: #e94560;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.account-delete-btn:hover {
    background: #e94560;
    color: #fff;
    border-color: #e94560;
}

.account-create {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.account-create input {
    flex: 1;
    min-width: 100px;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    border: 1px solid #444;
    background: #1a1a2e;
    color: #eee;
    font-size: 0.9rem;
}

.account-create button {
    padding: 0.6rem 1.2rem;
    background: #e94560;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-weight: bold;
    cursor: pointer;
}

.account-create button:hover {
    background: #ff6b81;
}

.no-accounts {
    color: #888;
    font-style: italic;
    padding: 1rem;
}

/* Password prompt */
.password-prompt {
    margin-top: 1rem;
    padding: 1rem;
    background: #1a1a2e;
    border: 1px solid #444;
    border-radius: 8px;
}

.password-prompt label {
    display: block;
    margin-bottom: 0.5rem;
    color: #ccc;
    font-size: 0.9rem;
}

.password-prompt input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    border: 1px solid #444;
    background: #0f0f1e;
    color: #eee;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.password-prompt-btns {
    display: flex;
    gap: 0.5rem;
}

.password-prompt-btns button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

.password-prompt-btns button:first-child {
    background: #e94560;
    color: #fff;
}

.password-prompt-btns button:first-child:hover {
    background: #ff6b81;
}

.btn-secondary {
    background: #333;
    color: #ccc;
}

.btn-secondary:hover {
    background: #444;
}

.login-divider {
    border: none;
    border-top: 1px solid #333;
    margin: 1.5rem 0;
}

.login-box h3 {
    font-size: 0.95rem;
    color: #aaa;
    margin-bottom: 0.75rem;
    font-weight: normal;
}

/* Header account badge */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.account-badge {
    background: #e94560;
    color: #fff;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: bold;
}

.switch-account-btn {
    padding: 0.3rem 0.7rem;
    background: transparent;
    border: 1px solid #666;
    border-radius: 6px;
    color: #aaa;
    font-size: 0.8rem;
    cursor: pointer;
}

.switch-account-btn:hover {
    border-color: #ffcc00;
    color: #ffcc00;
}

header {
    background: linear-gradient(135deg, #16213e, #0f3460);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e94560;
    flex-wrap: wrap;
    gap: 0.5rem;
}

header h1 {
    font-size: 1.5rem;
    color: #ffcc00;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.file-status {
    font-size: 0.85rem;
    color: #aaa;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #3282b8;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #4a9fd5;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #34ce57;
}

.btn-small {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
}

.btn-danger {
    background: #c0392b;
    color: #fff;
}

.btn-danger:hover {
    background: #e74c3c;
}

/* Admin Panel */
.admin-box { max-width: 700px; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.admin-table th, .admin-table td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid #333; }
.admin-table th { color: #e94560; font-size: 0.85rem; text-transform: uppercase; }
.admin-table td { font-size: 0.95rem; }
.admin-delete-btn { padding: 0.3rem 0.6rem; font-size: 0.8rem; cursor: pointer; border: none; border-radius: 4px; }

.manage-danger {
    border-top: 1px solid #333;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
}

/* Popup Overlay */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.popup-overlay.hidden {
    display: none;
}

.popup-content .move-all-select {
    width: 100%;
    margin: 0.75rem 0;
    padding: 0.5rem;
}

.popup-content {
    background: #1a1a2e;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 1.5rem;
    min-width: 300px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.popup-content h3 {
    margin: 0 0 1rem 0;
    color: #eee;
}

.popup-content .search-input {
    width: 100%;
    margin-bottom: 1rem;
    box-sizing: border-box;
}

.popup-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.variant-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.variant-btn {
    padding: 0.6rem 1rem;
    border: 1px solid #555;
    border-radius: 6px;
    background: #2a2a3e;
    color: #eee;
    cursor: pointer;
    font-size: 0.9rem;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
}

.variant-btn:hover {
    background: #3a3a5e;
    border-color: #ffcc00;
}

.variant-btn.variant-current {
    border-color: #bb86fc;
    background: #2a2a4e;
    opacity: 0.7;
}

/* Sources Tab */
.sources-header {
    padding: 1rem;
}

.manage-section {
    padding: 0 1rem 1.5rem;
    max-width: 600px;
}

.manage-section h3 {
    margin: 0 0 0.75rem;
    color: #ccc;
    border-bottom: 1px solid #333;
    padding-bottom: 0.5rem;
}

.manage-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.sources-list {
    max-width: 600px;
}

.source-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #16213e;
    border: 1px solid #333;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.source-item.source-add {
    justify-content: center;
    border-style: dashed;
    background: transparent;
}

.source-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.source-name {
    font-weight: 600;
    color: #eee;
    font-size: 1rem;
}

.source-name-editable {
    cursor: pointer;
    border-bottom: 1px dashed transparent;
    padding-bottom: 1px;
}

.source-name-editable:hover {
    border-bottom-color: #ffcc00;
}

.source-rename-input {
    background: #0f3460;
    border: 1px solid #ffcc00;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    outline: none;
    width: 140px;
}

.source-count {
    color: #888;
    font-size: 0.85rem;
}

.source-actions {
    display: flex;
    gap: 0.5rem;
}

/* Tabs */
.tabs {
    display: flex;
    background: #16213e;
    border-bottom: 1px solid #333;
}

.tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 0.95rem;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab:hover {
    color: #fff;
    background: rgba(255,255,255,0.05);
}

.tab.active {
    color: #ffcc00;
    border-bottom-color: #ffcc00;
}

/* Main content */
main {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

#tab-collection.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    overflow: hidden;
}

/* Filters */
.search-input {
    padding: 0.3rem 0.5rem;
    border: 1px solid #444;
    border-radius: 4px;
    background: #2a2a4a;
    color: #eee;
    font-size: 0.85rem;
    min-width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: #3282b8;
}

/* Set Filter Dropdown */
.set-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0 0 0.5rem;
}

.set-filter-tags:empty {
    display: none;
}

.collection-filter-wrapper {
    position: relative;
}

.filter-category-header {
    padding: 0.3rem 0.75rem;
    font-size: 0.65rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-top: 1px solid #333;
    margin-top: 0.2rem;
}

.filter-category-header:first-child {
    border-top: none;
    margin-top: 0;
}

.set-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: #3a3a5a;
    color: #ffcc00;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid currentColor;
    white-space: nowrap;
}

.tag-remove {
    cursor: pointer;
    color: #aaa;
    font-weight: bold;
    font-size: 0.85rem;
}

.tag-remove:hover {
    color: #ff4444;
}

.filter-mode-btn {
    background: #3a3a5a;
    color: #64b5f6;
    border: 1px solid #64b5f6;
    border-radius: 4px;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 600;
}

.filter-mode-btn:hover {
    background: #64b5f6;
    color: #1a1a2e;
}

.set-filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #2a2a4a;
    border: 1px solid #444;
    border-radius: 6px;
    margin-top: 4px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.set-filter-option {
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    color: #ccc;
    cursor: pointer;
    transition: background 0.1s;
}

.set-filter-option:hover {
    background: rgba(255, 204, 0, 0.1);
    color: #fff;
}

.set-filter-option.active {
    color: #ffcc00;
    font-weight: 600;
}

.filter-select {
    padding: 0.3rem 0.5rem;
    border: 1px solid #444;
    border-radius: 4px;
    background: #2a2a4a;
    color: #eee;
    font-size: 0.85rem;
}

.filter-select:focus {
    outline: none;
    border-color: #3282b8;
}

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding-bottom: 1rem;
}

.card-item {
    background: #2a2a4a;
    border-radius: 10px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    border: 2px solid transparent;
}

.card-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    border-color: #3282b8;
}

.card-item.owned {
    border-color: #ffcc00;
}

.card-item img {
    width: 100%;
    border-radius: 8px;
    display: block;
}

.card-item .card-name {
    font-size: 0.8rem;
    padding: 0.4rem 0.2rem 0.2rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-item .card-set {
    font-size: 0.7rem;
    color: #aaa;
    text-align: center;
}

.card-item .card-variant {
    font-size: 0.65rem;
    color: #bb86fc;
    text-align: center;
    font-weight: 500;
}

.card-variant-issue {
    font-size: 0.65rem;
    color: #e74c3c;
    text-align: center;
    font-weight: 500;
}

.card-variant-valid {
    font-size: 0.6rem;
    color: #4cdf6a;
    text-align: center;
}

.card-item .card-price {
    font-size: 0.75rem;
    color: #4cdf6a;
    text-align: center;
    font-weight: 600;
    padding-bottom: 0.2rem;
}

.card-item .owned-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #ffcc00;
    color: #111;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.card-item .owned-badge.editable-qty {
    cursor: pointer;
}

.card-item .owned-badge.editable-qty:hover {
    background: #ffe066;
    transform: scale(1.1);
}

.qty-edit-input {
    width: 2.5rem;
    font-size: 0.7rem;
    font-weight: bold;
    text-align: center;
    border: none;
    border-radius: 3px;
    background: #fff;
    color: #111;
    padding: 0.1rem;
}

.card-settings-btn {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.6);
    color: #ddd;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 2;
}

.card-item:hover .card-settings-btn {
    opacity: 1;
}

.card-settings-btn:hover {
    background: rgba(255, 204, 0, 0.3);
    color: #ffcc00;
}

.card-item .card-placeholder {
    width: 100%;
    aspect-ratio: 2.5/3.5;
    background: #3a3a5a;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.8rem;
}

/* Stats */
.stats-summary-box {
    background: #2a2a4a;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid #444;
}

.stats-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.stats-summary-row:last-child {
    border-bottom: none;
}

.stats-summary-row.sub {
    padding-top: 0.3rem;
}

.summary-label {
    font-size: 0.95rem;
    color: #aaa;
}

.summary-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffcc00;
}

.summary-value-sub {
    font-size: 1rem;
    color: #888;
}

.stats-details {
    background: #2a2a4a;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.stats-details h3 {
    margin-bottom: 1rem;
    color: #ddd;
}

.set-breakdown-table {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.collection-breakdown-table {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.collection-breakdown-header {
    display: grid;
    grid-template-columns: 1fr 80px 80px 100px;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #444;
}

.collection-breakdown-header span:nth-child(2),
.collection-breakdown-header span:nth-child(3),
.collection-breakdown-header span:nth-child(4) {
    text-align: right;
}

.collection-breakdown-row {
    display: grid;
    grid-template-columns: 1fr 80px 80px 100px;
    gap: 1rem;
    align-items: center;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
}

.collection-breakdown-row:nth-child(odd) {
    background: rgba(255,255,255,0.03);
}

.cb-name {
    font-size: 0.85rem;
    color: #eee;
}

.cb-stat {
    font-size: 0.85rem;
    color: #ffcc00;
    text-align: right;
}

.cb-value {
    font-size: 0.85rem;
    color: #2ecc71;
    text-align: right;
}

.breakdown-header {
    display: grid;
    grid-template-columns: 1fr 120px 60px 100px;
    gap: 2.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #444;
}

.breakdown-header span:nth-child(3),
.breakdown-header span:nth-child(4) {
    text-align: right;
}

.breakdown-row {
    display: grid;
    grid-template-columns: 1fr 120px 60px 100px;
    gap: 2.5rem;
    align-items: center;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
}

.breakdown-row:nth-child(odd) {
    background: rgba(255,255,255,0.03);
}

.breakdown-name {
    font-size: 0.85rem;
}

.breakdown-count {
    font-size: 0.85rem;
    color: #ffcc00;
    font-weight: 500;
    text-align: left;
}

.breakdown-pct {
    font-size: 0.85rem;
    color: #aaa;
    text-align: right;
}

.breakdown-value {
    font-size: 0.85rem;
    color: #8f8;
    text-align: right;
}

.stats-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.stats-details-header h3 {
    margin: 0;
    color: #ddd;
}

.stats-details-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.breakdown-row.clickable {
    cursor: pointer;
    transition: background 0.15s;
}

.breakdown-row.clickable:hover {
    background: rgba(255, 204, 0, 0.08);
}

.breakdown-row.unrepresented-row {
    opacity: 0.5;
}

.breakdown-row.unrepresented-row .breakdown-value {
    color: #888;
    font-style: italic;
}

/* Set Detail Popup */
.set-detail-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
}

.set-detail-popup.hidden {
    display: none;
}

.set-detail-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
}

.set-detail-popup-content {
    position: relative;
    background: #1e1e3a;
    border-radius: 12px;
    padding: 1.5rem;
    width: 90vw;
    max-width: 1100px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    border: 1px solid #444;
}

.set-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    position: sticky;
    top: -1.5rem;
    background: #1e1e3a;
    padding: 1rem 0 0.5rem;
    z-index: 1;
}

.set-detail-header h3 {
    color: #ddd;
    margin: 0;
}

.set-detail-popup .card-item.not-owned {
    opacity: 0.35;
    filter: grayscale(0.7);
}

.set-detail-popup .card-item.not-owned:hover {
    opacity: 0.7;
    filter: grayscale(0.3);
}

/* Unrepresented Sets */
.unrepresented-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.unrep-set {
    font-size: 0.78rem;
    color: #666;
    background: rgba(255,255,255,0.03);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.unrep-set:hover {
    color: #ffcc00;
    background: rgba(255, 204, 0, 0.08);
}

/* Context Menu */
.context-menu {
    position: fixed;
    z-index: 2000;
    background: #2a2a4a;
    border: 1px solid #555;
    border-radius: 6px;
    padding: 4px 0;
    min-width: 160px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.context-menu.hidden {
    display: none;
}

.context-menu-item {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: #ddd;
    cursor: pointer;
    position: relative;
}

.context-menu-item:hover {
    background: rgba(255, 204, 0, 0.1);
    color: #fff;
}

.context-menu-item.has-submenu:hover > .context-submenu {
    display: block;
}

.context-submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    background: #2a2a4a;
    border: 1px solid #555;
    border-radius: 6px;
    padding: 4px 0;
    min-width: 120px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.context-submenu-item {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: #ddd;
    cursor: pointer;
}

.context-submenu-item:hover {
    background: rgba(255, 204, 0, 0.1);
    color: #fff;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
}

.modal-content {
    position: relative;
    background: #2a2a4a;
    border-radius: 12px;
    padding: 2rem;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    display: flex;
    gap: 1.5rem;
}

.modal-image {
    flex: 0 0 250px;
}

.modal-image img {
    width: 100%;
    border-radius: 10px;
}

.modal-info {
    flex: 1;
}

.modal-info h2 {
    margin-bottom: 1rem;
    color: #ffcc00;
}

.modal-details p {
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.modal-pricing {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #444;
}

.modal-divider {
    border: none;
    border-top: 1px solid #444;
    margin: 1rem 0;
}

/* ===== Collection Nav Tabs ===== */
.collection-nav {
    margin-bottom: 0.5rem;
    border-bottom: 2px solid #333;
}

.collection-nav-tabs {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    padding: 0.5rem 0;
}

.col-nav-btn {
    padding: 0.4rem 1rem;
    border: none;
    background: #2a2a4a;
    color: #bbb;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.col-nav-btn:hover {
    background: #3a3a5e;
    color: #fff;
}

.col-nav-btn.active {
    background: #e94560;
    color: #fff;
    font-weight: 600;
}

.col-nav-add {
    background: #1e4d3a;
    color: #4cdf6a;
    font-weight: bold;
    font-size: 1rem;
    padding: 0.4rem 0.8rem;
}

.col-nav-add:hover {
    background: #2a6b4f;
}

/* ===== Collection Toolbar ===== */
.collection-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    flex-wrap: wrap;
}

.collection-toolbar-left {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex: 1;
}

.collection-toolbar-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ===== Selection Bar ===== */
.selection-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: #2c1f4e;
    border: 1px solid #7c3aed;
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.selection-bar span {
    font-weight: 600;
    color: #a78bfa;
}

/* ===== Select Mode Card Highlight ===== */
.card-grid.select-mode .card-item {
    cursor: pointer;
    position: relative;
}

.card-grid.select-mode .card-item:hover {
    outline: 2px solid #a78bfa;
}

.card-grid.select-mode .card-item.selected {
    outline: 3px solid #7c3aed;
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.5);
}

.card-grid.select-mode .card-item.selected::after {
    content: '\2713';
    position: absolute;
    top: 6px;
    right: 6px;
    background: #7c3aed;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
}

/* ===== Add Cards Panel ===== */
.collection-split {
    flex: 1;
    min-height: 0;
}

.collection-split .card-grid {
    height: 100%;
}

/* Add Cards Tab Split */
#tab-addcards.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    overflow: hidden;
}

.add-cards-split {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 0;
}

.add-cards-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-right: 2px solid #e94560;
}

.add-cards-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.add-cards-collection-grid {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    align-content: start;
}

.add-cards-right-toolbar {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #333;
    align-items: center;
}

.add-cards-right-toolbar .search-input {
    flex: 1;
    min-width: 0;
}

.add-cards-right-toolbar .filter-select {
    max-width: 150px;
}

.add-cards-right .set-filter-dropdown {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    max-height: 300px;
    overflow-y: auto;
    margin: 0.5rem 0.75rem;
    border: 1px solid #444;
    border-radius: 6px;
    background: #1e1e3a;
    box-shadow: none;
}

.filter-search-input {
    width: 100%;
    padding: 0.3rem 0.5rem;
    border: 1px solid #444;
    border-radius: 4px;
    background: #2a2a4a;
    color: #eee;
    font-size: 0.85rem;
    outline: none;
    position: sticky;
    top: 0;
    z-index: 1;
    box-sizing: border-box;
}

.filter-search-input:focus {
    border-color: #3282b8;
}

.filter-search-input::placeholder {
    color: #888;
}

.add-cards-right .set-filter-tags {
    padding: 0.25rem 1rem;
}

.add-cards-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #333;
}

.add-cards-header h3 {
    color: #ffcc00;
    font-size: 1rem;
}

/* Variant Toggle */
.variant-toggle { display: flex; align-items: center; }
.toggle-label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; font-size: 0.8rem; position: relative; }
.toggle-label input { display: none; }
.toggle-slider { width: 36px; height: 18px; background: #3498db; border-radius: 9px; position: relative; transition: background 0.2s; }
.toggle-slider::after { content: ''; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; background: #fff; border-radius: 50%; transition: transform 0.2s; }
.toggle-label input:checked ~ .toggle-slider { background: #9b59b6; }
.toggle-label input:checked ~ .toggle-slider::after { transform: translateX(18px); }
.toggle-text-left { color: #3498db; font-weight: 600; }
.toggle-text-right { color: #666; }
.toggle-label input:checked ~ .toggle-text-left { color: #666; }
.toggle-label input:checked ~ .toggle-text-right { color: #9b59b6; font-weight: 600; }

.add-cards-search {
    display: flex;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #333;
    align-items: center;
}

.add-cards-search input {
    flex: 1;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    border: 1px solid #444;
    background: #16162e;
    color: #eee;
    font-size: 0.85rem;
    min-width: 0;
}

.add-cards-search .collection-filter-wrapper {
    flex: 0 0 100px;
}

.add-cards-search .filter-select {
    flex: 0 0 100px;
    max-width: 100px;
}

.add-cards-results {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
    align-content: start;
}

.add-card-item {
    cursor: pointer;
    transition: transform 0.15s;
}

.add-card-item:hover {
    transform: scale(1.05);
}

.add-card-item.add-card-added {
    outline: 2px solid #4cdf6a;
}

.add-card-badge {
    position: absolute;
    bottom: 0.4rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #4cdf6a;
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    white-space: nowrap;
}

.change-amount-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0;
}

/* ===== Utility ===== */
.hidden {
    display: none !important;
}

/* ===== Source Order Buttons ===== */
.source-order-btns {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-right: 0.5rem;
}

.source-order-btns .btn {
    padding: 0.1rem 0.4rem;
    font-size: 0.65rem;
    line-height: 1;
    min-width: unset;
}

.source-order-btns .btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ===== Select Quantity Control ===== */
.select-qty-ctrl {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(30, 30, 58, 0.95);
    border: 1px solid #7c3aed;
    border-radius: 4px;
    padding: 2px 6px;
    z-index: 5;
}

.sq-btn {
    background: #7c3aed;
    color: #fff;
    border: none;
    border-radius: 3px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sq-btn:hover {
    background: #9b59f0;
}

.sq-val {
    color: #fff;
    font-weight: 600;
    font-size: 0.8rem;
    min-width: 16px;
    text-align: center;
}

.modal-pricing span {
    color: #4cdf6a;
    font-weight: 600;
}

.move-select {
    margin-left: auto;
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    max-width: 110px;
}

.qty-display {
    min-width: 30px;
    text-align: center;
    font-weight: bold;
    font-size: 1.1rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    color: #aaa;
}

.loading::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    margin: 1rem auto;
    border: 3px solid #444;
    border-top-color: #ffcc00;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal-body {
        flex-direction: column;
    }

    .modal-image {
        flex: none;
        max-width: 200px;
        margin: 0 auto;
    }

    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

/* Import Mode Dialog */
.import-dialog-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.import-dialog {
    background: #1e1e2e;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 1.5rem;
    min-width: 320px;
    text-align: center;
}

.import-dialog h3 {
    margin-bottom: 0.5rem;
    color: #fff;
}

.import-dialog p {
    color: #aaa;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.import-dialog-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.import-dialog-buttons .btn {
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.import-btn-add {
    background: #2ecc71;
    color: #000;
    border: none;
    border-radius: 4px;
}

.import-btn-replace {
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 4px;
}

.import-btn-cancel {
    background: #555;
    color: #fff;
    border: none;
    border-radius: 4px;
}

.import-dialog-desc {
    color: #888;
    text-align: left;
    line-height: 1.6;
}
