/* ============================================================================
   Text2Motion v2 — MTM-UAS Table Editor + Datacard (Add-on CSS)  ·  v11
   ----------------------------------------------------------------------------
   NACH text2motion_v2.css einbinden.

   FIXES in v11
   ─────────────────────────────────────────────────────────────────────────
   · max-height statt height  → Container wächst mit dem Inhalt,
     keine große weiße Fläche mehr bei wenigen Zeilen
   · Ecken sauber gerundet    → äußerer Rahmen kappt die Zellen korrekt
   · Fokus-Ring für Tastatur-Navigation (Pfeiltasten)
   · Status-Anzeige in der Toolbar
   ============================================================================ */

:root {
    --tm-h-header: 52px;
    --tm-h-toolbar: 52px;
    --tm-uas-fs: 13.5px;
    --tm-dc-fs: 11.5px;
    --tm-uas-gap: 30px;
    --tm-uas-max: calc(100dvh - var(--tm-h-header) - var(--tm-h-toolbar) - var(--tm-uas-gap));
    --tm-uas-radius: 12px;
}

/* ============================================================================
   TOOLBAR
   ============================================================================ */
.tm-uas-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    min-width: 0;
}

.tm-uas-grp {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    background: var(--tm-surface-2);
    border: 1px solid var(--tm-border);
    border-radius: 9px;
}

.tm-uas-grp-end {
    margin-left: auto;
    background: transparent;
    border-color: transparent;
    padding: 0;
    gap: 6px;
}

.tm-uas-tbtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 9px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--tm-text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .14s var(--tm-ease), color .14s var(--tm-ease), border-color .14s var(--tm-ease);
}

.tm-uas-tbtn:hover:not(:disabled) {
    background: var(--tm-surface);
    border-color: var(--tm-border);
}

.tm-uas-tbtn:disabled {
    opacity: .35;
    cursor: default;
}

.tm-uas-tbtn i {
    font-size: 11.5px;
    color: var(--tm-text-muted);
}

.tm-uas-tbtn:hover:not(:disabled) i {
    color: var(--tm-text);
}

.tm-uas-tbtn-sq {
    padding: 0;
    width: 28px;
    justify-content: center;
}

.tm-uas-tbtn-accent {
    color: var(--tm-primary);
    background: var(--tm-primary-tint);
}

.tm-uas-tbtn-accent i {
    color: var(--tm-primary);
}

.tm-uas-tbtn-accent:hover:not(:disabled) {
    background: color-mix(in oklab, var(--tm-primary-tint) 70%, var(--tm-primary) 14%);
    border-color: color-mix(in oklab, var(--tm-primary) 30%, transparent);
}

.tm-uas-tbtn-toggle {
    border-color: var(--tm-border);
    background: var(--tm-surface);
}

.tm-uas-tbtn-toggle.is-on {
    background: var(--tm-primary-tint);
    border-color: color-mix(in oklab, var(--tm-primary) 34%, transparent);
    color: var(--tm-primary);
}

.tm-uas-tbtn-toggle.is-on i {
    color: var(--tm-primary);
}

/* Auswahl-/Status-Anzeige */
.tm-uas-hint {
    font-size: 12px;
    color: var(--tm-text-soft);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding: 0 4px;
    min-width: 62px;
    transition: color .14s var(--tm-ease);
}

.tm-uas-hint.is-active {
    color: var(--tm-primary);
    font-weight: 600;
}

