/* ============================================
   DataClean — Project Styles
   Uses shared Sidequest Labs theme (css/theme.css)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');
@import url('theme.css');

/* === Project-specific Styles === */

.main { flex: 1; display: flex; flex-direction: column; padding: 2rem; max-width: 1400px; width: 100%; margin: 0 auto; }

/* Upload Panel */
.upload-panel { display: flex; flex-direction: column; align-items: center; gap: 2rem; padding: 2rem 0; }
.upload-area {
    width: 100%; max-width: 640px; padding: 3rem 2rem;
    border: 2px dashed var(--border-color); border-radius: var(--radius-lg);
    text-align: center; cursor: pointer; transition: all var(--transition);
}
.upload-area:hover, .upload-area.drag-over { border-color: var(--accent); background: var(--accent-light); }
.upload-icon { font-size: 3rem; margin-bottom: 1rem; }
.upload-area h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.upload-link { color: var(--accent); cursor: pointer; text-decoration: underline; }
.upload-examples { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border-color); }
.upload-examples p { font-size: 0.8125rem; color: var(--text-muted); }

/* Paste Area */
.paste-area { width: 100%; max-width: 640px; }
.paste-label { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.paste-area textarea {
    width: 100%; padding: 0.75rem 1rem; background: var(--bg-secondary);
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    color: var(--text-primary); font-family: monospace; font-size: 0.8125rem;
    resize: vertical; transition: border-color var(--transition);
}
.paste-area textarea:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(30,58,95,0.1); }

