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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    font-size: 14px;
}

/* Navigation */
.nav {
    background: #1a1a2e;
    color: white;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.nav h1 { font-size: 18px; font-weight: 600; }
.nav a {
    color: #aaa;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    transition: all 0.2s;
}
.nav a:hover, .nav a.active { color: white; background: rgba(255,255,255,0.1); }

/* Layout */
.explorer-layout {
    display: flex;
    height: calc(100vh - 48px);
}

/* Tree panel */
.tree-panel {
    width: 320px;
    min-width: 320px;
    background: white;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.tree-search {
    padding: 12px;
    border-bottom: 1px solid #eee;
}
.tree-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}
.tree-search input:focus { border-color: #4a90d9; }
.tree-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* Tree nodes */
.tree-node {
    cursor: pointer;
    user-select: none;
}
.tree-node-row {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    gap: 4px;
    transition: background 0.15s;
}
.tree-node-row:hover { background: #f0f4ff; }
.tree-node-row.selected { background: #e3edff; font-weight: 600; }
.tree-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #888;
    flex-shrink: 0;
}
.tree-node-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
}
.tree-children { display: none; }
.tree-node.expanded > .tree-children { display: block; }

/* Search results */
.search-results {
    padding: 8px 0;
}
.search-result-item {
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
}
.search-result-item:hover { background: #f0f4ff; }
.search-result-path { color: #888; font-size: 11px; }

/* Right panel */
.right-panel {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Category header */
.category-header {
    margin-bottom: 20px;
}
.category-header h2 { font-size: 20px; margin-bottom: 8px; }
.category-stats {
    display: flex;
    gap: 16px;
    color: #666;
    font-size: 13px;
}
.category-stats span { background: #f0f0f0; padding: 4px 10px; border-radius: 4px; }

/* Subtree toggle */
.subtree-toggle {
    margin-bottom: 16px;
}
.subtree-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #555;
}

/* Params table */
.params-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.params-table th {
    text-align: left;
    padding: 10px 14px;
    background: #f8f9fa;
    font-weight: 600;
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    border-bottom: 2px solid #eee;
}
.params-table td {
    padding: 8px 14px;
    border-bottom: 1px solid #f0f0f0;
}
.params-table tr:hover td { background: #fafbff; }
.params-table .param-name {
    cursor: pointer;
    color: #2563eb;
    font-weight: 500;
}
.params-table .param-name:hover { text-decoration: underline; }
.params-table .count { text-align: right; font-variant-numeric: tabular-nums; }
.params-table .pct { text-align: right; color: #888; font-variant-numeric: tabular-nums; }

/* Pct bar */
.pct-bar {
    width: 60px;
    height: 6px;
    background: #eee;
    border-radius: 3px;
    display: inline-block;
    vertical-align: middle;
    margin-left: 6px;
}
.pct-bar-fill {
    height: 100%;
    background: #4a90d9;
    border-radius: 3px;
}

/* Values sub-table */
.values-row td {
    padding: 0 !important;
    background: #f8faff;
}
.values-container {
    padding: 8px 14px 8px 40px;
}
.values-container table {
    width: 100%;
    border-collapse: collapse;
}
.values-container td {
    padding: 4px 10px !important;
    font-size: 13px;
    border-bottom: 1px solid #eef !important;
    background: transparent !important;
}
.values-container .load-more {
    padding: 6px 0;
    color: #4a90d9;
    cursor: pointer;
    font-size: 12px;
}

/* LP button */
.btn-add-lp {
    background: none;
    border: 1px solid #4a90d9;
    color: #4a90d9;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    transition: all 0.15s;
}
.btn-add-lp:hover { background: #4a90d9; color: white; }
.btn-add-lp.added { background: #28a745; border-color: #28a745; color: white; cursor: default; }

/* Multi button */
.btn-multi {
    background: none;
    border: 1px solid #7c3aed;
    color: #7c3aed;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    margin-left: 4px;
    transition: all 0.15s;
}
.btn-multi:hover { background: #7c3aed; color: white; }
.btn-multi.active { background: #7c3aed; color: white; }

.multi-badge {
    background: #7c3aed;
    color: white;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
    font-weight: 500;
}

/* Multi LP Builder Panel */
.multi-builder-panel {
    margin-top: 20px;
    background: #f5f0ff;
    border: 2px solid #7c3aed;
    border-radius: 8px;
    padding: 16px;
}
.multi-builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.multi-builder-header h3 { color: #7c3aed; font-size: 16px; }
.multi-builder-traits {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.multi-trait-tag {
    background: white;
    border: 1px solid #d4bfff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
}
.multi-builder-info {
    font-size: 13px;
    margin-bottom: 12px;
    color: #555;
}
.multi-builder-actions {
    display: flex;
    gap: 8px;
}

/* Multi results table */
.multi-results {
    margin-top: 16px;
}
.multi-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.multi-results-header span { font-size: 14px; }
.multi-results-header div { display: flex; gap: 8px; }
.multi-results-table tr.row-deselected { opacity: 0.4; }
.multi-results-table tr.row-duplicate-h1 { background: #fff4e5; }
.multi-results-table tr.row-duplicate-h1:hover { background: #ffe8c7; }
.multi-results-table tr.row-no-products { background: #f1f3f5; }
.multi-results-table tr.row-no-products:hover { background: #e9ecef; }
.multi-results-table tr.row-no-products.row-duplicate-h1 { background: #fef0d4; }
.ean-zero { color: #dc3545; font-weight: 600; }
.ean-low { color: #e67e22; }
.ean-ok { color: #28a745; font-weight: 600; }

tr.value-junk { opacity: 0.55; background: #fafafa; }
.junk-tag {
    display: inline-block;
    font-size: 10px;
    padding: 1px 5px;
    background: #e9ecef;
    color: #6c757d;
    border-radius: 3px;
    font-weight: 600;
    vertical-align: middle;
    cursor: help;
}
.dup-h1-badge,
.dup-saved-badge,
.dup-cat-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 3px;
    cursor: help;
}
.dup-h1-badge { color: #b25d00; background: #ffd8a8; }
.dup-saved-badge { color: #8b0000; background: #ffc9c9; }
.dup-cat-badge { color: #5a189a; background: #e5d4ff; }
.vol-zero { color: #dc3545; }
.vol-low { color: #e67e22; }
.vol-high { color: #28a745; font-weight: 600; }

/* Auto LP Discovery */
.auto-lp-view { height: calc(100vh - 48px); overflow-y: auto; }
.auto-lp-container { max-width: 1100px; margin: 0 auto; padding: 24px; }
.auto-lp-container h2 { margin-bottom: 16px; }
.auto-category-select {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 20px; position: relative;
}
.auto-category-select input[type="text"] {
    width: 300px; padding: 8px 12px; border: 1px solid #ddd;
    border-radius: 6px; font-size: 14px;
}
.auto-category-dropdown {
    position: absolute; top: 40px; left: 60px;
    width: 400px; max-height: 300px; overflow-y: auto;
    background: white; border: 1px solid #ddd; border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 100;
}
.auto-cat-item {
    padding: 8px 12px; cursor: pointer; display: flex;
    flex-direction: column; gap: 2px;
}
.auto-cat-item:hover { background: #f0f4ff; }

.auto-section { margin-bottom: 24px; }
.auto-section h3 { margin-bottom: 12px; font-size: 16px; }

.auto-traits-grid {
    display: flex; flex-wrap: wrap; gap: 10px;
}
.auto-trait-card {
    background: white; border: 1px solid #ddd; border-radius: 6px;
    padding: 10px 14px; min-width: 200px; max-width: 280px;
}
.auto-trait-card.seo { border-left: 3px solid #28a745; }
.auto-trait-card.rejected { border-left: 3px solid #dc3545; opacity: 0.6; }
.trait-name { font-weight: 600; margin-bottom: 4px; }
.trait-stats { font-size: 12px; color: #666; margin-bottom: 4px; }
.trait-samples { font-size: 11px; color: #888; }
.trait-reason { font-size: 11px; color: #dc3545; }

.score-badge {
    font-size: 11px; padding: 2px 8px; border-radius: 10px;
    font-weight: 600;
}
.score-high { background: #d4edda; color: #155724; }
.score-medium { background: #fff3cd; color: #856404; }
.score-manual { background: #cce5ff; color: #004085; }

.btn-tiny {
    display: inline-block;
    font-size: 10px;
    padding: 1px 6px;
    border: 0;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 600;
    vertical-align: middle;
}
.btn-tiny-restore { background: #17a2b8; color: #fff; }
.btn-tiny-restore:hover { background: #138496; }
.btn-tiny-gray { background: #6c757d; color: #fff; }
.btn-tiny-gray:hover { background: #5a6268; }

.rescued-badge {
    display: inline-block;
    font-size: 9px;
    padding: 1px 5px;
    background: #cce5ff;
    color: #004085;
    border-radius: 3px;
    font-weight: 600;
    vertical-align: middle;
}

.custom-pair-builder {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
}
.custom-pair-builder select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
}

.auto-pair-expand { background: #fafbff; }

/* Bulk modify bar */
.bulk-modify-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
}
.bulk-modify-bar input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d4bfff;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}
.bulk-modify-bar input:focus { border-color: #7c3aed; }

/* Inline H1 edit in multi results */
.h1-text-multi {
    cursor: pointer;
    font-weight: 600;
    padding: 2px 4px;
    border: 1px solid transparent;
    border-radius: 3px;
}
.h1-text-multi:hover { border-color: #7c3aed; background: #f5f0ff; }
.h1-text-multi.h1-empty {
    color: #999;
    font-style: italic;
    font-weight: 400;
    border: 1px dashed #bbb;
    background: #fafafa;
}
.h1-text-multi.h1-empty:hover { border-color: #7c3aed; background: #f5f0ff; color: #7c3aed; }

/* Used LP indicators */
.used-badge {
    background: #28a745;
    color: white;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
    font-weight: 500;
}
.used-tag {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 600;
    vertical-align: middle;
    display: inline-block;
    margin-left: 2px;
}
.used-tag.used-single { background: #28a745; color: white; }
.used-tag.used-multi { background: #6f42c1; color: white; }
.used-inline { color: #28a745; font-weight: 600; }
tr.value-used > td:first-child,
tr.value-used > td:nth-child(2) { opacity: 0.6; }

/* Combo summary bar */
.combo-summary-bar {
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #2e7d32;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.combo-summary-tag {
    background: white;
    border: 1px solid #a5d6a7;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: #333;
}

/* Multi filter links */
.multi-filter-links {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.multi-filter-links a {
    font-size: 11px;
    color: #7c3aed;
    text-decoration: none;
    white-space: nowrap;
}
.multi-filter-links a:hover { text-decoration: underline; }

/* LP Registry page */
.lp-registry {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}
.lp-registry h2 { margin-bottom: 16px; }
.lp-registry .toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: center;
}
.lp-registry .toolbar input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    flex: 1;
    max-width: 300px;
}
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}
.btn-primary { background: #4a90d9; color: white; }
.btn-primary:hover { background: #3a7bc8; }
.btn-danger { background: none; border: 1px solid #dc3545; color: #dc3545; }
.btn-danger:hover { background: #dc3545; color: white; }

.lp-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.lp-table th {
    text-align: left;
    padding: 10px 14px;
    background: #f8f9fa;
    font-weight: 600;
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    border-bottom: 2px solid #eee;
}
.lp-table td {
    padding: 8px 14px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}
.lp-table .url-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}
.lp-table .h1-cell {
    white-space: nowrap;
}
.lp-table .url-cell a { color: #4a90d9; text-decoration: none; }
.lp-table .url-cell a:hover { text-decoration: underline; }

/* Loading & empty states */
.loading {
    text-align: center;
    padding: 40px;
    color: #888;
}
.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: #4a90d9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}
.empty-state p { font-size: 15px; }

/* Toast notification */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s;
    z-index: 1000;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #28a745; }
.toast.error { background: #dc3545; }

/* H1 inline edit */
.h1-cell { min-width: 200px; }
.h1-text {
    cursor: pointer;
    font-weight: 500;
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.h1-text:hover { border-color: #4a90d9; background: #f0f4ff; }
.h1-text.h1-empty { color: #aaa; font-style: italic; font-weight: 400; }
.h1-input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #4a90d9;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    outline: none;
}

/* Hidden */
.hidden { display: none !important; }
