.tabulator .tabulator-cell{
    white-space: pre;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1; /* fallback for some fonts */
}

.tabulator-tree-level-1 .tabulator-data-tree-branch {
  margin-inline-start: 4px;
}

.tabulator-tree-level-2 .tabulator-data-tree-branch {
  margin-inline-start: 20px;
}

.tabulator .tabulator-row.tabulator-selected {
  background-color: var(--moto-row-selected-background) !important;
}

.tabulator {
  border-radius: 8px;
  overflow: hidden;
}

.tabulator.moto-pointer-focus:focus {
  outline: none;
}

.tabulator .tabulator-header {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

/* Filter popups live outside the table, so use the page's theme class. */
.silk-light .tabulator-edit-list,
.silk-dark .tabulator-edit-list {
  padding: 4px;
  border-radius: 8px;
}
.silk-light .tabulator-edit-list {
  /* Match Colors.topBackground and the border used by our other dropdowns. */
  background-color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
}
.silk-dark .tabulator-edit-list {
  background-color: #1c1c1e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.24);
}
.tabulator-edit-list .tabulator-edit-list-item {
  border-radius: 4px;
}
.tabulator-edit-list .tabulator-edit-list-item + .tabulator-edit-list-item {
  margin-block-start: 2px;
}
.silk-dark .tabulator-edit-list .tabulator-edit-list-item:is(.active, .focused) {
  color: #fff;
  background-color: #444;
}
.silk-dark .tabulator-edit-list .tabulator-edit-list-item.focused {
  outline: 1px solid #ddd;
  outline-offset: -1px;
}
/* Tabulator adds .focused after clicks too; retain the ring for keyboard navigation. */
.tabulator-edit-list .tabulator-edit-list-item.focused:focus:not(:focus-visible) {
  outline: none;
}
.tabulator-edit-list .tabulator-edit-list-item:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: -1px;
}
@media (hover: hover) and (pointer: fine) {
  .silk-dark .tabulator-edit-list .tabulator-edit-list-item:hover {
    color: #fff;
    background-color: #555;
  }
  /* Keep selection visible while giving already-selected items hover feedback. */
  .silk-dark .tabulator-edit-list .tabulator-edit-list-item.active:hover {
    background-color: #333;
  }
  .silk-light .tabulator-edit-list .tabulator-edit-list-item.active:hover {
    background-color: #1552a5;
  }
}

.tabulator .tabulator-tableholder {
  overscroll-behavior-x: contain;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}
