.grid-scroll-wrap {
  width: 100%;
  overflow: visible;
}

.grid-host {
  width: 100%;
  overflow-x: scroll;
  overflow-y: hidden;
}

.grid-fixed-rows tbody {
  display: block;
  max-height: var(--grid-body-max-height, 360px);
  overflow-y: auto;
  overflow-x: hidden;
}

.grid-fixed-rows thead,
.grid-fixed-rows tbody tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

.grid-fixed-rows thead tr.grid-filter-row th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #fff;
}

.grid-fixed-rows thead tr.grid-header-row th {
  position: sticky;
  top: 34px;
  z-index: 3;
  background: #fff;
}

table.grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

table.grid th,
table.grid td {
  border-bottom: 1px solid #e5e5e5;
  border-left: 0;
  border-right: 0;
  padding: 4px 6px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

table.grid th {
  position: relative;
}

table.grid th.grid-select-col,
table.grid td.grid-select-col {
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  padding-left: 4px;
  padding-right: 4px;
  text-align: center;
}

table.grid td.grid-select-col input[type="checkbox"] {
  margin: 0;
}

table.grid th.grid-id-col,
table.grid td.grid-id-col {
  width: 42px;
  min-width: 42px;
  max-width: 42px;
  padding-left: 4px;
  padding-right: 4px;
}

table.grid tbody tr:nth-child(odd) {
  background: #fafafa;
}

table.grid tbody tr:nth-child(even) {
  background: #fff;
}

table.grid tbody tr.row-selected {
  background: #d8ebe1 !important;
}

table.grid tbody tr.row-inactive td {
  background: #fce8e8;
}
table.grid tbody tr.row-inactive:nth-child(odd) td {
  background: #f9dddd;
}
table.grid tbody tr.row-inactive:nth-child(even) td {
  background: #fce8e8;
}
table.grid tbody tr.row-inactive.row-selected td {
  background: #f3c2c2;
}

table.grid tbody tr.row-file-missing {
  background: #fde8e8 !important;
  color: #7a1f1f;
}

table.grid tbody tr.row-file-missing.row-selected {
  background: #f5c6c6 !important;
}

table.grid th.sortable {
  cursor: pointer;
}

table.grid td.editable-cell {
  background: #fffceb;
  cursor: pointer;
}

.grid-col-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  z-index: 2;
}

.grid-col-resize-handle::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3px;
  width: 1px;
  background: transparent;
}

table.grid th:hover .grid-col-resize-handle::after {
  background: #cbd5e1;
}

.grid-filter-row input,
.grid-filter-row select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d0d7d3;
  border-radius: 2px;
  padding: 2px 4px;
  font: inherit;
  font-size: 12px;
  background: #fff;
}

.grid-pager {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 2px;
  border: 0;
}

.grid-pager button {
  background: #6b655a;
  padding: 0.2rem 0.55rem;
  font-size: 12px;
}

.grid-pager-status {
  color: #5a6860;
  font-size: 12px;
}

.grid-columns-btn {
  margin-left: auto;
  background: #6b8f7a;
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  height: 22px;
}

.grid-columns-btn:hover {
  background: #557866;
}

.grid-pager-size {
  margin-left: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #5a6860;
}

/* column layout modal */
.grid-column-layout-card {
  width: min(420px, 92vw);
  max-height: min(80vh, calc(100dvh - 32px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.grid-column-layout-card.is-drag-positioned {
  z-index: 1001;
}

.grid-column-layout-title {
  margin: 0 0 10px;
  cursor: grab;
  user-select: none;
}

.grid-column-layout-title:active {
  cursor: grabbing;
}

.grid-column-layout-search {
  width: 100%;
  margin-bottom: 8px;
}

.grid-column-layout-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 120px;
  max-height: min(52vh, 420px);
  border: 1px solid #ddd;
  border-radius: 6px;
}

.grid-column-layout-item {
  display: grid;
  grid-template-columns: 24px 20px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
  cursor: grab;
}

.grid-column-layout-item:last-child {
  border-bottom: 0;
}

.grid-column-layout-item.is-dragging {
  opacity: 0.55;
}

.grid-column-layout-item.is-drop-target {
  background: #f2f4f7;
}

.grid-column-layout-drag {
  color: #777;
  user-select: none;
  text-align: center;
}

.grid-column-layout-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-column-layout-modal .animals-modal-actions {
  margin-top: 10px;
  gap: 6px;
}

.grid-column-layout-modal .animals-modal-actions button {
  border-radius: 999px;
  padding: 0.28rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.25;
}

.grid-column-layout-modal .animals-modal-actions button:hover {
  background: #557866;
}

.grid-column-layout-modal .grid-column-layout-close {
  background: #8a857c !important;
}

.grid-column-layout-modal .grid-column-layout-close:hover {
  background: #6f6b63 !important;
}

.grid-column-layout-modal .grid-column-layout-reset {
  background: #7a8f9a !important;
}

.grid-column-layout-modal .grid-column-layout-reset:hover {
  background: #62747e !important;
}

/* shared modal shell (from compose/8 app.css) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-card {
  width: min(520px, 92vw);
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 14px;
}

.animals-modal-error {
  color: #b42318;
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

.animals-modal-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

table.grid tbody tr.row-no-media td {
  background: #fdeeee;
}
table.grid tbody tr.row-no-media:nth-child(odd) td {
  background: #fbe6e6;
}
table.grid tbody tr.row-no-media:nth-child(even) td {
  background: #fdeeee;
}
table.grid tbody tr.row-no-media.row-selected td {
  background: #f3d0d0;
}

.grid-inline-input,
table.grid td.editable-cell select,
table.grid td.editable-cell input.grid-inline-input {
  max-width: 7.5rem;
  width: 7.5rem;
  min-width: 0;
  box-sizing: border-box;
  font-size: 0.82rem;
  padding: 0.15rem 0.25rem;
}
table.grid td.editable-cell select {
  max-width: 6.5rem;
  width: 6.5rem;
}

table.grid td.editable-cell select.grid-inline-select {
  max-width: 6.5rem;
  width: 6.5rem;
  min-width: 0;
}
