/* Shared layout for record lists. Column roles come from the view's table schema. */
/* 184b/5 (owner 21.11, phone): a card always stands out from what it lies on — white on the grey page, light grey on
   a white panel or in a window (accepted 21.11); in the dark theme lighter than both. */
.table-wrap.record-table-wrap {
  --record-card-bg: var(--surface, #fff);
  container: record-list / inline-size;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
/* :where — no weight of its own, so the dark theme below always wins (K12 21.11: a light card in a dark panel). */
:where(.panel, dialog:not(.card-screen)) .table-wrap.record-table-wrap {
  --record-card-bg: #f4f4f4;
}
/* Dark theme: the app's own soft surface (#333, lighter than the panel #292929 and the page #202020). A page without
   the app's colours (the Makieta, still light in the dark theme) keeps a white card under its dark text. */
[data-theme='dark'] .table-wrap.record-table-wrap {
  --record-card-bg: var(--soft, var(--surface, #fff));
}
.table-wrap.record-table-wrap > table.record-table {
  width: 100%;
  min-width: 0;
  table-layout: auto;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}
.record-table-wrap .record-table tr {
  display: table-row;
}
.record-table-wrap .record-table :is(th, td) {
  padding: 12px 10px;
  line-height: 1.4;
  overflow-wrap: normal;
  word-break: normal;
}
.record-table-wrap .record-table th {
  font-size: 11px;
  white-space: normal;
}
.record-table-wrap .record-table td[data-column] {
  min-width: 0;
  vertical-align: middle;
}
.record-table [data-column='primary'] {
  font-weight: 650;
}
.record-table-wrap .record-table :is(th, td) {
  text-align: start;
}
.record-table [data-column='primary'] small,
.record-table .handover-unit {
  font-weight: 400;
}
.record-table .handover-cell,
.record-table .record-deadline {
  display: grid;
  justify-items: start;
  gap: 4px;
}
.record-table .record-deadline time,
.record-table [data-column='date'],
.record-table [data-column='number'],
.record-table [data-column='value'] {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.record-table-wrap .record-table td :is(.badge, .due-badge) {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  white-space: nowrap;
  text-align: center;
  line-height: 1.3;
}
.record-table-wrap .record-table .btn.text-link {
  display: inline;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: start;
  white-space: normal;
  overflow-wrap: normal;
}
/* 184b/3 (owner 21.11, „Otwórz kartę”): an icon and its text on one middle line. */
.record-table-wrap .record-table .btn.text-link:has(svg) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.record-table-wrap .record-table .btn.text-link:is(:hover, :focus-visible) {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.record-table .empty {
  caption-side: bottom;
  text-align: start;
}
/* 184b/2 (owner 21.11): „Działania” stands where the actions begin — the heading and the first button at the left
   edge of the column, in every row (rows with fewer buttons too). */
.record-table [data-column='actions'],
.record-table th[data-column='actions'] {
  width: 1%;
  text-align: start;
}
/* 184b/4: an action group keeps no outer margin of its own (.detail-actions has 22px around it elsewhere), so a row
   with one line and one row of buttons has the same height in every table. */
.record-table-wrap
  .record-table
  td
  :is(.row-actions, .crm-row-actions, .detail-actions, .planner-list-actions, .space-actions) {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 8px;
  margin: 0;
}
.record-table-wrap
  .record-table
  td
  :is(.row-actions, .crm-row-actions, .detail-actions, .planner-list-actions, .space-actions)
  .btn {
  flex: none;
  min-height: 36px;
  min-width: 36px;
  white-space: nowrap;
  font-size: 12px;
}
/* A link among the buttons of a group („Otwórz w CRM” by „Przedłuż” and „Edytuj” in Lokale, owner 28.11): its text on
   the buttons' middle line, not at the top of its row. */
.record-table-wrap
  .record-table
  td
  :is(.row-actions, .crm-row-actions, .detail-actions, .planner-list-actions, .space-actions)
  .btn.text-link {
  display: inline-flex;
  align-items: center;
}
@container record-list (min-width: 52.01rem) {
  .record-table:not(.stable-columns) :is(th, td):last-child {
    width: 1%;
    white-space: nowrap;
  }
  .record-table .action-measure {
    text-transform: none;
    letter-spacing: normal;
    display: flex;
    width: max-content;
    height: 0;
    overflow: hidden;
    gap: 8px;
    visibility: hidden;
  }
  .record-table .action-measure .btn {
    min-width: 36px;
    min-height: 0;
    font-size: 12px;
  }
  .record-table .action-measure .btn[data-label=''] {
    padding: 0;
    width: 38px;
  }
  .record-table .action-measure .btn::before {
    content: attr(data-label);
  }
}
@container record-list (max-width: 52rem) {
  .action-measure {
    display: none;
  }
}
@container record-list (max-width: 52rem) {
  .table-wrap.record-table-wrap > table.record-table,
  .record-table-wrap .record-table tbody {
    display: block;
  }
  .record-table-wrap .record-table colgroup {
    display: none;
  }
  .record-table-wrap .record-table caption {
    display: block;
  }
  .table-wrap.record-table-wrap > table.record-table {
    border: 0;
    border-radius: 0;
    overflow: visible;
  }
  .record-table-wrap .record-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .record-table-wrap .record-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--record-card-bg);
  }
  .record-table tbody tr + tr {
    margin-top: 10px;
  }
  .record-table-wrap .record-table td[data-column] {
    display: grid;
    grid-template-columns: minmax(72px, 31%) minmax(0, 1fr);
    align-items: baseline;
    gap: 8px;
    width: auto;
    padding: 0;
    border: 0;
    text-align: left;
    white-space: normal;
  }
  .record-table-wrap .record-table tbody td[data-column]:last-child {
    text-align: start;
  }
  .record-table td[data-column]::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 500;
    font-size: 12px;
  }
  .record-table-wrap .record-table td[data-column='primary'],
  .record-table-wrap .record-table td[data-column='actions'] {
    display: block;
  }
  .record-table td[data-column='primary'] {
    order: -1;
    font-size: 15px;
  }
  .record-table td:is([data-column='primary'], [data-column='actions'])::before {
    content: none;
  }
  .record-table td[data-column] > :is(.badge, .due-badge) {
    justify-self: start;
  }
  .record-table td[data-column='status'] > * {
    justify-self: start;
  }
  .record-table td[data-column='value'] > .due-badge {
    justify-self: start;
  }
  .record-table [data-column='status'] .handover-cell {
    justify-items: start;
  }
  .record-table-wrap .record-table tbody tr td[data-column] {
    background: transparent;
  }
  .record-table-wrap .record-table td[data-column='actions']:has(button) {
    margin-top: 2px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }
  .record-table-wrap
    .record-table
    td
    :is(.row-actions, .crm-row-actions, .detail-actions, .planner-list-actions, .space-actions) {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .record-table-wrap
    .record-table
    td
    :is(.row-actions, .crm-row-actions, .detail-actions, .planner-list-actions, .space-actions)
    .btn {
    min-height: 44px;
    min-width: 44px;
    max-width: 100%;
    white-space: normal;
  }
}
@container record-list (min-width: 32.01rem) and (max-width: 52rem) {
  .record-table-wrap .record-table:has(tbody:empty) {
    display: table;
  }
  .record-table-wrap .record-table:has(tbody:empty) thead {
    position: static;
    display: table-header-group;
    clip-path: none;
    width: auto;
    height: auto;
  }
  .record-table-wrap .record-table td[data-column]:not([data-column='primary'], [data-column='actions']) {
    grid-template-columns: minmax(90px, 1fr) minmax(9ch, 28%);
    justify-items: start;
    text-align: start;
  }
  .record-table td[data-column]::before {
    justify-self: start;
  }
  .record-table-wrap .record-table tr:has(> td:nth-child(2):last-child) td[data-column='detail'] {
    grid-template-columns: minmax(0, 1fr) 9ch;
  }
  .record-table-wrap
    .record-table
    td[data-column='actions']
    :is(.row-actions, .detail-actions, .planner-list-actions, .crm-row-actions) {
    justify-content: flex-start;
  }
}
@container record-list (max-width: 32rem) {
  .record-table-wrap .crm-task-row td .crm-row-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(min-content, 1fr));
  }
  .record-table-wrap .crm-task-row td .crm-row-actions:not(:has(> :nth-child(3))) {
    grid-template-columns: 1fr;
  }
  .record-table-wrap .crm-task-row td .crm-row-actions > .btn {
    width: 100%;
    justify-self: stretch;
    padding-inline: 4px;
  }
  .record-table-wrap .crm-task-row td .crm-row-actions > .btn:first-child {
    grid-column: 1 / -1;
  }
}
@container record-list (max-width: 17rem) {
  .record-table-wrap .record-table td:is([data-column='detail'], [data-column='status']) {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }
}

/* 184b/4 (owner 21.11, CRM → Team): on a computer every button of the actions column has the same height — the same
   type size whether or not it sits in an action group, and a button with an icon („Oznacz jako wykonane”) a little
   less padding above and below, so its 21px icon does not make it taller than a button with text only. */
@container record-list (min-width: 52.01rem) {
  .record-table-wrap .record-table td[data-column='actions'] .btn:not(.text-link) {
    flex: none;
    min-height: 36px;
    min-width: 36px;
    white-space: nowrap;
    font-size: 12px;
    line-height: 1.4;
  }
  .record-table-wrap .record-table td[data-column='actions'] .btn:not(.text-link):has(> svg + *) {
    padding-block: 9px;
  }
  /* A link of the actions („Otwórz kartę”) stays in one line like the buttons next to it. */
  .record-table-wrap .record-table td[data-column='actions'] .btn.text-link {
    white-space: nowrap;
  }
}
.table-wrap.record-table-wrap > table.stable-columns {
  table-layout: fixed;
}
@container record-list (min-width: 52.01rem) and (max-width: 62rem) {
  .record-table-wrap .record-table :is(th, td) {
    padding-inline: 6px;
  }
  .record-table-wrap .record-table td[data-column='actions'] button,
  .record-table .action-measure .btn:not([data-label='']) {
    padding-inline: 7px;
  }
}
/* Dense records keep one shared action column. Labelled fields occupy two columns to its left. */
@container record-list (min-width: 52.01rem) and (max-width: 78rem) {
  .table-wrap.record-table-wrap > table.record-dense {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) max-content;
  }
  .record-table-wrap .record-dense > :is(tbody, caption),
  .record-table-wrap .record-dense tbody tr {
    grid-column: 1/-1;
  }
  .record-table-wrap .record-dense colgroup {
    display: none;
  }
  .record-table-wrap .record-dense thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .record-table-wrap .record-dense tbody,
  .record-table-wrap .record-dense tbody tr {
    display: grid;
    grid-template-columns: subgrid;
  }
  .record-table-wrap .record-dense tbody tr {
    padding-block: 6px;
    border-bottom: 1px solid var(--line);
  }
  .record-table-wrap .record-dense td[data-column] {
    width: auto;
    padding: 5px 10px;
    text-align: start;
    border: 0;
  }
  .record-dense td::before {
    display: block;
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
  }
  .record-table-wrap .record-dense td[data-column='actions'] {
    grid-column: 3;
    grid-row: 1 / span var(--detail-rows);
    align-self: center;
  }
  .record-dense td[data-column='actions']::before {
    content: none;
  }
}
