* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  scrollbar-color: #4a5a6e #1b2330;
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: #1b2330;
}

*::-webkit-scrollbar-thumb {
  background: #4a5a6e;
  border-radius: 6px;
  border: 2px solid #1b2330;
}

*::-webkit-scrollbar-thumb:hover {
  background: #5d7189;
}

*::-webkit-scrollbar-corner {
  background: #1b2330;
}

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: Arial, sans-serif;
  background: #12161d;
  color: #e8edf2;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  min-height: 0;
  padding: 16px;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #2d3848;
  flex-shrink: 0;
}

.page-header-text {
  flex: 1 1 280px;
  min-width: 0;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 1.4rem;
}

.page-header p {
  margin: 0;
  color: #b1bcc9;
}

.page-header-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 0 1 auto;
}

.page-header-version {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  line-height: 1.2;
  white-space: nowrap;
}

.page-header-version select {
  min-width: 9.5rem;
  font-size: 0.86rem;
  padding: 6px 8px;
}

.drawer-trigger {
  font-size: 0.86rem;
  white-space: nowrap;
}

.drawer-trigger.is-active {
  background: #2f4158;
  border-color: #5a7a9e;
  color: #ffffff;
}

.drawer-trigger.has-applied-filters {
  border-color: #f0c040;
  color: #f0c040;
}

.drawer-trigger.has-applied-filters:hover {
  background: #2a3444;
  color: #f5d060;
}

.drawer-trigger.has-applied-filters.is-active {
  background: #2f4158;
  border-color: #f0c040;
  color: #ffffff;
}

.top-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0s 0.2s;
}

.top-drawer-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.2s ease, visibility 0s;
}

.top-drawer {
  position: fixed;
  z-index: 101;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -48%) scale(0.98);
  width: min(1100px, 96vw);
  max-height: min(92dvh, 880px);
  margin: 0;
  border: 1px solid #344252;
  border-radius: 8px;
  background: #141a23;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s 0.22s;
  display: flex;
  flex-direction: column;
}

.top-drawer.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s;
}

.top-drawer-inner {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: inherit;
  overflow: hidden;
  padding: 16px;
  box-sizing: border-box;
}

.top-drawer .drawer-panel-section {
  margin: 0;
  border: none;
  border-radius: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
}

.top-drawer .attribute-controls,
.top-drawer .filter-controls,
.top-drawer .column-order-controls {
  flex: 1 1 auto;
  min-height: 0;
}

.top-drawer .attribute-toolbar {
  flex-shrink: 0;
}

.top-drawer .attribute-chooser-wrap,
.top-drawer .filter-table-wrap,
.top-drawer .calc-table-wrap,
.top-drawer .column-order-list-wrap {
  flex: 1 1 auto;
  min-height: 12rem;
  max-height: none;
  overflow: auto;
}

.top-drawer .drawer-panel-section > h3 {
  margin: 0;
}

.top-drawer[data-drawer-panel="attributes"] .top-drawer-inner,
.top-drawer[data-drawer-panel="column-order"] .top-drawer-inner,
.top-drawer[data-drawer-panel="filters"] .top-drawer-inner,
.top-drawer[data-drawer-panel="calculated"] .top-drawer-inner {
  overflow: hidden;
}

.calc-col-name {
  width: 11rem;
}

.calc-col-expression {
  width: auto;
}

.calc-table tbody tr.calc-table-row td {
  vertical-align: top;
}

.calc-table tbody tr.calc-table-row td.filter-active-cell {
  vertical-align: middle;
}

.calc-name-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 0.86rem;
  padding: 6px 8px;
  border: 1px solid #3f4d5f;
  background: #1b2330;
  color: #e8edf2;
  border-radius: 6px;
}

.calc-name-input:focus {
  outline: none;
  border-color: #5a7a9e;
}

.calc-name-input.is-invalid {
  border-color: #f07070;
  box-shadow: 0 0 0 1px rgba(240, 112, 112, 0.35);
}

