/* th-technician only. The look comes from the shared th-theme.css; everything here uses its --th-* tokens. */

:root {
    --tt-focus: var(--th-teal);
}

/* Keyboard app: every control shows where the focus is, in both themes. */
:focus-visible {
    outline: 2px solid var(--tt-focus) !important;
    outline-offset: 2px;
}

/* Teal disappears on the dark sidebar. */
.th-sidebar {
    --tt-focus: var(--th-amber);
}

/* FocusOnNavigate puts the focus on the page title for screen readers; a ring there is noise. */
h1:focus {
    outline: none !important;
}

/* Radzen's top-right spot covers the panels' action buttons (Complete inspection). */
.rz-notification {
    inset-block-start: auto;
    inset-block-end: 1rem;
}

.tt-loading {
    display: grid;
    place-items: center;
    min-height: 100vh;
    color: var(--th-muted);
    font-family: var(--th-font-mono);
}

/* Blazor reveals this with an inline display style only when recovery is needed. */
#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0;
    z-index: 10000;
    padding: .75rem 1.25rem;
    color: var(--th-ink);
    background: var(--th-surface);
    border-top: 2px solid var(--th-red);
}

/* The banner carries both languages; boot.js sets <html lang> from the stored one. */
html:not([lang="de"]) #blazor-error-ui [lang="de"],
html[lang="de"] #blazor-error-ui [lang="en"] {
    display: none;
}

#blazor-error-ui .reload {
    margin-inline-start: .75rem;
    color: var(--th-teal);
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    min-height: 28px;
    margin-inline-start: .75rem;
}

/* ===== Shell ===== */

.tt-topbar-title {
    min-width: 0;
}

/* The theme's implicit column grows to the widest child (the Prüfliste): pinned to the content area, a wide
   table scrolls in its own frame instead of pushing the page past the screen. */
.th-content {
    grid-template-columns: minmax(0, 1fr);
}

.tt-nav-key {
    color: color-mix(in srgb, var(--th-sidebar-text) 56%, transparent);
    font-family: var(--th-font-mono);
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
}

/* Unsent changes, next to Sync. Amber, as the brand mark: readable on the dark sidebar in both themes. */
.tt-nav-count {
    padding: 1px 7px;
    border-radius: 999px;
    color: var(--th-sidebar);
    background: var(--th-amber);
    font-family: var(--th-font-mono);
    font-size: 11px;
    font-weight: 600;
}

/* th-manager's rail (th-theme.css) hides the text; the unsent count stays, as a badge on the Sync icon. */
html[data-th-sidebar-collapsed="true"] .th-sidebar .tt-nav-key {
    display: none;
}

html[data-th-sidebar-collapsed="true"] .th-sidebar .tt-nav-count {
    position: absolute;
    top: 1px;
    right: 1px;
    padding: 0 5px;
    font-size: 10px;
    line-height: 16px;
}

/* Theme and language as th-manager's top-bar pills: the chosen segment is raised, not tinted teal. */
.th-top-actions .rz-selectbar {
    --rz-selectbar-background-color: transparent;
    --rz-selectbar-color: var(--th-muted);
    --rz-selectbar-border: none;
    --rz-selectbar-selected-background-color: var(--th-surface);
    --rz-selectbar-selected-color: var(--th-ink);
    --rz-selectbar-selected-border: none;
    padding: 3px;
    border: 1px solid var(--th-line);
    border-radius: var(--th-radius);
    background: var(--th-surface-2);
}

.th-top-actions .rz-selectbar .rz-button {
    min-width: 30px;
    min-height: 24px;
    margin: 0;
    padding: 0 8px;
    border-radius: 6px;
    font-family: var(--th-font-mono);
    font-size: 12px;
}

.th-top-actions .rz-selectbar .rz-button.rz-state-active {
    box-shadow: 0 1px 4px color-mix(in srgb, var(--th-sidebar) 12%, transparent);
}

