/* ==========================================================================
   Components
   Flat, quiet and neutral: hairline borders instead of shadows, grey fills for hover and selection,
   the brand colour only on primary actions and focus.
   ========================================================================== */

/* ---------------------------------- buttons ---------------------------------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--line-strong); --btn-hover: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--btn-border);
  background: var(--btn-bg); color: var(--btn-fg); font-weight: 500; font-size: 14px; line-height: 1; white-space: nowrap;
  text-decoration: none; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--btn-hover); text-decoration: none; color: var(--btn-fg); }
.btn:active { transform: translateY(.5px); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn .icon { width: 16px; height: 16px; }

.btn--primary { --btn-bg: var(--brand-strong); --btn-fg: var(--on-brand); --btn-border: var(--brand-strong); --btn-hover: var(--brand-hover); }
.btn--primary:hover { border-color: var(--brand-hover); }
.btn--dark { --btn-bg: var(--ink); --btn-fg: #fff; --btn-border: var(--ink); --btn-hover: color-mix(in srgb, var(--ink) 82%, white); }
.btn--ghost { --btn-bg: transparent; --btn-border: transparent; --btn-hover: var(--surface-3); color: var(--text-2); }
.btn--ghost:hover { color: var(--text); }
.btn--soft { --btn-bg: var(--surface-3); --btn-fg: var(--text); --btn-border: transparent; --btn-hover: var(--line); }
.btn--danger { --btn-bg: var(--state-danger); --btn-fg: #fff; --btn-border: var(--state-danger); --btn-hover: var(--danger-ink); }
.btn--danger-outline { --btn-fg: var(--danger-ink); --btn-border: var(--line-strong); --btn-hover: var(--danger-soft); }
.btn--sm { height: 30px; padding: 0 11px; font-size: 13px; border-radius: var(--radius-sm); }
.btn--sm .icon { width: 15px; height: 15px; }
.btn--lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn--block { width: 100%; }
.btn--icon { width: 36px; padding: 0; }
.btn--icon.btn--sm { width: 30px; }

/* ---------------------------------- badges ----------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; white-space: nowrap;
  font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge--plain::before { display: none; }
.badge--success { background: var(--success-soft); color: var(--success-ink); }
.badge--warning { background: var(--warning-soft); color: var(--warning-ink); }
.badge--danger { background: var(--danger-soft); color: var(--danger-ink); }
.badge--info { background: var(--info-soft); color: var(--info-ink); }
.badge--brand { background: var(--brand-badge); color: var(--brand-hover); }
.badge--neutral { background: var(--surface-3); color: var(--text-2); }

.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px; border-radius: var(--radius-xs);
  font-size: 12px; font-weight: 500; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line);
}
.tag--mono { font-family: var(--mono); font-size: 11.5px; letter-spacing: -.01em; }

.count-pill { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--text-2); }

/* ----------------------------------- cards ----------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.card--pad { padding: 20px; }
.card--hover { transition: border-color .15s, background .15s; }
.card--hover:hover { border-color: var(--line-strong); }
.card__header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card__header h2, .card__header h3 { font-size: 15px; }
.card__body { padding: 20px; }
.card__footer { padding: 12px 20px; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card__title-icon { display: inline-grid; place-items: center; color: var(--text-3); margin-right: 2px; }
.card__title-icon .icon { width: 18px; height: 18px; }
.card__header > a:not(.btn) { color: var(--text-2); font-size: 13px; }
.card__header > a:not(.btn):hover { color: var(--text); }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--main-side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@container page (max-width: 940px) { .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid--main-side { grid-template-columns: minmax(0, 1fr); } }
@container page (max-width: 640px) { .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); } }

/* --------------------------------- key / value ------------------------------- */
.kv { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; gap: 0; }
.kv > dt, .kv > dd { padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv > dt { color: var(--text-2); font-size: 13.5px; }
.kv > dd { min-width: 0; overflow-wrap: anywhere; }
.kv > dt:last-of-type, .kv > dd:last-of-type { border-bottom: 0; }
.kv .unit { color: var(--text-3); margin-left: 4px; }
.kv-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 8px; background: var(--text-3); vertical-align: 2px; }
.kv-dot--custom { background: var(--brand); }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; } .kv > dt { border-bottom: 0; padding-bottom: 0; } }