.calc-expression-editor {
  position: relative;
  width: 100%;
}

.calc-expression-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 2.5rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.4;
  padding: 6px 8px;
  border: 1px solid #3f4d5f;
  background: #1b2330;
  color: #e8edf2;
  border-radius: 6px;
}

.calc-expression-input:focus {
  outline: none;
  border-color: #5a7a9e;
}

.calc-expression-input.is-invalid {
  border-color: #f07070;
  box-shadow: 0 0 0 1px rgba(240, 112, 112, 0.35);
}

.calc-expression-error {
  padding-top: 4px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #f07070;
}

.calc-row-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.calc-table tbody tr.calc-table-row.is-draft td {
  background: rgba(240, 112, 112, 0.04);
}

.calc-table tbody tr.calc-table-row.is-editing td {
  background: rgba(90, 122, 158, 0.08);
}

.top-drawer:not([data-drawer-panel="attributes"]):not([data-drawer-panel="column-order"]):not([data-drawer-panel="filters"]):not([data-drawer-panel="calculated"]) .top-drawer-inner {
  overflow: auto;
}

.top-drawer .filter-row {
  gap: 10px;
}

.top-drawer .active-filters {
  margin-top: 0;
}

body.drawer-open {
  overflow: hidden;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

label.is-hidden {
  display: none;
}

input,
select,
button {
  border: 1px solid #3f4d5f;
  background: #1b2330;
  color: #e8edf2;
  border-radius: 6px;
  padding: 8px 10px;
}

button:hover {
  background: #253043;
  cursor: pointer;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.attribute-controls h3,
.filter-controls h3,
.calc-controls h3 {
  font-size: 0.95rem;
}

.calc-expression-input {
  min-width: 520px;
}

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

.active-filters {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  border: 1px solid #3f4d5f;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.attribute-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid #2d3848;
}

.attribute-toolbar-title {
  margin: 0;
  font-size: 0.95rem;
  flex: 0 0 auto;
}

.attribute-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 0 auto;
}

.attribute-toolbar-search {
  flex: 1 1 180px;
  min-width: 140px;
  max-width: 280px;
}

.attribute-toolbar-presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: 0 1 auto;
}

.attribute-toolbar-presets-label {
  font-size: 0.86rem;
  color: #b1bcc9;
}

.attribute-toolbar-presets select {
  min-width: 120px;
}

@media (max-width: 768px) {
  .top-drawer-inner {
    padding: 12px;
  }

  .attribute-toolbar-presets {
    margin-left: 0;
    width: 100%;
  }

  .attribute-toolbar-search {
    max-width: none;
    width: 100%;
  }
}

@media (max-height: 540px) {
  body {
    overflow: auto;
    height: auto;
    min-height: 100dvh;
  }

  .container {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
}

.preset-manage-dialog {
  border: 1px solid #344252;
  border-radius: 8px;
  padding: 0;
  background: #1b2330;
  color: #e8edf2;
  width: min(420px, 92vw);
  max-width: 92vw;
  overflow: hidden;
}

.preset-manage-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.preset-manage-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #2d3848;
}

.preset-manage-dialog-header h3 {
  margin: 0;
  font-size: 0.95rem;
}

.preset-manage-table-wrap {
  overflow-x: hidden;
  overflow-y: auto;
  max-height: min(50vh, 320px);
}

.preset-manage-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

.preset-manage-table col.preset-col-actions {
  width: 5.5rem;
}

.preset-manage-table th,
.preset-manage-table td {
  padding: 8px 14px;
  border-bottom: 1px solid #2d3848;
  border-right: none;
  text-align: left;
  font-size: 0.86rem;
  vertical-align: middle;
  height: 2.75rem;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #1b2330;
}

.preset-manage-table tbody tr:nth-child(even) td {
  background: #171f2b;
}

.preset-manage-table tbody tr:hover td {
  background: #1b2330;
  cursor: default;
}

