/* The data-collection terminal (ТСД): phones and warehouse terminals, one task per screen, big type, thumb-sized
   buttons at the bottom, a result you can read from a metre away. Every class here starts with t- and lives only
   under .t-app, so the panel's own pages are untouched. */

.t-app {
    --t-green: #3E5B47;
    --t-green-dark: #2C4234;
    --t-cream: #F4F8EB;
    --t-bg: #EEF1EA;
    --t-card: #FFFFFF;
    --t-ink: #1B211D;
    --t-muted: #5E6A61;
    --t-line: #D9DED5;
    --t-ok: #1E7B34;
    --t-bad: #C62828;
    --t-warn: #E3A008;
    --t-info: #2D5B8A;
    --t-radius: 14px;

    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--t-bg);
    color: var(--t-ink);
    font: 17px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

.t-app * { box-sizing: border-box; }

/* ---- Bar at the top ----------------------------------------------------------------------------------------- */

.t-bar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 56px;
    padding: calc(env(safe-area-inset-top) + 4px) 8px 4px;
    background: var(--t-green);
    color: var(--t-cream);
}

.t-bar-back, .t-bar-menu {
    flex: none;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 12px;
    background: none;
    color: inherit;
    font-size: 26px;
    text-decoration: none;
    cursor: pointer;
}

.t-bar-back:active, .t-bar-menu:active { background: rgba(255, 255, 255, .15); }

.t-bar-title { flex: 1; min-width: 0; padding: 0 4px; }
.t-bar-title b { display: block; font-size: 19px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-bar-title small { display: block; font-size: 13px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.t-menu {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 58px);
    right: 8px;
    z-index: 20;
    min-width: 230px;
    padding: 8px;
    border-radius: var(--t-radius);
    background: var(--t-card);
    color: var(--t-ink);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .25);
}

.t-menu p { margin: 4px 8px 10px; color: var(--t-muted); font-size: 14px; }
.t-menu a, .t-menu button { display: block; width: 100%; padding: 12px; border: 0; border-radius: 10px; background: none; color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.t-menu a:active, .t-menu button:active { background: var(--t-bg); }

/* ---- Body and bottom actions ---------------------------------------------------------------------------------- */

.t-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px 20px;
}

.t-body > * + * { margin-top: 12px; }

.t-actions {
    flex: none;
    display: flex;
    gap: 10px;
    padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
    background: var(--t-card);
    border-top: 1px solid var(--t-line);
}

.t-actions > * { flex: 1; }

/* ---- Buttons ------------------------------------------------------------------------------------------------- */

.t-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 56px;
    padding: 10px 16px;
    border: 2px solid var(--t-green);
    border-radius: var(--t-radius);
    background: var(--t-green);
    color: #fff;
    font-weight: 600; font-size: 18px; line-height: 1.2; font-family: inherit;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
}