.tm-uas-hint.is-status {
    color: var(--tm-accent, #16a34a);
    font-weight: 600;
    animation: tm-hint-in .18s var(--tm-ease);
}

@keyframes tm-hint-in {
    from {
        opacity: 0;
        transform: translateY(-2px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.tm-uas-unit {
    display: inline-flex;
    padding: 2px;
    background: var(--tm-surface-2);
    border: 1px solid var(--tm-border);
    border-radius: 8px;
}

.tm-uas-unit-btn {
    border: 0;
    background: transparent;
    color: var(--tm-text-muted);
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
    transition: all .14s var(--tm-ease);
}

.tm-uas-unit-btn.is-on {
    background: var(--tm-surface);
    color: var(--tm-text);
    box-shadow: var(--tm-shadow-sm);
}

.tm-uas-zoom {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    background: var(--tm-surface-2);
    border: 1px solid var(--tm-border);
    border-radius: 8px;
}

.tm-uas-menu-wrap {
    position: relative;
    display: inline-flex;
}

.tm-uas-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 190px;
    padding: 6px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: 10px;
    box-shadow: var(--tm-shadow-lg);
    z-index: 40;
    animation: tm-fade-in .14s var(--tm-ease);
}

.tm-uas-menu-h {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--tm-text-soft);
    padding: 5px 8px 7px;
}

.tm-uas-menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border-radius: 7px;
    font-size: 13px;
    color: var(--tm-text);
    cursor: pointer;
}

.tm-uas-menu-item:hover {
    background: var(--tm-surface-2);
}

.tm-uas-menu-item input {
    accent-color: var(--tm-primary);
    cursor: pointer;
}

@media (max-width: 1240px) {
    .tm-uas-tbtn span {
        display: none;
    }

    .tm-uas-hint {
        display: none;
    }
}

/* ============================================================================
   SPLIT  ·  Tabelle | Datenkarte
   ============================================================================ */
.tm-uas-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    /* wichtig: beide Boxen wachsen nach Inhalt */
}

.tm-uas-split.has-card {
    grid-template-columns: minmax(0, 1fr) 420px;
}

@media (max-width: 1280px) {
    .tm-uas-split.has-card {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ============================================================================
   TABELLEN-CONTAINER
   ✅ max-height statt height → keine weiße Fläche bei wenigen Zeilen
   ✅ overflow: hidden am Rahmen → Ecken werden sauber gekappt
   ============================================================================ */
.tm-uas-wrap {
    max-height: var(--tm-uas-max);
    overflow: auto;
    overscroll-behavior: contain;
    font-size: var(--tm-uas-fs);
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-uas-radius);
    box-shadow: var(--tm-shadow-sm);
}

/* ============================================================================
   TABELLE
   ============================================================================ */
.tm-uas-editable-table {
    width: 100%;
    font-size: var(--tm-uas-fs);
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

/* — Kopfzeile klebt oben im Container — */
.tm-uas-editable-table thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    background: var(--tm-surface-2);
    box-shadow: inset 0 -1px 0 var(--tm-border);
    padding: 8px 10px;
    font-size: .8em;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--tm-text);
    white-space: nowrap;
    text-align: left;
}

.tm-uas-editable-table thead th.is-num {
    text-align: right;
}

.tm-uas-editable-table thead th.is-ah {
    text-align: center;
}

/* ✅ Ecken oben sauber runden */
.tm-uas-editable-table thead tr th:first-child {
    border-top-left-radius: calc(var(--tm-uas-radius) - 1px);
}

.tm-uas-editable-table thead tr th:last-child {
    border-top-right-radius: calc(var(--tm-uas-radius) - 1px);
}

/* tg / tg ges. */
.tm-th-t {
    text-transform: none;
    font-weight: 600;
    letter-spacing: 0;
    font-size: 1.08em;
}

.tm-th-t sub {
    font-size: .68em;
    bottom: -.22em;
    position: relative;
    line-height: 0;
}

.tm-th-t em {
    font-style: normal;
    font-size: .62em;
    font-weight: 500;
    margin-left: 2px;
    opacity: .7;
    text-transform: none;
}

/* A × H Kopf */
.tm-th-ah {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    text-transform: none;
    letter-spacing: 0;
}

.tm-th-ah i {
    font-style: normal;
    font-weight: 700;
    width: 42px;
    text-align: center;
}

.tm-th-ah b {
    font-weight: 400;
    opacity: .45;
    width: 12px;
    text-align: center;
    font-size: .9em;
}

.tm-uas-th-unit {
    display: inline-block;
    margin-left: 4px;
    padding: 0 4px;
    border-radius: 3px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    font-size: .72em;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--tm-text-muted);
}

/* — Zellen — */
.tm-uas-editable-table td {
    padding: 2px 10px;
    border-bottom: 1px solid var(--tm-border-soft);
    vertical-align: middle;
    background: var(--tm-surface);
    overflow: hidden;
    text-overflow: ellipsis;
}