.preset-manage-table th:last-child,
.preset-manage-table td:last-child {
  width: 5.5rem;
  padding-left: 8px;
  padding-right: 10px;
  text-align: center;
  overflow: visible;
  text-overflow: clip;
}

.preset-manage-table th {
  position: static;
  background: #243041;
  color: #c9d2dd;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-shadow: none;
}

.preset-manage-actions {
  display: flex;
  align-items: center;
  justify-content: center;
}

.preset-manage-actions button {
  padding: 4px 10px;
  font-size: 0.82rem;
  line-height: 1.2;
  min-height: 0;
  white-space: nowrap;
}

.preset-manage-name {
  cursor: pointer;
  color: #e8edf2;
}

.preset-manage-name:hover {
  color: #ffffff;
  text-decoration: underline;
}

.preset-manage-row.is-default .preset-manage-name {
  cursor: default;
  font-weight: 600;
}

.preset-manage-row.is-default .preset-manage-name:hover {
  text-decoration: none;
}

.preset-manage-actions-muted {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.75rem;
  color: #9fb0c5;
  line-height: 1.2;
}

.preset-name-edit-input {
  width: 100%;
  box-sizing: border-box;
}

.attribute-chooser-wrap {
  border: 1px solid #2d3848;
  border-radius: 8px;
  min-height: 12rem;
  overflow: auto;
  background: #141a23;
}

.attribute-chooser-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}

.attribute-chooser-table thead {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #243041;
  box-shadow: 0 -2px 0 #243041, 0 2px 6px rgba(0, 0, 0, 0.45);
}

.attribute-chooser-table thead tr {
  background: #243041;
}

.attribute-chooser-table thead th {
  position: relative;
  background: #243041;
  color: #c9d2dd;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  line-height: 1.15;
  border-bottom: 1px solid #2d3848;
  border-top: 1px solid #243041;
  text-align: left;
  vertical-align: middle;
}

.attribute-col-group {
  min-width: 280px;
  width: 38%;
}

.attribute-col-items {
  width: auto;
}

.column-order-toolbar {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.column-order-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.column-order-hint {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.35;
  color: #9fb0c5;
}

.column-order-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.column-order-list.is-dragging {
  touch-action: none;
}

.column-order-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #2d3848;
  border-radius: 6px;
  background: #171f2b;
  cursor: grab;
  user-select: none;
  touch-action: none;
  flex: 0 0 auto;
  transition: opacity 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.column-order-item:nth-child(even):not(.is-dragging) {
  background: #1b2330;
}

.column-order-list.is-dragging .column-order-item.is-dragging {
  opacity: 0.42;
  border-style: dashed;
  border-color: rgba(240, 192, 64, 0.5);
  background: rgba(240, 192, 64, 0.08);
  pointer-events: none;
  cursor: grabbing;
}

.column-order-list.is-dragging .column-order-item:not(.is-dragging) {
  cursor: grabbing;
}

.column-order-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  list-style: none;
}

.column-order-group-children {
  margin: 0;
  padding: 0 0 0 18px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.column-order-group.is-collapsed > .column-order-group-children {
  display: none;
}

.column-order-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #3a4658;
  border-radius: 6px;
  background: #1e2836;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: opacity 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.column-order-group-label {
  flex: 1 1 auto;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #9fb0c5;
  line-height: 1.2;
}

.column-order-group-count {
  flex: 0 0 auto;
  font-size: 0.78rem;
  line-height: 1;
  color: #9fb0c5;
  border: 1px solid #3f4d5f;
  border-radius: 999px;
  padding: 1px 6px;
}

.column-order-toggle-btn {
  flex: 0 0 auto;
  width: auto;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #c9d2dd;
  cursor: pointer;
  line-height: 1.1rem;
  font-size: 1rem;
}

.column-order-toggle-btn:hover {
  background: transparent;
  color: #ffffff;
}

.column-order-group.is-dragging-group {
  opacity: 0.42;
  pointer-events: none;
}

