/* src/pages/gtable/styles.css */
:root {
  --buncss-light: ;
  --buncss-dark: initial;
  color-scheme: dark;
  --bg-page: #0a0f14;
  --bg-panel: #0b1218;
  --bg-elevated: #0d141c;
  --bg-row-hover: #111820;
  --bg-row-selected: #1a2d3d;
  --border: #1a2430;
  --border-strong: #243040;
  --border-hover: #3a4550;
  --text: #d8e2ea;
  --text-bright: #e8eef3;
  --text-muted: #6f7d89;
  --text-dim: #5f6d78;
  --text-label: #8a98a3;
  --text-hover: #a8b4be;
  --text-header: #b8c8d4;
  --accent: #5a9e86;
  --accent-hover: #3a8b61;
  --accent-border: #28523d;
  --accent-bg: #102019;
  --error: #ff8a80;
  --error-bg: #1a1214;
  --error-border: #4a3034;
  background: var(--bg-page);
  color: var(--text);
  font-synthesis: none;
  text-rendering: geometricPrecision;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif;
  line-height: 1.45;
}

* {
  box-sizing: border-box;
}

html, body, #root {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  min-width: 320px;
}

.demo-shell {
  display: flex;
  background: var(--bg-page);
  color: var(--text);
  flex-direction: column;
  gap: 6px;
  width: 100vw;
  height: 100vh;
  padding: 8px;
}

.search-row button {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  color: var(--text-hover);
  cursor: pointer;
  border-radius: 4px;
  height: 34px;
  padding: 0 .75rem;
  transition: border-color .12s, color .12s, background .12s;
  font-size: .75rem;
  font-weight: 500;
}

.search-row button:hover {
  border-color: var(--border-hover);
  color: var(--text-bright);
  background: var(--bg-elevated);
}

.landing-shell {
  overflow: hidden;
  gap: 12px;
  padding: 16px 20px 20px;
}

.landing-hero {
  max-width: 760px;
}

.landing-title {
  letter-spacing: -.03em;
  color: var(--text-bright);
  margin: 0;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 600;
  line-height: 1.1;
}

.landing-lede {
  color: var(--text-label);
  max-width: 42rem;
  margin: 8px 0 0;
  font-size: .875rem;
  line-height: 1.5;
}

.landing-lede code {
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  color: var(--text-hover);
  border-radius: 3px;
  padding: .1rem .4rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .8rem;
}

.landing-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items:  center;
  gap: 10px 14px;
}

.landing-search {
  flex: 280px;
  min-width: 220px;
  max-width: 420px;
}

.landing-meta {
  color: var(--text-muted);
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .75rem;
}

.landing-panel, .error-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: flex-start;
  align-items: stretch;
  min-height: 0;
  padding: 0;
}

.landing-message {
  color: var(--text-muted);
  padding: 20px 4px;
  font-size: 13px;
}

.landing-message code {
  color: var(--text-label);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.source-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  overflow: auto;
  align-content:  start;
  gap: 8px;
  width: 100%;
  padding: 2px 2px 8px;
}

.source-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  color: var(--text);
  text-decoration: none;
  border-radius: 4px;
  gap: 4px 12px;
  padding: 12px 14px;
  transition: border-color .12s, background .12s;
}

.source-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-elevated);
}

.source-card-label {
  grid-column: 1;
  grid-row: 1;
  color: var(--text-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .875rem;
  font-weight: 500;
}

.source-card-path {
  grid-column: 1;
  grid-row: 2;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .7rem;
}

.source-card-arrow {
  grid-column: 2;
  grid-row: 1 / span 2;
  color: var(--text-muted);
  align-self:  center;
  font-size: .9rem;
}

.row-count-display {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
}

.row-count-value {
  letter-spacing: -.02em;
  color: var(--text-bright);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
  font-weight: 600;
  line-height: 1;
}

.row-count-label {
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-muted);
  font-size: .65rem;
}

.error-panel {
  display: flex;
  color: var(--error);
  flex-direction: column;
  flex: 1;
  justify-content: center;
  align-items:  center;
  padding: 24px;
  font-size: 14px;
}

.error-panel code {
  color: var(--text-bright);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  grid-template-rows: auto auto;
  border-bottom: 1px solid var(--border);
  align-items:  center;
  gap: 6px 12px;
  min-height: 56px;
  padding-bottom: 6px;
}

.title-block {
  grid-column: 1;
  grid-row: 1 / span 2;
  min-width: 220px;
  max-width: 360px;
}

.title-block h1 {
  letter-spacing: -.02em;
  color: var(--text-bright);
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: clamp(.95rem, 1.4vw, 1.2rem);
  font-weight: 600;
  line-height: 1.1;
}

.eyebrow {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .14em;
  margin-bottom: .15rem;
  font-size: .6rem;
}

