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

body {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
}

.sidebar-tab-panel {
    display: block;
}

.controls {
    background: var(--surface);
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

.top-controls-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.file-input {
    margin-bottom: 0;
}

.file-input input[type="file"] {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
}

.range-overview {
    flex: 1;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--panel);
}

#rangeOverviewCanvas {
    width: 100%;
    height: 44px;
    display: block;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    cursor: crosshair;
}

.range-overview-labels {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--muted);
}

.range-overview-value {
    white-space: nowrap;
}

.range-overview-columns {
    flex: 1;
    min-width: 160px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
}

.overview-column-btn {
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    line-height: 1.2;
    cursor: pointer;
}

.overview-column-btn:hover {
    border-color: var(--accent);
}

.overview-column-btn.active {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.columns-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
}

.add-column-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
    padding: 8px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.add-column-top-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
}

.add-column-controls select,
.add-column-controls input {
    width: 100%;
    padding: 6px;
    font-size: 12px;
}

#addColumnSelect,
.modifier-grid .filter-order,
.modifier-block .math-operation,
.modifier-block .math-source,
.modifier-block .math-column {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px;
    font-size: 12px;
    line-height: 1.2;
}

#addColumnSelect option,
.modifier-grid .filter-order option,
.modifier-block .math-operation option,
.modifier-block .math-source option,
.modifier-block .math-column option {
    background: var(--panel-2);
    color: var(--text);
}

.column-pill {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
    background: var(--panel);
    border: 1px solid var(--accent);
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
    width: 100%;
}

.column-pill-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.column-pill-body {
    display: none;
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    flex-direction: column;
    gap: 6px;
}

.column-pill-body.active {
    display: flex;
}

.column-pill.disabled {
    opacity: 0.5;
    background: var(--surface);
    border-color: var(--border);
}

.column-pill input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.column-pill-title {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    width: 100%;
    min-width: 0;
    text-overflow: ellipsis;
}

.remove-pill-btn {
    border: 1px solid var(--border);
    background: var(--panel-2);
    cursor: pointer;
    font-size: 14px;
    line-height: 1.2;
    color: var(--text);
    border-radius: 4px;
    padding: 0;
    width: 22px;
    height: 22px;
}

.remove-pill-btn:hover {
    border-color: var(--accent);
}

.modifier-close-btn,
.modifier-add-btn {
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
    border-radius: 4px;
    padding: 0;
    line-height: 1.2;
    width: 22px;
    height: 22px;
}

.modifier-menu-wrap {
    position: relative;
    display: inline-flex;
}

.modifier-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    display: none;
    flex-direction: column;
    min-width: 92px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    z-index: 20;
}

.modifier-menu.active {
    display: flex;
}

.modifier-menu-item {
    border: none;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 6px 8px;
    font-size: 12px;
    cursor: pointer;
}

.modifier-menu-item:hover {
    background: var(--panel-2);
}

.modifier-close-btn:hover,
.modifier-add-btn:hover {
    border-color: var(--accent);
}

.modifier-add-btn:disabled {
    background: var(--surface);
    color: var(--muted);
    border-color: var(--border);
    cursor: not-allowed;
}

.add-column-btn {
    padding: 6px 10px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: background 0.2s, border-color 0.2s;
    width: 36px;
    text-align: center;
    line-height: 1;
}

.add-column-btn:hover {
    background: var(--panel-2);
    border-color: var(--accent);
}

.add-column-btn:disabled {
    background: var(--surface);
    color: var(--muted);
    border-color: var(--border);
    cursor: not-allowed;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 0;
}

.zoom-controls label {
    font-size: 14px;
    font-weight: 500;
}

.zoom-controls input[type="range"] {
    width: 200px;
}

#globalFs {
    width: 88px;
    padding: 6px;
}

.zoom-value {
    font-size: 14px;
    color: var(--muted);
    min-width: 50px;
}

.chart-panel {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--border);
}

#chart {
    flex: 1;
    min-width: 0;
    min-height: 0;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
}

.chart-layout {
    display: flex;
    gap: 0;
    flex: 1;
    min-height: 0;
    margin: 0;
    overflow: hidden;
}

#chart .js-plotly-plot,
#chart .plot-container,
#chart .svg-container {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
}

.columns-sidebar {
    width: 280px;
    flex: 0 0 auto;
    min-width: 120px;
    max-width: 360px;
    background: var(--surface);
    border-radius: 0;
    border-right: 1px solid var(--border);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: auto;
    overflow-x: hidden;
}

.columns-title {
    font-size: 12px;
    font-weight: 600;
}

.columns-sidebar .column-pill {
    padding: 6px;
    border-radius: 4px;
    gap: 4px;
}

.columns-sidebar .column-pill input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

.columns-sidebar .column-pill-title {
    font-size: 12px;
}

.columns-sidebar .remove-pill-btn {
    font-size: 14px;
}

.modifier-block {
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--panel);
}

.modifier-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 4px 6px;
}

.modifier-block-title {
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
}

.modifier-block-content {
    flex-direction: column;
    gap: 4px;
    border-top: 1px solid var(--border);
    padding: 6px;
}

.modifier-block-content {
    display: flex;
    min-width: 0;
}

.modifier-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 4px 8px;
    align-items: center;
    width: 100%;
    min-width: 0;
}

.modifier-label {
    font-size: 11px;
    color: var(--muted);
}

.modifier-block input {
    width: 100%;
    padding: 5px;
    font-size: 12px;
}

.modifier-grid .filter-fc {
    width: 100%;
    min-width: 0;
    max-width: none;
}

.modifier-grid .filter-order {
    width: auto;
    min-width: 0;
    max-width: none;
    justify-self: start;
}

.math-grid {
    grid-template-columns: max-content minmax(0, 1fr);
}

.math-grid .math-operation {
    width: auto;
    justify-self: start;
}

.math-grid .math-value,
.math-grid .math-column {
    width: 100%;
    min-width: 0;
}

.math-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info {
    font-size: 12px;
    color: var(--muted);
    margin-top: 0;
}