.t-btn:active { transform: scale(.98); filter: brightness(.95); }
.t-btn[disabled] { opacity: .4; pointer-events: none; }
.t-btn.ghost { background: var(--t-card); color: var(--t-green); }
.t-btn.bad { background: var(--t-bad); border-color: var(--t-bad); }
.t-btn.warn { background: var(--t-warn); border-color: var(--t-warn); color: #1B1300; }
.t-btn.small { min-height: 44px; font-size: 16px; padding: 6px 12px; border-radius: 12px; }

/* ---- Cards, key-values, lists -------------------------------------------------------------------------------- */

.t-card {
    padding: 14px;
    border-radius: var(--t-radius);
    background: var(--t-card);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

.t-card h2 { margin: 0 0 8px; font-size: 15px; font-weight: 600; color: var(--t-muted); text-transform: uppercase; letter-spacing: .04em; }

.t-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.t-kv dt { color: var(--t-muted); }
.t-kv dd { margin: 0; font-weight: 600; text-align: right; }

.t-big { font-size: 44px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.t-big small { font-size: 20px; font-weight: 600; margin-left: 4px; }
.t-code { font: 700 20px/1.2 ui-monospace, "IBM Plex Mono", Consolas, monospace; letter-spacing: .03em; }
.t-muted { color: var(--t-muted); }
.t-center { text-align: center; }

.t-count { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.t-count b { font-size: 30px; font-variant-numeric: tabular-nums; }

.t-list { list-style: none; margin: 0; padding: 0; border-radius: var(--t-radius); background: var(--t-card); overflow: hidden; }
.t-list > li + li { border-top: 1px solid var(--t-line); }

.t-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 10px 14px;
    color: inherit;
    text-decoration: none;
}

a.t-row:active, button.t-row:active { background: var(--t-bg); }
button.t-row { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.t-row-main { flex: 1; min-width: 0; }
.t-row-main b { display: block; }
.t-row-main small { display: block; color: var(--t-muted); font-size: 14px; }
.t-row-side { flex: none; text-align: right; font-weight: 600; }
.t-row-go { flex: none; color: var(--t-muted); font-size: 22px; }
.t-row .t-code { font-size: 17px; }
.t-row.flag .t-row-main small { color: var(--t-bad); }

.t-x {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 10px;
    background: var(--t-bg);
    color: var(--t-muted);
    font-size: 20px;
    cursor: pointer;
}

.t-sw { flex: none; width: 28px; height: 28px; border-radius: 8px; border: 1px solid rgba(0, 0, 0, .12); }

.t-progress { display: block; height: 8px; margin-top: 6px; border-radius: 4px; background: var(--t-line); overflow: hidden; }
.t-progress i { display: block; height: 100%; background: var(--t-green); }
.t-progress.done i { background: var(--t-ok); }

.t-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.t-chip { padding: 6px 12px; border-radius: 16px; background: var(--t-card); border: 1px solid var(--t-line); font-size: 15px; }
.t-chip.main { border-color: var(--t-green); }

.t-empty { padding: 28px 16px; color: var(--t-muted); text-align: center; }

/* ---- Home tiles ---------------------------------------------------------------------------------------------- */

.t-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

.t-tile {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    min-height: 132px;
    padding: 16px;
    border-radius: 18px;
    background: var(--t-card);
    color: var(--t-ink);
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

.t-tile:active { transform: scale(.98); background: #F7F9F4; }
.t-tile-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--t-green); color: var(--t-cream); }
.t-tile b { font-size: 19px; }
.t-tile small { display: block; margin-top: 2px; color: var(--t-muted); font-size: 14px; }
.t-tile.accent { background: var(--t-green); color: var(--t-cream); }
.t-tile.accent .t-tile-icon { background: var(--t-cream); color: var(--t-green); }
.t-tile.accent small { color: rgba(244, 248, 235, .8); }

/* ---- Result banner -------------------------------------------------------------------------------------------- */

.t-banner {
    padding: 16px;
    border-radius: var(--t-radius);
    background: var(--t-info);
    color: #fff;
}

.t-banner b { display: block; font-size: 22px; line-height: 1.2; }
.t-banner span { display: block; margin-top: 4px; font-size: 16px; opacity: .95; }
.t-banner.ok { background: var(--t-ok); }
.t-banner.bad { background: var(--t-bad); }
.t-banner.warn { background: var(--t-warn); color: #1B1300; }
.t-banner.idle { background: var(--t-card); color: var(--t-ink); border: 2px dashed var(--t-line); }
.t-banner.idle span { color: var(--t-muted); }

/* ---- Fields --------------------------------------------------------------------------------------------------- */

.t-field { display: flex; flex-direction: column; gap: 6px; font-size: 15px; color: var(--t-muted); }

.t-field input, .t-field select {
    width: 100%;
    min-height: 52px;
    padding: 10px 14px;
    border: 2px solid var(--t-line);
    border-radius: 12px;
    background: var(--t-card);
    color: var(--t-ink);
    font-weight: 600; font-size: 19px; line-height: 1.2; font-family: inherit;
}

.t-field input:focus, .t-field select:focus { outline: none; border-color: var(--t-green); }
.t-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.t-toggle { display: flex; align-items: center; gap: 12px; min-height: 52px; font-size: 17px; color: var(--t-ink); }
.t-toggle input { width: 26px; height: 26px; accent-color: var(--t-green); }

.t-seg { display: flex; padding: 4px; border-radius: 14px; background: var(--t-line); }
.t-seg button { flex: 1; min-height: 46px; border: 0; border-radius: 11px; background: none; color: var(--t-ink); font-weight: 600; font-size: 16px; line-height: 1.2; font-family: inherit; cursor: pointer; }
.t-seg button.on { background: var(--t-card); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }

/* ---- Scan: camera and manual code ----------------------------------------------------------------------------- */

.t-cam { position: relative; overflow: hidden; border-radius: var(--t-radius); background: #000; }
.t-cam video { display: block; width: 100%; height: min(38vh, 300px); object-fit: cover; }
.t-cam-frame { position: absolute; left: 8%; right: 8%; top: 30%; bottom: 30%; border: 3px solid #fff; border-radius: 12px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); pointer-events: none; }
.t-cam-line { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: #ff5252; box-shadow: 0 0 8px #ff5252; animation: t-scanline 1.6s ease-in-out infinite alternate; }
@keyframes t-scanline { from { transform: translateY(-40px); } to { transform: translateY(40px); } }
.t-cam-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 8px; }
.t-cam-tools button { display: grid; place-items: center; width: 46px; height: 46px; border: 0; border-radius: 23px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 20px; cursor: pointer; }
.t-cam-tools button.on { background: #fff; color: #000; }

.t-manual { display: flex; gap: 8px; }
.t-manual input {
    flex: 1;
    min-width: 0;
    min-height: 52px;
    padding: 10px 14px;
    border: 2px solid var(--t-line);
    border-radius: 12px;
    background: var(--t-card);
    font: 600 18px/1.2 ui-monospace, "IBM Plex Mono", Consolas, monospace;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.t-manual input:focus { outline: none; border-color: var(--t-green); }
.t-manual input::placeholder { text-transform: none; letter-spacing: 0; font-family: system-ui, sans-serif; font-weight: 500; }

/* ---- A sheet over the screen (a decision, settings) ---------------------------------------------------------- */

.t-sheet-back { position: absolute; inset: 0; z-index: 30; display: flex; align-items: flex-end; background: rgba(0, 0, 0, .45); }
.t-sheet {
    width: 100%;
    max-height: 90%;
    overflow-y: auto;
    padding: 18px 14px calc(env(safe-area-inset-bottom) + 14px);
    border-radius: 20px 20px 0 0;
    background: var(--t-card);
}
.t-sheet > * + * { margin-top: 12px; }
.t-sheet h3 { margin: 0; font-size: 21px; }
.t-sheet .t-stack { display: flex; flex-direction: column; gap: 10px; }

/* ---- The whole screen flashes on a scan: seen from the corner of the eye ------------------------------------ */

.t-flash { position: fixed; inset: 0; z-index: 50; pointer-events: none; opacity: 0; }
.t-flash.flash-ok { animation: t-flash-ok .55s ease-out; }
.t-flash.flash-bad { animation: t-flash-bad .9s ease-out; }
@keyframes t-flash-ok { from { opacity: .45; background: #1E7B34; } to { opacity: 0; background: #1E7B34; } }
@keyframes t-flash-bad { 0% { opacity: .6; background: #C62828; } 30% { opacity: .15; background: #C62828; } 45% { opacity: .5; background: #C62828; } 100% { opacity: 0; background: #C62828; } }

/* A terminal on a desk (a PC at the scales) gets the same screens, centred. */
@media (min-width: 900px) {
    .t-body > *, .t-actions { max-width: 760px; margin-left: auto; margin-right: auto; width: 100%; }
    .t-body { padding-top: 20px; }
    .t-actions { border-radius: 16px 16px 0 0; }
}

/* ---- Weighing ------------------------------------------------------------------------------------------------ */

.t-weigh { padding: 18px 14px; border: 3px solid transparent; text-align: center; }
.t-weigh .t-big { font-size: 64px; }
.t-weigh-state { margin-top: 6px; font-size: 20px; font-weight: 650; }
.t-weigh-norm { margin-top: 4px; font-size: 14px; }
.t-weigh.ok { border-color: var(--t-ok); background: #EAF5EC; }
.t-weigh.ok .t-weigh-state { color: var(--t-ok); }
.t-weigh.bad { border-color: var(--t-bad); background: #FCEBEB; }
.t-weigh.bad .t-weigh-state { color: var(--t-bad); }
.t-weigh.done { border-color: var(--t-info); background: #EAF1F8; }
.t-weigh.done .t-weigh-state { color: var(--t-info); }
.t-weigh .t-field { text-align: left; }
.t-weigh .t-field input { font-size: 36px; min-height: 68px; text-align: center; }

.t-setrow { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.t-setrow > span { min-width: 0; }
.t-setrow > span b { display: block; font-size: 18px; }
.t-setrow > span small { display: block; color: var(--t-muted); font-size: 13px; }
.t-setrow .grow { flex: 1; }
.t-setrow > :last-child { margin-left: auto; color: var(--t-muted); }
.t-setrow:active { background: #F7F9F4; }

.t-swatches { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.t-swatches > div { display: flex; align-items: center; gap: 10px; }
.t-swatches small { color: var(--t-muted); font-size: 13px; line-height: 1.3; }
.t-swatch { width: 56px; height: 56px; border-radius: 12px; border: 1px solid rgba(0, 0, 0, .12); display: inline-block; }
.t-swatch.empty { background: repeating-linear-gradient(45deg, transparent 0 6px, var(--t-line) 6px 7px); }
.t-delta { flex-direction: column; align-items: flex-start !important; gap: 0 !important; }
.t-delta b { font-size: 22px; }
.t-delta.ok b { color: var(--t-ok); }
.t-delta.bad b { color: var(--t-bad); }
.t-actions-inline { display: flex; gap: 10px; }
.t-actions-inline > * { flex: 1; }
.t-sheet p { margin: 0; }
.t-sheet > .t-btn, .t-stack > .t-btn, .t-body > .t-btn { width: 100%; }
.t-section { margin: 18px 4px 0; font-size: 14px; font-weight: 600; color: var(--t-muted); text-transform: uppercase; letter-spacing: .05em; }
.t-body > .t-section:first-child { margin-top: 4px; }