/* Export membership colors only the checkbox; preview colors the whole row. */
.tabulator.moto-export-selection .tabulator-row.tabulator-selected:not(.moto-preview) {
  background-color: var(--moto-row-background) !important;
}
.tabulator.moto-export-selection .tabulator-row.tabulator-selected.tabulator-row-even:not(.moto-preview) {
  background-color: var(--moto-row-even-background) !important;
}
@media (hover: hover) and (pointer: fine) {
  .tabulator.moto-export-selection .tabulator-row.tabulator-selected:not(.moto-preview):hover {
    background-color: var(--moto-row-hover-background) !important;
  }
}
.tabulator.moto-export-selection .tabulator-row.moto-preview {
  background-color: var(--moto-row-selected-background) !important;
}
.tabulator.moto-export-selection .tabulator-row:is(.moto-preview, .tabulator-selected) .moto-selection-cell {
  /* Flatten the tint against the theme's table background so frozen cells are opaque. */
  background-color: color-mix(in srgb, var(--moto-row-selection-color) 40%, var(--moto-row-background));
}
.tabulator.moto-export-selection .tabulator-row.tabulator-selected .moto-selection-cell {
  /* Two 40% tint layers previously produced 64% coverage: 1 - (1 - .4)^2. */
  background-color: color-mix(in srgb, var(--moto-row-selection-color) 64%, var(--moto-row-background));
}
.moto-selection-cell { cursor: pointer; }
.moto-selection-cell input, .moto-selection-all {
  width: 16px;
  height: 16px;
  cursor: pointer;
  --moto-checkbox-accent: var(--moto-row-selection-color, Highlight);
}
.moto-checkbox {
  accent-color: var(--moto-checkbox-accent);
}
/* Use the same white marks in both themes and let forced-colors mode draw its own. */
@media (forced-colors: none) {
  .moto-checkbox:is(:checked, :indeterminate) {
    appearance: none;
    position: relative;
    box-sizing: border-box;
    border: 0;
    border-radius: 2px;
    background-color: var(--moto-checkbox-accent);
  }
  .moto-checkbox:is(:checked, :indeterminate)::before {
    content: "";
    position: absolute;
    inset: 0;
    background: white;
    mask: var(--moto-checkbox-mark) center / contain no-repeat;
  }
  .moto-checkbox:is(:checked, :indeterminate):disabled {
    background-color: GrayText;
  }
}
.moto-checkbox:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
.moto-selection-count { position: relative; display: inline-flex; }
.moto-selection-count:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; border-radius: 9999px; }
.moto-selection-summary { width: 100%; }
.moto-summary-group { min-width: 0; overflow-wrap: anywhere; }
.moto-summary-stats { width: 100%; display: flex; flex-direction: column; gap: 4px; }
.moto-summary-stat { display: grid; align-items: baseline; gap: 12px; }
.moto-summary-stat > span:first-child {
  /* Shared report labels use leading spaces to indent breakdowns on mobile. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.moto-summary-value { text-align: end; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.moto-summary-spacer { height: 12px; }

.moto-report-layout {
    border: 0;
    margin: 0;
    padding: 8px 0 16px;
    min-inline-size: 0;
    width: 100%;
}

.moto-outlined-field {
    position: relative;
    inline-size: 100%;
    min-inline-size: 0;
    border-radius: 8px;
}
.moto-field-form > .moto-outlined-field:has(legend) {
    margin-block-start: 0.5rem;
}
.moto-outlined-field > :is(input, textarea) {
    display: block;
    box-sizing: border-box;
    inline-size: 100%;
    min-inline-size: 0;
    border: 1px solid transparent;
    border-radius: inherit;
    padding: 10px;
    font-size: 1rem;
    line-height: 1.3;
    background: transparent;
    color: inherit;
    outline: none;
}
.moto-field-outline {
    position: absolute;
    inset: 0;
    min-inline-size: 0;
    margin: 0;
    /* The 7px inset and 3px legend gap match the input's 10px text padding. */
    padding: 0 7px;
    border: 1px solid var(--moto-field-border);
    border-radius: inherit;
    pointer-events: none;
    font-size: 0.75rem;
    line-height: 1.1;
}
/* The legend cuts a gap in the border without painting over the field's background. */
.moto-field-outline:has(legend) { inset-block-start: -0.55em; }
.moto-field-outline legend {
    box-sizing: border-box;
    max-inline-size: 100%;
    height: 1.1em;
    padding: 0 3px;
    color: var(--moto-field-label);
    text-align: start;
}
.moto-field-outline label {
    position: relative;
    top: 50%;
    transform: translateY(-50%);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
    pointer-events: auto;
    cursor: text;
}
.moto-outlined-field:focus-within > .moto-field-outline {
    border: 2px solid var(--moto-field-focus);
    padding-inline: 6px;
}

.moto-multiline-field { height: var(--moto-textarea-height); resize: none; }
.moto-report-editor-title {
    min-inline-size: 0;
    overflow-wrap: anywhere;
}
:has(> .moto-report-editor-title) {
    container: report-layout-toolbar / inline-size;
    flex-wrap: wrap;
}
@container report-layout-toolbar (max-width: 20rem) {
    .moto-report-editor-title { order: 1; flex-basis: 100%; }
}
[role="dialog"]:has(> .moto-report-vehicle-list) {
    width: 220px;
}
.moto-report-vehicle-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    inline-size: 100%;
    min-block-size: 2rem;
    overflow-y: auto;
}
.moto-report-layout textarea[name="header"] {
    /* Two visible lines initially. The native grip adjusts only the height. */
    height: auto;
    min-height: calc(2lh + 22px);
    resize: vertical;
    overflow: auto;
}