.column-order-group.is-dragging-group .column-order-group-header {
  border-style: dashed;
  border-color: rgba(240, 192, 64, 0.5);
  background: rgba(240, 192, 64, 0.08);
  cursor: grabbing;
}

.column-order-list.is-dragging .column-order-group-header.is-dragging {
  cursor: grabbing;
}

.column-order-placeholder {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 0;
  min-height: 0;
  padding: 0 10px;
  border: 2px dashed transparent;
  border-radius: 6px;
  background: rgba(240, 192, 64, 0.06);
  overflow: hidden;
  box-sizing: border-box;
  opacity: 0;
  transition:
    height 180ms ease,
    min-height 180ms ease,
    padding 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease,
    opacity 120ms ease;
}

.column-order-placeholder.is-open {
  height: var(--column-order-item-height, 2.75rem);
  min-height: var(--column-order-item-height, 2.75rem);
  padding: 8px 10px;
  border-color: rgba(240, 192, 64, 0.55);
  background: rgba(240, 192, 64, 0.1);
  opacity: 1;
}

.column-order-placeholder .column-order-label {
  color: #f0c040;
}

.column-order-handle {
  flex: 0 0 auto;
  color: #6d8098;
  font-size: 0.9rem;
  line-height: 1;
  letter-spacing: -0.08em;
}

.column-order-label {
  flex: 1 1 auto;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.3;
  color: #e8edf2;
  word-break: break-all;
}

.column-order-empty {
  padding: 14px 10px;
  font-size: 0.86rem;
  font-style: italic;
  color: #9fb0c5;
}

.filter-col-active {
  width: 4.5rem;
  text-align: center;
}

.filter-col-definition {
  width: auto;
}

.filter-table tbody td {
  border-bottom: 1px solid #2d3848;
  border-right: 1px solid #2d3848;
  padding: 8px 10px;
  font-size: 0.86rem;
  line-height: 1.15;
  vertical-align: middle;
}

.filter-table tbody td:last-child {
  border-right: none;
}

.filter-table tbody tr.filter-table-row.filter-row-odd td {
  background: #171f2b;
}

.filter-table tbody tr.filter-table-row.filter-row-even td {
  background: #1b2330;
}

.filter-table tbody tr.filter-table-row:hover td {
  background: #263245;
}

.filter-table tbody tr.filter-table-row.is-editing td {
  background: #263245;
}

.filter-table tbody tr.filter-table-row.is-draft td {
  background: #1e2836;
}

.filter-table tbody tr.filter-table-row.is-editing.is-draft td {
  background: #243041;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.filter-clause-block + .filter-clause-block {
  border-top: 1px solid #2d3848;
  margin-top: 8px;
  padding-top: 8px;
}

.filter-clause-join-label {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: lowercase;
  color: #9fb0c5;
  margin-bottom: 6px;
}

.filter-clause-join-label.is-editable {
  cursor: pointer;
}

.filter-clause-join-label.is-editable:hover {
  color: #f0c040;
}

.filter-clause-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-clause-row .filter-row-controls {
  flex: 1 1 auto;
  min-width: 0;
}

.filter-clause-actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.filter-join-toggle {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: #6d8098;
  cursor: pointer;
  line-height: 1.2;
}

.filter-join-opt {
  cursor: pointer;
}

.filter-join-opt:hover {
  color: #b8c8dc;
}

.filter-join-opt.is-active {
  color: #f0c040;
}

.filter-join-sep {
  color: #6d8098;
}

.filter-add-clause-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #b8c8dc;
  cursor: pointer;
  line-height: 0;
}

.filter-add-clause-btn:hover {
  color: #f0c040;
}

.filter-add-clause-icon {
  display: block;
}

.filter-active-cell {
  text-align: center;
  width: 4.5rem;
  vertical-align: middle;
}