/* ---------------------------------- forms ------------------------------------ */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .field__label { font-size: 13px; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 6px; }
.field__hint { font-size: 12.5px; color: var(--text-3); }
.field__error { font-size: 12.5px; color: var(--danger-ink); font-weight: 500; display: flex; gap: 6px; align-items: center; }
.field .req { color: var(--state-danger); }

.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font-size: 14px; transition: border-color .15s, box-shadow .15s, background .15s;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none; padding-right: 36px; background-repeat: no-repeat; background-position: right 11px center; background-size: 15px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%238E8C87' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input[disabled], .select[disabled], .textarea[disabled], .input[readonly] { background: var(--surface-2); color: var(--text-2); border-color: var(--line); }
.field--invalid .input, .field--invalid .select, .field--invalid .textarea { border-color: var(--state-danger); }
.input--sm, .select--sm { height: 32px; font-size: 13.5px; border-radius: var(--radius-sm); }
/* An input with a fixed text (or a button) glued to one side. The input gives way, the addon never wraps. */
.input-group { display: flex; align-items: stretch; }
.input-group .input { flex: 1 1 auto; min-width: 0; border-radius: var(--radius) 0 0 var(--radius); }
.input-group__addon {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; white-space: nowrap;
  border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface-2); color: var(--text-2); font-size: 13px;
}
.input-group__addon:first-child { border-left: 1px solid var(--line-strong); border-right: 0; border-radius: var(--radius) 0 0 var(--radius); }
.input-group__addon:first-child + .input { border-radius: 0 var(--radius) var(--radius) 0; }
.input-group > .btn { flex: none; height: auto; border-radius: 0 var(--radius) var(--radius) 0; }
@container page (max-width: 520px) {
  .input-group__addon--optional { display: none; }
  .input-group__addon--optional + .input { border-radius: var(--radius) 0 0 var(--radius); }
}
.input-group .input:has(+ .btn) { border-right: 0; border-radius: var(--radius) 0 0 var(--radius); }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; width: 16px; height: 16px; }
.input-icon .input { padding-left: 36px; }

.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px 16px; }
/* .field-set groups fields that are shown or hidden together (e.g. per equipment category) without leaving the grid */
.field-set { display: contents; }
.form-grid > *, .form-grid > .field-set > * { grid-column: span 12; }
.form-grid > .col-6, .form-grid > .field-set > .col-6 { grid-column: span 6; }
.form-grid > .col-4, .form-grid > .field-set > .col-4 { grid-column: span 4; }
.form-grid > .col-3, .form-grid > .field-set > .col-3 { grid-column: span 3; }
.form-grid > .col-8, .form-grid > .field-set > .col-8 { grid-column: span 8; }
@media (max-width: 720px) { .form-grid > [class*="col-"], .form-grid > .field-set > [class*="col-"] { grid-column: span 12; } }

