/* TERP - application stylesheet, on top of Bootstrap 5.
 *
 * Two modules, and the user must always know which one he is in (mock-up design, section 3):
 * the module class on <body> (tp-mod-flows / tp-mod-masterdata) swaps header colour and accent,
 * and every component below refers only to --tp-accent*. Flussi di magazzino is navy and blue,
 * Anagrafica e distinte is plum and violet: the difference is visible before anything is read.
 *
 * Numbers are what people come here to read: every figure is tabular and right-aligned.
 * Rules for every page: no FORM element, no placeholder next to a label, no long dash, no emoji,
 * cursor:pointer on what can be clicked, cursor:not-allowed on what cannot, 44 px touch targets,
 * nothing that needs a mouse hover, phone and tablet first-class (C12).
 */

:root
{
    --tp-ink:        #0e1a26;
    --tp-ink-2:      #31465a;
    --tp-ink-3:      #6a8199;
    --tp-ink-4:      #93a8bb;
    --tp-line:       #dde4ec;
    --tp-line-2:     #eef2f7;
    --tp-canvas:     #f4f7fa;
    --tp-card:       #ffffff;

    --tp-blue:       #1d6fb8;  --tp-blue-d:   #12507f;  --tp-blue-l:   #e7f1fa;  --tp-blue-line:   #c9e0f3;
    --tp-violet:     #6b3fa0;  --tp-violet-d: #4e2c78;  --tp-violet-l: #f2ecf9;  --tp-violet-line: #ddd0ee;
    --tp-teal:       #0e7c66;  --tp-teal-l:   #e3f4f0;  --tp-teal-line: #c5e5dd;
    --tp-amber:      #a86a08;  --tp-amber-l:  #fcf2e2;  --tp-amber-line: #f0dcbb;
    --tp-red:        #a32424;  --tp-red-l:    #fbeceb;  --tp-red-line:   #f2d3d1;
    --tp-slate:      #4b5d70;  --tp-slate-l:  #eef1f5;  --tp-slate-line: #d9e0e8;

    --tp-shadow:     0 1px 2px rgba(16, 32, 48, .06), 0 3px 10px rgba(16, 32, 48, .05);
    --tp-radius:     10px;
    --tp-radius-sm:  7px;
    --tp-header-h:   56px;
    --tp-side-w:     240px;
}

/* Flussi di magazzino */
body.tp-mod-flows
{
    --tp-header-bg:   #0d1f30;
    --tp-header-soft: #a9c2d8;
    --tp-header-mark: #5aa3dd;
    --tp-accent:      var(--tp-blue);
    --tp-accent-d:    var(--tp-blue-d);
    --tp-accent-l:    var(--tp-blue-l);
    --tp-accent-line: var(--tp-blue-line);
    --tp-accent-rgb:  29, 111, 184;
}

/* Anagrafica e distinte */
body.tp-mod-masterdata
{
    --tp-header-bg:   #26142f;
    --tp-header-soft: #cdb8e0;
    --tp-header-mark: #b98ce6;
    --tp-accent:      var(--tp-violet);
    --tp-accent-d:    var(--tp-violet-d);
    --tp-accent-l:    var(--tp-violet-l);
    --tp-accent-line: var(--tp-violet-line);
    --tp-accent-rgb:  107, 63, 160;
}

/* --- Bootstrap, retuned ---------------------------------------------------- */

body
{
    --bs-body-color:        var(--tp-ink);
    --bs-body-bg:           var(--tp-canvas);
    --bs-body-font-family:  "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    --bs-body-font-size:    .875rem;
    --bs-body-line-height:  1.45;
    --bs-border-color:      var(--tp-line);
    --bs-link-color:        var(--tp-accent);
    --bs-link-color-rgb:    var(--tp-accent-rgb);
    --bs-link-hover-color:  var(--tp-accent-d);
    --bs-primary:           var(--tp-accent);
    --bs-primary-rgb:       var(--tp-accent-rgb);
    --bs-border-radius:     var(--tp-radius-sm);
    --bs-secondary-color:   var(--tp-ink-3);
    background: var(--tp-canvas);
    min-height: 100vh;
}

a, button, summary, label[for], select, .tp-click,
input[type=checkbox], input[type=radio], input[type=file]
{
    cursor: pointer;
}

:disabled, .disabled, [aria-disabled=true]
{
    cursor: not-allowed !important;
}

h1, h2, h3, h4 { letter-spacing: -.01em; }

.btn
{
    --bs-btn-font-size: .84375rem;
    --bs-btn-padding-x: .875rem;
    --bs-btn-padding-y: .45rem;
    --bs-btn-border-radius: var(--tp-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 38px;
}

.btn-sm { --bs-btn-font-size: .78rem; --bs-btn-padding-x: .625rem; --bs-btn-padding-y: .28rem; min-height: 30px; }

.btn-primary
{
    --bs-btn-bg: var(--tp-accent);
    --bs-btn-border-color: var(--tp-accent);
    --bs-btn-hover-bg: var(--tp-accent-d);
    --bs-btn-hover-border-color: var(--tp-accent-d);
    --bs-btn-active-bg: var(--tp-accent-d);
    --bs-btn-active-border-color: var(--tp-accent-d);
    --bs-btn-disabled-bg: var(--tp-accent);
    --bs-btn-disabled-border-color: var(--tp-accent);
}

.btn-light
{
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--tp-line);
    --bs-btn-color: var(--tp-ink-2);
    --bs-btn-hover-bg: var(--tp-line-2);
    --bs-btn-hover-border-color: var(--tp-ink-4);
}

.form-control, .form-select
{
    border-color: var(--tp-line);
    min-height: 38px;
}

.form-control:focus, .form-select:focus
{
    border-color: var(--tp-accent);
    box-shadow: 0 0 0 .2rem rgba(var(--tp-accent-rgb), .15);
}

.form-label { font-weight: 600; color: var(--tp-ink-2); margin-bottom: .3rem; }
.form-text { color: var(--tp-ink-3); }