.filter-active-cell input[type="checkbox"] {
  box-sizing: border-box;
  width: 0.86rem;
  height: 0.86rem;
  margin: 0;
  padding: 0;
  border-radius: 3px;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: inline-block;
  vertical-align: middle;
  border: 1px solid #4a5d78;
  background: #171f2b;
  cursor: pointer;
}

.filter-active-cell input[type="checkbox"]:checked {
  border-color: #3b82f6;
  background: #3b82f6;
}

.filter-active-cell input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.18rem;
  height: 0.36rem;
  border: solid #ffffff;
  border-width: 0 1.5px 1.5px 0;
  transform: translate(-50%, -58%) rotate(45deg);
  transform-origin: center;
}

.filter-active-cell input[type="checkbox"]:indeterminate {
  border-color: #3b82f6;
  background: #3b82f6;
}

.filter-active-cell input[type="checkbox"]:indeterminate::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.5rem;
  height: 2px;
  transform: translate(-50%, -50%);
  background: #ffffff;
  border-radius: 1px;
}

.filter-active-cell input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.filter-clause-error {
  padding-top: 4px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #f07070;
}

.filter-row-controls select.is-invalid,
.filter-row-controls input.is-invalid,
.searchable-attribute-picker.is-invalid .searchable-attribute-input {
  border-color: #f07070;
  box-shadow: 0 0 0 1px rgba(240, 112, 112, 0.35);
}

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

.filter-join-toggle:hover .filter-join-opt.is-active,
.filter-join-toggle:hover {
  color: #e8edf2;
}

.filter-row-controls select,
.filter-row-controls input:not(.searchable-attribute-input) {
  font-size: 0.86rem;
  padding: 6px 8px;
}

.searchable-attribute-picker {
  position: relative;
  min-width: 10rem;
  flex: 1 1 10rem;
  max-width: 16rem;
}

.filter-compare-picker {
  min-width: 10rem;
  flex: 1 1 10rem;
  max-width: 16rem;
}

.searchable-attribute-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 0.86rem;
  padding: 6px 8px;
  border: 1px solid #3f4d5f;
  background: #1b2330;
  color: #e8edf2;
  border-radius: 6px;
}

.searchable-attribute-input:focus {
  outline: none;
  border-color: #5a7a9e;
}

.searchable-attribute-list {
  margin: 0;
  padding: 4px 0;
  list-style: none;
  overflow: auto;
  border: 1px solid #3f4d5f;
  border-radius: 6px;
  background: #1b2330;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.searchable-attribute-list.is-floating {
  position: fixed;
}

.searchable-attribute-option,
.searchable-attribute-empty {
  padding: 6px 10px;
  font-size: 0.86rem;
  line-height: 1.2;
  color: #e8edf2;
  cursor: default;
}

.searchable-attribute-option {
  cursor: pointer;
}

.searchable-attribute-option:hover {
  background: #263245;
}

.searchable-attribute-option.is-highlighted {
  background: #2f3d52;
  box-shadow: inset 0 0 0 1px #f0c040;
}

.searchable-attribute-option.is-selected {
  color: #f0c040;
}

.searchable-attribute-empty {
  color: #9fb0c5;
  font-style: italic;
}

.filter-row-controls .filter-operator-picker {
  min-width: 4.5rem;
  flex: 0 0 5.75rem;
  max-width: 5.75rem;
}

.filter-row-controls .filter-mode-picker {
  min-width: 9rem;
  flex: 0 1 auto;
  max-width: 12rem;
}

.filter-row-controls .filter-value-input {
  min-width: 6rem;
  flex: 1 1 6rem;
  max-width: 10rem;
}

.filter-remove-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #9fb0c5;
  cursor: pointer;
  line-height: 0;
}

.filter-remove-btn:hover {
  color: #f0c040;
}

.filter-delete-icon {
  display: block;
}

.filter-empty-row td {
  color: #9fb0c5;
  font-style: italic;
  padding: 14px 10px;
}