.tm-uas-editable-table td.tm-uas-editable {
    position: relative;
    padding: 2px 6px;
}

.tm-uas-editable-table td.tm-uas-mono {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* — Spaltenbreiten — */
.tm-uas-editable-table th[data-key="no"],
.tm-uas-editable-table td[data-key="no"] {
    width: 44px;
    text-align: center;
    color: var(--tm-text-soft);
    font-size: .88em;
}

.tm-uas-editable-table th[data-key="code"],
.tm-uas-editable-table td[data-key="code"] {
    width: 74px;
}

.tm-uas-editable-table th[data-key="basicTime"],
.tm-uas-editable-table td[data-key="basicTime"],
.tm-uas-editable-table th[data-key="basicTimeTotal"],
.tm-uas-editable-table td[data-key="basicTimeTotal"] {
    width: 92px;
}

.tm-uas-editable-table th[data-key="ah"],
.tm-uas-editable-table td[data-key="ah"] {
    width: 112px;
}

.tm-uas-editable-table th[data-key="comment"],
.tm-uas-editable-table td[data-key="comment"] {
    width: 190px;
}

/* — Summenzeile klebt unten — */
.tm-uas-editable-table tr.tm-uas-sum td {
    position: sticky;
    bottom: 0;
    z-index: 3;
    font-weight: 700;
    background: var(--tm-surface-2);
    box-shadow: inset 0 1px 0 var(--tm-border);
    border-bottom: 0;
    padding: 8px 10px;
}

/* ✅ Ecken unten sauber runden (Summenzeile bzw. letzte Zeile) */
.tm-uas-editable-table tr.tm-uas-sum td:first-child {
    border-bottom-left-radius: calc(var(--tm-uas-radius) - 1px);
}

.tm-uas-editable-table tr.tm-uas-sum td:last-child {
    border-bottom-right-radius: calc(var(--tm-uas-radius) - 1px);
}

.tm-uas-editable-table tbody tr:last-child td {
    border-bottom: 0;
}

/* ============================================================================
   EINGABEFELDER
   ============================================================================ */
.tm-uas-input {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 1em;
    padding: 4px 7px;
    border-radius: 5px;
    outline: none;
    transition: background .12s var(--tm-ease), border-color .12s var(--tm-ease), box-shadow .12s var(--tm-ease);
}

.tm-uas-input:hover {
    background: var(--tm-surface-2);
    border-color: var(--tm-border-soft);
}

/* ✅ Deutlicher Fokus für Tastatur-Navigation */
.tm-uas-input:focus {
    background: var(--tm-surface);
    border-color: var(--tm-primary);
    box-shadow: 0 0 0 3px var(--tm-primary-tint), 0 1px 3px rgba(37, 99, 235, .18);
    position: relative;
    z-index: 2;
}

.tm-uas-input::selection {
    background: color-mix(in oklab, var(--tm-primary) 26%, transparent);
}

/* Zeile mit Fokus dezent hervorheben */
.tm-uas-editable-table tbody tr:focus-within td {
    background: color-mix(in oklab, var(--tm-primary-tint) 45%, transparent);
}

.tm-uas-editable-table tbody tr:focus-within td[data-key="no"] {
    box-shadow: inset 3px 0 0 var(--tm-primary);
    color: var(--tm-primary);
    font-weight: 600;
}

.tm-uas-input-desc {
    text-align: left;
}

.tm-uas-input-comment {
    text-align: left;
}

.tm-uas-input-comment::placeholder {
    color: transparent;
}

.tm-uas-input-comment:hover::placeholder,
.tm-uas-input-comment:focus::placeholder {
    color: var(--tm-text-soft);
}

.tm-uas-input-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
    color: var(--tm-primary);
    text-align: center;
    padding: 4px 2px;
}