.moto-report-columns, .moto-report-column {
    box-sizing: border-box;
    inline-size: 100%;
    min-inline-size: 0;
}
.moto-report-column {
    position: relative;
    display: grid;
    /* Match the Settings rows' 24px icon and 16px gap before their text. */
    grid-template-columns: 24px 16px minmax(0, 1fr) 6px clamp(68px, 24%, 109px) 36px;
    grid-template-areas:
        ".     . .       . .       ."
        "check . heading . buttons handle"
        ".     . caption . .       .";
    /* Balance the caption below the input so the controls stay centered in the row. */
    grid-template-rows: 1fr auto 1fr;
    align-items: center;
    padding: 6px 16px;
    background: var(--column-surface);
}
.moto-report-column + .moto-report-column {
    border-block-start: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}
.moto-report-column input[type="checkbox"] {
    grid-area: check;
    justify-self: center;
    inline-size: 18px;
    block-size: 18px;
    margin: 0;
    --moto-checkbox-accent: var(--column-accent);
}
.moto-column-heading-group { grid-area: heading; }
.moto-column-heading { min-block-size: 46px; }
.moto-column-width-caption {
    grid-area: caption;
    align-self: start;
    justify-self: end;
    padding-block-start: 2px;
    color: var(--column-secondary);
    font-size: 0.6875rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
    text-align: end;
    font-variant-numeric: tabular-nums;
}
.moto-column-width-buttons { grid-area: buttons; min-inline-size: 0; justify-self: stretch; margin-inline: 6px; }
.moto-column-handle {
    grid-area: handle;
    display: grid;
    place-items: center;
    inline-size: 100%;
    block-size: 44px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    cursor: grab;
    touch-action: none;
    user-select: none;
}
.moto-column-handle:hover { background: color-mix(in srgb, currentColor 7%, transparent); }
.moto-column-handle:focus-visible { outline: 2px solid var(--column-accent); }
.moto-column-handle:active, .moto-column-drag-preview { cursor: grabbing; }
.moto-column-placeholder {
    background: color-mix(in srgb, var(--column-accent) 9%, var(--column-surface));
    outline: 2px dashed var(--column-accent);
    outline-offset: -3px;
    border-radius: 8px;
}
.moto-column-placeholder > * { visibility: hidden; }
.moto-column-drag-preview {
    border-radius: 8px;
    box-shadow: 0 4px 16px rgb(0 0 0 / 24%);
}

.moto-entry-layout-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    inline-size: 100%;
    min-block-size: 0;
    overflow: hidden;
}
.moto-entry-layout-body[hidden] { display: none; }
.moto-entry-layout-preview,
.moto-entry-layout-controls {
    min-block-size: 0;
    overflow: auto;
    overscroll-behavior: contain;
}
.moto-entry-layout-preview {
    flex: 0 1 auto;
    max-block-size: 50%;
}
.moto-entry-layout-controls { flex: 1 1 0; }
.moto-entry-layout-settings {
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
    inline-size: 100%;
    min-inline-size: 0;
    margin: 0;
    border: 0;
    padding: 8px 0 16px;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
}
.moto-entry-layout-settings button[aria-haspopup="dialog"] { font: inherit; }
.moto-entry-layout-setting, .moto-entry-layout-field {
    align-items: center;
    min-inline-size: 0;
    overflow-wrap: anywhere;
}
.moto-entry-layout-setting {
    display: flex;
    box-sizing: border-box;
    inline-size: 100%;
    min-block-size: 44px;
    padding: 8px 16px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
}
.moto-entry-layout-setting:hover { background: color-mix(in srgb, currentColor 6%, transparent); }
.moto-entry-layout-setting:focus-visible { outline-offset: -2px; }
/* Match the Layout picker's 24px leading slot and 16px gap on every row. */
label.moto-entry-layout-setting, .moto-entry-layout-field {
    display: grid;
    column-gap: 16px;
}
label.moto-entry-layout-setting { grid-template-columns: 24px minmax(0, 1fr) auto; }
.moto-entry-layout-field { grid-template-columns: 24px 20px minmax(0, 1fr); }
.moto-entry-layout-field > input { justify-self: center; }
.moto-entry-layout-row {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    inline-size: 100%;
    min-block-size: 48px;
    padding-block: 2px;
    padding-inline: 16px 8px;
    background: var(--column-surface);
}
.moto-entry-layout-row + .moto-entry-layout-row {
    border-block-start: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}