.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.code { font-family: "Cascadia Mono", Consolas, monospace; font-size: .8125rem; }

/* --- Demo strip -------------------------------------------------------------- */

.tp-demo-strip
{
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .35rem 1rem;
    background: repeating-linear-gradient(-45deg, #fff6e0, #fff6e0 12px, #fdeec9 12px, #fdeec9 24px);
    border-bottom: 1px solid var(--tp-amber-line);
    color: #6d4605;
    font-size: .78rem;
}

.tp-demo-strip[hidden] { display: none; }

/* --- Office header and module switcher -------------------------------------- */

.tp-header
{
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: .75rem;
    height: var(--tp-header-h);
    padding: 0 1rem;
    background: var(--tp-header-bg);
    color: #fff;
    box-shadow: inset 0 -3px 0 var(--tp-accent);
}

.tp-brand
{
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: .04em;
}

.tp-brand svg { height: 14px; width: auto; opacity: .9; }
.tp-brand:hover { color: #fff; }

.tp-icon-btn
{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: var(--tp-radius-sm);
    background: transparent;
    color: var(--tp-header-soft);
    font-size: 1.1rem;
    text-decoration: none;
}

.tp-icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.tp-burger { display: none; }

.tp-switch-btn
{
    display: flex;
    align-items: center;
    gap: .55rem;
    min-height: 40px;
    padding: .35rem .8rem;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 999px;
    background: rgba(var(--tp-accent-rgb), .45);
    color: #fff;
    font-weight: 600;
}

.tp-switch-btn > .fa-duotone:first-child { color: var(--tp-header-mark); font-size: 1.05rem; }
.tp-switch-btn:hover { background: rgba(var(--tp-accent-rgb), .65); }
.tp-switch-caret { font-size: .7rem; opacity: .8; }

.tp-switch-menu { min-width: 320px; padding: .4rem; }
.tp-switch-head { padding: .35rem .6rem .45rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--tp-ink-3); }

.tp-switch-item
{
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem;
    border-radius: var(--tp-radius-sm);
    white-space: normal;
}

.tp-switch-item b { display: block; color: var(--tp-ink); }
.tp-switch-item small { display: block; color: var(--tp-ink-3); }
.tp-switch-item.active, .tp-switch-item:active { background: var(--tp-line-2); color: var(--tp-ink); }

.tp-switch-ico
{
    display: inline-flex;
    flex: 0 0 38px;
    align-items: center;
    justify-content: center;
    height: 38px;
    border-radius: 9px;
    font-size: 1.05rem;
}

.tp-swatch-flows .tp-switch-ico      { background: var(--tp-blue-l);   color: var(--tp-blue); }
.tp-swatch-masterdata .tp-switch-ico { background: var(--tp-violet-l); color: var(--tp-violet); }

.tp-who
{
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 44px;
    padding: 0 .4rem;
    border: 0;
    background: transparent;
    color: var(--tp-header-soft);
}

.tp-avatar
{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
}

/* --- Office body: side menu and main ----------------------------------------- */

.tp-body { display: flex; min-height: calc(100vh - var(--tp-header-h)); }

.tp-side
{
    flex: 0 0 var(--tp-side-w);
    padding: .9rem .7rem;
    background: var(--tp-card);
    border-right: 1px solid var(--tp-line);
}

.tp-side-module
{
    display: flex;
    align-items: center;
    gap: .7rem;
    margin-bottom: .8rem;
    padding: .7rem .75rem;
    border: 1px solid var(--tp-accent-line);
    border-radius: var(--tp-radius);
    background: var(--tp-accent-l);
    color: var(--tp-accent-d);
}

.tp-side-module > i { font-size: 1.35rem; color: var(--tp-accent); }
.tp-side-module small { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--tp-ink-3); }
.tp-side-module b { display: block; line-height: 1.2; }

.tp-nav
{
    display: flex;
    align-items: center;
    gap: .65rem;
    min-height: 44px;
    padding: .45rem .7rem;
    border-radius: var(--tp-radius-sm);
    color: var(--tp-ink-2);
    text-decoration: none;
}

.tp-nav i { color: var(--tp-ink-3); }
.tp-nav:hover { background: var(--tp-line-2); color: var(--tp-ink); }
.tp-nav.active { background: var(--tp-accent-l); color: var(--tp-accent-d); font-weight: 600; }
.tp-nav.active i { color: var(--tp-accent); }

.tp-nav-group { display: block; margin: 14px 0 2px; padding: 0 12px; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--tp-ink-4); }
.tp-nav-group[hidden] { display: none; }
.tp-nav[hidden] { display: none; }
.tp-nav-off { color: var(--tp-ink-4); }
.tp-nav-off i { color: var(--tp-ink-4); }
.tp-nav-off:hover { background: transparent; color: var(--tp-ink-4); }
.tp-nav-off em
{
    margin-left: auto;
    padding: .05rem .4rem;
    border: 1px solid var(--tp-line);
    border-radius: 999px;
    font-size: .68rem;
    font-style: normal;
    color: var(--tp-ink-3);
}

.tp-main
{
    flex: 1 1 auto;
    min-width: 0;
    padding: 1rem 1.5rem 3rem;
}

.tp-crumbs
{
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem;
    margin-bottom: .9rem;
    font-size: .8rem;
    color: var(--tp-ink-3);
}

.tp-crumbs a { color: var(--tp-ink-2); text-decoration: none; }
.tp-crumbs a:hover { text-decoration: underline; }
.tp-crumb-module
{
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .15rem .55rem;
    border-radius: 999px;
    background: var(--tp-accent-l);
    color: var(--tp-accent-d) !important;
    font-weight: 600;
}

.tp-crumb-sep { font-size: .6rem; color: var(--tp-ink-4); }

.tp-scrim { position: fixed; inset: 0; z-index: 1039; background: rgba(13, 31, 48, .45); }