.tm-uas-ah {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.tm-uas-ah-x {
    font-size: 11px;
    color: var(--tm-text-soft);
    line-height: 1;
    flex: 0 0 12px;
    text-align: center;
}

.tm-uas-input-num {
    width: 42px;
    flex: 0 0 42px;
    text-align: center;
    padding: 4px 2px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
}

/* ============================================================================
   ZUSTÄNDE
   ============================================================================ */
.tm-uas-editable-table td.tm-uas-edited {
    background: rgba(217, 119, 6, .10);
    box-shadow: inset 3px 0 0 var(--tm-warn);
}

.tm-uas-editable-table td.tm-uas-edited .tm-uas-input {
    color: var(--tm-warn);
    font-weight: 600;
}

[data-bs-theme="dark"] .tm-uas-editable-table td.tm-uas-edited {
    background: rgba(217, 119, 6, .18);
}

.tm-uas-reset {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 15px;
    height: 15px;
    border: 0;
    border-radius: 50%;
    background: var(--tm-warn);
    color: #fff;
    font-size: 7.5px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity .12s var(--tm-ease), transform .12s var(--tm-ease);
}

.tm-uas-editable-table td.tm-uas-edited:hover .tm-uas-reset {
    opacity: 1;
}

.tm-uas-reset:hover {
    transform: scale(1.15);
}

.tm-uas-editable-table td.tm-uas-kept::after {
    content: "";
    position: absolute;
    top: 4px;
    right: 4px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--tm-text-soft);
    opacity: .5;
}

.tm-uas-editable-table td.tm-uas-invalid {
    background: rgba(220, 38, 38, .07);
    box-shadow: inset 3px 0 0 var(--tm-danger);
}

.tm-uas-editable-table td.tm-uas-invalid .tm-uas-input-code {
    color: var(--tm-danger);
}

[data-bs-theme="dark"] .tm-uas-editable-table td.tm-uas-invalid {
    background: rgba(220, 38, 38, .16);
}

.tm-uas-editable-table tbody tr.tm-uas-selected td {
    background: var(--tm-primary-tint);
}

.tm-uas-editable-table tbody tr.tm-uas-selected td[data-key="no"] {
    box-shadow: inset 3px 0 0 var(--tm-primary);
}

.tm-uas-editable-table tbody tr:not(.tm-uas-selected):not(.tm-uas-sum):hover td {
    background: var(--tm-surface-2);
}

.tm-uas-editable-table td.tm-uas-handle {
    cursor: grab;
    user-select: none;
}

.tm-uas-editable-table td.tm-uas-handle:active {
    cursor: grabbing;
}

.tm-uas-editable-table tbody tr.tm-uas-dragging {
    opacity: .45;
}

.tm-uas-editable-table tbody tr.tm-uas-drop td {
    box-shadow: inset 0 2px 0 var(--tm-primary);
}

/* ============================================================================
   DATENKARTE
   ============================================================================ */
.tm-dc {
    display: flex;
    flex-direction: column;
    background: #fff;
    color: #12263f;
    border: 1px solid #b9c6d4;
    border-radius: 9px;
    overflow: hidden;
    font-size: var(--tm-dc-fs);
    animation: tm-fade-in .18s var(--tm-ease);
}

/* Angedockt: wächst mit dem Inhalt, aber nie höher als die Tabelle */
.tm-dc.is-docked {
    max-height: var(--tm-uas-max);
    box-shadow: var(--tm-shadow-sm);
}

.tm-dc:not(.is-docked) {
    position: fixed;
    top: 92px;
    right: 20px;
    width: 460px;
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 120px);
    z-index: 46;
    box-shadow: var(--tm-shadow-lg);
    resize: both;
}

.tm-dc-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 7px 6px 10px;
    background: #123a5e;
    color: #fff;
    user-select: none;
    flex: 0 0 auto;
}

.tm-dc:not(.is-docked) .tm-dc-bar {
    cursor: move;
}

.tm-dc.is-docked .tm-dc-grip {
    display: none;
}

.tm-dc-grip {
    opacity: .6;
    font-size: 11px;
}

.tm-dc-bar h3 {
    margin: 0;
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
}

.tm-dc-tools {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 2px;
}

.tm-dc-search {
    width: 100px;
    padding: 4px 9px;
    margin-right: 4px;
    border: 1px solid #33597c;
    border-radius: 5px;
    background: #0f314f;
    color: #fff;
    font-size: 11.5px;
    outline: none;
    transition: width .18s var(--tm-ease), background .18s var(--tm-ease);
}