/* Sample Data */
.sample-data { text-align: center; }
.sample-data p { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 0.75rem; }
.sample-buttons { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.btn-sample {
    padding: 0.5rem 1rem; background: var(--accent-light); border: 1px solid var(--accent);
    border-radius: var(--radius-sm); color: var(--accent); font-size: 0.8125rem;
    font-weight: 500; cursor: pointer; transition: all var(--transition);
}
.btn-sample:hover { background: var(--accent-light); border-color: var(--accent); transform: translateY(-1px); }

/* Issues Banner */
.issues-banner {
    background: var(--bg-secondary); border: 1px solid var(--warning);
    border-radius: var(--radius-md); padding: 1rem; margin-bottom: 1rem;
}
.issues-header { display: flex; align-items: center; gap: 0.75rem; }
.issues-icon { font-size: 1.25rem; }
.issues-list { margin-top: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.issue-tag {
    padding: 0.25rem 0.75rem; background: var(--accent-light); border-radius: 1rem;
    font-size: 0.75rem; color: var(--accent); font-weight: 500;
}

/* Controls Bar */
.controls-bar { margin-bottom: 1rem; }

/* Data Table with Issue Highlighting */
.data-table .cell-issue { background: #fef2f2; color: #991b1b; }
[data-theme="dark"] .data-table .cell-issue { background: #450a0a; color: #fca5a5; }
.data-table .cell-fixed { background: #f0fdf4; color: #166534; }
[data-theme="dark"] .data-table .cell-fixed { background: #14532d; color: #86efac; }
/* Before/after diff highlighting */
.data-table .cell-touched {
    background: #f0fdf4;
    color: #166534;
    position: relative;
}
[data-theme="dark"] .data-table .cell-touched { background: #14532d; color: #86efac; }
.data-table .cell-changed {
    background: #dcfce7 !important;
    color: #14532d !important;
    box-shadow: inset 0 0 0 2px #16a34a;
    font-weight: 500;
}
[data-theme="dark"] .data-table .cell-changed {
    background: #166534 !important;
    color: #dcfce7 !important;
    box-shadow: inset 0 0 0 2px #4ade80;
}
/* Active toggle button (currently-on swatch toggle) */
.btn-icon.btn-icon-square.active {
    background: var(--accent-light, #dbeafe);
    color: var(--accent, #1e40af);
}
.btn-icon.btn-icon-square {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}
[data-theme="dark"] .btn-icon.btn-icon-square.active {
    background: var(--accent-light, #1e3a8a);
    color: var(--accent, #bfdbfe);
}

/* Statistics Panel */
.statistics-panel {
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    padding: 1rem; background: var(--bg-secondary); margin-bottom: 1.5rem;
}
.statistics-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0.75rem;
}
.statistics-header h3 { font-size: 0.875rem; margin: 0; }
.statistics-controls { display: flex; gap: 1rem; align-items: center; font-size: 0.75rem; color: var(--text-secondary); }
.statistics-type-filter { display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; user-select: none; }
.statistics-table-wrapper {
    overflow-x: auto;
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
}
.statistics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
.statistics-table th, .statistics-table td {
    padding: 0.5rem 0.65rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.statistics-table th:first-child, .statistics-table td:first-child {
    text-align: left;
    position: sticky; left: 0;
    background: var(--bg-primary);
    z-index: 1;
}
.statistics-table thead th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky; top: 0;
    z-index: 2;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.05em;
}
.statistics-table thead th:first-child { z-index: 3; }
.statistics-table tbody tr:nth-child(even) { background: rgba(0,0,0,0.02); }
[data-theme="dark"] .statistics-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.statistics-table tbody tr.clickable { cursor: pointer; }
.statistics-table tbody tr.clickable:hover { background: var(--bg-hover); }
.statistics-table tbody tr.selected { background: var(--accent-light); }
[data-theme="dark"] .statistics-table tbody tr.selected { background: rgba(30,58,95,0.25); }
.statistics-table .col-name { font-weight: 500; color: var(--text-primary); }
.statistics-table .col-name-wrap { display: inline-flex; align-items: center; gap: 0.4rem; }
.statistics-table .num-cell { font-variant-numeric: tabular-nums; color: var(--text-primary); }
.statistics-table .muted { color: var(--text-muted); }
.statistics-table .null-warn { color: #b45309; font-weight: 600; }
[data-theme="dark"] .statistics-table .null-warn { color: #fbbf24; }
.statistics-table .type-cell { text-align: left; }
.statistics-table .placeholder { color: var(--text-muted); font-style: italic; }
.statistics-table tbody tr.stats-group-header td.stats-group-label {
    text-align: left;
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.05em;
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid var(--border-color);
}

/* Frequency Distribution */
.frequency-section {
    margin-top: 1rem; padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
}
.frequency-section h4 {
    font-size: 0.8125rem; font-weight: 600; margin-bottom: 0.5rem;
    color: var(--text-secondary);
}
#frequency-col-name { color: var(--accent); font-weight: 500; }
.frequency-list { display: flex; flex-direction: column; gap: 0.35rem; }
.frequency-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 60%;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
}
.frequency-value {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--text-primary);
}
.frequency-count {
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    font-weight: 500;
}
.frequency-bar {
    height: 10px; background: var(--bg-primary);
    border-radius: 5px; overflow: hidden;
    border: 1px solid var(--border-color);
}
.frequency-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, transparent));
    border-radius: 5px;
    transition: width 0.3s ease-out;
}
#frequency-help {
    font-size: 0.7rem; color: var(--text-muted);
    margin-top: 0.5rem; margin-bottom: 0;
}

/* Outlier Detection */
/* ----- Per-column Quality badge (in statistics table) ----- */
.q-badge {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 2px 8px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.78rem; font-weight: 600;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.12s ease;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
}
.q-badge:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.q-badge:active { transform: translateY(0); }
.q-badge .q-grade {
    font-size: 0.62rem; font-weight: 700;
    padding: 0 4px;
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}
.q-badge.q-good  { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.q-badge.q-good  .q-grade { background: #bbf7d0; color: #166534; }
.q-badge.q-ok    { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.q-badge.q-ok    .q-grade { background: #fde68a; color: #92400e; }
.q-badge.q-bad   { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.q-badge.q-bad   .q-grade { background: #fecaca; color: #991b1b; }
[data-theme="dark"] .q-badge.q-good  { background: rgba(34,197,94,0.18);  color: #86efac; border-color: rgba(34,197,94,0.4); }
[data-theme="dark"] .q-badge.q-good  .q-grade { background: rgba(34,197,94,0.3); color: #bbf7d0; }
[data-theme="dark"] .q-badge.q-ok    { background: rgba(245,158,11,0.18); color: #fcd34d; border-color: rgba(245,158,11,0.4); }
[data-theme="dark"] .q-badge.q-ok    .q-grade { background: rgba(245,158,11,0.3); color: #fde68a; }
[data-theme="dark"] .q-badge.q-bad   { background: rgba(239,68,68,0.18);  color: #fca5a5; border-color: rgba(239,68,68,0.4); }
[data-theme="dark"] .q-badge.q-bad   .q-grade { background: rgba(239,68,68,0.3);  color: #fecaca; }

.quality-cell { text-align: center; padding: 4px 6px !important; white-space: nowrap; }

/* ----- Column Health drill-down panel ----- */
.column-health-section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-color);
}
.column-health-section h4 {
    font-size: 0.8rem; font-weight: 600; margin: 0 0 0.5rem 0;
}
#column-health-name { color: var(--accent); font-weight: 500; }
.column-health-grid {
    display: flex; flex-direction: column; gap: 0.4rem;
    margin-top: 0.4rem;
}
.ch-dim {
    display: flex; flex-direction: column; gap: 0.2rem;
}
.ch-dim-row {
    display: flex; justify-content: space-between; align-items: baseline;
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.ch-dim-label { font-weight: 500; }
.ch-dim-score {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--text-primary);
}
.ch-dim-bar {
    background: var(--bg-secondary);
    border-radius: 4px;
    height: 6px; overflow: hidden;
    border: 1px solid var(--border-color);
}
.ch-dim-bar-fill { display: block; height: 100%; transition: width 0.25s ease; }
.ch-dim-bar-fill.tier-good { background: #16a34a; }
.ch-dim-bar-fill.tier-ok   { background: #d97706; }
.ch-dim-bar-fill.tier-bad  { background: #dc2626; }
[data-theme="dark"] .ch-dim-bar-fill.tier-good { background: #22c55e; }
[data-theme="dark"] .ch-dim-bar-fill.tier-ok   { background: #f59e0b; }
[data-theme="dark"] .ch-dim-bar-fill.tier-bad  { background: #ef4444; }

.ch-summary {
    display: flex; align-items: center; gap: 0.6rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}
.ch-summary .ch-score {
    flex: 0 0 auto;
}
.ch-summary .ch-reason {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.35;
}

.outlier-section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-color);
}
.outlier-header {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
    flex-wrap: wrap; margin-bottom: 0.5rem;
}
.outlier-header h4 {
    font-size: 0.8rem; font-weight: 600; margin: 0;
}
#outlier-col-name { color: var(--accent); font-weight: 500; }
.outlier-method { font-size: 0.75rem; color: var(--text-secondary); display: inline-flex; gap: 0.4rem; align-items: center; }
.outlier-method select {
    font-size: 0.75rem; padding: 0.2rem 0.4rem;
    background: var(--bg-primary); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
}
.outlier-summary {
    font-size: 0.75rem; color: var(--text-secondary);
    margin-bottom: 0.5rem; line-height: 1.4;
}
.outlier-summary strong { color: var(--text-primary); }
.outlier-list {
    display: flex; flex-direction: column; gap: 2px;
    max-height: 220px; overflow-y: auto;
    padding: 0.25rem 0;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--bg-primary);
}
.outlier-row {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr) 90px;
    gap: 0.5rem;
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}
.outlier-row:nth-child(even) { background: rgba(0,0,0,0.02); }
[data-theme="dark"] .outlier-row:nth-child(even) { background: rgba(255,255,255,0.02); }
.outlier-row-head {
    font-weight: 600; color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase; font-size: 0.65rem; letter-spacing: 0.04em;
    background: transparent !important;
}
.outlier-row-head { padding-top: 0.4rem; padding-bottom: 0.4rem; }
.outlier-empty {
    padding: 0.6rem; color: var(--text-muted); font-style: italic; font-size: 0.75rem;
}
.outlier-more {
    padding: 0.3rem 0.6rem; font-size: 0.7rem;
}
.outlier-actions {
    margin-top: 0.5rem;
    display: flex; gap: 0.5rem;
}
.outlier-actions .btn-secondary { font-size: 0.75rem; padding: 0.4rem 0.75rem; }
.outlier-actions .btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
#outlier-help { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.4rem; margin-bottom: 0; }

/* Outlier modal preview */
.outlier-modal-preview {
    margin-top: 0.5rem;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--bg-primary); padding: 0.4rem;
    max-height: 280px; overflow-y: auto;
}
.outlier-modal-preview .outlier-row { grid-template-columns: 80px minmax(0, 1fr); }
.outlier-preview-summary {
    font-size: 0.75rem; color: var(--text-secondary);
    padding: 0.25rem 0.5rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.25rem;
}
.outlier-preview-summary strong { color: var(--text-primary); }

@media (max-width: 600px) {
    .statistics-table-wrapper { max-height: 280px; }
    .statistics-table th, .statistics-table td { padding: 0.4rem 0.5rem; font-size: 0.75rem; }
    .frequency-row { grid-template-columns: minmax(0, 1fr) auto 50%; gap: 0.5rem; }
}

/* Quality Score (0–100) */
.quality-score {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}
.quality-score-head {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}
.quality-score-circle {
    position: relative;
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}
.quality-score-svg {
    width: 120px;
    height: 120px;
    transform: rotate(-90deg);
}
.quality-score-svg circle {
    fill: none;
    stroke-width: 10;
    stroke-linecap: round;
}
.quality-score-svg .qs-track {
    stroke: var(--border-color);
}
.quality-score-svg .qs-fill {
    stroke: var(--accent);
    stroke-dasharray: 326.7; /* 2π × 52 */
    stroke-dashoffset: 326.7;
    transition: stroke-dashoffset 0.6s ease, stroke 0.3s ease;
}
.quality-score-svg .qs-fill.grade-a { stroke: #16a34a; }
.quality-score-svg .qs-fill.grade-b { stroke: #65a30d; }
.quality-score-svg .qs-fill.grade-c { stroke: #d97706; }
.quality-score-svg .qs-fill.grade-d { stroke: #ea580c; }
.quality-score-svg .qs-fill.grade-f { stroke: #dc2626; }
[data-theme="dark"] .quality-score-svg .qs-fill.grade-a { stroke: #22c55e; }
[data-theme="dark"] .quality-score-svg .qs-fill.grade-b { stroke: #84cc16; }
[data-theme="dark"] .quality-score-svg .qs-fill.grade-c { stroke: #f59e0b; }
[data-theme="dark"] .quality-score-svg .qs-fill.grade-d { stroke: #f97316; }
[data-theme="dark"] .quality-score-svg .qs-fill.grade-f { stroke: #ef4444; }
.qs-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.qs-score {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.qs-grade {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
}
.quality-score-summary {
    flex: 1;
    min-width: 200px;
}
.quality-score-summary h3 {
    font-size: 0.875rem;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}
.quality-score-actions {
    flex-shrink: 0;
}
.quality-score-actions .btn-secondary {
    font-size: 0.75rem;
    padding: 0.45rem 0.85rem;
    white-space: nowrap;
}
.qs-summary {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}
.qs-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}
.qs-dim {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.55rem 0.7rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}
.qs-dim-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}
.qs-dim-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.qs-dim-score {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.qs-dim-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}
.qs-dim-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease, background 0.3s ease;
}
.qs-dim-bar-fill.tier-good { background: #16a34a; }
.qs-dim-bar-fill.tier-ok   { background: #d97706; }
.qs-dim-bar-fill.tier-bad  { background: #dc2626; }
[data-theme="dark"] .qs-dim-bar-fill.tier-good { background: #22c55e; }
[data-theme="dark"] .qs-dim-bar-fill.tier-ok   { background: #f59e0b; }
[data-theme="dark"] .qs-dim-bar-fill.tier-bad  { background: #ef4444; }
.qs-dim-detail {
    font-size: 0.6875rem;
    color: var(--text-muted);
}
.qs-recommendations {
    border-top: 1px dashed var(--border-color);
    padding-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.qs-rec {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text-secondary);
}
.qs-rec-prio {
    flex-shrink: 0;
    display: inline-block;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-top: 1px;
}
.qs-rec-prio.prio-high { background: #fee2e2; color: #b91c1c; }
.qs-rec-prio.prio-medium { background: #fef3c7; color: #92400e; }
.qs-rec-prio.prio-low { background: #dbeafe; color: #1e40af; }
.qs-rec-prio.prio-info { background: #dcfce7; color: #166534; }
[data-theme="dark"] .qs-rec-prio.prio-high { background: #450a0a; color: #fecaca; }
[data-theme="dark"] .qs-rec-prio.prio-medium { background: #451a03; color: #fde68a; }
[data-theme="dark"] .qs-rec-prio.prio-low { background: #1e3a8a; color: #bfdbfe; }
[data-theme="dark"] .qs-rec-prio.prio-info { background: #14532d; color: #bbf7d0; }

@media (max-width: 480px) {
    .quality-score-head { flex-direction: column; align-items: flex-start; }
    .quality-score-circle { width: 96px; height: 96px; }
    .quality-score-svg { width: 96px; height: 96px; }
    .qs-score { font-size: 1.6rem; }
}

/* Quality Report */
.quality-report {
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    padding: 1rem; background: var(--bg-secondary);
    margin-bottom: 1.5rem;
}
.quality-report h3 { font-size: 0.875rem; margin-bottom: 0.75rem; }
.quality-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; }

/* Before/After diff summary */
.diff-summary {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
}
.diff-summary h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}
#diff-summary-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}
.diff-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 0.35rem;
    border: 1px solid var(--border-color);
}
.legend-swatch.swatch-current {
    background: #dcfce7;
    border-color: #16a34a;
    box-shadow: inset 0 0 0 2px #16a34a;
}
.legend-swatch.swatch-touched { background: #f0fdf4; border-color: #86efac; }
.legend-swatch.swatch-issue   { background: #fef2f2; border-color: #fca5a5; }
[data-theme="dark"] .legend-swatch.swatch-current { background: #166534; border-color: #4ade80; }
[data-theme="dark"] .legend-swatch.swatch-touched { background: #14532d; border-color: #166534; }
[data-theme="dark"] .legend-swatch.swatch-issue   { background: #450a0a; border-color: #fca5a5; }
.quality-stat {
    padding: 0.75rem; background: var(--bg-primary); border-radius: var(--radius-sm);
    border: 1px solid var(--border-color); text-align: center;
}
.quality-stat .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.quality-stat .stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

/* Column Operations Toolbar */
.columns-bar {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 1rem; background: var(--bg-primary);
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    margin-bottom: 1rem; flex-wrap: wrap;
}
.columns-label { font-size: 0.8125rem; font-weight: 600; color: var(--text-secondary); margin-right: 0.25rem; }
.btn-toolbar {
    padding: 0.35rem 0.75rem; background: var(--bg-primary);
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 0.75rem; font-weight: 500;
    cursor: pointer; transition: all var(--transition);
}
.btn-toolbar:hover { background: var(--accent-light); border-color: var(--accent); }
.btn-toolbar-danger:hover { background: #fee2e2; border-color: var(--danger); }
[data-theme="dark"] .btn-toolbar-danger:hover { background: #450a0a; }

/* Language picker (v0.12.0): small <select> styled like a header chip. */
.lang-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-primary);
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                      linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 12px) 50%, calc(100% - 8px) 50%;
    background-size: 4px 4px;
    background-repeat: no-repeat;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0 1.6rem 0 0.6rem;
    height: 32px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color var(--transition), background-color var(--transition);
}
.lang-select:hover { border-color: var(--accent); }
.lang-select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.lang-select-landing {
    height: 38px;
    padding-left: 0.75rem;
    padding-right: 1.8rem;
    font-size: 0.8125rem;
}

/* Sortable Column Headers */
.data-table th { cursor: pointer; user-select: none; }
.data-table th:hover { background: var(--bg-hover); }
.data-table th.selected { background: var(--accent-light); color: var(--accent); }
.data-table th .col-type {
    display: inline-block; font-size: 0.625rem; padding: 0.1rem 0.4rem;
    margin-left: 0.4rem; border-radius: 0.25rem;
    background: var(--bg-secondary); color: var(--text-muted); font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.05em; vertical-align: middle;
}
.data-table th .col-blank-count {
    display: inline-block; font-size: 0.625rem; padding: 0.1rem 0.35rem;
    margin-left: 0.25rem; border-radius: 0.25rem;
    background: #fef3c7; color: #92400e; font-weight: 600;
}
[data-theme="dark"] .data-table th .col-blank-count { background: #78350f; color: #fbbf24; }
.data-table th .sort-indicator { margin-left: 0.25rem; opacity: 0.7; }
.data-table-section.hidden { display: none; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 1rem;
}
.modal {
    background: var(--bg-primary); color: var(--text-primary);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    width: 100%; max-width: 480px; max-height: 90vh; overflow: auto;
    display: flex; flex-direction: column;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.25rem; }
.modal-body label { display: block; font-size: 0.8125rem; font-weight: 500; margin-bottom: 0.35rem; color: var(--text-secondary); }
.modal-body input[type="text"], .modal-body select {
    width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); background: var(--bg-secondary);
    color: var(--text-primary); font-size: 0.875rem; margin-bottom: 1rem;
}
.modal-body input[type="text"]:focus, .modal-body select:focus { outline: none; border-color: var(--accent); }
.modal-body .form-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.modal-body .form-row > * { flex: 1; }
.modal-body .checkbox-list {
    max-height: 200px; overflow: auto; padding: 0.5rem;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--bg-secondary);
}
.modal-body .checkbox-list label {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem;
    font-weight: 400; cursor: pointer; margin-bottom: 0;
}
.modal-body .checkbox-list label:hover { background: var(--bg-hover); border-radius: 4px; }
.modal-footer {
    padding: 0.75rem 1.25rem; border-top: 1px solid var(--border-color);
    display: flex; justify-content: flex-end; gap: 0.5rem;
}
.modal-body .help { font-size: 0.75rem; color: var(--text-muted); margin-top: -0.5rem; margin-bottom: 1rem; }

/* Type Badges */
.type-badge {
    display: inline-block; font-size: 0.6875rem; padding: 0.15rem 0.5rem;
    border-radius: 0.25rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; margin-top: 0.25rem;
}
.type-text { background: #dbeafe; color: #1e40af; }
.type-number { background: #dcfce7; color: #166534; }
.type-date { background: #fef3c7; color: #92400e; }
.type-boolean { background: #fce7f3; color: #9f1239; }
.type-email { background: #ede9fe; color: #5b21b6; }
.type-phone { background: #cffafe; color: #155e75; }
.type-empty { background: var(--bg-tertiary); color: var(--text-muted); }
[data-theme="dark"] .type-text { background: #1e3a8a; color: #bfdbfe; }
[data-theme="dark"] .type-number { background: #14532d; color: #86efac; }
[data-theme="dark"] .type-date { background: #78350f; color: #fde68a; }
[data-theme="dark"] .type-boolean { background: #831843; color: #fbcfe8; }
[data-theme="dark"] .type-email { background: #4c1d95; color: #ddd6fe; }
[data-theme="dark"] .type-phone { background: #164e63; color: #a5f3fc; }

/* Toast */
.toast {
    position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--text-primary); color: var(--bg-primary);
    padding: 0.75rem 1.5rem; border-radius: var(--radius-md);
    box-shadow: var(--shadow-md); z-index: 2000;
    font-size: 0.875rem; opacity: 0; transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* DataClean-specific responsive */
@media (max-width: 768px) {
    .columns-bar { padding: 0.5rem; }
    .btn-toolbar { font-size: 0.6875rem; padding: 0.3rem 0.5rem; }
    .modal { max-width: 100%; }
}

/* Logo dark mode switching */
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }

.logo-compass { color: var(--accent); }

/* ============================================
   Custom Cleaning Rules modal
   ============================================ */
.cr-rules { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.5rem; }
.cr-rule {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.65rem;
    background: var(--bg-secondary);
    margin-bottom: 0;
}
.cr-rule-row {
    display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem;
}
.cr-rule-row label {
    font-weight: 600; font-size: 0.78rem; color: var(--text-secondary);
    margin: 0; min-width: 48px;
}
.cr-rule-row select {
    flex: 1; padding: 0.3rem 0.5rem; font-size: 0.8125rem;
    background: var(--bg-primary); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    margin: 0;
}
.cr-ops {
    width: 100%; padding: 0.45rem 0.6rem; font-family: var(--font-mono); font-size: 0.78rem;
    background: var(--bg-primary); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    margin: 0;
}
.cr-ops:focus { outline: none; border-color: var(--accent); }
.cr-ops-help { margin-top: 0.3rem; margin-bottom: 0; font-size: 0.7rem; }
.cr-actions-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.cr-preview {
    margin: 0.5rem 0; padding: 0.55rem 0.7rem;
    background: var(--bg-primary); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); font-size: 0.78rem;
    color: var(--text-secondary); min-height: 1.5rem; line-height: 1.4;
}
.cr-preview strong { color: var(--text-primary); }
.cr-preview .muted { color: var(--text-muted); font-style: italic; }
.cr-saved-row {
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
    padding: 0.5rem 0;
    border-top: 1px dashed var(--border-color);
    margin-top: 0.5rem;
}
.cr-saved-row > label {
    font-size: 0.78rem; font-weight: 600; color: var(--text-secondary);
    margin: 0; flex: 0 0 auto;
}
.cr-saved-row select, .cr-saved-row input {
    flex: 1; min-width: 120px; padding: 0.3rem 0.5rem; font-size: 0.78rem;
    background: var(--bg-secondary); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    margin: 0;
}
.cr-dsl-help {
    margin-top: 0.5rem; padding-top: 0.5rem;
    border-top: 1px dashed var(--border-color);
    font-size: 0.78rem;
}
.cr-dsl-help summary {
    cursor: pointer; font-weight: 600; color: var(--text-secondary);
    padding: 0.25rem 0; user-select: none;
}
.cr-dsl-help summary:hover { color: var(--accent); }
.cr-dsl-table {
    width: 100%; margin-top: 0.4rem;
    border-collapse: collapse;
    font-size: 0.75rem;
}
.cr-dsl-table th, .cr-dsl-table td {
    padding: 0.35rem 0.5rem; text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}
.cr-dsl-table th {
    font-weight: 600; color: var(--text-secondary);
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
}
.cr-dsl-table code {
    background: var(--bg-secondary); padding: 1px 4px;
    border-radius: 3px; font-size: 0.72rem;
}
.cr-dsl-table tbody tr:nth-child(even) { background: rgba(0,0,0,0.02); }
[data-theme="dark"] .cr-dsl-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
@media (max-width: 600px) {
    .cr-saved-row { flex-direction: column; align-items: stretch; }
    .cr-saved-row select, .cr-saved-row input { width: 100%; }
    .cr-dsl-table th:nth-child(3), .cr-dsl-table td:nth-child(3) { display: none; }
}

/* ============================================
   Before/After Diff View modal
   ============================================ */
.diff-meta {
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
    padding: 0.75rem 1rem; margin-bottom: 1rem;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}
.diff-meta-label {
    font-weight: 600; font-size: 0.875rem; color: var(--text-primary);
}
.diff-meta-stats { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.diff-stat {
    font-size: 0.75rem; padding: 0.125rem 0.5rem; border-radius: var(--radius-sm);
    background: var(--bg-primary); color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.diff-stat-num { color: var(--text-primary); font-weight: 600; }

.diff-empty {
    text-align: center; padding: 3rem 1rem; color: var(--text-secondary);
}
.diff-empty h4 { margin: 0 0 0.5rem; color: var(--text-primary); }

.diff-row-card {
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    padding: 0.75rem 1rem; margin-bottom: 0.5rem;
    background: var(--bg-primary);
}
.diff-row-card-header {
    font-size: 0.75rem; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.05em;
    margin-bottom: 0.5rem; font-weight: 600;
}
.diff-cell-list { display: flex; flex-direction: column; gap: 0.25rem; }
.diff-cell {
    display: grid; grid-template-columns: minmax(120px, 0.4fr) 1fr auto 1fr;
    gap: 0.5rem; align-items: center; padding: 0.25rem 0;
    font-size: 0.8125rem;
}
.diff-cell-name { color: var(--text-secondary); font-weight: 500; }
.diff-cell-old {
    padding: 0.25rem 0.5rem; background: rgba(239, 68, 68, 0.12);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-family: var(--font-mono); word-break: break-word;
    border: 1px solid rgba(239, 68, 68, 0.25);
}
.diff-cell-arrow { color: var(--text-secondary); font-weight: 700; }
.diff-cell-new {
    padding: 0.25rem 0.5rem; background: rgba(34, 197, 94, 0.12);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-family: var(--font-mono); word-break: break-word;
    border: 1px solid rgba(34, 197, 94, 0.25);
}
.diff-empty-value {
    color: var(--text-secondary); font-style: italic;
}
[data-theme="dark"] .diff-cell-old { background: rgba(239, 68, 68, 0.18); border-color: rgba(239, 68, 68, 0.35); }
[data-theme="dark"] .diff-cell-new { background: rgba(34, 197, 94, 0.18); border-color: rgba(34, 197, 94, 0.35); }
.diff-truncated {
    text-align: center; padding: 0.5rem; color: var(--text-secondary);
    font-size: 0.75rem; font-style: italic;
}

@media (max-width: 640px) {
    .diff-cell {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
    .diff-cell-name { font-weight: 600; }
}

/* ----- Printable Quality Report ----- */
/* The report lives in #print-report, hidden on screen, visible only when the
   user triggers the browser print dialog. Both "Print / Save as PDF" and
   "Download HTML" use the same generated DOM. */
.print-report { display: none; }

/* Self-contained SVG ring used in both the print report AND the on-screen
   profile dashboard. Inline strokes set the colour, these rules set sizing +
   stroke width + the base track. */
.report-svg { width: 110px; height: 110px; display: block; }
.report-svg circle.track { fill: none; stroke: var(--border-color, #e5e7eb); stroke-width: 10; }
.report-svg circle.fill  { fill: none; stroke-width: 10; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 60px 60px; }
.report-svg text.text    { font-family: inherit; }
.report-svg text.num     { font-size: 28px; font-weight: 700; fill: var(--text-primary, #111); }
.report-svg text.grade   { font-size: 11px; font-weight: 600; fill: var(--text-secondary, #555); text-transform: uppercase; letter-spacing: 0.05em; }

/* Small metadata grid that previews report contents inside the export modal. */
.report-modal-preview {
    margin-top: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.report-preview-row {
    display: grid;
    grid-template-columns: 1fr auto;
    padding: 0.5rem 0.85rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}
.report-preview-row:last-child { border-bottom: none; }
.report-preview-row strong { color: var(--text-primary); font-weight: 600; }
[data-theme="dark"] .report-preview-row { background: var(--bg-primary); }

@media print {
    /* Hide chrome and show only the generated report. */
    body > *:not(.print-report) { display: none !important; }
    .print-report { display: block !important; }
    @page { margin: 0.5in; size: letter; }
}

/* Pivot modal — compact preview table that scrolls horizontally if wide. */
.pivot-preview-wrap {
    margin-top: 0.75rem;
    max-height: 280px;
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}
.pivot-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
.pivot-preview-table th,
.pivot-preview-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}
.pivot-preview-table th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}
.pivot-preview-table tbody tr:last-child td { border-bottom: 0; }
.pivot-preview-table tbody tr:hover { background: var(--bg-hover, var(--accent-light)); }

/* Merge-with-File modal — two side-by-side panels showing LEFT (current) and
   RIGHT (user-supplied) datasets, then a shared config block underneath.
   The modal is naturally wider than the default 480px so the two columns
   fit comfortably side-by-side; we widen once the merge modal is open. */
.modal.modal-merge { max-width: 880px; width: min(880px, 96vw); max-height: 96vh; }
.merge-two-side {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.75rem;
    margin: 0.5rem 0 1rem;
}
.merge-side {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    background: var(--bg-secondary);
    min-height: 120px;
    min-width: 0; /* let grid columns shrink */
}
.merge-side.merge-left { border-color: var(--accent); }
.merge-side.merge-right { border-color: var(--accent-light); }
.merge-side-meta {
    font-size: 0.8125rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.merge-side-headers {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono, monospace);
    word-break: break-word;
    white-space: normal;
}
.merge-empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.8125rem;
    text-align: center;
    padding: 1rem 0;
}
/* Side-panel preview tables scroll horizontally — they get tight inside the
   narrow merge panels — but the right-side "Right dataset" sample table and
   the merge preview wrap both honour max-width and overflow. */
.merge-side .pivot-preview-wrap,
#merge-preview-wrap {
    max-width: 100%;
}
.merge-side .pivot-preview-table,
#merge-preview-wrap .pivot-preview-table {
    table-layout: auto;
    max-width: 100%;
}
/* The file picker + filename row should not collapse into awkward stacking
   on narrow widths — keep them aligned with shrink/grow. */
.merge-source-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
    flex-wrap: wrap;
}
.merge-source-row .merge-filename {
    flex: 1; min-width: 0; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
    font-size: 0.75rem; color: var(--text-muted);
}
.merge-side textarea,
.merge-source-row textarea {
    width: 100%;
    font-family: var(--font-mono, monospace);
    font-size: 0.75rem;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: vertical;
    box-sizing: border-box;
}
.merge-side textarea { margin-top: 0.25rem; }

/* ---------- Pipelines (v0.5.0) ---------- */
.columns-bar-sep {
    color: var(--border-color);
    margin: 0 0.25rem;
    font-weight: 300;
    user-select: none;
}
.pipeline-list {
    list-style: none; padding: 0; margin: 0 0 0.5rem 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
}
.pipeline-list:empty::before {
    content: "No saved pipelines yet. Apply some operations, then choose “Save History as Pipeline…” from the operations menu.";
    display: block;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-style: italic;
    text-align: center;
}
.pipeline-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.pipeline-item:last-child { border-bottom: none; }
.pipeline-item:hover { background: var(--accent-light); }
.pipeline-item-info { min-width: 0; }
.pipeline-item-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pipeline-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}
.pipeline-item-meta .pi-tag {
    display: inline-block;
    padding: 0.05rem 0.4rem;
    margin-right: 0.25rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 0.6875rem;
    color: var(--text-secondary);
}
.pipeline-item-meta .pi-tag.builtin {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}
.pipeline-step-list {
    margin: 0.25rem 0 0 0; padding: 0;
    list-style: none;
    display: flex; flex-wrap: wrap; gap: 0.25rem;
}
.pipeline-step-list li {
    font-size: 0.6875rem;
    padding: 0.1rem 0.4rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-secondary);
}
.pipeline-actions {
    display: flex; gap: 0.25rem; align-items: center;
}
.pipeline-run-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}
.pipeline-run-btn:hover { background: var(--accent-hover, var(--accent)); }
.pipeline-run-btn:disabled { background: var(--border-color); cursor: not-allowed; }
.pipeline-icon-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
}
.pipeline-icon-btn:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.pipeline-icon-btn.danger:hover { background: #fee2e2; border-color: var(--danger); color: var(--danger); }
[data-theme="dark"] .pipeline-icon-btn.danger:hover { background: #450a0a; }
.pipeline-save-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: end;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
}
.pipeline-save-row label { font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 0.25rem; display: block; }
.pipeline-save-row .help { font-size: 0.75rem; color: var(--text-muted); margin: 0.25rem 0 0 0; }
.pipeline-toolbar {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0 0.75rem 0;
    align-items: center;
    flex-wrap: wrap;
}
.pipeline-toolbar input[type="file"] { display: none; }
.pipeline-summary {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
    padding: 0.5rem 0.75rem;
    background: var(--accent-light);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
}
.pipeline-summary strong { color: var(--accent); }

@media (max-width: 720px) {
    .pipeline-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .pipeline-actions { justify-content: flex-end; }
    .pipeline-save-row { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .merge-two-side { grid-template-columns: 1fr; }
}

/* ===== Batch Processing (v0.7.0) ===== */
.modal.modal-batch { max-width: 780px; width: min(780px, 96vw); max-height: 96vh; }
.batch-section {
    margin: 0.75rem 0;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}
.batch-section > label:first-child {
    display: block;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}
.batch-format-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 0.8125rem;
}
.batch-format-row label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    color: var(--text-primary);
}
.batch-source-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.batch-file-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}
.batch-paste-wrap,
.batch-sample-wrap {
    margin-top: 0.5rem;
    border-top: 1px dashed var(--border-color);
    padding-top: 0.5rem;
}
.batch-paste-wrap > summary,
.batch-sample-wrap > summary {
    cursor: pointer;
    color: var(--accent);
    font-size: 0.8125rem;
    user-select: none;
    padding: 0.25rem 0;
}
.batch-paste-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
}
.batch-paste-row input[type="text"],
.batch-paste-row textarea {
    width: 100%;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.8125rem;
    box-sizing: border-box;
    font-family: inherit;
}
.batch-paste-row textarea {
    font-family: var(--font-mono, monospace);
    font-size: 0.75rem;
    resize: vertical;
}
.batch-paste-row button {
    align-self: flex-start;
}
.batch-sample-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}
.batch-sample-btn {
    font-size: 0.75rem !important;
}
.batch-file-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    max-height: 160px;
    overflow-y: auto;
}
.batch-file-list .batch-empty {
    padding: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.8125rem;
    text-align: center;
}
.batch-file-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8125rem;
}
.batch-file-item:last-child { border-bottom: 0; }
.batch-file-item:hover { background: var(--accent-light); }
.batch-file-source {
    display: inline-block;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.batch-file-source.batch-src-sample {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}
.batch-file-source.batch-src-paste {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
}
[data-theme="dark"] .batch-file-source.batch-src-paste {
    background: #451a03;
    border-color: #b45309;
    color: #fbbf24;
}
.batch-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
    font-weight: 500;
}
.batch-file-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.batch-step-tag {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    margin: 0.05rem 0.15rem 0.05rem 0;
    border-radius: 999px;
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid var(--accent);
    font-size: 0.6875rem;
}
.batch-results-summary {
    font-size: 0.8125rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}
.batch-results-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    max-height: 220px;
    overflow-y: auto;
}
.batch-result-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8125rem;
}
.batch-result-item:last-child { border-bottom: 0; }
.batch-result-item.batch-result-ok { border-left: 3px solid var(--success, #16a34a); }
.batch-result-item.batch-result-fail { border-left: 3px solid var(--danger); opacity: 0.85; }
.batch-result-status {
    font-weight: 700;
    font-size: 0.875rem;
}
.batch-result-ok .batch-result-status { color: var(--success, #16a34a); }
.batch-result-fail .batch-result-status { color: var(--danger); }
.batch-result-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}
.batch-result-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.batch-results-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 720px) {
    .batch-file-item,
    .batch-result-item {
        grid-template-columns: auto 1fr auto;
    }
    .batch-file-meta,
    .batch-result-meta {
        grid-column: 1 / -1;
    }
}

/* ===== PWA install button (header) ===== */
.btn-icon[hidden] { display: none; }
.install-badge {
    position: relative;
}
.install-badge::after {
    content: '';
    position: absolute;
    top: 4px; right: 4px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent, #1e40af);
    box-shadow: 0 0 0 2px var(--bg-elevated, #fff);
}
[data-theme="dark"] .install-badge::after {
    box-shadow: 0 0 0 2px var(--bg-elevated, #1a2332);
}

/* ===== PWA offline / online toast ===== */
#pwa-offline-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-elevated, #1a2332);
    color: var(--text-primary, #e6edf3);
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 0.875rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.05);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 9999;
    max-width: calc(100vw - 32px);
    text-align: center;
}
#pwa-offline-toast.pwa-toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
#pwa-offline-toast[data-kind="warn"] {
    background: #b45309;
    color: #fff;
}
#pwa-offline-toast[data-kind="success"] {
    background: #15803d;
    color: #fff;
}
#pwa-offline-toast[data-kind="error"] {
    background: #b91c1c;
    color: #fff;
}

/* ===== PWA update banner ===== */
.pwa-update-banner {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-150%);
    background: var(--bg-elevated, #1a2332);
    color: var(--text-primary, #e6edf3);
    padding: 12px 16px;
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    display: flex;
    gap: 12px;
    align-items: center;
    z-index: 9999;
    transition: transform 0.3s ease;
    max-width: calc(100vw - 32px);
}
.pwa-update-banner.pwa-update-show {
    transform: translateX(-50%) translateY(0);
}
.pwa-update-banner span { font-size: 0.875rem; }
.pwa-update-banner button {
    background: var(--accent, #1e40af);
    color: #fff;
    border: 0;
    padding: 6px 12px;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
}
.pwa-update-banner button:hover { background: var(--accent-hover, #1d4ed8); }


/* ===== Share / Embed modal (v0.6.0) ===== */
.share-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border, rgba(127,127,127,0.2));
    padding-bottom: 0;
}
.share-tab {
    background: transparent;
    border: 0;
    padding: 0.6rem 1rem;
    font: 600 0.875rem system-ui;
    color: var(--text-muted, #888);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}
.share-tab:hover { color: var(--text-primary, #111); }
.share-tab.is-active {
    color: var(--accent, #1e3a5f);
    border-bottom-color: var(--accent, #1e3a5f);
}
[data-theme="dark"] .share-tab.is-active { color: #6aa3ff; }

.share-panel { display: block; }
.share-panel[hidden] { display: none; }
.share-panel textarea {
    width: 100%;
    font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
    font-size: 0.8125rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-tertiary, #f6f8fa);
    color: var(--text-primary, #111);
    border: 1px solid var(--border, rgba(127,127,127,0.25));
    border-radius: 6px;
    resize: vertical;
    word-break: break-all;
}
[data-theme="dark"] .share-panel textarea {
    background: #0c1119;
    color: #e6edf3;
}
.share-panel label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    margin: 0.75rem 0 0.35rem;
    color: var(--text-secondary, #555);
}
.share-panel input[type="text"],
.share-panel select {
    width: 100%;
    padding: 0.5rem 0.6rem;
    font-size: 0.875rem;
    background: var(--bg-tertiary, #f6f8fa);
    color: var(--text-primary, #111);
    border: 1px solid var(--border, rgba(127,127,127,0.25));
    border-radius: 6px;
}
[data-theme="dark"] .share-panel input[type="text"],
[data-theme="dark"] .share-panel select {
    background: #0c1119;
    color: #e6edf3;
}
.share-panel input[type="text"]:focus,
.share-panel select:focus { outline: 2px solid var(--accent, #1e3a5f); outline-offset: 1px; }

.share-size { font-weight: 400; color: var(--text-muted, #888); font-size: 0.75rem; }
.share-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.share-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.share-grid-2 label { margin-top: 0.5rem; }
@media (max-width: 480px) {
    .share-grid-2 { grid-template-columns: 1fr; }
}

/* Compact Share button in the header (sits next to Export) */
#share-btn {
    padding: 0.45rem 0.85rem;
    font-size: 0.875rem;
}

/* ===== Data Profiling Dashboard (v0.7.0) ===== */
.modal-profile { max-width: 980px; width: 100%; }
.modal-profile .modal-body { max-height: 78vh; overflow-y: auto; padding: 0.5rem 0.25rem; }

.profile-dashboard { display: flex; flex-direction: column; gap: 1.5rem; padding: 0.5rem 0.75rem 0.5rem 0.75rem; }

.profile-h3 {
    font-size: 0.875rem;
    margin: 0 0 0.75rem 0;
    color: var(--text-secondary, #555);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    padding-bottom: 0.4rem;
}

/* Header summary band */
.profile-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-secondary, #f8fafc);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
}
.profile-summary-stat { text-align: center; }
.profile-summary-num {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.profile-summary-lbl {
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.15rem;
}

/* Quality overview */
.profile-section { display: flex; flex-direction: column; }
.profile-quality-row {
    display: flex;
    gap: 1.25rem;
    align-items: center;
}
.profile-ring svg { width: 110px; height: 110px; }
.profile-quality-detail { flex: 1; }
.profile-grade-big { font-size: 1.125rem; margin-bottom: 0.4rem; color: var(--text-primary); }
.profile-grade-big strong { font-variant-numeric: tabular-nums; }
.profile-quality-detail p {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-secondary, #555);
}

/* Grade pill (re-uses type-badge style) */
.profile-grade {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}
.profile-grade.grade-a { background: rgba(22,163,74,0.15); color: #166534; }
.profile-grade.grade-b { background: rgba(101,163,13,0.15); color: #4d7c0f; }
.profile-grade.grade-c { background: rgba(217,119,6,0.15); color: #92400e; }
.profile-grade.grade-d { background: rgba(234,88,12,0.15); color: #9a3412; }
.profile-grade.grade-f { background: rgba(220,38,38,0.15); color: #991b1b; }
[data-theme="dark"] .profile-grade.grade-a { color: #4ade80; }
[data-theme="dark"] .profile-grade.grade-b { color: #a3e635; }
[data-theme="dark"] .profile-grade.grade-c { color: #fbbf24; }
[data-theme="dark"] .profile-grade.grade-d { color: #fb923c; }
[data-theme="dark"] .profile-grade.grade-f { color: #f87171; }

/* Type distribution bars */
.profile-types { display: flex; flex-direction: column; gap: 0.4rem; }
.profile-type-row {
    display: grid;
    grid-template-columns: 110px 1fr 90px;
    gap: 0.75rem;
    align-items: center;
    font-size: 0.8125rem;
}
.profile-type-label { color: var(--text-secondary); }
.profile-type-bar {
    background: var(--bg-secondary, #f3f4f6);
    border-radius: 999px;
    height: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color, #e5e7eb);
}
.profile-type-fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--accent, #1e3a5f), var(--accent-light, #4a6b8a));
    border-radius: 999px;
}
.profile-type-count { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.profile-type-count .muted { color: var(--text-muted, #888); margin-left: 0.15rem; }

/* Tables shared */
.profile-table-wrap { overflow-x: auto; border: 1px solid var(--border-color, #e5e7eb); border-radius: 6px; }
.profile-stats-table,
.profile-corr-table,
.profile-colq-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    background: var(--bg-primary, #fff);
}
.profile-stats-table th,
.profile-stats-table td,
.profile-corr-table th,
.profile-corr-table td,
.profile-colq-table th,
.profile-colq-table td {
    padding: 0.45rem 0.7rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    text-align: left;
}
.profile-stats-table th,
.profile-corr-table th,
.profile-colq-table th {
    background: var(--bg-secondary, #f8fafc);
    color: var(--text-secondary, #555);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.profile-stats-table td.num,
.profile-corr-table td.num,
.profile-colq-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.profile-stats-table tbody tr:last-child td,
.profile-corr-table tbody tr:last-child td,
.profile-colq-table tbody tr:last-child td { border-bottom: none; }

/* Correlation r badge + bar */
.profile-corr-r {
    display: inline-block;
    min-width: 56px;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.profile-corr-r.tier-strong { background: rgba(22,163,74,0.15); color: #166534; }
.profile-corr-r.tier-medium { background: rgba(217,119,6,0.15); color: #92400e; }
.profile-corr-r.tier-weak   { background: rgba(234,88,12,0.10); color: #9a3412; }
.profile-corr-r.tier-none   { background: var(--bg-secondary, #f3f4f6); color: var(--text-muted, #888); }
[data-theme="dark"] .profile-corr-r.tier-strong { color: #4ade80; }
[data-theme="dark"] .profile-corr-r.tier-medium { color: #fbbf24; }
[data-theme="dark"] .profile-corr-r.tier-weak   { color: #fb923c; }

.profile-corr-bar {
    display: inline-block;
    width: 110px;
    height: 8px;
    background: var(--bg-secondary, #f3f4f6);
    border-radius: 999px;
    overflow: hidden;
    vertical-align: middle;
    margin-right: 0.4rem;
}
.profile-corr-bar > span {
    display: block;
    height: 100%;
    border-radius: 999px;
}
.profile-corr-bar.tier-strong > span { background: #16a34a; }
.profile-corr-bar.tier-medium > span { background: #d97706; }
.profile-corr-bar.tier-weak > span   { background: #ea580c; }
.profile-corr-bar.tier-none > span   { background: var(--text-muted, #888); }

/* Percentage pills in per-column table */
.profile-pct {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
}
.profile-pct.tier-good { background: rgba(22,163,74,0.12); color: #166534; }
.profile-pct.tier-ok   { background: rgba(217,119,6,0.12); color: #92400e; }
.profile-pct.tier-bad  { background: rgba(220,38,38,0.12); color: #991b1b; }
[data-theme="dark"] .profile-pct.tier-good { color: #4ade80; }
[data-theme="dark"] .profile-pct.tier-ok   { color: #fbbf24; }
[data-theme="dark"] .profile-pct.tier-bad  { color: #f87171; }

/* Heatmap */
.profile-heat-wrap { max-height: 360px; overflow: auto; }
.profile-heat-table {
    border-collapse: collapse;
    font-size: 0.75rem;
    width: 100%;
}
.profile-heat-table th,
.profile-heat-table td {
    border: 1px solid var(--border-color, #e5e7eb);
    text-align: center;
    padding: 0.25rem;
    min-width: 36px;
    max-width: 80px;
    white-space: nowrap;
}
.profile-heat-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary, #f8fafc);
    color: var(--text-secondary, #555);
    font-weight: 600;
    z-index: 2;
}
.profile-heat-table tbody th {
    position: sticky;
    left: 0;
    background: var(--bg-secondary, #f8fafc);
    color: var(--text-secondary, #555);
    font-weight: 500;
    z-index: 1;
    text-align: left;
    padding-left: 0.5rem;
    min-width: 90px;
}
.profile-heat-cell { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.profile-heat-legend {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    margin-top: 0.6rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}
.profile-heat-swatch {
    display: inline-flex;
    width: 24px;
    height: 16px;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.7rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 3px;
    margin-right: 0.25rem;
    color: var(--text-primary);
}

/* Top issues list */
.profile-recs {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.profile-recs li {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    font-size: 0.8125rem;
    color: var(--text-primary);
    line-height: 1.4;
}
.profile-prio {
    flex: 0 0 auto;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.profile-prio.prio-high   { background: rgba(220,38,38,0.15); color: #991b1b; }
.profile-prio.prio-medium { background: rgba(217,119,6,0.15); color: #92400e; }
.profile-prio.prio-low    { background: rgba(59,130,246,0.15); color: #1e40af; }
.profile-prio.prio-info   { background: var(--bg-secondary, #f3f4f6); color: var(--text-secondary, #555); }
[data-theme="dark"] .profile-prio.prio-high   { color: #f87171; }
[data-theme="dark"] .profile-prio.prio-medium { color: #fbbf24; }
[data-theme="dark"] .profile-prio.prio-low    { color: #60a5fa; }

/* Compact Profile button (sits next to Share in header) */
#profile-btn {
    padding: 0.45rem 0.85rem;
    font-size: 0.875rem;
}

/* Print shell for the profile */
@media print {
    .print-h1 { font-size: 1.4rem; margin: 0 0 0.4rem 0; }
    .print-meta { font-size: 0.8rem; color: #555; margin: 0 0 1rem 0; }
    .print-dashboard .profile-summary,
    .print-dashboard .profile-section { page-break-inside: avoid; }
}

@media (max-width: 600px) {
    .profile-summary { grid-template-columns: repeat(2, 1fr); }
    .profile-quality-row { flex-direction: column; align-items: flex-start; }
    .profile-type-row { grid-template-columns: 80px 1fr 70px; }
}

/* ============================================================================
 *  Template Gallery  (v0.8.0)
 * ============================================================================ */
.tpl-summary {
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}
.tpl-category { margin-bottom: 1.25rem; }
.tpl-category-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem;
}
.tpl-card-grid {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}
.tpl-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tpl-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.tpl-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.tpl-card-name {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}
.tpl-card-cat {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--accent-light, rgba(99,102,241,0.15));
    color: var(--accent);
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-weight: 600;
}
.tpl-card-desc {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.4;
}
.tpl-card-tags { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.tpl-tag {
    font-size: 0.7rem;
    background: var(--bg-tertiary, var(--bg-primary));
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
}
.tpl-card-steps {
    list-style: none;
    padding: 0.4rem 0.5rem;
    margin: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm, 4px);
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.tpl-card-steps li {
    line-height: 1.3;
}
.tpl-step-more {
    color: var(--text-muted);
    font-style: italic;
}
.tpl-card-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: auto;
    padding-top: 0.25rem;
}
.tpl-card-actions .btn-primary,
.tpl-card-actions .btn-secondary {
    padding: 0.35rem 0.6rem;
    font-size: 0.8125rem;
    flex: 1;
    text-align: center;
}

/* ============================================================================
 *  Column-Mapping Modal  (v0.8.0)
 * ============================================================================ */
.cm-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.875rem;
}
.cm-table thead th {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 600;
    background: var(--bg-secondary);
}
.cm-table tbody tr {
    border-bottom: 1px solid var(--border-color);
}
.cm-table tbody tr:hover {
    background: var(--bg-secondary);
}
.cm-from { padding: 0.5rem; width: 28%; }
.cm-from code {
    background: var(--bg-secondary);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
}
.cm-arrow {
    text-align: center;
    color: var(--text-muted);
    font-weight: 700;
    width: 24px;
    padding: 0.5rem 0;
}
.cm-to { padding: 0.5rem; width: 50%; }
.cm-to select {
    width: 100%;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: var(--radius-sm, 4px);
}
.cm-to select:disabled {
    opacity: 0.5;
    background: var(--bg-secondary);
}
.cm-skip { padding: 0.5rem; width: 22%; color: var(--text-secondary); }

/* ===== Accent & Branding (v0.9.0) ===== */
.modal.modal-accent { max-width: 640px; width: min(640px, 96vw); }
.theme-section {
    margin: 0.75rem 0 1rem;
    padding: 0.75rem 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}
.theme-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
}
.palette-swatch {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem;
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    gap: 0.4rem;
    font-family: inherit;
    color: var(--text-primary);
}
.palette-swatch:hover {
    border-color: var(--accent-muted);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.palette-swatch.is-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}
.palette-swatch-color {
    display: block;
    width: 100%;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.1);
}
.palette-swatch-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
}
.palette-swatch.is-active .palette-swatch-label {
    color: var(--accent);
    font-weight: 600;
}

.custom-color-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.custom-color-row input[type="color"] {
    width: 56px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    cursor: pointer;
}
.custom-color-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.custom-color-row input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
.custom-color-row input[type="text"] {
    flex: 1;
    padding: 0.4rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8125rem;
}
.custom-color-row input[type="text"]:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.accent-preview {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
    padding: 0.625rem 0.75rem;
    background: var(--bg-primary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
}
.accent-preview .preview-link {
    color: var(--accent);
    text-decoration: underline;
    font-size: 0.8125rem;
    font-weight: 500;
}
.cm-skip label { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; }

/* ============================================================================
 * Command Palette + Keyboard Shortcuts Help (v1.0.0)
 * ============================================================================ */

/* ----- Command Palette ----- */
.cmdk-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 22, 35, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    z-index: 9999;
}
.cmdk-modal {
    width: min(640px, 92vw);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 70vh;
    animation: cmdk-in 140ms cubic-bezier(.16,.84,.44,1);
}
@keyframes cmdk-in {
    from { opacity: 0; transform: translateY(-12px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}
.cmdk-input-row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}
.cmdk-prompt {
    color: var(--accent);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1;
}
.cmdk-input {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
}
.cmdk-input::placeholder { color: var(--text-tertiary); }
.cmdk-hint {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    padding: 0.125rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.cmdk-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
    min-height: 80px;
}
.cmdk-group {
    padding: 0.25rem 0;
}
.cmdk-group-label {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.cmdk-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: background-color 60ms linear;
    user-select: none;
}
.cmdk-item:hover { background: var(--bg-secondary); }
.cmdk-item.cmdk-active {
    background: var(--accent);
    color: white;
}
.cmdk-item.cmdk-active .cmdk-hint-row,
.cmdk-item.cmdk-active .cmdk-shortcut {
    color: rgba(255, 255, 255, 0.9);
}
.cmdk-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cmdk-hint-row {
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    margin-right: 0.25rem;
}
.cmdk-shortcut {
    color: var(--text-tertiary);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
    padding: 0.125rem 0.4375rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    flex-shrink: 0;
}
.cmdk-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-tertiary);
    font-style: italic;
}
.cmdk-footer {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-tertiary);
    font-size: 0.75rem;
}
.cmdk-footer kbd {
    display: inline-block;
    padding: 0.0625rem 0.375rem;
    margin: 0 0.125rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--bg-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.6875rem;
    color: var(--text-secondary);
}

/* ----- Keyboard Shortcuts Help ----- */
.kbd-help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 22, 35, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 2vh 2vw;
}
.kbd-help-modal {
    width: min(720px, 96vw);
    max-height: 90vh;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: cmdk-in 140ms cubic-bezier(.16,.84,.44,1);
}
.kbd-help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}
.kbd-help-header h3 { margin: 0; font-size: 1.0625rem; }
.kbd-help-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
}
.kbd-help-blurb {
    margin: 0 0 1.25rem 0;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}
.kbd-help-blurb kbd,
.kbd-help-row kbd {
    display: inline-block;
    padding: 0.0625rem 0.4375rem;
    margin: 0 0.0625rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8125rem;
    font-weight: 500;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}
.kbd-help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem 1.5rem;
}
.kbd-help-section { min-width: 0; }
.kbd-help-section-title {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.kbd-help-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.4375rem 0;
    font-size: 0.9375rem;
    color: var(--text-primary);
}
.kbd-help-label {
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
}
.kbd-help-keys {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.1875rem;
}
.kbd-help-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-tertiary);
    font-size: 0.8125rem;
}
.kbd-help-footer kbd {
    display: inline-block;
    padding: 0.0625rem 0.375rem;
    margin: 0 0.125rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* When the accent modal is open, also handle in iOS / small screens */
@media (max-width: 640px) {
    .cmdk-overlay { padding-top: 6vh; }
    .cmdk-modal { max-height: 84vh; }
    .kbd-help-grid { grid-template-columns: 1fr; }
}

/* Dark mode polish */
[data-theme="dark"] .cmdk-overlay,
[data-theme="dark"] .kbd-help-overlay {
    background: rgba(0, 0, 0, 0.65);
}
[data-theme="dark"] .cmdk-shortcut,
[data-theme="dark"] .kbd-help-row kbd,
[data-theme="dark"] .kbd-help-footer kbd {
    background: var(--bg-elevated);
}

/* "?" hint button in the header — small text/keys chip */
.kbd-hint-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    margin-left: 0.25rem;
    line-height: 1.2;
    transition: all var(--transition);
    transition: border-color 80ms linear, color 80ms linear;
}
.kbd-hint-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
/* Pro Modal Part 1 */
.pro-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(4px);
    padding: 1rem;
}
.pro-modal-overlay.active { opacity: 1; }
.pro-modal {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.92) translateY(10px);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}.pro-modal-overlay.active .pro-modal { transform: scale(1) translateY(0); }
.pro-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.pro-modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.pro-modal-header {
    text-align: center;
    margin-bottom: 1rem;
}
.pro-modal-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}
.pro-modal-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
.pro-modal-highlight {
    background: rgba(30, 58, 95, 0.08);
    border: 1px solid rgba(30, 58, 95, 0.15);
    border-radius: 8px;
    padding: 0.6rem 0.85rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 1rem;
}[data-theme="dark"] .pro-modal-highlight {
    background: rgba(111, 163, 224, 0.1);
    border-color: rgba(111, 163, 224, 0.2);
}
.pro-modal-features {
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
}
.pro-modal-features li {
    padding: 0.4rem 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    line-height: 1.45;
}
.pro-modal-features li:last-child { border-bottom: none; }
.pro-modal-pricing-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.pro-modal-pricing-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 0.75rem;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
    font-family: inherit;
    color: var(--text-primary);
    position: relative;
}
.pro-modal-pricing-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.pro-modal-pricing-card:active { transform: translateY(0); }
/* v0.11.0 — Highlight the card the user picked on the landing page */
.pro-modal-pricing-card.pro-plan-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    background: linear-gradient(135deg, var(--accent-light), var(--bg-secondary));
}
.pro-modal-pricing-card.pro-plan-active::before {
    content: "Recommended";
    position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
    background: var(--accent); color: #fff;
    font-size: 0.6rem; font-weight: 700; letter-spacing: 0.05em;
    text-transform: uppercase; padding: 2px 8px; border-radius: 999px;
    pointer-events: none;
}
.pro-modal-pricing-card-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}.pro-modal-pricing-card-price {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1.1;
}
.pro-modal-pricing-card-mo {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.pro-modal-pricing-card-desc {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
    line-height: 1.3;
}
.pro-modal-guarantee {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.6rem 0 0;
}
.pro-modal-pricing-loading { pointer-events: none; position: relative; }
.pro-modal-pricing-loading .pro-modal-pricing-card { opacity: 0.5; cursor: wait; }
.pro-modal-pricing-loading .pro-modal-pricing-card::after {
    content: '⏳ Redirecting to checkout…';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--bg-primary);
    border-radius: 8px;
    opacity: 0.92;
    animation: pulse-opacity 1.2s ease-in-out infinite;
}
@keyframes pulse-opacity {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}.pro-modal-checkout-error {
    background: rgba(231, 76, 60, 0.08);
    border: 1px solid rgba(231, 76, 60, 0.25);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    text-align: center;
}
.pro-modal-checkout-error p {
    margin: 0;
    font-size: 0.85rem;
    color: #e74c3c;
    line-height: 1.4;
}
[data-theme="dark"] .pro-modal-checkout-error {
    background: rgba(231, 76, 60, 0.12);
    border-color: rgba(231, 76, 60, 0.3);
}
[data-theme="dark"] .pro-modal-checkout-error p { color: #f1948a; }
.pro-modal-checkout-error-hint {
    font-size: 0.78rem !important;
    color: var(--text-secondary) !important;
    margin-top: 0.35rem !important;
}
.pro-modal-divider {
    height: 1px;
    background: var(--border-color);
    margin: 1.25rem 0;
}
.pro-modal-key-section { text-align: center; }
.pro-modal-key-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 0.5rem;
}
.pro-modal-key-input-row { display: flex; gap: 0.5rem; }
.pro-modal-key-input {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    outline: none;
    transition: border-color 0.15s;
}.pro-modal-key-input:focus { border-color: var(--accent); }
.pro-modal-key-input.pro-modal-key-error {
    border-color: #e74c3c;
    animation: pro-shake 0.4s ease;
}
@keyframes pro-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}
.pro-modal-key-btn {
    padding: 0.6rem 1rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: filter 0.15s;
    white-space: nowrap;
}
.pro-modal-key-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.pro-modal-key-btn:hover { filter: brightness(1.1); }
.pro-modal-key-error-msg {
    color: #e74c3c;
    font-size: 0.8rem;
    margin-top: 0.35rem;
    text-align: left;
}
.pro-modal-active-status {
    text-align: center;
    font-size: 1rem;
    color: #27ae60;
    font-weight: 600;
    margin: 0.5rem 0 1rem;
}
[data-theme="dark"] .pro-modal-active-status { color: #4ade80; }
.pro-modal-key-display {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    display: inline-block;
    margin: 0;
}.pro-modal-help-text {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.75rem 0 0;
}
.pro-modal-deactivate {
    display: block;
    width: 100%;
    text-align: center;
    background: none;
    border: 1px solid #e74c3c;
    color: #e74c3c;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.pro-modal-deactivate:hover {
    background: #e74c3c;
    color: #fff;
}.pro-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--accent);
    background: rgba(30, 58, 95, 0.08);
    border: 1px solid rgba(30, 58, 95, 0.18);
    border-radius: 4px;
    padding: 0.05rem 0.3rem;
    line-height: 1;
    vertical-align: middle;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-left: 0.25rem;
}
[data-theme="dark"] .pro-badge {
    background: rgba(111, 163, 224, 0.12);
    border-color: rgba(111, 163, 224, 0.22);
}.pro-badge-small {
    display: inline-flex;
    align-items: center;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--accent);
    background: rgba(30, 58, 95, 0.08);
    border: 1px solid rgba(30, 58, 95, 0.18);
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    vertical-align: middle;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-left: 0.4rem;
}

/* v0.11.0 — Export modal "Open in VizFlow" promo (Sidequest Labs suite) */
.vizflow-promo {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin: 0.5rem 0 1.25rem;
    padding: 0.875rem 1rem;
    background: linear-gradient(135deg, var(--accent-light, #dcfce7), transparent);
    border: 1px solid var(--accent, #16a34a);
    border-radius: 8px;
}
.vizflow-promo-text { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; min-width: 0; }
.vizflow-promo-text strong {
    display: inline-flex; align-items: center; gap: 0.35rem;
    color: var(--accent); font-size: 0.9rem;
}
.vizflow-promo-text strong span[data-heroicon] { width: 16px; height: 16px; }
.vizflow-promo-text span {
    color: var(--text-secondary); font-size: 0.825rem; line-height: 1.45;
}
.vizflow-promo-text .inline-link { font-weight: 600; }
#vizflow-send-btn {
    flex-shrink: 0;
    display: inline-flex; align-items: center; gap: 0.35rem;
    text-decoration: none;
    font-size: 0.825rem;
    padding: 0.5rem 0.875rem;
}
#vizflow-send-btn span[data-heroicon] { width: 14px; height: 14px; }
@media (max-width: 520px) {
    .vizflow-promo { flex-direction: column; align-items: flex-start; }
    #vizflow-send-btn { width: 100%; justify-content: center; }
}
[data-theme="dark"] .pro-badge-small {
    background: rgba(111, 163, 224, 0.12);
    border-color: rgba(111, 163, 224, 0.22);
}
.pro-active {
    background: var(--accent) !important;
    color: #fff !important;
}
#upgrade-btn {
    background: var(--accent);
    color: #ffffff;
    border: 1px solid var(--accent);
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s, background 0.15s, color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
#upgrade-btn:hover { filter: brightness(0.97); }
#upgrade-btn [data-heroicon] {
    width: 14px;
    height: 14px;
}.pro-locked {
    opacity: 0.45;
    cursor: not-allowed !important;
    pointer-events: none;
}
.pro-gated-wrapper {
    position: relative;
    display: inline-block;
}
.pro-gated-wrapper .pro-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    z-index: 2;
    font-size: 0.55rem;
    pointer-events: none;
}.pro-row-cap-toast {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #b45309;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
[data-theme="dark"] .pro-row-cap-toast {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}
.pro-row-cap-toast button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}
.pro-row-cap-toast button:hover { filter: brightness(1.1); }
@media (max-width: 480px) {
    .pro-modal-pricing-options { grid-template-columns: 1fr; }
}
/* Fix star alignment in buttons */
#upgrade-btn [data-heroicon],
.btn-primary [data-heroicon],
.btn-secondary [data-heroicon] {
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
}

/* Spacing between data table and statistics panel */
.data-table-section {
    margin-bottom: 1.5rem;
}

/* Match VizFlow spacing: paste button after textarea */
.paste-area .btn-primary,
#paste-btn {
    margin-top: 12px;
}

/* ============================================================
   Transformation History Panel (v0.13.0)
   Power Query-style right sidebar showing all applied steps.
   ============================================================ */

/* Layout wrapper: content + sidebar sit side-by-side */
.history-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 0;
}
.history-data-content {
    flex: 1;
    min-width: 0;
    overflow: auto;
    transition: margin-right 0.25s ease;
}
.history-panel.open ~ .history-data-content {
    /* nudge content away from sidebar on very wide screens only */
}

/* Toggle button in header */
#history-toggle-btn {
    position: relative;
}
#history-toggle-btn .history-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    background: var(--accent, #1e40af);
    color: #fff;
    border-radius: 8px;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    padding: 0 4px;
    pointer-events: none;
}

/* Sidebar panel */
.history-panel {
    width: 0;
    overflow: hidden;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease;
    flex-shrink: 0;
}
.history-panel.open {
    width: 320px;
    min-width: 320px;
}

/* Panel header */
.history-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    flex-shrink: 0;
}
.history-panel-header h4 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}
.history-panel-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    line-height: 1;
}
.history-panel-close:hover { color: var(--text-primary); }

.history-diff-toggle {
    font-size: 0.875rem;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.history-diff-toggle:hover,
.history-diff-toggle.active {
    opacity: 1;
    color: var(--accent, #1e40af);
}

/* Step list */
.history-step-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
    list-style: none;
    margin: 0;
}

/* Individual step */
.history-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
    border-left: 3px solid transparent;
    user-select: none;
}
.history-step:hover {
    background: var(--accent-light, #dbeafe);
}
.history-step.selected {
    background: var(--accent-light, #dbeafe);
    border-left-color: var(--accent, #1e40af);
}
.history-step.current {
    border-left-color: #16a34a;
}
[data-theme="dark"] .history-step:hover,
[data-theme="dark"] .history-step.selected {
    background: var(--accent-light, #1e3a8a);
}
[data-theme="dark"] .history-step.current {
    border-left-color: #4ade80;
}

/* Step number */
.history-step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.history-step.current .history-step-num {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}
[data-theme="dark"] .history-step.current .history-step-num {
    background: #4ade80;
    border-color: #4ade80;
    color: #000;
}

/* Step icon */
.history-step-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

/* Step info */
.history-step-info {
    flex: 1;
    min-width: 0;
}
.history-step-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-step-detail {
    font-size: 0.6875rem;
    color: var(--text-muted);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.125rem;
}
.history-step-col {
    color: var(--accent, #1e40af);
    font-weight: 500;
}
.history-step-changes {
    color: #16a34a;
}
[data-theme="dark"] .history-step-changes {
    color: #4ade80;
}

/* Step actions area */
.history-step-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}
.history-step-badge {
    font-size: 0.625rem;
    font-weight: 600;
    color: #16a34a;
    background: #dcfce7;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
}
[data-theme="dark"] .history-step-badge {
    color: #4ade80;
    background: #14532d;
}
.history-step-menu-btn {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s;
}
.history-step:hover .history-step-menu-btn {
    opacity: 1;
}
.history-step-menu-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Drag states */
.history-step.dragging {
    opacity: 0.4;
}
.history-step.drag-over {
    border-top: 2px solid var(--accent, #1e40af);
}

/* Panel footer */
.history-panel-footer {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    flex-shrink: 0;
    background: var(--bg-primary);
}
.history-panel-footer .history-footer-info {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-align: center;
}
.history-panel-footer .history-footer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}
.history-panel-footer .history-footer-actions button {
    flex: 1 1 calc(50% - 0.375rem);
    font-size: 0.75rem;
    padding: 0.375rem 0.5rem;
}

/* Context menu */
.history-context-menu {
    position: fixed;
    z-index: 10000;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 0.25rem 0;
    min-width: 180px;
}
.history-context-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text-primary);
    text-align: left;
}
.history-context-item:hover {
    background: var(--accent-light, #dbeafe);
}
.history-context-item.danger { color: #dc2626; }
[data-theme="dark"] .history-context-item.danger { color: #f87171; }
.history-context-item.danger:hover { background: #fef2f2; }
[data-theme="dark"] .history-context-item.danger:hover { background: #450a0a; }
.history-context-icon { font-size: 0.875rem; width: 18px; text-align: center; }
.history-context-separator {
    height: 1px;
    background: var(--border-color);
    margin: 0.25rem 0;
}

/* Empty state */
.history-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* Responsive: collapse sidebar on narrow screens */
@media (max-width: 900px) {
    .history-panel.open {
        width: 260px;
        min-width: 260px;
    }
}
@media (max-width: 640px) {
    .history-panel.open {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        min-width: 0;
        z-index: 9999;
    }
}

/* Success Modal */
.pro-modal-success {
    max-width: 500px;
    text-align: center;
    padding: 2.5rem 2rem;
}
.pro-modal-success-icon {
    margin-bottom: 1.5rem;
}
.pro-modal-success-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}
.pro-modal-success-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}
.pro-modal-key-display {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pro-modal-key-loading {
    text-align: center;
    color: var(--text-muted);
}
.pro-modal-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 0.75rem;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.pro-modal-key-result {
    width: 100%;
}
.pro-modal-key-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.pro-modal-key-value-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
}
.pro-modal-key-value {
    flex: 1;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 1rem;
    color: var(--accent);
    letter-spacing: 0.05em;
    word-break: break-all;
}
.pro-modal-key-copy {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.pro-modal-key-copy:hover {
    background: var(--accent-hover);
}
.pro-modal-key-lookup {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}
.pro-modal-key-recover-btn {
    padding: 0.625rem 1.25rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.pro-modal-key-recover-btn:hover {
    background: var(--accent-hover);
}
.pro-modal-success-note {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}
.pro-modal-success-recover {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}
.pro-modal-success-close {
    padding: 0.75rem 2rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.pro-modal-success-close:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}


.pro-modal-key-recovery {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
}
.pro-modal-key-recovery-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