.subtitle {
  color: var(--text-dim);
  margin-top: .1rem;
  font-size: .65rem;
}

.stats-panel, .search-row {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items:  center;
  gap: 6px;
  min-width: 0;
}

.stats-panel {
  grid-column: 2;
  grid-row: 2;
}

.search-row {
  grid-column: 2;
  grid-row: 1;
}

.stats-panel::-webkit-scrollbar {
  display: none;
}

.search-row::-webkit-scrollbar {
  display: none;
}

.stat-pill {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  white-space: nowrap;
  border-radius: 3px;
  padding: .2rem .5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .65rem;
}

.debug-pill {
  color: var(--text-dim);
}

.delay-control {
  display: flex;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: 3px;
  align-items:  center;
  gap: .35rem;
  padding: .2rem .5rem;
}

.delay-control span {
  white-space: nowrap;
  font-size: .65rem;
}

.delay-control input[type="range"] {
  accent-color: var(--accent);
  width: 96px;
}

.grid-input, .grid-select {
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  color: var(--text-bright);
  outline: none;
  border-radius: 4px;
  min-width: 130px;
  height: 34px;
  padding: 0 .65rem;
  font-size: .8rem;
}

.grid-input::placeholder {
  color: var(--text-dim);
}

.grid-input:focus, .grid-select:focus {
  border-color: var(--border-hover);
}

.global-search-input {
  width: min(440px, 46vw);
}

.header-composite {
  position: relative;
  display: flex;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  align-items:  center;
  gap: 3px;
  padding: 0 6px;
}

.header-composite:hover, .header-composite.sorted {
  color: var(--text-header);
}

.header-composite:hover {
  padding-right: 20px;
}

.header-composite:has(.header-filter-button.active) {
  padding-right: 20px;
}

.header-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: auto;
  min-width: 0;
}

.header-sort-icon {
  opacity: .6;
  color: var(--text-label);
  flex-shrink: 0;
  width: 10px;
  height: 10px;
}

.header-filter-button, .small-button, .value-filter-row {
  appearance: none;
  font: inherit;
}

.header-filter-button {
  position: absolute;
  display: inline-flex;
  color: var(--text-dim);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  background: none;
  border: 0;
  border-radius: 2px;
  justify-content: center;
  align-items:  center;
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  transition: opacity .1s, color .1s;
  top: 50%;
  right: 3px;
  transform: translateY(-50%);
}

.header-filter-icon {
  width: 11px;
  height: 11px;
}

.header-composite:hover .header-filter-button, .header-filter-button.active {
  opacity: 1;
  pointer-events: auto;
}

.header-filter-button:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.header-filter-button:hover {
  color: var(--text-label);
}

.header-filter-button.active {
  opacity: 1;
  pointer-events: auto;
  color: var(--accent);
}

.icon-button {
  display: inline-flex;
  justify-content: center;
  align-items:  center;
  width: auto;
  height: auto;
  padding: .35rem;
}

.grid-card {
  position: relative;
  display: flex;
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-page);
  border-radius: 0;
  flex-direction: column;
  flex: auto;
  min-height: 300px;
}

.header-row {
  display: flex;
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-dim);
  position: relative;
  z-index: 3;
  flex-shrink: 0;
  align-items: stretch;
  height: 28px;
}

.header-cell {
  display: flex;
  letter-spacing: .03em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  border: 0;
  flex-shrink: 0;
  align-items:  center;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 500;
}

.header-cell.numeric {
  justify-content: flex-end;
}

.header-cell.gutter {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  flex: none;
  justify-content: flex-end;
  width: 84px;
}

.header-scroll {
  overflow: hidden;
  flex: auto;
  min-width: 0;
}

.header-scroll-content {
  display: flex;
  will-change: transform;
  height: 100%;
}

.header-scroll-content .header-cell {
  flex: none;
  min-width: 0;
}

.value-filter-backdrop {
  position: fixed;
  z-index: 29;
  cursor: default;
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
  inset: 0;
}

.value-filter-panel {
  position: fixed;
  z-index: 30;
  display: flex;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  overflow: hidden;
  border-radius: 6px;
  flex-direction: column;
  width: min(360px, 100vw - 24px);
  max-height: min(560px, 100vh - 24px);
  box-shadow: 0 14px 34px #00000080;
}

.value-filter-header, .value-filter-actions {
  display: flex;
  border-bottom: 1px solid var(--border);
  justify-content: space-between;
  align-items:  center;
  gap: 8px;
  padding: 10px 12px;
}

.value-filter-actions {
  border-top: 1px solid var(--border);
  border-bottom: 0;
  justify-content: flex-end;
}

.value-filter-eyebrow {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .6rem;
}

.value-filter-subtitle {
  color: var(--text-dim);
  margin-top: 3px;
  font-size: .7rem;
}