.tm-dc-search::placeholder {
    color: #9fb4c8;
}

.tm-dc-search:focus {
    width: 140px;
    border-color: #7fb0da;
    background: #16436b;
}

.tm-dc-ibtn {
    border: 0;
    background: transparent;
    color: #cdd9e6;
    cursor: pointer;
    font-size: 11px;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
}

.tm-dc-ibtn:hover {
    background: rgba(255, 255, 255, .15);
    color: #fff;
}

.tm-dc-body {
    flex: 1 1 auto;
    overflow: auto;
    overscroll-behavior: contain;
}

.tm-dc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1em;
    line-height: 1.25;
}

.tm-dc-table col.c1 {
    width: 68px;
}

.tm-dc-table col.c2 {
    width: 54px;
}

.tm-dc-table col.c3 {
    width: 66px;
}

.tm-dc-table col.cK {
    width: 40px;
}

.tm-dc-table col.cT {
    width: 40px;
}

.tm-dc-table td {
    border: 1px solid #b9c6d4;
    padding: 2px 6px;
    text-align: center;
}

.tm-dc-sec td {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #123a5e;
    color: #fff;
    font-weight: 700;
    padding: 3px 6px;
}

.tm-dc-sec td:first-child {
    text-align: left;
}

.tm-dc-sec .tm-dc-sec-k {
    color: #ff9d9d;
}

.tm-dc-sub td {
    background: #eef3f8;
    color: #5b6b7d;
    font-size: .88em;
    font-weight: 600;
    padding: 2px 4px;
}

.tm-dc-lbl {
    text-align: left !important;
    color: #1e3247;
    white-space: nowrap;
    background: #fff;
}

.tm-dc-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 700;
    color: #c0121f;
}

.tm-dc-cell {
    cursor: pointer;
    font-variant-numeric: tabular-nums;
    color: #12263f;
    transition: background .1s ease;
}

.tm-dc-cell:hover {
    background: #cfe3fa;
    box-shadow: inset 0 0 0 2px #2563eb;
}

.tm-dc-cell:active {
    background: #a9cdf5;
}

.tm-dc-empty {
    text-align: center;
    color: #5b6b7d;
    padding: 26px;
    font-size: 12.5px;
}

/* ── Datenkarten-Footer: Logo + Hinweis + Link ────────────────────── */
.tm-dc-foot {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #dbe3ec;
    font-size: 10px;
    color: #12263f;
    line-height: 1.5;
}

.tm-dc-logo {
    width: 46px;
    height: auto;
    flex: 0 0 auto;
    margin-top: 1px;
}

.tm-dc-foot-txt {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.tm-dc-foot-txt b {
    font-size: 11px;
    font-weight: 700;
    color: #12263f;
}

.tm-dc-foot-txt span {
    color: #3a4b5e;
}

.tm-dc-foot-txt a {
    color: #1f5fa9;
    text-decoration: underline;
    width: fit-content;
}

.tm-dc-foot-txt a:hover {
    color: #c0121f;
}

.tm-dc-copy {
    color: #5b6b7d;
}

/* Shortcut-Hinweis */
.tm-dc-mode {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px dashed #dbe3ec;
    font-weight: 600;
    color: #123a5e;
    letter-spacing: -.01em;
}

.tm-dc-mode.is-append {
    color: #16a34a;
}


[data-bs-theme="dark"] .tm-dc-logo {
    filter: none;
}


[data-bs-theme="dark"] .tm-dc {
    border-color: #3a4657;
}

@media (max-width: 900px) {
    .tm-dc:not(.is-docked) {
        right: 10px;
        left: 10px;
        width: auto;
    }
}

/* ============================================================================
   VOLLBILD
   ============================================================================ */
#stageResult:fullscreen {
    background: var(--tm-bg);
    color: var(--tm-text);
    padding: 14px 18px 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#stageResult:fullscreen::backdrop {
    background: var(--tm-bg);
}

