/* Toolbars, data tables and list footers shared by catalogue, workflow and activity. */
.table-panel {
  position: relative;
}
.cat-toolbar {
  display: grid;
  gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.cat-toolbar-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.toolbar-spacer {
  flex: 1;
}
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 320px;
  min-width: 0;
  height: 38px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-3);
  transition:
    border-color var(--dur-1) var(--ease),
    box-shadow var(--dur-1) var(--ease),
    background-color var(--dur-1) var(--ease);
}
.search-box:focus-within {
  background: var(--surface);
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cobalt) 22%, transparent);
}
.search-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.8125rem;
}
.search-input:focus {
  outline: none;
}
.search-input::-webkit-search-cancel-button {
  display: none;
}
.search-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-2);
  cursor: pointer;
}
.select-compact {
  width: auto;
  min-height: 34px;
  height: 34px;
  padding-top: 0;
  padding-bottom: 0;
  font-size: 0.78rem;
  max-width: 230px;
}
.filters-row {
  gap: 6px;
}
.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  color: var(--text-3);
}
.chip-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}
.result-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  margin-right: 4px;
}
/* Filter chips are the only pill shape: removable conditions, not actions. */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 4px 0 10px;
  border: 1px solid var(--cobalt-line);
  border-radius: var(--r-pill);
  background: var(--cobalt-soft);
  color: var(--cobalt-text);
  font-size: 0.72rem;
  font-weight: 600;
  animation: pop-in var(--dur-2) var(--ease);
}
.filter-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.filter-chip button:hover {
  background: var(--cobalt-soft-2);
}
.chip-reset {
  font-size: 0.75rem;
  margin-left: 4px;
}

/* Data table */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
  table-layout: fixed;
}
/* SATRIA keeps header cells in normal flow. Every data table sits in a panel or a .table-scroll box, and
   overflow-x: auto makes that box the scroll container of a sticky cell: `top: var(--topbar-h)` then pushed
   the header ~60px down over the first rows (the first row showed above the header on Client tickets). */
.data-table th {
  position: static;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  min-width: 0;
  overflow-wrap: anywhere;
}
.data-table tbody tr {
  cursor: pointer;
  transition:
    background-color var(--dur-1) var(--ease),
    box-shadow var(--dur-1) var(--ease);
}
.data-table tbody tr:hover {
  background: var(--surface-2);
}
.data-table tbody tr.is-selected {
  background: color-mix(in srgb, var(--cobalt-soft) 70%, var(--surface));
}
.data-table tbody tr.is-selected:hover {
  background: var(--cobalt-soft);
}
/* The rule currently open in the drawer. */
.data-table tbody tr.is-open {
  box-shadow: inset 3px 0 0 var(--cobalt);
}
.compact-table td,
.compact-table th {
  position: static;
}
.col-check {
  width: 46px;
  padding-left: 12px !important;
  padding-right: 0 !important;
}
.check-hit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: -6px 0 -6px -7px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.check-hit:hover {
  background: var(--surface-3);
}
.row-title {
  display: block;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.84rem;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.row-title:hover {
  color: var(--cobalt-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.row-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
  font-size: 0.72rem;
  color: var(--text-3);
}
.cell-main {
  display: block;
  font-weight: 500;
}
.source-id {
  font-size: 0.6875rem;
  color: var(--text-3);
  overflow-wrap: anywhere;
}
.technique-list {
  font-size: 0.66rem;
}
.kind {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  line-height: 20px;
}
.kind-nrt {
  border-color: var(--cobalt-line);
  color: var(--cobalt-text);
  background: var(--cobalt-soft);
}
.scope-cell {
  display: grid;
  gap: 6px;
  max-width: 150px;
}
.catalogue-table .col-name {
  width: auto;
}
.catalogue-table .col-kind {
  width: 118px;
}
.catalogue-table .col-state {
  width: 112px;
}
.catalogue-table .col-mitre {
  width: 22%;
}
.catalogue-table .col-schedule {
  width: 140px;
}
.catalogue-table .col-scope {
  width: 168px;
}
.workflow-table .col-stage {
  width: 150px;
}
.workflow-table .col-owner {
  width: 160px;
}
.workflow-table .col-due {
  width: 130px;
}
.workflow-table .col-evidence {
  width: 20%;
}
.workflow-table .col-recorded {
  width: 160px;
}
.evidence-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-2);
}
.table-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  font-size: 0.75rem;
  color: var(--text-2);
  border-radius: 0 0 var(--r-md) var(--r-md);
  background: var(--surface);
}
.page-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.range {
  margin-right: auto;
}
.pager {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.source-note {
  margin: 12px 2px 0;
  font-size: 0.75rem;
  color: var(--text-3);
}

/* Bulk action bar floats above the list while rules are selected. */
.app-shell {
  --rail-current: var(--rail-w);
}
.app-shell[data-rail='collapsed'],
:root[data-nav='collapsed'] .app-shell {
  --rail-current: var(--rail-w-collapsed);
}
.bulk-bar {
  position: fixed;
  bottom: 20px;
  left: calc((100vw + var(--rail-current)) / 2);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(720px, calc(100vw - var(--rail-current) - 32px));
  padding: 8px 8px 8px 16px;
  border-radius: 12px;
  background: #0f1729;
  color: #f1f4fb;
  box-shadow: var(--shadow-3);
  transform: translate(-50%, calc(100% + 32px));
  opacity: 0;
  pointer-events: none;
  transition:
    transform var(--dur-3) var(--ease),
    opacity var(--dur-2) var(--ease);
}
:root[data-theme='dark'] .bulk-bar {
  background: #1d2a63;
  border: 1px solid #33406a;
}
.bulk-bar.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}
.bulk-bar :focus-visible {
  outline-color: var(--focus-on-ink);
}
.bulk-count {
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}
.bulk-link {
  color: #b9c5ff;
  font-size: 0.78rem;
  white-space: nowrap;
}
.bulk-spacer {
  flex: 1;
}
.bulk-btn {
  --btn-bg: transparent;
  --btn-fg: #f1f4fb;
  --btn-border: rgb(255 255 255 / 0.28);
}
.bulk-btn:hover {
  --btn-bg: rgb(255 255 255 / 0.1);
  --btn-border: rgb(255 255 255 / 0.5);
}
.bulk-close {
  --btn-fg: #c9d1ea;
}
.bulk-close:hover {
  --btn-bg: rgb(255 255 255 / 0.1);
  --btn-fg: #fff;
}