.th-usermenu__item:disabled {
    color: var(--th-faint);
    cursor: default;
}

.th-usermenu__item:disabled:hover {
    background: transparent;
}

.th-usermenu__item:disabled .th-usermenu__ico {
    color: var(--th-faint);
}

.tt-notice {
    display: grid;
    gap: 12px;
    justify-items: start;
    max-width: 560px;
}

.tt-notice p {
    margin: 0;
}

/* ===== Connection indicator ===== */

.tt-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 5px 0 12px;
    border: 1px solid color-mix(in srgb, currentColor 32%, transparent);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.tt-pill-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding-right: 7px;
    border-radius: 999px;
}

.tt-pill small {
    font-size: 12px;
    font-weight: 500;
}

.tt-pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: currentColor;
}

.tt-pill.ok {
    color: var(--th-badge-green-color);
    background: var(--th-badge-green-bg);
}

.tt-pill.busy {
    color: var(--th-teal-strong);
    background: var(--th-teal-soft);
}

.tt-pill.warning {
    color: color-mix(in srgb, var(--th-amber) 62%, var(--th-ink));
    background: var(--th-amber-soft);
}

.tt-pill.error {
    color: var(--th-red);
    background: var(--th-red-soft);
}

.tt-pill .tt-pill-action.rz-button {
    min-height: 24px;
    border-radius: 999px;
}

.tt-spin {
    transform-origin: 12px 12px;
    animation: tt-spin 0.9s linear infinite;
}

@keyframes tt-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tt-spin {
        animation: none;
    }
}

/* ===== Shortcut list ===== */

.tt-keys {
    display: grid;
}

.tt-keys-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 32px;
    border-bottom: 1px solid var(--th-line);
}

.tt-keys-row:last-child {
    border-bottom: 0;
}

kbd {
    display: inline-block;
    min-width: 20px;
    padding: 0 5px;
    border: 1px solid var(--th-line);
    border-bottom-width: 2px;
    border-radius: 5px;
    color: var(--th-ink);
    background: var(--th-surface-2);
    font-family: var(--th-font-mono);
    font-size: 11px;
    font-weight: 500;
    line-height: 17px;
    text-align: center;
    white-space: nowrap;
}

/* ===== Sync page ===== */

.tt-sync {
    display: grid;
    gap: 12px;
}

.tt-sync-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}