.attribute-group-row td {
  border-bottom: 1px solid #2d3848;
  vertical-align: middle;
  padding: 8px 10px;
  font-size: 0.86rem;
  line-height: 1.15;
  min-height: calc(0.86rem * 1.15 + 16px);
  box-sizing: border-box;
}

.attribute-chooser-table input[type="checkbox"] {
  box-sizing: border-box;
  width: 0.86rem;
  height: 0.86rem;
  margin: 0;
  padding: 0;
  border-radius: 3px;
  flex: 0 0 auto;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: inline-block;
  vertical-align: middle;
  border: 1px solid #4a5d78;
  background: #171f2b;
  cursor: pointer;
}

.attribute-chooser-table input[type="checkbox"]:checked {
  border-color: #3b82f6;
  background: #3b82f6;
}

.attribute-chooser-table input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.18rem;
  height: 0.36rem;
  border: solid #ffffff;
  border-width: 0 1.5px 1.5px 0;
  transform: translate(-50%, -58%) rotate(45deg);
  transform-origin: center;
}

.attribute-chooser-table input[type="checkbox"]:indeterminate {
  border-color: #3b82f6;
  background: #3b82f6;
}

.attribute-chooser-table input[type="checkbox"]:indeterminate::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.5rem;
  height: 2px;
  transform: translate(-50%, -50%);
  background: #ffffff;
  border-radius: 1px;
}

.attribute-group-row.is-collapsed td {
  background: #1b2330;
}

.attribute-group-row.is-expanded td {
  background: #171f2b;
}

.attribute-group-row.is-expanded + .attribute-group-row.is-expanded td {
  background: #171f2b;
}

.attribute-group-cell {
  min-width: 280px;
}

.attribute-group-cell-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: calc(0.86rem * 1.15);
}

.attribute-group-cell--continued {
  padding: 8px 10px;
  min-width: 280px;
}

.attribute-group-checkbox {
  flex: 0 0 auto;
  margin: 0;
  align-self: center;
}

.attribute-toggle-btn {
  flex: 0 0 auto;
  margin-left: auto;
  align-self: center;
  width: auto;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #c9d2dd;
  cursor: pointer;
  line-height: 1.1rem;
  font-size: 1rem;
}

.attribute-toggle-btn:hover {
  background: transparent;
  color: #ffffff;
}

.attribute-group-name {
  flex: 1 1 auto;
  font-size: inherit;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #e8edf2;
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  line-height: inherit;
}

.attribute-group-count {
  flex: 0 0 auto;
  align-self: center;
  font-size: 0.78rem;
  line-height: 1;
  color: #9fb0c5;
  border: 1px solid #3f4d5f;
  border-radius: 999px;
  padding: 1px 6px;
}

.attribute-summary-cell {
  color: #e8edf2;
  font-size: inherit;
  line-height: inherit;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attribute-summary-cell:hover {
  background: #253043;
}

.attribute-item-cell {
  padding-left: 12px;
}

.attribute-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: inherit;
  line-height: inherit;
  font-weight: 400;
  min-height: calc(0.86rem * 1.15);
}

.attribute-item:hover {
  background: #253043;
}

.attribute-item input {
  margin: 0;
  flex: 0 0 auto;
}

.attribute-item-label {
  flex: 1 1 auto;
  min-width: 0;
  line-height: inherit;
  word-break: break-word;
  color: #e8edf2;
  font-size: inherit;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#attributeSearchInput {
  max-width: 100%;
}

#statusText {
  color: #c9d2dd;
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-wrap {
  flex: 1 1 auto;
  min-height: 12rem;
  border: 1px solid #344252;
  border-radius: 8px;
  overflow: auto;
  --table-header-height: 0px;
}

#statsTable .sticky-col {
  position: sticky;
  left: 0;
  z-index: 6;
  background-color: #171f2b;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.28);
}

#statsTable thead .sticky-col {
  z-index: 26;
  background-color: #202a38;
}

#statsTable tbody tr:nth-child(even) .sticky-col {
  background-color: #1b2330;
}