.moto-entry-layout-field, .moto-entry-layout-break { flex: 1 1 0; }
.moto-entry-layout-field { cursor: pointer; }
.moto-entry-layout-field small { display: block; color: var(--column-secondary); font-weight: normal; }
.moto-entry-layout-field input, .moto-entry-layout-setting input {
    inline-size: 18px;
    block-size: 18px;
    margin: 0;
}
.moto-entry-layout-row .moto-column-handle { flex: 0 0 36px; }
.moto-entry-layout-break { border-block-start: 1px dashed var(--column-secondary); }

.attachment-row, .attachment-open, .attachment-preview-bar {
    display: flex;
    align-items: center;
    gap: .65rem;
}
.attachment-row {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    padding: 0 .75rem;
}
.attachment-row + .attachment-row { border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent); }
.attachment-open {
    flex: 1;
    min-width: 0;
    min-height: 3rem;
    padding: .35rem 0;
    text-align: start;
    background: transparent;
    border: 0;
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.attachment-open:enabled:hover .attachment-name { text-decoration: underline; }
.attachment-open:disabled { opacity: .6; cursor: progress; }
.attachment-label { display: grid; gap: .1rem; min-width: 0; }
.attachment-label .attachment-name { font-size: .875rem; font-weight: 700; }
.attachment-label small { opacity: .72; }
.attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-open > :first-child { flex-shrink: 0; }
.attachment-actions { display: flex; align-items: center; flex: none; }
.attachment-picker-button {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .25rem .75rem;
    border: 0;
    border-radius: .5rem;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    font-size: .875rem;
    cursor: pointer;
}
.attachment-picker-button:enabled:hover { text-decoration: underline; }
.attachment-picker-button:disabled { opacity: .6; cursor: progress; }
.attachment-upload-error {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    width: 100%;
    padding: .4rem .75rem;
    overflow-wrap: anywhere;
    font-size: .875rem;
}
@media (hover: hover) and (pointer: fine) {
    /* Keep hidden actions in the tab order while giving the filename their space. */
    .attachment-row:not(:hover):not(:focus-within) .attachment-actions {
        position: absolute;
        inset-inline-end: .75rem;
        opacity: 0;
        pointer-events: none;
    }
}
.attachment-history-toggle {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .65rem .75rem;
    background: transparent;
    border: 0;
    border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent);
    color: inherit;
    font: inherit;
    font-size: .875rem;
    cursor: pointer;
}
.attachment-history-toggle:hover { text-decoration: underline; }
.attachment-preview {
    width: min(58rem, 94vw);
    max-height: 92vh;
    overscroll-behavior: contain;
    padding: 0;
    border: 0;
    border-radius: .75rem;
    background: Canvas;
    color: CanvasText;
}
html:has(.attachment-preview[open]) { overscroll-behavior-x: contain; }
/* The carousel focuses the dialog between attachments so arrow keys keep working. */
.attachment-preview:focus { outline: none; }
.attachment-preview::backdrop { background: rgb(0 0 0 / .65); }
.attachment-delete-confirmation {
    width: min(420px, 96vw);
    padding: 24px;
    border: 0;
    border-radius: 14px;
    background: Canvas;
    color: CanvasText;
    overflow-wrap: anywhere;
}
.attachment-delete-confirmation::backdrop { background: rgb(0 0 0 / .45); }
.attachment-delete-error { padding: .25rem .75rem; }
.attachment-preview-bar { padding: .65rem; padding-inline-start: 1rem; gap: .25rem; }
.attachment-preview-title { flex: 1; font-weight: 600; }
.attachment-preview-bar span { white-space: nowrap; }
.attachment-preview-body {
    display: grid;
    place-items: center;
    height: min(70vh, 45rem);
    background: color-mix(in srgb, CanvasText 6%, Canvas);
}
.attachment-preview-unavailable {
    display: grid;
    justify-items: center;
    gap: .75rem;
    padding: 1rem;
    text-align: center;
}
.attachment-preview-unavailable p { margin: 0; }
.attachment-photo {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    touch-action: none;
    user-select: none;
}
/* Keep the wheel target on the persistent preview body as individual photos are replaced. */
.attachment-photo img { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; pointer-events: none; }
.attachment-preview-body > [role="progressbar"] { pointer-events: none; }
.attachment-photo.zoomed { cursor: grab; }
.attachment-photo.zoomed:active { cursor: grabbing; }
.attachment-preview-body iframe { width: 100%; height: 100%; min-width: 0; min-height: 0; border: 0; }