@media (max-width: 991.98px)
{
    .tp-burger { display: inline-flex; }
    .tp-side
    {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1040;
        width: min(300px, 86vw);
        overflow-y: auto;
        transform: translateX(-105%);
        transition: transform .2s ease;
        box-shadow: var(--tp-shadow);
    }
    body.tp-side-open .tp-side { transform: none; }
    .tp-main { padding: .9rem 1rem 3rem; }
}

@media (max-width: 575.98px)
{
    .tp-brand svg, .tp-who-name, .tp-demo-more, .tp-header-hh { display: none; }
    .tp-switch { min-width: 0; flex: 0 1 auto; }
    .tp-switch-btn { padding: .35rem .65rem; }
    .tp-switch-name { max-width: 9.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .tp-header { gap: .4rem; padding: 0 .5rem; }
}

/* --- Page head, cards, panels ------------------------------------------------ */

.tp-page-head
{
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .75rem 1rem;
    margin-bottom: 1rem;
}

.tp-page-head h1 { margin: 0; font-size: 1.35rem; font-weight: 700; }
.tp-page-head p { margin: .2rem 0 0; color: var(--tp-ink-3); }
.tp-page-head .tp-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: .5rem; }

.tp-card
{
    background: var(--tp-card);
    border: 1px solid var(--tp-line);
    border-radius: var(--tp-radius);
    box-shadow: var(--tp-shadow);
}

.tp-card-head
{
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--tp-line-2);
    font-weight: 600;
}

.tp-card-head i { color: var(--tp-accent); }
.tp-card-body { padding: 1rem; }

.tp-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; }
.tp-kpi { padding: .8rem 1rem; }
.tp-kpi small { display: block; color: var(--tp-ink-3); }
.tp-kpi b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }

/* Cross-module link: says in words AND colour which module it leads to. */
.tp-xmod
{
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-height: 36px;
    padding: .3rem .75rem;
    border-radius: 999px;
    border: 1px solid;
    font-weight: 600;
    font-size: .8rem;
    text-decoration: none;
}

.tp-xmod-masterdata { border-color: var(--tp-violet-line); background: var(--tp-violet-l); color: var(--tp-violet-d); }
.tp-xmod-flows      { border-color: var(--tp-blue-line);   background: var(--tp-blue-l);   color: var(--tp-blue-d); }
.tp-xmod:hover { filter: brightness(.97); }

/* --- Status badges: material states (7.1), kit states (7.2) ---------------------- */

.tp-badge
{
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .12rem .55rem;
    border: 1px solid;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
    white-space: nowrap;
}

.tp-badge i { font-size: .7rem; }
.tp-tone-blue  { color: var(--tp-blue-d); background: var(--tp-blue-l);  border-color: var(--tp-blue-line); }
.tp-tone-teal  { color: var(--tp-teal);   background: var(--tp-teal-l);  border-color: var(--tp-teal-line); }
.tp-tone-amber { color: var(--tp-amber);  background: var(--tp-amber-l); border-color: var(--tp-amber-line); }
.tp-tone-red   { color: var(--tp-red);    background: var(--tp-red-l);   border-color: var(--tp-red-line); }
.tp-tone-slate { color: var(--tp-slate);  background: var(--tp-slate-l); border-color: var(--tp-slate-line); }
.tp-tone-violet{ color: var(--tp-violet-d); background: var(--tp-violet-l); border-color: var(--tp-violet-line); }

/* --- Lists: a table on wide screens, cards on the phone ------------------------- */

.tp-toolbar
{
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--tp-line-2);
}

.tp-toolbar .tp-search { flex: 1 1 220px; max-width: 360px; }
.tp-toolbar .tp-count { margin-left: auto; color: var(--tp-ink-3); font-size: .8rem; }