.form-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding-top: 6px; }
.form-bar {
  position: sticky; bottom: 12px; z-index: 10; margin-top: 20px; padding: 12px 16px; display: flex; gap: 8px; justify-content: flex-end; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
}

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin-top: 2px; flex: none; }
.check small { display: block; color: var(--text-3); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { width: 36px; height: 22px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background .2s; flex: none; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .2s var(--ease); }
.switch input:checked + .switch__track { background: var(--text); }
.switch input:checked + .switch__track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--focus); }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius); background: var(--surface-3); }
.segmented a, .segmented button {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 7px; border: 0; background: transparent;
  color: var(--text-2); font-weight: 500; font-size: 13px; text-decoration: none;
}
.segmented a:hover, .segmented button:hover { color: var(--text); text-decoration: none; }
.segmented .is-active, .segmented [aria-current="page"], .segmented [aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.segmented .icon { width: 15px; height: 15px; }
.segmented--icons a, .segmented--icons button { width: 32px; padding: 0; justify-content: center; }
.segmented--icons .icon { width: 16px; height: 16px; }

.form-errors { padding: 12px 14px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger-ink); }
.form-errors ul { margin: 6px 0 0 18px; list-style: disc; font-size: 13.5px; }
.form-section { display: grid; gap: 4px; padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.form-section h3 { font-size: 15px; }
.form-section p { color: var(--text-2); font-size: 13.5px; }

/* ----------------------------------- tabs ------------------------------------ */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 12px; color: var(--text-2);
  font-weight: 500; font-size: 14px; white-space: nowrap; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab[aria-current="page"], .tab.is-active { color: var(--text); border-bottom-color: var(--text); }
.tab .icon { width: 16px; height: 16px; color: var(--text-3); }
.tab[aria-current="page"] .icon, .tab.is-active .icon { color: var(--text); }

/* --------------------------------- tables ------------------------------------ */
.table-wrap {
  overflow-x: auto;
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) 0 0 / 40px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) 100% 0 / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .12), transparent) 0 0 / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .12), transparent) 100% 0 / 14px 100% no-repeat scroll;
}
.table { font-size: 14px; }
.table th {
  position: sticky; top: 0; text-align: left; padding: 10px 16px; font-size: 12.5px; font-weight: 500;
  color: var(--text-3); background: var(--surface); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table th a:hover { color: var(--text); text-decoration: none; }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.is-clickable { cursor: pointer; }
.table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.table .col-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-card { overflow: hidden; }
.table-card .table th:first-child { border-top-left-radius: var(--radius-lg); }
.table-card .table th:last-child { border-top-right-radius: var(--radius-lg); }

/* Stacked rows (.table--stack): below 640px of page width the rows read as a list of cards. The header is hidden, every
   cell becomes a line of the card (a cell's data-label, when set, is shown in front of its value) and the "open" button
   goes away because the whole row is tappable (row_link). The page file orders and sizes the cells of each table. */
@container page (max-width: 640px) {
  .table--stack, .table--stack tbody { display: block; }
  .table--stack thead, .table--stack .col-actions { display: none; }
  .table--stack tbody tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table--stack tbody tr:last-child { border-bottom: 0; }
  .table--stack td { display: block; min-width: 0; max-width: 100%; padding: 0; border: 0; }
  .table--stack td.col-num { text-align: left; }
  .table--stack td[data-label]::before { content: attr(data-label) " "; color: var(--text-3); }
  .table--stack td > .truncate { display: block; }
  .table--stack td.col-check { order: -1; flex-basis: 100%; }
}

/* Selection of rows for a bulk action (.table--selectable + shared/_bulk_bar, Stimulus bulk-select): a checkbox column
   and, while something is ticked, a bar with the count, "select all N" and the actions, which open in the modal. */
.table .col-check { width: 1%; padding-right: 0; }
.row-check { width: 16px; height: 16px; margin: 0; vertical-align: middle; cursor: pointer; accent-color: var(--brand-strong); }
.bulk-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--line);
  background: var(--brand-soft);
}
.bulk-bar__count { font-weight: 500; font-size: 13.5px; }
.bulk-bar__actions { display: inline-flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.list-hint { display: flex; align-items: center; gap: 6px; padding: 8px 16px 0; color: var(--text-3); font-size: 13px; }

/* People picker (shared/_people_picker): a searchable list of people with checkboxes. */
.people-picker .input { margin-top: 6px; }
.people-picker__list { max-height: 300px; margin: 8px 0 0; }
.bulk-summary { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); }
.bulk-summary > .icon { margin-top: 2px; flex: none; color: var(--text-3); }

/* Entity cell: thumbnail + name + subtitle */
.entity { display: flex; align-items: center; gap: 12px; min-width: 0; color: inherit; }
.entity:hover { text-decoration: none; }
.entity__thumb {
  width: 36px; height: 36px; border-radius: var(--radius); flex: none; overflow: hidden; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line);
}
.entity__thumb img { width: 100%; height: 100%; object-fit: cover; }
.entity__thumb .icon { width: 18px; height: 18px; }
.entity__name { font-weight: 500; color: var(--text); line-height: 1.3; }
.entity:hover .entity__name { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.entity__sub { display: block; font-size: 12.5px; color: var(--text-3); line-height: 1.35; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------- filters ---------------------------------- */
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.filters .input-icon { flex: 1 1 260px; max-width: 360px; }
.filters .input, .filters .select { height: 34px; font-size: 13.5px; }
.filters .select { width: auto; min-width: 140px; }
.filters__count { margin-left: auto; color: var(--text-3); font-size: 13px; }

/* -------------------------------- pagination --------------------------------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--text-2); font-size: 13.5px; }
.pagination__links { display: flex; gap: 6px; }

/* ------------------------------ menus & dropdowns ----------------------------- */
.dropdown { position: relative; display: inline-block; }
.menu {
  position: absolute; z-index: 60; top: calc(100% + 6px); right: 0; min-width: 220px; max-width: 320px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-3);
  transform-origin: top right; animation: pop .12s var(--ease);
}
.menu--left { right: auto; left: 0; transform-origin: top left; }
.menu--up { top: auto; bottom: calc(100% + 6px); transform-origin: bottom left; }
.menu__label { padding: 8px 10px 4px; font-size: 12px; font-weight: 500; color: var(--text-3); }
.menu__sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); border: 0; background: transparent;
  color: var(--text); font-size: 14px; font-weight: 400; text-align: left; text-decoration: none; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.menu-item .icon { color: var(--text-3); width: 16px; height: 16px; }