@media (max-width: 900px) {
    .tt-sync-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

.tt-card {
    display: grid;
    gap: 12px;
    align-content: start;
    min-width: 0;
}

.tt-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tt-card h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.tt-card h2 small {
    color: var(--th-muted);
    font-family: var(--th-font-mono);
    font-size: 13px;
    font-weight: 500;
}

.tt-mono {
    font-family: var(--th-font-mono);
}

.tt-sync-step {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.tt-sync-step-body {
    display: grid;
    gap: 6px;
}

.tt-sync-step-title {
    font-weight: 600;
}

.tt-sync-step.waiting .tt-sync-step-title,
.tt-sync-step-sub {
    color: var(--th-muted);
}

.tt-sync-step-sub {
    font-size: 13px;
}

.tt-sync-step-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    color: var(--th-muted);
    background: var(--th-badge-gray-bg);
}

.tt-sync-step.done .tt-sync-step-icon {
    color: var(--th-badge-green-color);
    background: var(--th-badge-green-bg);
}

.tt-sync-step.running .tt-sync-step-icon {
    color: var(--th-teal-strong);
    background: var(--th-teal-soft);
}

.tt-sync-step.failed .tt-sync-step-icon {
    color: var(--th-red);
    background: var(--th-red-soft);
}

.tt-sync-error {
    margin: 0;
    color: var(--th-red);
}

.tt-list {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.tt-list th {
    padding: 6px 12px 6px 0;
    border-bottom: 1px solid var(--th-line);
    color: var(--th-muted);
    font-family: var(--th-font-mono);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-align: left;
    text-transform: uppercase;
}

.tt-list td {
    padding: 6px 12px 6px 0;
    border-bottom: 1px solid var(--th-line);
    /* A long rejection message wraps inside its card. */
    overflow-wrap: anywhere;
}

/* An order number stays in one piece. */
.tt-list td.tt-mono {
    white-space: nowrap;
}

.tt-list th:last-child,
.tt-list td:last-child {
    padding-right: 0;
}

.tt-list tr:last-child td {
    border-bottom: 0;
}

.tt-list .num {
    font-family: var(--th-font-mono);
    text-align: right;
}

.tt-facts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 20px;
    margin: 0;
}

@media (max-width: 700px) {
    .tt-facts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.tt-facts dt {
    color: var(--th-muted);
    font-size: 13px;
}

.tt-facts dd {
    margin: 0;
}

/* ===== Read-only table (Shared/DataTable.razor): th-manager's ColumnGrid look on a plain table ===== */

/* The frame scrolls, as the manager's grid does, so the header stays in view over long lists
   and a wide table scrolls here instead of clipping the page. */
.tt-table-wrap {
    max-height: calc(100dvh - 250px);
    overflow: auto;
    overscroll-behavior: contain;
    /* Both sticky header rows: a row scrolled into view must not end up under them. */
    scroll-padding-top: 66px;
}

.tt-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.tt-table:focus-visible {
    outline-offset: -2px;
}

.tt-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    height: 30px;
    padding: 3px 8px;
    border-bottom: 1px solid var(--th-line);
    color: var(--th-muted);
    background: var(--th-grid-head-bg);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

/* Sits under the 30px title row. */
.tt-table .tt-filter-row th {
    top: 30px;
    height: 36px;
    padding: 2px 8px 6px;
    font-weight: normal;
}

.tt-table th.sortable {
    user-select: none;
}

.tt-table th:focus-visible {
    outline-offset: -2px;
}

/* Title and Radzen's sort icon side by side; the div is what Radzen's icon hover rule looks for. */
.tt-th {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tt-table th.end .tt-th {
    justify-content: flex-end;
}

.tt-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--th-line);
    color: var(--th-ink);
    background: var(--th-surface);
    vertical-align: middle;
    white-space: nowrap;
}

.tt-table tbody tr:last-child td {
    border-bottom: 0;
}

.tt-table tbody tr:nth-child(even) td {
    background: var(--th-grid-row-stripe);
}

.tt-table tbody tr[aria-selected] {
    cursor: pointer;
}

.tt-table tbody tr[aria-selected="false"]:hover td {
    background: var(--th-grid-row-hover);
}

.tt-table tbody tr[aria-selected="true"] td {
    background: var(--th-amber-soft);
}

.tt-table tbody tr[aria-selected="true"] td:first-child {
    box-shadow: inset 4px 0 0 var(--th-amber);
}

/* The manager's dark selected row: the amber wash, not the brown soft tile. */
html[data-th-theme="dark"] .tt-table tbody tr[aria-selected="true"] td {
    background: color-mix(in srgb, var(--th-amber) 14%, transparent);
}

.tt-table .end {
    text-align: right;
}

.tt-table td.end {
    font-family: var(--th-font-mono);
    font-variant-numeric: tabular-nums;
}

.tt-table td.tt-table-empty {
    padding: 14px 12px;
    color: var(--th-muted);
    white-space: normal;
}

/* max-width 0: the column gives up its text width and shares what the others leave (width as the ratio). */
.tt-table td.tt-clip {
    max-width: 0;
    width: 10%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tt-table td.tt-clip-wide {
    width: 30%;
}

.tt-strong {
    font-weight: 600;
}

.tt-muted {
    color: var(--th-muted);
}

/* ===== Order header (top bar of the open order's screens) ===== */

.tt-order-head {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--th-muted);
    font-size: 13px;
    white-space: nowrap;
}

.tt-order-head b {
    color: var(--th-ink);
    font-weight: 600;
}

.tt-order-head i {
    width: 1px;
    height: 14px;
    background: var(--th-line);
}

/* ===== Entry grid (Shared/EntryGrid.razor): the Prüfliste, same tokens as the read-only table ===== */

.tt-entry-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--th-line);
    background: var(--th-tabs-bg);
}