.tp-table { width: 100%; margin: 0; }
.tp-table th
{
    padding: .55rem .75rem;
    border-bottom: 1px solid var(--tp-line);
    background: #fafbfd;
    color: var(--tp-ink-3);
    font-size: .74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

.tp-table td { padding: .6rem .75rem; border-bottom: 1px solid var(--tp-line-2); vertical-align: middle; }
.tp-table tbody tr.tp-click:hover { background: var(--tp-accent-l); }
.tp-table .tp-cell-sub { display: block; color: var(--tp-ink-3); font-size: .78rem; }

@media (max-width: 767.98px)
{
    .tp-table thead { display: none; }
    .tp-table, .tp-table tbody, .tp-table tr, .tp-table td { display: block; width: 100%; }
    .tp-table tr
    {
        margin: .6rem .6rem 0;
        width: auto;
        padding: .55rem .75rem;
        border: 1px solid var(--tp-line);
        border-radius: var(--tp-radius);
        background: #fff;
    }
    .tp-table tr:last-child { margin-bottom: .6rem; }
    .tp-table td { display: flex; gap: .75rem; justify-content: space-between; padding: .3rem 0; border: 0; text-align: right; }
    .tp-table td::before { content: attr(data-label); color: var(--tp-ink-3); font-size: .78rem; text-align: left; }
    .tp-table td.tp-cell-main { display: block; text-align: left; font-weight: 600; padding-bottom: .4rem; border-bottom: 1px solid var(--tp-line-2); margin-bottom: .2rem; }
    .tp-table td.tp-cell-main::before { content: none; }
    .tp-toolbar .tp-search { max-width: none; }
}

/* --- Record (scheda): header and tabs ------------------------------------------ */

.tp-record-head { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-start; padding: 1rem; }
.tp-record-head h1 { font-size: 1.3rem; margin: 0; }
.tp-record-head .tp-meta { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; margin-top: .4rem; color: var(--tp-ink-3); font-size: .8rem; }
.tp-tabs { display: flex; gap: .25rem; padding: 0 1rem; border-bottom: 1px solid var(--tp-line); overflow-x: auto; }
.tp-tab
{
    min-height: 44px;
    padding: .55rem .8rem;
    border: 0;
    border-bottom: 3px solid transparent;
    background: none;
    color: var(--tp-ink-3);
    font-weight: 600;
    white-space: nowrap;
}

.tp-tab.active { color: var(--tp-accent-d); border-bottom-color: var(--tp-accent); }

/* --- Modals: full screen on the phone (C12), never closed by a click outside (C11) */

@media (max-width: 575.98px)
{
    .modal-dialog { margin: 0; max-width: none; height: 100%; }
    .modal-content { height: 100%; border: 0; border-radius: 0; }
}

.modal-header { border-bottom-color: var(--tp-line-2); }
.modal-footer { border-top-color: var(--tp-line-2); }
.tp-steps { display: flex; gap: .4rem; padding: .6rem 1rem; border-bottom: 1px solid var(--tp-line-2); overflow-x: auto; }
.tp-step { display: flex; align-items: center; gap: .4rem; color: var(--tp-ink-4); font-size: .8rem; white-space: nowrap; }
.tp-step b { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid currentColor; font-size: .72rem; }
.tp-step.done { color: var(--tp-teal); }
.tp-step.now { color: var(--tp-accent-d); font-weight: 600; }
.tp-step.now b { background: var(--tp-accent); border-color: var(--tp-accent); color: #fff; }

/* --- Toasts ---------------------------------------------------------------- */

.tp-toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; max-width: min(380px, calc(100vw - 2rem)); }
.tp-toast { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .9rem; border-radius: var(--tp-radius); border: 1px solid; background: #fff; box-shadow: var(--tp-shadow); }

/* --- Handheld ---------------------------------------------------------------- */

body.tp-handheld { font-size: 1rem; }
body.tp-handheld .btn { min-height: 52px; font-size: 1rem; }

.tp-hh-header
{
    position: sticky;
    top: 0;
    z-index: 1030;
    padding: .5rem .75rem .45rem;
    background: var(--tp-header-bg);
    color: #fff;
    box-shadow: inset 0 -3px 0 var(--tp-accent);
}

.tp-hh-row { display: flex; align-items: center; gap: .6rem; }
.tp-hh-back { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: var(--tp-radius-sm); color: #fff; font-size: 1.15rem; background: rgba(255, 255, 255, .08); }
.tp-hh-title { min-width: 0; flex: 1 1 auto; }
.tp-hh-title b { display: block; font-size: 1.1rem; line-height: 1.2; }
.tp-hh-module { display: inline-flex; align-items: center; gap: .35rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--tp-header-mark); font-weight: 600; }
.tp-hh-net { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .55rem; border-radius: 999px; background: rgba(14, 124, 102, .35); font-size: .75rem; white-space: nowrap; }
.tp-hh-net.offline { background: rgba(168, 106, 8, .55); }
.tp-hh-who { display: flex; align-items: center; gap: .45rem; margin-top: .3rem; color: var(--tp-header-soft); font-size: .78rem; }
.tp-hh-main { padding: .9rem .75rem 7rem; max-width: 640px; margin: 0 auto; }

.tp-task
{
    display: flex;
    align-items: center;
    gap: .8rem;
    min-height: 64px;
    margin-bottom: .6rem;
    padding: .7rem .85rem;
    border: 1px solid var(--tp-line);
    border-radius: var(--tp-radius);
    background: #fff;
    color: var(--tp-ink);
    text-decoration: none;
    box-shadow: var(--tp-shadow);
}

.tp-task > i { flex: 0 0 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--tp-accent-l); color: var(--tp-accent); font-size: 1.15rem; }
.tp-task b { display: block; }
.tp-task small { display: block; color: var(--tp-ink-3); }
.tp-task .tp-task-n { margin-left: auto; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--tp-accent-d); }
.tp-task.tp-task-off { opacity: .55; box-shadow: none; }

/* Scanner dock: the hardware scanner types into the field and ends with Enter. */
.tp-scan
{
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1020;
    padding: .65rem .75rem calc(.65rem + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--tp-line);
    box-shadow: 0 -4px 14px rgba(16, 32, 48, .08);
}

.tp-scan-inner { max-width: 640px; margin: 0 auto; }
.tp-scan-prompt { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; font-weight: 600; color: var(--tp-accent-d); }
.tp-scan-row { display: flex; gap: .5rem; }
.tp-scan-row input { flex: 1 1 auto; min-height: 52px; font-size: 1.05rem; font-family: "Cascadia Mono", Consolas, monospace; }
.tp-scan-row .btn { flex: 0 0 auto; }