@media (max-width: 1280px) {
  .catalogue-table .col-schedule {
    display: none;
  }
  .workflow-table .col-evidence {
    display: none;
  }
}
@media (max-width: 1100px) {
  .catalogue-table .col-mitre {
    display: none;
  }
  .sort-control > span {
    display: none;
  }
}
@media (max-width: 760px) {
  .app-shell {
    --rail-current: 0px !important;
  }
  .cat-toolbar {
    padding: 10px;
  }
  .search-box {
    flex-basis: 100%;
  }
  .filters-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -10px;
    padding: 2px 10px 4px;
    scrollbar-width: none;
  }
  .select-compact {
    flex: none;
  }
  .toolbar-spacer {
    display: none;
  }
  /* Rows become cards on phones; column headers move into cell labels. */
  .data-table,
  .data-table tbody {
    display: block;
  }
  .data-table thead {
    display: none;
  }
  .data-table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    padding: 12px 12px 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .catalogue-table tbody tr {
    grid-template-columns: 34px 1fr 1fr;
  }
  .data-table td {
    display: block;
    padding: 0;
    border: 0;
  }
  .data-table td[data-label]:not(.col-name)::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-3);
  }
  .data-table .col-name {
    grid-column: 1 / -1;
  }
  .catalogue-table .col-check {
    grid-row: 1 / span 3;
    width: auto;
    padding: 0 !important;
  }
  .catalogue-table .col-name {
    grid-column: 2 / -1;
  }
  .catalogue-table .col-mitre,
  .catalogue-table .col-schedule {
    display: none;
  }
  .catalogue-table .col-scope {
    grid-column: 2 / -1;
  }
  .workflow-table .col-evidence {
    display: none;
  }
  .compact-table tbody tr {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .table-footer {
    flex-wrap: wrap;
    gap: 8px 12px;
  }
  .range {
    order: -1;
    width: 100%;
  }
  .pager {
    margin-left: auto;
  }
  .bulk-bar {
    left: 50%;
    bottom: 12px;
    width: calc(100vw - 24px);
    flex-wrap: wrap;
    padding: 10px 10px 10px 14px;
  }
  .bulk-link {
    order: 5;
    width: 100%;
  }
}