/* The bar draws the line the active tab sits on. Tabs and toolbar keep their size; the chips wrap between them. */
.tt-entry-bar .th-tabs {
    flex: none;
    align-self: flex-end;
    border-bottom: 0;
    background: transparent;
}

.tt-entry-bar .th-grid-filter-chips {
    flex: 1 1 auto;
    min-width: 0;
}

.tt-entry-toolbar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    padding: 0 4px;
}

/* The tab line's height, as the grid toolbar's buttons in DataTable. */
.tt-entry-toolbar .th-button {
    min-height: 30px;
    padding: 4px 10px;
    font-size: 12px;
}

.tt-entry-tabs .th-tab {
    padding: 8px 14px;
}

.tt-usermenu-key {
    margin-left: auto;
}

.tt-entry-tabs kbd {
    margin-left: 6px;
}

.tt-entry-split {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.tt-entry-wrap {
    flex: 1 1 auto;
    min-width: 0;
    max-height: calc(100dvh - 210px);
    overflow: auto;
    overscroll-behavior: contain;
    /* A cell scrolled into view must not end up under the sticky header. */
    scroll-padding-top: 31px;
    border: 1px solid var(--th-line);
    border-radius: var(--th-radius);
    background: var(--th-surface);
}

/* Narrowed to its minimum columns next to the panel; it still scrolls rather than push the panel out. */
.has-panel .tt-entry-wrap {
    flex: 0 1 auto;
}

.tt-entry-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.has-panel .tt-entry-table {
    width: auto;
}

.tt-entry-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    height: 30px;
    padding: 0 8px;
    border-bottom: 1px solid var(--th-line);
    color: var(--th-muted);
    background: var(--th-grid-head-bg);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tt-entry-table th.end {
    text-align: right;
}

.tt-entry-table th.end .tt-th {
    justify-content: flex-end;
}

.tt-entry-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.tt-entry-table th:focus-visible {
    outline-offset: -2px;
}

/* Sits under the 30px title row, as in the read-only table. */
.tt-entry-table .tt-filter-row th {
    top: 30px;
    height: 36px;
    padding: 2px 8px 6px;
    font-weight: normal;
    overflow: visible;
}

/* Both sticky header rows. */
.tt-entry-wrap.has-filters {
    scroll-padding-top: 67px;
}

/* Frozen columns (GridColumn.Frozen, left offset inline): the device stays in sight while the table scrolls
   sideways. Headers above the frozen cells, frozen cells above the rest; every cell background is opaque. */
.tt-entry-table th.is-frozen {
    z-index: 3;
    box-shadow: inset -1px 0 0 var(--th-line);
}

.tt-entry-table tr td.is-frozen {
    position: sticky;
    z-index: 1;
}

.tt-entry-table td {
    height: 30px;
    box-sizing: border-box;
    padding: 0;
    border-bottom: 1px solid var(--th-line);
    border-right: 1px solid var(--th-line);
    color: var(--th-ink);
    background: var(--th-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tt-entry-table td:last-child {
    border-right: 0;
}

.tt-entry-table td.is-text {
    padding: 0 8px;
}

.tt-entry-table td.is-number {
    text-align: right;
    font-family: var(--th-font-mono);
    font-variant-numeric: tabular-nums;
}

/* A plain cell look: the cell, not the input, shows the focus. */
.tt-cell-input {
    display: block;
    width: 100%;
    height: 29px;
    box-sizing: border-box;
    margin: 0;
    padding: 0 8px;
    border: 0;
    border-radius: 0;
    outline: 0;
    color: inherit;
    background: transparent;
    font: inherit;
    text-align: inherit;
}

.tt-cell-input:focus-visible {
    outline: none !important;
}

.tt-entry-table td.is-choice .tt-cell-input {
    padding-right: 20px;
    background-image: linear-gradient(45deg, transparent 50%, var(--th-muted) 50%),
    linear-gradient(135deg, var(--th-muted) 50%, transparent 50%);
    background-position: calc(100% - 11px) 13px, calc(100% - 7px) 13px;
    background-size: 4px 4px;
    background-repeat: no-repeat;
}

/* A unit after the value (GridColumn.Suffix): visible before anything is typed, quiet, and never under the text. */
.tt-entry-table td.has-suffix {
    position: relative;
    padding-right: 28px;
}

.tt-entry-table td.has-suffix .tt-cell-input {
    padding-right: 2px;
}

.tt-cell-suffix {
    position: absolute;
    top: 0;
    right: 6px;
    line-height: 29px;
    color: var(--th-muted);
    pointer-events: none;
}

.tt-entry-table tr:focus-within td {
    background: color-mix(in srgb, var(--th-teal-soft) 55%, var(--th-surface));
}

/* A focused row (none of its cells can take the focus) shows by its tint. */
.tt-entry-table tr:focus-visible {
    outline: none !important;
}

.tt-entry-table tr.tt-entry-new td {
    background: var(--th-field-bg);
}

.tt-entry-table tr td.is-off {
    color: var(--th-muted);
    background: var(--th-surface-2);
}

/* The row a side panel shows, also while the focus is in the panel and on locked cells. */
.tt-entry-table tr.is-current td {
    background: var(--th-teal-soft);
}

.tt-entry-table tr.is-current td:first-child {
    box-shadow: inset 3px 0 0 var(--th-teal);
}

/* A value the column refused (CellRefusedException), until it is taken or Esc restores the stored one. */
.tt-entry-table tr td:has(> .tt-cell-input[aria-invalid="true"]) {
    outline: 2px solid var(--th-red);
    outline-offset: -2px;
    background: var(--th-red-soft);
}

.tt-entry-table tr td:focus-within {
    outline: 2px solid var(--tt-focus);
    outline-offset: -2px;
    background: var(--th-field-bg);
}

/* A stored value worth a look (GridColumn.Warning): amber, not the refusal's red, and kept while focused. */
.tt-entry-table tr td.is-warn {
    box-shadow: inset 3px 0 0 var(--th-amber);
    background: var(--th-amber-soft);
}

.tt-entry-panel {
    flex: 1 1 0;
    min-width: 0;
    min-height: 240px;
    border: 1px solid var(--th-line);
    border-radius: var(--th-radius);
    background: var(--th-surface);
}

/* ===== Test-steps tab (Shared/StepsTab.razor); the steps use th-manager's th-inspection-* look ===== */

.tt-steps {
    display: grid;
    gap: 8px;
    max-height: calc(100dvh - 210px);
    overflow: auto;
    padding: 8px 10px;
}

.tt-steps-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tt-steps-count {
    margin-right: auto;
    color: var(--th-muted);
    font-variant-numeric: tabular-nums;
}

.tt-steps-count strong {
    color: var(--th-ink);
}

.tt-steps-actions {
    display: inline-flex;
    gap: 8px;
}

.tt-steps-actions kbd,
.tt-step .th-inspection-result__option kbd {
    margin-left: 6px;
    opacity: 0.7;
}

.tt-steps-result {
    font-weight: 600;
}

.tt-steps-result.is-pass {
    color: var(--th-badge-green-color);
}

.tt-steps-result.is-fail {
    color: var(--th-red);
}

.tt-steps-list {
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tt-step {
    outline: none;
}

.tt-step.is-current {
    border-color: var(--th-teal);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--th-teal) 18%, transparent);
}

.tt-step:focus-visible {
    outline: 2px solid var(--th-teal);
    outline-offset: -2px;
}

.tt-step-measure {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.tt-step-measure .rz-textbox.tt-step-reading {
    width: 84px;
    height: 28px;
    padding: 0 8px;
    text-align: right;
    font-family: var(--th-font-mono);
}

.tt-step-value {
    font-family: var(--th-font-mono);
    font-weight: 600;
}

.tt-step-measure .rz-textbox.tt-step-reading.is-outside {
    border-color: var(--th-red);
    color: var(--th-red);
}

.tt-step-value.is-outside {
    color: var(--th-red);
}

.tt-step-unit,
.tt-step-limits,
.tt-step-note small,
.tt-steps-empty {
    color: var(--th-muted);
}

.tt-steps-empty {
    margin: 0;
}

.tt-step-note {
    padding: 0 8px 6px 42px;
}

.tt-step-note .rz-textbox {
    width: 100%;
    height: 28px;
}

/* An empty note takes room only on the step being worked on. */
.tt-step-note.is-empty {
    display: none;
}

.tt-step.is-current .tt-step-note.is-empty,
.tt-step:focus-within .tt-step-note.is-empty {
    display: block;
}

.tt-step-defects {
    display: grid;
    gap: 3px;
    margin: 0;
    padding: 0 8px 6px 42px;
    list-style: none;
    font-size: 12px;
}

.tt-step-defects li {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.tt-step-defects .th-defect-severity {
    min-width: 26px;
    height: 20px;
    padding: 0 5px;
    font-size: 10px;
}

/* ===== Defects tab (Shared/DefectsTab.razor) and the defect menu (Shared/DefectMenu.razor) ===== */

.tt-defects {
    display: grid;
    gap: 10px;
    max-height: calc(100dvh - 210px);
    overflow: auto;
    padding: 8px 10px;
}

.tt-defects-section {
    display: grid;
    gap: 6px;
}

.tt-defects-section h3 {
    margin: 0;
}

.tt-defects-list,
.tt-defect-options {
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tt-defect {
    outline: none;
    padding: 7px 9px;
}

.tt-defect.is-current {
    border-color: var(--th-teal);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--th-teal) 18%, transparent);
}

.tt-defect:focus-visible {
    outline: 2px solid var(--th-teal);
    outline-offset: -2px;
}

.tt-defect-photos {
    display: inline-flex;
    gap: 4px;
}

.tt-defect-photos img {
    width: 36px;
    height: 36px;
    border: 1px solid var(--th-line);
    border-radius: 5px;
    object-fit: cover;
}

.tt-defect-actions {
    grid-column: 2 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tt-defect-actions kbd,
.tt-defect-options kbd {
    margin-left: 6px;
    opacity: 0.7;
}

.tt-defect-menu {
    display: grid;
    gap: 10px;
}

.tt-defect-options {
    max-height: 320px;
    overflow: auto;
}

.tt-defect-options:focus-visible {
    outline: 2px solid var(--th-teal);
    outline-offset: 2px;
}

.tt-defect-options .th-defect-choice {
    padding: 7px 10px;
}

.tt-defect-options .th-defect-choice.is-recorded {
    opacity: .64;
}

.tt-defect-none,
.tt-defect-message {
    margin: 0;
    color: var(--th-muted);
}

.tt-defect-message {
    color: var(--th-red);
}

/* ===== Master-data tab (Shared/MasterDataTab.razor) and the "+" dialog (Shared/CatalogEntryDialog.razor) ===== */

.tt-master {
    display: grid;
    gap: 12px;
    align-content: start;
    max-height: calc(100dvh - 210px);
    overflow: auto;
    padding: 8px 10px;
}

.tt-master-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
}

.tt-master-field {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.tt-master-field.is-wide {
    grid-column: 1 / -1;
}

.tt-master-label {
    color: var(--th-muted);
    font-size: 12px;
}

.tt-master-control {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.tt-master-control .rz-textbox {
    flex: 1 1 auto;
    min-width: 0;
    height: 28px;
}

/* th-theme shows placeholders in ink; the date format must not read as a stored date. */
.tt-master-control input:not(:disabled)::placeholder {
    color: var(--th-muted);
}

.tt-master-history {
    display: grid;
    gap: 6px;
    outline: none;
}

.tt-master-history:focus-visible {
    outline: 2px solid var(--th-teal);
    outline-offset: 2px;
}

.tt-master-history h3 {
    margin: 0;
}

.tt-master-visits {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tt-master-visit {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.tt-master-visits .tt-step-defects {
    padding: 2px 0 0 12px;
}

.tt-catalog {
    display: grid;
    gap: 10px;
}

/* Fixed to the viewport by js/grid.js, so the table's scrolling frame cannot clip it. */
.tt-choices {
    position: fixed;
    z-index: 1000;
    box-sizing: border-box;
    max-height: 264px;
    max-width: 360px;
    margin: 0;
    padding: 4px;
    overflow: auto;
    list-style: none;
    border: 1px solid var(--th-line);
    border-radius: var(--th-radius);
    color: var(--th-ink);
    background: var(--th-surface);
    box-shadow: var(--th-shadow);
    font-size: 13px;
}

.tt-choices li {
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tt-choices li:hover {
    background: var(--th-grid-row-hover);
}

.tt-choices li[aria-selected="true"] {
    color: var(--th-teal-strong);
    background: var(--th-teal-soft);
    font-weight: 600;
}

.tt-choices li.tt-choices-none {
    color: var(--th-muted);
    cursor: default;
}

/* ===== Prüfliste page (Pages/Order.razor) ===== */

.tt-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-left: 4px;
    border-radius: 999px;
}

.tt-dot.is-pass {
    background: var(--th-badge-green-color);
}

.tt-dot.is-fail {
    background: var(--th-red);
}

.tt-dot.is-open {
    background: var(--th-blue);
}

.tt-result {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.tt-result-mark {
    font-weight: 700;
    line-height: 1;
}

.tt-result-mark.is-incomplete {
    color: var(--th-amber);
}

.tt-result-mark.is-limit {
    color: var(--th-red);
}

.tt-move-facts {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 6px 14px;
    margin: 0 0 16px;
}

.tt-move-facts dt {
    color: var(--th-muted);
    font-size: 12px;
}

.tt-move-facts dd {
    margin: 0;
    font-weight: 600;
}

.tt-move-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.tt-move-actions kbd {
    margin-left: 6px;
}

/* ===== Order workspace (plan 053 M5): order data, documents, time tracking, statistics ===== */

.tt-order-data {
    display: grid;
    gap: 12px;
    max-width: 1100px;
}

.tt-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 20px;
}

@media (max-width: 900px) {
    .tt-form {
        grid-template-columns: minmax(0, 1fr);
    }
}

.tt-field {
    display: grid;
    gap: 4px;
    min-width: 0;
    align-content: start;
}

.tt-field.is-wide {
    grid-column: 1 / -1;
}

.tt-field > label {
    color: var(--th-muted);
    font-size: 13px;
}

.tt-field-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.tt-order-refs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tt-order-reflist {
    display: grid;
    gap: 2px;
    margin: 6px 0 0;
    padding-left: 18px;
}

.tt-order-complete,
.tt-doc-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}

/* A field whose value was not taken (a blank signer, an address no email can go to). */
.tt-invalid,
.rz-textbox.tt-invalid {
    outline: 2px solid var(--th-red);
    outline-offset: -1px;
}

.tt-time-total {
    font-family: var(--th-font-mono);
    font-weight: 600;
}

.tt-statistics {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.tt-statistics dd {
    font-family: var(--th-font-mono);
    font-size: 18px;
    font-weight: 600;
}

@media (max-width: 1000px) {
    .tt-statistics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.tt-doc-mails {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 0 0 0 auto;
    padding: 0;
    list-style: none;
    font-size: 13px;
}

.tt-doc-mails li {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* The signature and email dialogs. */
.tt-sign {
    display: grid;
    gap: 12px;
}

.tt-sign p {
    margin: 0;
}

.tt-sign-pad {
    width: 100%;
    height: 180px;
    border: 1px solid var(--th-line);
    border-radius: var(--th-radius);
    /* Paper in both themes: the ink is dark, as on the printed sheet. */
    background: #fff;
    cursor: crosshair;
    touch-action: none;
}

.tt-sign-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tt-sign-spacer {
    flex: 1;
}

/* The print view: an A4 sheet, paper-white in both themes, with the PDF's colours (QuestPDF renderer). */
.tt-sheet {
    display: flex;
    flex-direction: column;
    gap: 22px;
    box-sizing: border-box;
    width: min(100%, 210mm);
    min-height: 297mm;
    padding: 15mm 20mm;
    border: 1px solid var(--th-line);
    color: #28343a;
    background: #fff;
    font-family: var(--th-font-sans, sans-serif);
    font-size: 13px;
    line-height: 1.45;
}

.tt-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #c9a227;
}

.tt-sheet-head img {
    max-width: 210px;
    max-height: 56px;
}

.tt-sheet-head b {
    font-size: 18px;
}

.tt-sheet-head h1 {
    margin: 0;
    color: #c9a227;
    font-size: 24px;
    font-weight: 700;
}

.tt-sheet-top {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 24px;
}

.tt-sheet address {
    display: grid;
    align-content: start;
    font-style: normal;
}

.tt-sheet address small {
    margin-bottom: 8px;
    color: #5f6b72;
    font-size: 9px;
    text-decoration: underline;
}

.tt-sheet-top dl {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 3px 8px;
    align-content: start;
    margin: 0;
}

.tt-sheet-top dt {
    color: #5f6b72;
}

.tt-sheet-top dd {
    margin: 0;
}

.tt-sheet-lines {
    width: 100%;
    border-collapse: collapse;
}

.tt-sheet-lines th {
    padding: 5px 4px;
    background: #f4ebc8;
    font-weight: 700;
    text-align: left;
}

.tt-sheet-lines td {
    padding: 5px 4px;
    border-bottom: 1px solid #dde2e5;
    vertical-align: top;
}

.tt-sheet-lines .end {
    text-align: right;
    white-space: nowrap;
}

.tt-sheet-lines small {
    display: block;
    color: #5f6b72;
    font-size: 11px;
}

.tt-sheet-signature {
    display: grid;
    justify-items: start;
    gap: 2px;
    width: 260px;
    margin-top: 12px;
    color: #5f6b72;
    font-size: 11px;
}

.tt-sheet-signature img {
    width: 240px;
    height: 80px;
    border-bottom: 1px solid #28343a;
    object-fit: contain;
    object-position: left bottom;
}

.tt-sheet-foot {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #c9a227;
    color: #5f6b72;
    font-size: 10px;
}

.tt-sheet-foot div {
    display: grid;
    align-content: start;
}

.tt-sheet-legal {
    white-space: pre-line;
}

/* Printing (the browser's dialog, also Ctrl+P): only the sheet, on the paper's own margins. */
@media print {
    @page {
        size: A4;
        margin: 15mm 20mm;
    }

    html,
    body,
    .th-shell,
    .th-main,
    .th-content {
        display: block;
        min-height: 0;
        padding: 0;
        background: #fff !important;
    }

    .th-sidebar,
    .th-topbar,
    .tt-doc-bar,
    .rz-notification,
    #blazor-error-ui {
        display: none !important;
    }

    .tt-sheet {
        width: auto;
        min-height: 0;
        padding: 0;
        border: 0;
    }

    .tt-sheet-lines tr,
    .tt-sheet-signature {
        break-inside: avoid;
    }

    .tt-sheet-lines th,
    .tt-sheet-head {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}