.tp-step-card { padding: .85rem; margin-bottom: .6rem; border: 1px solid var(--tp-line); border-radius: var(--tp-radius); background: #fff; }
.tp-step-card.done { border-color: var(--tp-teal-line); background: var(--tp-teal-l); }
.tp-step-card.now { border-color: var(--tp-accent); box-shadow: 0 0 0 3px rgba(var(--tp-accent-rgb), .15); }
.tp-step-card small { display: block; color: var(--tp-ink-3); text-transform: uppercase; letter-spacing: .05em; font-size: .7rem; }
.tp-step-card b { font-size: 1.1rem; }

/* --- G1 additions ----------------------------------------------------------- */

.tp-row-link { color: inherit; text-decoration: none; display: block; }
.tp-row-link:hover { color: var(--tp-accent-d); }
.tp-row-link .code { color: var(--tp-accent-d); font-weight: 600; }
.tp-back { color: var(--tp-ink-3); text-decoration: none; min-height: 32px; }
.tp-back:hover { color: var(--tp-accent-d); }
.tp-tab-count { display: inline-block; min-width: 1.4rem; padding: 0 .35rem; margin-left: .25rem; border-radius: 999px; background: var(--tp-line-2); color: var(--tp-ink-3); font-size: .72rem; text-align: center; }
.tp-tab.active .tp-tab-count { background: var(--tp-accent-l); color: var(--tp-accent-d); }
a.tp-kpi:hover { border-color: var(--tp-accent-line); }
.tp-kpi .tp-badge { font-size: .72rem; }
.tp-task-n small { display: block; font-size: .7rem; font-weight: 400; color: var(--tp-ink-3); }
button.tp-task { border: 1px solid var(--tp-line); }
.tp-tone-red.tp-card { background: var(--tp-red-l); color: var(--tp-red); }

@media (max-width: 575.98px)
{
    .tp-tab > i { display: none; }
    .tp-tabs { padding: 0 .5rem; }
}

/* KPI tiles that are links: the whole tile is the link, no underline on its text. */
a.tp-kpi, a.tp-kpi * , .tp-kpis a, .tp-kpis a * { text-decoration: none; }
a.tp-kpi b, .tp-kpis a b { color: var(--tp-accent-d); }

/* --- G5+: richer dashboard, charts, floor map, feed, timeline, labels, avatars ------------- */

/* Record header icon tile (was a bare icon): a small coloured square, the closest a mock-up
 * gets to "an illustration of the item or the location" without drawing one per referenza. */
.tp-record-tile
{
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: var(--tp-radius);
    background: var(--tp-accent-l);
    color: var(--tp-accent);
    font-size: 1.5rem;
}

.tp-record-head { align-items: center; }
.tp-record-metric { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

/* Sparkline / ring charts ----------------------------------------------------------------- */

.tp-spark { display: block; overflow: visible; }
.tp-ring { display: block; }
.tp-ring-text { fill: var(--tp-ink); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Stacked bar (state mix of one referenza) and mini bar lists (zone fill, supplier on-time) -- */

.tp-stackbar { display: inline-flex; width: 100%; min-width: 60px; height: 8px; border-radius: 999px; overflow: hidden; background: var(--tp-line-2); vertical-align: middle; }
.tp-stackbar span { display: block; height: 100%; transform-origin: left center; }
.tp-stackbar-empty { width: 100%; }

.tp-bars { display: flex; flex-direction: column; gap: .45rem; }
.tp-bars-row { display: flex; align-items: center; gap: .6rem; }
.tp-bars-label { flex: 0 0 auto; min-width: 72px; font-size: .78rem; color: var(--tp-ink-2); }
.tp-bars-track { flex: 1 1 auto; height: 10px; border-radius: 999px; background: var(--tp-line-2); overflow: hidden; }
.tp-bars-fill { display: block; height: 100%; border-radius: 999px; transform-origin: left center; }
.tp-bars-value { flex: 0 0 auto; min-width: 54px; font-size: .78rem; color: var(--tp-ink-2); }

/* Avatars (operators, holders, people in a feed or a movements list) --------------------------- */

.tp-pavatar
{
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    color: #fff;
}

.tp-pavatar-sm { width: 24px; height: 24px; font-size: .62rem; }
.tp-pavatar-md { width: 34px; height: 34px; font-size: .78rem; }
.tp-pavatar-lg { width: 46px; height: 46px; font-size: .95rem; }
.tp-pavatar.tp-tone-blue   { background: var(--tp-blue); }
.tp-pavatar.tp-tone-teal   { background: var(--tp-teal); }
.tp-pavatar.tp-tone-violet { background: var(--tp-violet); }
.tp-pavatar.tp-tone-amber  { background: var(--tp-amber); }
.tp-pavatar.tp-tone-red    { background: var(--tp-red); }
.tp-pavatar.tp-tone-slate  { background: var(--tp-slate); }

/* Activity feed (Oggi) and the vertical timeline (a piece's life, revisions) ------------------- */

.tp-feed { display: flex; flex-direction: column; }
.tp-feed-empty { font-size: .85rem; }
.tp-feed-row
{
    display: flex;
    align-items: center;
    gap: .7rem;
    min-height: 52px;
    padding: .5rem .25rem;
    border-bottom: 1px solid var(--tp-line-2);
    color: inherit;
    text-decoration: none;
}

.tp-feed-row:last-child { border-bottom: 0; }
a.tp-feed-row:hover { background: var(--tp-accent-l); border-radius: var(--tp-radius-sm); }
.tp-feed-ico
{
    display: inline-flex;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    font-size: .95rem;
}

.tp-feed-body { flex: 1 1 auto; min-width: 0; }
.tp-feed-body b { display: block; font-weight: 600; font-size: .85rem; }
.tp-feed-body small { display: block; color: var(--tp-ink-3); }
.tp-feed-time { flex: 0 0 auto; color: var(--tp-ink-3); font-size: .76rem; white-space: nowrap; }

/* Named "vtrail" on purpose: g5.css already owns `.tp-timeline` for the custody chain's own
 * <ul><li> markup (Esemplari critici, U9) - kept apart so the two never fight over one class. */
.tp-vtrail { position: relative; padding: 1rem 1rem 1rem 1.4rem; }
.tp-vtrail-row { position: relative; display: flex; gap: .85rem; padding-bottom: 1.1rem; }
.tp-vtrail-row:last-child { padding-bottom: 0; }
.tp-vtrail-row::before
{
    content: '';
    position: absolute;
    left: 15px;
    top: 34px;
    bottom: -2px;
    width: 2px;
    background: var(--tp-line);
}

.tp-vtrail-row:last-child::before { display: none; }
.tp-vtrail-dot
{
    position: relative;
    z-index: 1;
    display: inline-flex;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--tp-card);
    font-size: .85rem;
}

.tp-vtrail-card { flex: 1 1 auto; min-width: 0; padding-top: .1rem; }
.tp-vtrail-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; }
.tp-vtrail-time { color: var(--tp-ink-3); font-size: .76rem; }
.tp-vtrail-row.current .tp-vtrail-card { font-weight: 600; }

/* Floor map (Oggi): plain CSS grid, like components/tree.js - never an SVG block that shrinks
 * its own text when the CONTAINER (not even the viewport) is narrow. A grid cell's font-size is
 * fixed CSS, so a narrow column wraps text instead of shrinking it past legible. ------------- */

.tp-floor { display: flex; flex-wrap: wrap; gap: 1rem; align-items: stretch; }
.tp-floor-wing { flex: 1 1 auto; min-width: 0; }
.tp-floor-wing-outside { flex: 0 0 190px; display: flex; flex-direction: column; }
.tp-floor-wing-outside .tp-floor-tile { flex: 1 1 auto; justify-content: center; min-height: 170px; }
.tp-floor-wing-outside .tp-floor-tile .tp-floor-track { margin-top: .6rem; }
.tp-floor-wing-label { margin-bottom: .5rem; color: var(--tp-ink-4); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }

.tp-floor-grid
{
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-areas:
        "recv recv recv insp insp insp ret ret ship ship"
        "capa capa capa capa capb capb capb bdl bdl cage"
        "line line line line line line line line line line";
    gap: .6rem;
}

@media (max-width: 767.98px)
{
    .tp-floor-grid
    {
        grid-template-columns: repeat(4, 1fr);
        grid-template-areas: "recv recv insp insp" "ret ret ship ship" "capa capa capb capb" "bdl bdl cage cage" "line line line line";
    }
}

.tp-floor-tile
{
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-height: 96px;
    padding: .65rem .75rem;
    border: 1px solid var(--tp-line);
    border-radius: var(--tp-radius-sm);
    background: var(--tp-card);
    color: var(--tp-ink);
    text-decoration: none;
    font-family: inherit;
}

a.tp-floor-tile:hover { border-color: var(--tp-accent-line); background: var(--tp-accent-l); }
.tp-floor-tile > i:first-child { color: var(--tp-accent); font-size: 1.05rem; }
.tp-floor-tile b { display: block; margin-top: .25rem; font-size: .85rem; line-height: 1.3; }
.tp-floor-tile small { display: block; margin-top: .1rem; color: var(--tp-ink-3); font-size: .74rem; line-height: 1.3; }
.tp-floor-track { margin-top: auto; height: 6px; border-radius: 999px; background: var(--tp-line-2); overflow: hidden; }
.tp-floor-fill { display: block; height: 100%; background: var(--tp-accent); border-radius: 999px; transform-origin: left center; }
.tp-floor-fill.tp-floor-hot { background: var(--tp-amber); }
.tp-floor-fill.tp-floor-alert { background: var(--tp-red); }
.tp-floor-places { display: block; margin-top: .3rem; color: var(--tp-ink-3); font-size: .72rem; font-variant-numeric: tabular-nums; }
.tp-floor-flag { position: absolute; top: .55rem; right: .55rem; color: var(--tp-red); font-size: .8rem; }
.tp-floor-tile.tp-floor-alert { border-color: var(--tp-red-line); background: var(--tp-red-l); }
.tp-floor-tile.tp-floor-hot { border-color: var(--tp-amber-line); }
.tp-floor-note { margin: .75rem 0 0; color: var(--tp-ink-3); font-size: .78rem; }
.tp-floor-note i { margin-right: .3rem; color: var(--tp-accent); }

/* Below ~576px even a grid this dense gets cramped (C12): a plain row list replaces it there,
 * same data, same fill bars. */
.tp-floor-list { display: none; }

@media (max-width: 575.98px)
{
    .tp-floor, .tp-floor-note { display: none; }
    .tp-floor-list { display: flex; flex-direction: column; gap: .5rem; }
}

.tp-floor-list-row
{
    display: flex;
    align-items: center;
    gap: .65rem;
    min-height: 44px;
    padding: .55rem .7rem;
    border: 1px solid var(--tp-line);
    border-radius: var(--tp-radius-sm);
    background: var(--tp-card);
    color: var(--tp-ink);
    text-decoration: none;
}

.tp-floor-list-row > i:first-child { flex: 0 0 18px; color: var(--tp-accent); text-align: center; }
.tp-floor-list-text { flex: 1 1 auto; min-width: 0; }
.tp-floor-list-text b { display: block; font-size: .85rem; }
.tp-floor-list-text small { display: block; color: var(--tp-ink-3); }
.tp-floor-list-row .tp-floor-track { flex: 0 0 70px; margin-top: 0; }
.tp-floor-list-row .tp-floor-places { margin-top: 0; flex: 0 0 auto; width: 3.4rem; text-align: right; }
.tp-floor-list-row.tp-floor-alert { border-color: var(--tp-red-line); background: var(--tp-red-l); }
.tp-floor-list-row.tp-floor-hot { border-color: var(--tp-amber-line); }

/* Printable label preview (QR-like schematic + barcode strip) for a location or a bin ---------- */

.tp-label-wrap { max-width: 320px; }
.tp-label-card { padding: 1rem; border: 1px solid var(--tp-line); border-radius: var(--tp-radius); background: #fff; }
.tp-label-row { display: flex; align-items: center; gap: 1rem; }
.tp-qr-bg { fill: #fff; }
.tp-qr-mod rect { fill: var(--tp-ink); }
.tp-label-text { display: flex; flex-direction: column; min-width: 0; }
.tp-label-text small { text-transform: uppercase; letter-spacing: .05em; color: var(--tp-ink-3); font-size: .68rem; }
.tp-label-text b { font-size: 1.4rem; }
.tp-label-text span { color: var(--tp-ink-3); font-size: .8rem; }
.tp-label-barcode { display: flex; align-items: center; gap: 1px; height: 30px; margin-top: .8rem; }
.tp-label-barcode span { display: block; height: 100%; background: var(--tp-ink); }
.tp-label-foot { margin-top: .5rem; text-align: center; color: var(--tp-ink-4); font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; }

/* Global header search -------------------------------------------------------------------- */

.tp-gsearch { position: relative; flex: 1 1 260px; max-width: 360px; }
.tp-gsearch input
{
    width: 100%;
    min-height: 38px;
    padding: 0 .75rem 0 2.1rem;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 999px;
    background: rgba(255, 255, 255, .1);
    color: #fff;
}

.tp-gsearch input::placeholder { color: var(--tp-header-soft); }
.tp-gsearch input:focus { background: #fff; color: var(--tp-ink); outline: none; }
.tp-gsearch input:focus::placeholder { color: var(--tp-ink-4); }
.tp-gsearch > i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--tp-header-soft); pointer-events: none; }
.tp-gsearch input:focus ~ i { color: var(--tp-ink-4); }
.tp-gsearch-menu
{
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 1050;
    max-height: 60vh;
    overflow-y: auto;
    border: 1px solid var(--tp-line);
    border-radius: var(--tp-radius);
    background: #fff;
    box-shadow: var(--tp-shadow);
}

.tp-gsearch-item
{
    display: flex;
    align-items: center;
    gap: .6rem;
    min-height: 44px;
    padding: .4rem .75rem;
    color: var(--tp-ink);
    text-decoration: none;
}

.tp-gsearch-item:hover, .tp-gsearch-item.active { background: var(--tp-accent-l); }
.tp-gsearch-item i { color: var(--tp-accent); width: 18px; text-align: center; }
.tp-gsearch-item small { display: block; color: var(--tp-ink-3); }
.tp-gsearch-empty { padding: .75rem; color: var(--tp-ink-3); font-size: .82rem; }

@media (max-width: 767.98px)
{
    .tp-gsearch { flex: 1 1 auto; max-width: none; order: 5; width: 100%; margin: .35rem 0 0; }
    .tp-header { flex-wrap: wrap; height: auto; min-height: var(--tp-header-h); padding-bottom: .4rem; }
}

/* Side-menu counters ----------------------------------------------------------------------- */

.tp-nav-badge
{
    margin-left: auto;
    min-width: 1.4rem;
    padding: .05rem .4rem;
    border-radius: 999px;
    background: var(--tp-line-2);
    color: var(--tp-ink-2);
    font-size: .68rem;
    font-weight: 700;
    text-align: center;
}

.tp-nav-badge.tp-nav-badge-alert { background: var(--tp-red-l); color: var(--tp-red); }
.tp-nav.active .tp-nav-badge { background: #fff; }

/* Skeleton shimmer while loading ------------------------------------------------------------ */

.tp-skel { border-radius: var(--tp-radius-sm); background: var(--tp-line-2); overflow: hidden; position: relative; }
.tp-skel::after
{
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .7) 50%, transparent 70%);
    background-size: 200% 100%;
    background-position: 150% 0;
}

/* =================================================================================================
   Animations: short (150-600ms), decorative only, never gating a click, and off entirely when the
   OS asks for reduced motion. Every element above is rendered in its correct FINAL state first;
   the keyframes below only add a transient "from" state, so nothing here can get stuck half-shown.
   ================================================================================================= */

@media (prefers-reduced-motion: no-preference)
{
    .tp-anim-fadein { animation: tp-fadein .45s ease both; }
    .tp-anim-pop { animation: tp-pop .3s cubic-bezier(.34, 1.56, .64, 1) .35s both; transform-box: fill-box; transform-origin: center; }
    .tp-anim-drawline { animation: tp-drawline .55s cubic-bezier(.22, .8, .32, 1) both; }
    .tp-anim-drawring { animation: tp-drawring .6s cubic-bezier(.22, .8, .32, 1) both; }
    .tp-anim-growx { animation: tp-growx .45s cubic-bezier(.22, .8, .32, 1) both; transform-box: fill-box; transform-origin: left center; }

    .tp-anim-stagger > * { animation: tp-fadeup .4s ease both; animation-delay: calc(var(--i, 0) * 45ms); }
    .tp-kpis.tp-anim-stagger > *, .tp-floor-tile { animation-delay: calc(var(--i, 0) * 45ms); }

    .tp-feed-row.tp-anim-new { animation: tp-slidein .35s cubic-bezier(.22, .8, .32, 1) both; }
    .tp-anim-ack { animation: tp-flash-ok .45s ease both; }

    .tp-tab-panel.tp-anim-show { animation: tp-fadeup .25s ease both; }

    .tp-skel::after { animation: tp-shimmer 1.3s ease-in-out infinite; }

    a.tp-kpi, .tp-card.tp-kpi, .tp-nav, .tp-task, .tp-floor-tile, .btn, .tp-feed-row
    {
        transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background-color .15s ease;
    }

    a.tp-kpi:hover, .tp-task:hover { transform: translateY(-1px); }
    .btn:active, a.tp-kpi:active, .tp-task:active { transform: scale(.98); }
}

/* --- Tree diagram (Distinte, illustrative): plain flexbox, never an SVG block that shrinks its
 * own text when the viewport does (the Oggi floor map lesson). Wraps naturally at any width. -- */

.tp-tree { display: flex; flex-direction: column; align-items: center; }
.tp-tree-root-row { display: flex; justify-content: center; margin-bottom: 28px; }

.tp-tree-row
{
    position: relative;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px 10px;
    padding-top: 24px;
    width: 100%;
}

.tp-tree-row::before { content: ''; position: absolute; top: 0; left: 8%; right: 8%; height: 2px; background: var(--tp-line); }
.tp-tree-row > .tp-tree-node { position: relative; }
.tp-tree-row > .tp-tree-node::before { content: ''; position: absolute; top: -24px; left: 50%; width: 2px; height: 24px; background: var(--tp-line); }

.tp-tree-node
{
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    width: 168px;
    padding: .55rem .65rem;
    border: 1px solid var(--tp-line);
    border-radius: var(--tp-radius-sm);
    background: #fff;
    box-shadow: var(--tp-shadow);
}

.tp-tree-root { width: auto; min-width: 200px; border-color: var(--tp-accent-line); background: var(--tp-accent-l); }
.tp-tree-node-head { display: flex; align-items: center; gap: .4rem; }
.tp-tree-node-head i { color: var(--tp-accent); flex-shrink: 0; }
.tp-tree-node-head b { font-size: .82rem; line-height: 1.25; }
.tp-tree-node small { color: var(--tp-ink-3); font-size: .74rem; }
.tp-tree-chips { display: flex; flex-wrap: wrap; gap: .2rem; margin-top: .3rem; }
.tp-tree-chip { padding: .04rem .35rem; border-radius: 999px; background: var(--tp-line-2); color: var(--tp-ink-2); font-size: .66rem; font-family: "Cascadia Mono", Consolas, monospace; }
.tp-tree-chip-more { background: transparent; color: var(--tp-ink-3); }

@media (max-width: 575.98px)
{
    .tp-tree-node { width: 100%; }
    .tp-tree-row { gap: 20px 0; }
    .tp-tree-row::before { display: none; }
    .tp-tree-row > .tp-tree-node::before { left: 0; width: 2px; height: 14px; top: -14px; }
}

/* --- Flow / pipeline diagram (Conto lavoro: fuori -> presso il terzista -> rientrato) -------- */

.tp-flow { display: flex; align-items: stretch; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tp-flow-stage
{
    flex: 1 1 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    padding: .9rem .75rem;
    border: 1px solid var(--tp-line);
    border-radius: var(--tp-radius);
    background: var(--tp-card);
    text-align: center;
}

.tp-flow-stage i { font-size: 1.3rem; color: var(--tp-ink-4); }
.tp-flow-stage b { font-size: .82rem; }
.tp-flow-stage small { color: var(--tp-ink-3); font-size: .74rem; }
.tp-flow-stage.done { border-color: var(--tp-teal-line); background: var(--tp-teal-l); }
.tp-flow-stage.done i { color: var(--tp-teal); }
.tp-flow-stage.now { border-color: var(--tp-accent); box-shadow: 0 0 0 3px rgba(var(--tp-accent-rgb), .15); }
.tp-flow-stage.now i { color: var(--tp-accent); }
.tp-flow-arrow { display: flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 28px; color: var(--tp-ink-4); }

@media (max-width: 575.98px)
{
    .tp-flow { flex-direction: column; }
    .tp-flow-arrow { transform: rotate(90deg); width: auto; height: 20px; align-self: center; }
}

/* --- Ageing mini-bar: a value shown relative to the oldest/largest in its own list ------------ */

.tp-age-bar { display: inline-flex; align-items: center; gap: .4rem; min-width: 70px; }
.tp-age-bar .tp-floor-track { flex: 1 1 46px; width: 46px; margin-top: 0; }

@keyframes tp-fadein { from { opacity: 0; } }
@keyframes tp-pop { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } }
@keyframes tp-drawline { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes tp-drawring { from { stroke-dashoffset: var(--tp-dash-from, 0); } to { stroke-dashoffset: 0; } }
@keyframes tp-growx { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes tp-fadeup { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes tp-slidein { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }
@keyframes tp-shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
@keyframes tp-flash-ok { from { background-color: var(--tp-teal-l); } to { background-color: transparent; } }

/* Dashboard: the activity feed never makes its row taller than the floor map beside it. */
@media (min-width: 1400px)
{
    .tp-home-feed { max-height: 360px; overflow-y: auto; }
}

/* ---- Language switch (GUI/APP/i18n.js): IT | EN in the office header and the handheld header ---- */

html.tp-lang-pending body { visibility: hidden; }

.tp-lang
{
    display: inline-flex;
    flex: 0 0 auto;
    border: 1px solid currentColor;
    border-radius: 999px;
    overflow: hidden;
    color: var(--tp-header-soft, #c9d6e3);
}

.tp-lang button
{
    min-width: 36px;
    min-height: 32px;
    padding: 0 .55rem;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .04em;
    cursor: pointer;
}

.tp-lang button.active
{
    background: #fff;
    color: var(--tp-ink, #0e1a26);
}

.tp-lang button:not(.active):hover,
.tp-lang button:focus-visible
{
    background: rgba(255, 255, 255, .14);
}

.tp-handheld .tp-lang-hh
{
    margin-left: auto;
    margin-right: .4rem;
}

@media (pointer: coarse)
{
    .tp-lang button { min-height: 44px; min-width: 44px; }
}

/* The same switch inside the user menu: the only one on a phone, where the header has no room. */
.tp-lang-menu-row { display: none; align-items: center; justify-content: space-between; gap: .5rem; padding: .25rem 1rem .25rem 0; }
.tp-lang-menu { color: var(--tp-ink-2, #31465a); }
.tp-lang-menu button.active { background: var(--tp-ink, #0e1a26); color: #fff; }
.tp-lang-menu button:not(.active):hover { background: var(--tp-line-2, #eef2f7); }

@media (max-width: 575.98px)
{
    .tp-lang-header { display: none; }
    .tp-lang-menu-row { display: flex; }
}

/* --- File import (components/importer.js) ------------------------------------ */

.tp-imp-counts { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.tp-imp-counts b { font-variant-numeric: tabular-nums; }
.tp-imp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.tp-imp-maps { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem 1rem; }
.tp-imp-sum { padding-left: 1.2rem; }
.tp-imp-sample td, .tp-imp-sample th { white-space: nowrap; }
@media (max-width: 767.98px)
{
    .tp-imp-actions .btn { flex: 1 1 100%; min-height: 44px; }
    .tp-imp-maps { grid-template-columns: 1fr; }
}

/* Da risolvere (home) and the age of a position (stock pages). */
.tp-attn-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--tp-line, #e5e8ee); }
.tp-attn-item:last-child { border-bottom: 0; }
.tp-attn-icon { font-size: 1.4rem; flex-shrink: 0; }
.tp-attn-text { flex: 1 1 auto; min-width: 0; }
.tp-attn-text b { display: block; overflow-wrap: anywhere; }
.tp-attn-actions { display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
.tp-attn-actions .btn { min-height: 44px; }
.tp-since { color: var(--tp-ink-3, #5b6472); white-space: nowrap; cursor: help; }
@media (max-width: 767.98px)
{
    .tp-attn-item { flex-wrap: wrap; }
    .tp-attn-actions { width: 100%; }
    .tp-attn-actions .btn { flex: 1 1 auto; }
}

/* A choice in a modal (radio or check) is a 44 px touch target, label included (C12). */
.form-check.tp-touch { min-height: 44px; padding-top: .6rem; padding-bottom: .4rem; }
.form-check.tp-touch .form-check-label, .form-check.tp-touch .form-check-input { cursor: pointer; }