#stageResult:fullscreen .tm-result-bar {
    position: static;
    margin-bottom: 12px;
    flex: 0 0 auto;
    background: transparent;
    backdrop-filter: none;
    border-bottom: 1px solid var(--tm-border-soft);
}

#stageResult:fullscreen .tm-segmented {
    display: none;
}

#stageResult:fullscreen .tm-view {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
}

#stageResult:fullscreen .tm-uas-split {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
}

/* Im Vollbild volle Höhe nutzen */
#stageResult:fullscreen .tm-uas-wrap,
#stageResult:fullscreen .tm-dc.is-docked {
    max-height: 100%;
    height: 100%;
}

#stageResult:fullscreen .tm-report-frame {
    height: 100%;
    min-height: 0;
}

/* ============================================================================
   RESPONSIVE — Tabelle scrollt horizontal statt zu kollabieren
   ============================================================================ */
.tm-uas-editable-table {
    min-width: 720px;
    /* darunter wird horizontal gescrollt */
}

@media (max-width: 900px) {
    :root {
        --tm-uas-gap: 18px;
    }

    .tm-uas-wrap {
        border-radius: 10px;
        -webkit-overflow-scrolling: touch;
    }

    /* Nr.-Spalte klebt beim horizontalen Scrollen links */
    .tm-uas-editable-table th[data-key="no"],
    .tm-uas-editable-table td[data-key="no"] {
        position: sticky;
        left: 0;
        z-index: 3;
        background: var(--tm-surface-2);
    }

    .tm-uas-editable-table thead th[data-key="no"] {
        z-index: 5;
    }

    /* Kompaktere Maße */
    .tm-uas-editable-table td {
        padding: 3px 8px;
    }

    .tm-uas-editable-table thead th {
        padding: 7px 8px;
        font-size: .74em;
    }

    .tm-uas-input {
        padding: 4px 6px;
    }

    .tm-uas-input-num {
        width: 36px;
        flex-basis: 36px;
    }

    .tm-th-ah i {
        width: 36px;
    }

    .tm-uas-editable-table th[data-key="comment"],
    .tm-uas-editable-table td[data-key="comment"] {
        width: 150px;
    }

    .tm-uas-editable-table th[data-key="ah"],
    .tm-uas-editable-table td[data-key="ah"] {
        width: 96px;
    }

    /* Toolbar darf umbrechen statt zu überlaufen */
    .tm-uas-toolbar {
        flex-wrap: wrap;
        gap: 6px;
        row-gap: 8px;
    }

    .tm-uas-grp-end {
        margin-left: 0;
    }
}

@media (max-width: 560px) {
    .tm-uas-editable-table {
        min-width: 620px;
    }

    /* Kommentar ausblenden — auf dem Handy selten gebraucht */
    .tm-uas-editable-table th[data-key="comment"],
    .tm-uas-editable-table td[data-key="comment"] {
        display: none;
    }
}


/* ── A × H mit Rechenausdrücken ─────────────────────────────────────── */
.tm-uas-editable-table td[data-key="ah"] {
    width: 132px;
}

.tm-uas-input-num {
    width: 52px;
    flex: 1 1 52px;
    min-width: 0;
    font-size: .94em;
}

/* Feld enthält eine Formel → dezent blau hervorheben */
.tm-uas-input-num.is-expr {
    color: var(--tm-primary);
    font-weight: 600;
    letter-spacing: -.02em;
}

/* Ungültige Formel → rot */
.tm-uas-input-num.is-bad {
    color: var(--tm-danger);
    background: rgba(220, 38, 38, .07);
}

/* Ergebnis unter den Feldern */
.tm-uas-ah-res {
    display: block;
    text-align: center;
    font-size: 9.5px;
    font-weight: 600;
    color: var(--tm-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin-top: 1px;
    opacity: .85;
}

@media (max-width: 900px) {
    .tm-uas-editable-table td[data-key="ah"] {
        width: 118px;
    }
}

/* Modus-Hinweis in der Datenkarten-Fußzeile */
.tm-dc-mode {
    display: block;
    font-weight: 600;
    font-size: 10px;
    color: #123a5e;
    margin-bottom: 3px;
    letter-spacing: -.01em;
}

.tm-dc-mode.is-append {
    color: #16a34a;
}