.value-filter-list {
  overflow: auto;
  padding: 6px;
}

.value-filter-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 12px 4px;
}

.value-filter-stat-card {
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  border-radius: 4px;
  padding: 6px 8px 5px;
}

.value-filter-stat-label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: .58rem;
}

.value-filter-stat-value {
  color: var(--text-bright);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .75rem;
  font-weight: 600;
}

.value-filter-chart-card {
  position: relative;
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  border-radius: 4px;
  margin: 6px 12px 0;
  padding: 8px 8px 6px;
}

.value-filter-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.value-filter-chart-label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: .58rem;
}

.value-filter-chart-subtitle {
  color: var(--text-dim);
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .62rem;
}

.value-filter-histogram {
  display: block;
  width: 100%;
  height: 148px;
}

.value-filter-search {
  padding: 8px 12px 4px;
}

.value-filter-range {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 4px;
}

.value-filter-range-slider {
  padding: 4px 2px 2px;
}

.value-filter-range-row {
  display: flex;
  align-items:  center;
  gap: 8px;
}

.value-filter-range-label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  width: 28px;
  font-size: .68rem;
}

.value-filter-input {
  width: 100%;
  min-width: 0;
  height: 32px;
  font-size: .75rem;
}

.value-filter-actions-top {
  justify-content: flex-start;
  padding-top: 6px;
  padding-bottom: 6px;
}

.value-filter-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  background: none;
  border: 0;
  border-radius: 4px;
  align-items:  center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  font-size: .8rem;
}

.value-filter-row:hover, .value-filter-row.active {
  background: var(--bg-row-hover);
}

.value-filter-row.active {
  background: linear-gradient(90deg, #5a9e862e, #5a9e8614);
  box-shadow: inset 0 0 0 1px #5a9e8657;
}

.checkmark {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  color: var(--accent);
  border-radius: 3px;
  justify-content: center;
  align-items:  center;
  width: 16px;
  height: 16px;
  font-size: .65rem;
}

.value-filter-row.active .checkmark {
  border-color: var(--accent-border);
  background: var(--accent-bg);
  color: var(--text-bright);
}

.value-filter-row.active .value-text, .value-filter-row.active .value-count {
  color: var(--text-bright);
}

.value-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.value-count {
  color: var(--text-muted);
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .7rem;
}

.value-filter-empty {
  color: var(--text-muted);
  padding: 12px 10px;
  font-size: .8rem;
}

.small-button {
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  color: var(--text-hover);
  cursor: pointer;
  border-radius: 3px;
  height: auto;
  padding: .35rem .6rem;
  font-size: .7rem;
  font-weight: 500;
}

.small-button:hover {
  border-color: var(--border-hover);
  color: var(--text-bright);
  background: var(--bg-elevated);
}

.stage {
  position: relative;
  overflow: hidden;
  outline: none;
  background: var(--bg-page);
  flex: 1;
  min-height: 290px;
}

.gpu-layer, .text-layer {
  position: absolute;
  width: 100%;
  height: 100%;
  inset: 0;
}

.gpu-layer, .text-layer {
  pointer-events: none;
}

.thumb-track {
  position: absolute;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  z-index: 5;
  cursor: pointer;
  border-radius: 4px;
  width: 10px;
  top: 8px;
  bottom: 8px;
  right: 6px;
}

.thumb {
  position: absolute;
  background: var(--border-strong);
  border-radius: 3px;
  min-height: 44px;
  top: 0;
  left: 1px;
  right: 1px;
}

.thumb:hover, .thumb:active {
  background: var(--text-dim);
}

.h-thumb-track {
  position: absolute;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  z-index: 5;
  cursor: pointer;
  border-radius: 4px;
  height: 10px;
  bottom: 8px;
  left: 14px;
  right: 28px;
}

.h-thumb {
  position: absolute;
  background: var(--border-strong);
  border-radius: 3px;
  min-width: 56px;
  top: 1px;
  bottom: 1px;
  left: 0;
}

.h-thumb:hover, .h-thumb:active {
  background: var(--text-dim);
}

.hint {
  position: absolute;
  z-index: 4;
  color: var(--text-label);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  pointer-events: none;
  border-radius: 3px;
  max-width: min(900px, 100% - 120px);
  padding: .3rem .5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .65rem;
  bottom: 30px;
  left: 10px;
}

.warning {
  position: fixed;
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
  border-radius: 4px;
  padding: .6rem .85rem;
  font-size: .8rem;
  bottom: 18px;
  right: 18px;
}

@media (width <= 960px) {
  .topbar {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    min-height: unset;
  }

  .title-block, .stats-panel, .search-row {
    grid-column: 1;
    grid-row: auto;
  }

  .stats-panel, .search-row {
    justify-content: flex-start;
  }

  .hint {
    max-width: calc(100% - 40px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