#statsTable tbody tr:hover .sticky-col {
  background-color: #263245;
}

#statsTable tbody.pinned-rows {
  position: sticky;
  top: var(--table-header-height, 0px);
  z-index: 15;
  box-shadow: 0 -1px 0 #202a38;
}

#statsTable tbody.pinned-rows tr td:not(:last-child) {
  border-right-color: #5d7189;
}

#statsTable tbody.pinned-rows tr td {
  border-bottom-color: #5d7189;
}

#statsTable tbody.pinned-rows tr:first-child td {
  border-top: 1px solid #5d7189;
}

#statsTable tbody.pinned-rows tr:last-child td {
  box-shadow: none;
}

.cell-weapon-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.cell-weapon-name-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-pin-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  max-height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #9fb0c5;
  cursor: pointer;
  line-height: 0;
}

.row-pin-btn:hover {
  color: #d4deea;
}

.row-pin-btn.is-pinned {
  color: #f0c040;
}

.row-pin-btn.is-pinned:hover {
  color: #f5d060;
}

.table-pin-icon {
  display: block;
  flex-shrink: 0;
}

#statsTable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1200px;
  table-layout: fixed;
}

#statsTable th.scalar-col,
#statsTable td.scalar-col:not(.cell-weapon-name),
#statsTable th.array-col,
#statsTable td.array-col {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
}

#statsTable thead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #202a38;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

#statsTable thead tr {
  background: #202a38;
}

#statsTable thead th {
  background-color: #202a38;
  border-right: 1px solid #2d3848;
  border-bottom: 1px solid #2d3848;
  vertical-align: middle;
  padding: 7px 10px;
  line-height: 1.15;
}

#statsTable thead tr:first-child th {
  border-top: 1px solid #2d3848;
}

#statsTable th.header-tier {
  font-size: 0.73rem;
  color: #9fb0c5;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: default;
  user-select: none;
  text-align: center;
  font-weight: 600;
  padding: 6px 8px;
}

#statsTable th.header-leaf {
  font-size: 0.86rem;
  color: #e8edf2;
  cursor: pointer;
  user-select: none;
  text-align: left;
  font-weight: 600;
  padding: 8px 10px;
}

#statsTable th.header-calc-col {
  position: relative;
  overflow: hidden;
}

#statsTable th.header-calc-col::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 11px 11px 0 0;
  border-color: #f0a030 transparent transparent transparent;
  pointer-events: none;
}

#statsTable td {
  border-bottom: 1px solid #2d3848;
  border-right: 1px solid #2d3848;
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
  font-size: 0.86rem;
  background: inherit;
}

#statsTable tbody td {
  background: #171f2b;
}

#statsTable tbody tr:nth-child(even) td {
  background: #1b2330;
}

#statsTable tbody tr:hover td {
  background: #263245;
}

#statsTable tbody.pinned-rows tr td,
#statsTable tbody.pinned-rows tr:nth-child(even) td {
  background-color: #2a3548;
}

#statsTable tbody.pinned-rows tr:hover td {
  background-color: #36465d;
}

#statsTable tbody.pinned-rows tr:hover td:not(:last-child) {
  border-right-color: #6a839f;
}

#statsTable tbody.pinned-rows tr:hover td {
  border-bottom-color: #6a839f;
}

#statsTable tbody.pinned-rows tr:hover:first-child td {
  border-top-color: #6a839f;
}

#statsTable tbody.pinned-rows tr .sticky-col,
#statsTable tbody.pinned-rows tr:nth-child(even) .sticky-col {
  z-index: 22;
  background-color: #2f3d52;
}

#statsTable tbody.pinned-rows tr:hover .sticky-col {
  background-color: #3b4d67;
}

#statsTable thead th.header-last-col,
#statsTable tbody td:last-child {
  border-right: none;
}

.sort-indicator {
  opacity: 0.7;
  margin-left: 4px;
}