.menu-item--danger { color: var(--danger-ink); }
.menu-item--danger .icon { color: var(--danger-ink); }
.menu-item.is-current { background: var(--surface-2); }
.menu-item small { display: block; color: var(--text-3); font-size: 12px; }
.menu-item__check { margin-left: auto; color: var(--text) !important; }
.menu--sidebar { top: calc(100% + 4px); left: 0; right: 0; max-width: none; color: var(--text); }

@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(-3px); } }

/* ---------------------------------- modals ----------------------------------- */
dialog.modal {
  padding: 0; border: 0; border-radius: var(--radius-xl); width: min(540px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-3); overflow: hidden;
  animation: modal-in .2s var(--ease);
}
dialog.modal--wide { width: min(760px, calc(100vw - 32px)); }
dialog.modal--sm { width: min(420px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(15, 28, 46, .32); animation: fade-in .2s; }
dialog.modal[open] { display: flex; flex-direction: column; }
.modal__header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px 22px 4px; }
.modal__header h2 { font-size: 1.1rem; }
.modal__body { padding: 12px 22px 8px; overflow-y: auto; }
.modal__footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; }
.modal__lede { color: var(--text-2); margin-bottom: 14px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
@keyframes fade-in { from { opacity: 0; } }

/* ----------------------------------- toasts ---------------------------------- */
.toasts { position: fixed; z-index: 200; top: 16px; right: 16px; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: #fff;
  box-shadow: var(--shadow-3); pointer-events: auto; animation: toast-in .3s var(--ease); font-size: 14px;
}
.toast .icon { margin-top: 1px; color: #86EFAC; }
.toast--alert .icon { color: #FCA5A5; }
.toast__close { margin: -6px -6px -6px auto; width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 8px; background: transparent; border: 0; color: rgba(255, 255, 255, .55); padding: 0; }
.toast__close:hover { background: rgba(255, 255, 255, .12); }
.toast__close:hover { color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
.toast.is-leaving { opacity: 0; transform: translateY(-8px); transition: all .25s; }

/* ---------------------------------- avatars ---------------------------------- */
.avatar {
  --size: 32px; width: var(--size); height: var(--size); flex: none; border-radius: 50%; overflow: hidden; display: inline-grid; place-items: center;
  font-size: calc(var(--size) * .38); font-weight: 600; letter-spacing: .02em; color: var(--text-2); background: var(--surface-3);
  background-size: cover; background-position: center;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--xs { --size: 22px; }
.avatar--sm { --size: 28px; }
.avatar--lg { --size: 48px; }
.avatar--xl { --size: 80px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
/* soft, desaturated tones: people are told apart without turning the page into a rainbow */
.avatar--tone-0 { background: #F6E7DC; color: #8A4B26; } .avatar--tone-1 { background: #E1E8F3; color: #34507A; }
.avatar--tone-2 { background: #E2EEE3; color: #3C6B45; } .avatar--tone-3 { background: #ECE4F1; color: #634A7A; }
.avatar--tone-4 { background: #F3E2E1; color: #84403C; } .avatar--tone-5 { background: #DFEDEE; color: #335F64; }
.avatar--tone-6 { background: #F2ECD9; color: #6F5B25; } .avatar--tone-7 { background: #E2E6EC; color: #4A5361; }

/* -------------------------------- empty states ------------------------------- */
.empty { display: grid; justify-items: center; gap: 8px; padding: 48px 24px; text-align: center; }
.empty__icon {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 6px;
  background: var(--surface-2); color: var(--text-3); border: 1px solid var(--line);
}
.empty__icon .icon { width: 22px; height: 22px; }
.empty h3 { font-size: 15px; }
.empty p { color: var(--text-2); max-width: 46ch; }
.empty .row { margin-top: 6px; }
.empty--compact { padding: 28px 20px; }

/* --------------------------------- misc blocks -------------------------------- */
/* Informative text (explanations, hints): light blue. Variants for warnings, errors and brand notices. */
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--info-soft); color: var(--text-2); border: 1px solid color-mix(in srgb, var(--info) 14%, white); font-size: 13.5px; }
.callout .icon { margin-top: 2px; flex: none; color: var(--info); }
.callout strong { color: var(--text); }
.callout--warning { background: var(--warning-soft); color: var(--warning-ink); border-color: transparent; }
.callout--danger { background: var(--danger-soft); color: var(--danger-ink); border-color: transparent; }
.callout--brand { background: var(--brand-soft); color: var(--brand-hover); border-color: transparent; }
.callout--warning .icon, .callout--danger .icon, .callout--brand .icon,
.callout--warning strong, .callout--danger strong, .callout--brand strong { color: inherit; }

.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.progress--success > span { background: var(--state-success); }
.progress--danger > span { background: var(--state-danger); }

.stat { display: grid; gap: 4px; padding: 18px 20px; position: relative; overflow: hidden; }
.stat__label { font-size: 13px; font-weight: 500; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.stat__value { font-size: 1.75rem; font-weight: 600; letter-spacing: -.025em; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text); }
.stat__sub { font-size: 12.5px; color: var(--text-3); }
.stat__icon { position: absolute; right: 18px; top: 18px; display: grid; place-items: center; color: var(--text-3); }
.stat__icon .icon { width: 18px; height: 18px; }
.stat__icon--success { color: var(--success-ink); }
.stat__icon--danger { color: var(--danger-ink); }
.stat__icon--info { color: var(--text-3); }

.link-list { display: grid; }
.link-list a, .link-list .link-list__item {
  display: flex; align-items: center; gap: 12px; padding: 11px 20px; color: var(--text); border-bottom: 1px solid var(--line); min-width: 0;
}
.link-list .entity__sub { white-space: normal; overflow-wrap: anywhere; }
.link-list a:hover { background: var(--surface-2); text-decoration: none; }
.link-list > :last-child { border-bottom: 0; }

.divider-label { display: flex; align-items: center; gap: 14px; color: var(--text-3); font-size: 12.5px; font-weight: 500; }
.divider-label::before, .divider-label::after { content: ""; height: 1px; background: var(--line); flex: 1; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.timeline { display: grid; gap: 0; }
.timeline__item { position: relative; display: grid; grid-template-columns: 20px 1fr; gap: 12px; padding-bottom: 16px; }
.timeline__item::before { content: ""; position: absolute; left: 9px; top: 22px; bottom: 0; width: 1px; background: var(--line); }
.timeline__item:last-child::before { display: none; }
.timeline__dot { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); z-index: 1; }
.timeline__dot .icon { width: 11px; height: 11px; }
.timeline__title { font-weight: 500; }
.timeline__title a { color: var(--text); }
.timeline__meta { font-size: 12.5px; color: var(--text-3); }

.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 8px; min-height: 14px; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .6), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* Dropzone */
.dropzone {
  display: grid; justify-items: center; gap: 6px; padding: 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg);
  text-align: center; color: var(--text-2); background: var(--surface); transition: border-color .15s, background .15s; cursor: pointer;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--text-3); background: var(--surface-2); }
.dropzone .icon { width: 24px; height: 24px; color: var(--text-3); }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-list { display: grid; gap: 6px; margin-top: 10px; }
.file-list__item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; }

/* Tooltip via title replacement */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; z-index: 80; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  white-space: nowrap; padding: 5px 9px; border-radius: 7px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 500; pointer-events: none;
}

/* utility spacing */
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }

.input-icon--right .input { padding-left: 12px; padding-right: 42px; }
.input-icon__button { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text-3); display: grid; place-items: center; }
.input-icon__button:hover { background: var(--surface-2); color: var(--text); }
.input-icon--right .icon { position: static; transform: none; pointer-events: none; }

/* cards that are links keep the text colour */
a.card, a.card:hover { color: var(--text); text-decoration: none; }
