/* ==========================================================================
   Ventura WIP System - skin over AdminLTE 3.2
   AdminLTE is an office theme; the factory needs something calmer to look at
   all shift and bigger to touch on the floor. This file does both:
     1. a modern, low-noise back-office skin (cards, spacing, type)
     2. a .shop-floor mode with large targets for scan screens (NF-06 / TS-13)
   No fonts are fetched from the internet - the factory server may have none.
   ========================================================================== */

:root {
    --wip-bg:            #f1f4f9;
    --wip-surface:       #ffffff;
    --wip-border:        #e4e8f0;
    --wip-text:          #1f2937;
    --wip-muted:         #6b7280;

    --wip-primary:       #2563eb;
    --wip-primary-dark:  #1d4ed8;
    --wip-primary-soft:  #e8f0fe;

    --wip-cutting:       #0d6efd;
    --wip-glue:          #fd7e14;
    --wip-color:         #198754;
    --wip-assembly:      #dc3545;
    --wip-warehouse:     #64748b;

    --wip-success:       #16a34a;
    --wip-warning:       #f59e0b;
    --wip-danger:        #dc2626;
    --wip-info:          #0ea5e9;

    --wip-radius:        14px;
    --wip-radius-sm:     10px;
    --wip-shadow:        0 1px 2px rgba(16,24,40,.04), 0 6px 20px -8px rgba(16,24,40,.12);
    --wip-shadow-lg:     0 2px 6px rgba(16,24,40,.06), 0 18px 40px -16px rgba(16,24,40,.22);

    --wip-font: "Inter", "Segoe UI", "Noto Sans Bengali", "SolaimanLipi", system-ui,
                -apple-system, "Helvetica Neue", Arial, sans-serif;
}

/* -------------------------------------------------------------- base */
body,
.wrapper {
    font-family: var(--wip-font);
    background: var(--wip-bg);
    color: var(--wip-text);
    -webkit-font-smoothing: antialiased;
}

body { font-size: .9rem; letter-spacing: -.01em; }

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5 { font-weight: 650; letter-spacing: -.02em; }

a { color: var(--wip-primary); }
a:hover { color: var(--wip-primary-dark); }

.text-muted { color: var(--wip-muted) !important; }

.content-wrapper { background: var(--wip-bg); }

/* Spacing is deliberately tight. A factory screen shows a lot at once, and every
   extra 4px of padding is a row of data someone has to scroll for. */
.content-header { padding: .7rem .5rem .1rem; }
.content-header h1 { font-size: 1.22rem; margin: 0; }
.content-header .sub { color: var(--wip-muted); font-size: .76rem; margin-top: .1rem; }

.content { padding-top: .35rem; }
.container-fluid { padding-left: .5rem; padding-right: .5rem; }

/* tighter grid gutters than Bootstrap's default 15px */
.row { margin-left: -.35rem; margin-right: -.35rem; }
.row > [class*="col"] { padding-left: .35rem; padding-right: .35rem; }

.mb-3, .my-3 { margin-bottom: .7rem !important; }
.mt-3, .my-3 { margin-top: .7rem !important; }
.mb-2 { margin-bottom: .45rem !important; }

/* -------------------------------------------------------------- sidebar */
.main-sidebar {
    background: linear-gradient(180deg, #111a2e 0%, #16203a 55%, #1b2745 100%);
    box-shadow: inset -1px 0 0 rgba(255,255,255,.04);
}

.brand-link {
    border-bottom: 1px solid rgba(255,255,255,.06) !important;
    padding: .7rem .85rem;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.brand-link .brand-mark {
    width: 34px; height: 34px;
    border-radius: 10px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--wip-primary), #60a5fa);
    color: #fff; font-weight: 800; font-size: .95rem;
    box-shadow: 0 4px 14px -4px rgba(37,99,235,.7);
    flex: 0 0 auto;
}

.brand-link .brand-text { line-height: 1.1; }
.brand-link .brand-text strong { display: block; font-size: .95rem; color: #fff; font-weight: 700; }
.brand-link .brand-text span { font-size: .68rem; color: #94a3b8; letter-spacing: .02em; }

.nav-sidebar .nav-header {
    color: #64748b;
    text-transform: uppercase;
    font-size: .63rem;
    letter-spacing: .1em;
    font-weight: 700;
    padding: .7rem .85rem .2rem;
}

.nav-sidebar > .nav-item > .nav-link,
.nav-sidebar .nav-treeview > .nav-item > .nav-link {
    color: #b9c4d8;
    border-radius: 8px;
    margin: 1px .45rem;
    padding: .38rem .6rem;
    font-size: .81rem;
    transition: background .15s ease, color .15s ease;
}

.nav-sidebar .nav-link .nav-icon { width: 1.4rem; text-align: center; opacity: .85; }

.nav-sidebar > .nav-item > .nav-link:hover,
.nav-sidebar .nav-treeview > .nav-item > .nav-link:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}

.nav-sidebar > .nav-item > .nav-link.active,
.nav-sidebar .nav-treeview > .nav-item > .nav-link.active {
    background: linear-gradient(90deg, rgba(37,99,235,.95), rgba(37,99,235,.55));
    color: #fff;
    box-shadow: 0 6px 18px -8px rgba(37,99,235,.9);
}

.nav-sidebar .nav-treeview { padding-left: .6rem; }
.nav-sidebar .nav-treeview > .nav-item > .nav-link { font-size: .82rem; }

.sidebar-scrollbar { padding-bottom: 2rem; }

.nav-sidebar .badge { font-weight: 600; }

/* -------------------------------------------------------------- navbar */
.main-header.navbar {
    background: rgba(255,255,255,.92);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--wip-border);
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
}

.main-header .nav-link { color: #475569; font-size: .88rem; }
.main-header .nav-link:hover { color: var(--wip-primary); }

.navbar-search {
    background: var(--wip-bg);
    border: 1px solid var(--wip-border);
    border-radius: 999px;
    padding: .28rem .8rem;
    display: flex; align-items: center; gap: .45rem;
    min-width: 230px;
}
.navbar-search input { border: 0; background: transparent; outline: none; width: 100%; font-size: .84rem; }

.user-chip {
    display: flex; align-items: center; gap: .55rem;
    padding: .25rem .6rem .25rem .3rem;
    border-radius: 999px;
    border: 1px solid var(--wip-border);
    background: #fff;
}
.user-chip .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    color: #fff; font-weight: 700; font-size: .72rem;
}
.user-chip .who { line-height: 1.05; }
.user-chip .who strong { display: block; font-size: .78rem; }
.user-chip .who span { font-size: .67rem; color: var(--wip-muted); }

/* -------------------------------------------------------------- cards */
.card {
    border: 1px solid var(--wip-border);
    border-radius: var(--wip-radius);
    box-shadow: var(--wip-shadow);
    background: var(--wip-surface);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--wip-border);
    padding: .6rem .85rem;
    display: flex; align-items: center; gap: .55rem;
    min-height: 0;
}

/* AdminLTE floats .card-title, which makes the subtitle run into it - undo that */
.card-header .card-title {
    display: block;
    float: none;
    font-size: .9rem;
    font-weight: 650;
    margin: 0;
    line-height: 1.3;
    letter-spacing: -.01em;
}

.card-header .card-sub {
    display: block;
    font-size: .73rem;
    color: var(--wip-muted);
    font-weight: 400;
    line-height: 1.35;
}

/* the title block takes the space it needs; trailing actions wrap below on a phone */
.card-header > div { min-width: 0; }
.card-header > .ml-auto, .card-header > form.ml-auto { flex: 0 0 auto; }
.card-body { padding: .85rem; }
.card-body.pb-0 { padding-bottom: 0 !important; }
.card-footer {
    background: #fbfcfe;
    border-top: 1px solid var(--wip-border);
    border-radius: 0 0 var(--wip-radius) var(--wip-radius);
    padding: .6rem .85rem;
}

/* a short note explaining WHY a screen behaves the way it does */
.rule-note {
    background: #f8fafc;
    border: 1px solid var(--wip-border);
    border-left: 3px solid var(--wip-primary);
    border-radius: var(--wip-radius-sm);
    padding: .5rem .7rem;
    font-size: .765rem;
    line-height: 1.5;
    color: #475569;
}
.rule-note .req { font-weight: 700; color: var(--wip-primary); }

/* -------------------------------------------------------------- stat tiles */
.stat-tile {
    position: relative;
    background: var(--wip-surface);
    border: 1px solid var(--wip-border);
    border-radius: var(--wip-radius);
    padding: .75rem .9rem;
    box-shadow: var(--wip-shadow);
    overflow: hidden;
    height: 100%;
}
.stat-tile::after {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
    background: var(--tile-accent, var(--wip-primary));
}
.stat-tile .label { font-size: .69rem; text-transform: uppercase; letter-spacing: .07em; color: var(--wip-muted); font-weight: 650; }
.stat-tile .value { font-size: 1.62rem; font-weight: 700; line-height: 1.1; margin: .15rem 0 0; letter-spacing: -.03em; }
.stat-tile .unit { font-size: .75rem; font-weight: 500; color: var(--wip-muted); margin-left: .18rem; }
.stat-tile .foot { font-size: .72rem; color: var(--wip-muted); margin-top: .2rem; line-height: 1.35; }
.stat-tile .tile-icon {
    position: absolute; right: .7rem; top: .7rem;
    width: 32px; height: 32px; border-radius: 9px;
    display: grid; place-items: center;
    background: var(--tile-soft, var(--wip-primary-soft));
    color: var(--tile-accent, var(--wip-primary));
    font-size: .9rem;
}

/* -------------------------------------------------------------- section colour keys */
.sec-cutting  { --tile-accent: var(--wip-cutting);   --tile-soft: #e7f0ff; }
.sec-glue     { --tile-accent: var(--wip-glue);      --tile-soft: #fff1e5; }
.sec-color    { --tile-accent: var(--wip-color);     --tile-soft: #e6f5ec; }
.sec-assembly { --tile-accent: var(--wip-assembly);  --tile-soft: #fdeaec; }
.sec-warehouse{ --tile-accent: var(--wip-warehouse); --tile-soft: #eef1f5; }

/* -------------------------------------------------------------- charts */
/* Chart.js runs with maintainAspectRatio off, so the wrapper must own the height,
   otherwise the canvas grows to fill the page. */
.chart-box { position: relative; height: 260px; }
@media (max-width: 991.98px) { .chart-box { height: 220px; } }
@media (max-width: 767.98px)  { .chart-box { height: 190px; } }

/* -------------------------------------------------------------- flow strip */
.flow-strip { display: flex; gap: .55rem; flex-wrap: wrap; }
.flow-node {
    flex: 1 1 150px;
    border: 1px solid var(--wip-border);
    border-radius: var(--wip-radius-sm);
    background: #fff;
    padding: .7rem .8rem;
    position: relative;
}
.flow-node .n-name { font-size: .78rem; font-weight: 650; display: flex; align-items: center; gap: .4rem; }
.flow-node .n-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--n-color, #94a3b8); }
.flow-node .n-val { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }
.flow-node .n-sub { font-size: .7rem; color: var(--wip-muted); }
.flow-node .n-arrow {
    position: absolute; right: -.45rem; top: 50%; transform: translateY(-50%);
    color: #cbd5e1; font-size: .8rem; z-index: 2;
}
@media (max-width: 767.98px) { .flow-node .n-arrow { display: none; } }

/* the section you are standing in, on the chain strip */
.flow-node.is-here { border-color: var(--n-color); box-shadow: 0 0 0 2px color-mix(in srgb, var(--n-color) 18%, transparent); }

/* -------------------------------------------------------------- round picker
   Which pile of work is in front of the operator: fresh, or back for the second or
   third time. Big tap targets, because this is chosen on a phone with gloved hands. */
.round-picker { display: flex; gap: .5rem; flex-wrap: wrap; }
.round-opt {
    flex: 1 1 130px;
    display: flex; flex-direction: column; gap: .1rem;
    border: 1px solid var(--wip-border);
    border-radius: var(--wip-radius-sm);
    background: #fff;
    padding: .55rem .7rem;
    margin: 0;
    cursor: pointer;
    min-height: 58px;
    transition: border-color .12s, background .12s;
}
.round-opt input { position: absolute; opacity: 0; pointer-events: none; }
.round-opt .r-name { font-size: .74rem; font-weight: 650; color: var(--wip-muted); }
.round-opt .r-qty  { font-size: 1.15rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.round-opt .r-flag { font-size: .64rem; font-weight: 600; }
.round-opt.active { border-color: var(--wip-primary); background: var(--wip-primary-soft); }
.round-opt.active .r-name { color: var(--wip-primary); }
/* an empty pile is still shown - "nothing on its third round" is worth knowing */
.round-opt.is-empty { opacity: .55; }
.round-opt.is-empty .r-qty { color: var(--wip-muted); }

/* -------------------------------------------------------------- quantity rows
   A row of number boxes that must read as one line of figures: Cut / Good / Loss /
   Save / Reject, or Receive / Good / Reject / Rework.

   The rule that matters is that every box carries a hint line even when it has
   nothing to say. Without it, one hint under one box made that whole column taller,
   and with bottom alignment the other labels dropped - the row looked broken while
   the grid was perfectly correct. Reserving the line costs 1.05rem and removes the
   whole class of problem. */
.qty-row .form-group { margin-bottom: .6rem; }
.qty-row label { white-space: nowrap; }
.field-hint {
    display: block;
    min-height: 1.05rem;
    margin-top: .2rem;
    font-size: .7rem;
    line-height: 1.05rem;
    color: var(--wip-muted);
}

/* numbers are read and compared down a column, so they line up on the right */
.qty-row input[type="number"] { font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- balance note
   Sits beside Save and says why the numbers do not add up. It has to be readable at a
   glance from arm's length, because the alternative - a dead-looking button with the
   reason somewhere else on the card - is how this got reported as "save not working". */
.balance-note {
    display: inline-flex; align-items: center;
    padding: .38rem .7rem;
    border-radius: 999px;
    border: 1px solid var(--wip-border);
    background: #f8fafc;
    color: var(--wip-muted);
    font-weight: 600;
    line-height: 1.25;
    max-width: 46ch;
}
.balance-note.is-good { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.balance-note.is-bad  { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

@keyframes wip-shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-5px); }
    40%      { transform: translateX(5px); }
    60%      { transform: translateX(-3px); }
    80%      { transform: translateX(3px); }
}
.balance-note.shake { animation: wip-shake .45s ease; }

/* on a phone the note goes above the buttons rather than squeezing beside them */
@media (max-width: 575.98px) {
    .balance-note { max-width: 100%; width: 100%; justify-content: center; margin-bottom: .5rem; }
    .card-footer .d-flex.ml-auto { flex-wrap: wrap; width: 100%; }
    .card-footer .d-flex.ml-auto > .btn { width: 100%; }
}

/* -------------------------------------------------------------- tables */
.table { color: var(--wip-text); }
.table thead th {
    background: #f8fafc;
    border-bottom: 1px solid var(--wip-border) !important;
    border-top: 0 !important;
    font-size: .69rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748b;
    font-weight: 700;
    white-space: nowrap;
    padding: .45rem .65rem;
}
.table tbody td { padding: .45rem .65rem; vertical-align: middle; border-top: 1px solid #f1f5f9; font-size: .84rem; }
.table-hover tbody tr:hover { background: #f8fbff; }
.table-sm td, .table-sm th { padding: .32rem .55rem; }

.table-wrap {
    border: 1px solid var(--wip-border);
    border-radius: var(--wip-radius);
    overflow: hidden;
    background: #fff;
}
.table-wrap .table { margin-bottom: 0; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .82rem; }

/* -------------------------------------------------------------- badges & chips */
.badge { font-weight: 600; letter-spacing: .01em; padding: .3em .6em; border-radius: 7px; }
.badge-soft {
    background: var(--chip-soft, #eef2ff);
    color: var(--chip-ink, #3730a3);
    border: 1px solid color-mix(in srgb, var(--chip-ink, #3730a3) 18%, transparent);
}
.chip {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .2rem .55rem; border-radius: 999px;
    font-size: .73rem; font-weight: 600;
    background: #f1f5f9; color: #475569;
    border: 1px solid var(--wip-border);
}
.chip i { font-size: .7rem; }

.round-pill {
    display: inline-grid; place-items: center;
    width: 22px; height: 22px; border-radius: 50%;
    font-size: .72rem; font-weight: 700;
    background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa;
}
.round-pill.r2 { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.round-pill.r3 { background: #450a0a; color: #fff; border-color: #450a0a; }

/* -------------------------------------------------------------- forms */
.form-control, .custom-select, .select2-container--bootstrap4 .select2-selection {
    border-radius: 9px;
    border-color: #dfe5ee;
    font-size: .85rem;
    min-height: calc(1.9rem + 2px);
    padding: .3rem .6rem;
}
.form-control:focus {
    border-color: var(--wip-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.13);
}
label { font-size: .755rem; font-weight: 600; color: #475569; margin-bottom: .18rem; }
.form-group { margin-bottom: .6rem; }
.form-control-sm { min-height: calc(1.7rem + 2px); padding: .2rem .5rem; font-size: .8rem; }
.select2-container--bootstrap4 .select2-selection--single { height: calc(1.9rem + 2px); }
.select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered { line-height: 1.9rem; padding-left: .6rem; }
.select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow { height: calc(1.9rem + 2px); }
hr { margin: .7rem 0; }

.required-mark { color: var(--wip-danger); margin-left: .12rem; }

/* jQuery Validation output, styled to sit inside AdminLTE's form groups (TS-05) */
label.error {
    color: var(--wip-danger);
    font-size: .74rem;
    font-weight: 500;
    margin: .25rem 0 0;
    display: block;
}
input.error, select.error, textarea.error,
.form-control.is-invalid {
    border-color: var(--wip-danger) !important;
    background-image: none;
}
.valid-tick { color: var(--wip-success); }

.input-group-text { background: #f8fafc; border-color: #dfe5ee; border-radius: var(--wip-radius-sm); font-size: .8rem; }

/* -------------------------------------------------------------- buttons */
.btn {
    border-radius: 9px;
    font-weight: 600;
    font-size: .81rem;
    padding: .34rem .75rem;
    transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--wip-primary); border-color: var(--wip-primary); box-shadow: 0 6px 16px -8px rgba(37,99,235,.8); }
.btn-primary:hover { background: var(--wip-primary-dark); border-color: var(--wip-primary-dark); }
.btn-light { background: #fff; border-color: var(--wip-border); color: #334155; }
.btn-light:hover { background: #f8fafc; }
.btn-sm { padding: .22rem .55rem; font-size: .755rem; }
.btn-icon { width: 27px; height: 27px; padding: 0; display: inline-grid; place-items: center; }

.btn-group-toolbar { display: flex; gap: .35rem; flex-wrap: wrap; }

/* -------------------------------------------------------------- empty state */
.empty-state { text-align: center; padding: 1.8rem 1rem; color: var(--wip-muted); }
.empty-state i { font-size: 1.7rem; opacity: .35; display: block; margin-bottom: .45rem; }
.empty-state p { margin: 0; font-size: .82rem; }

/* -------------------------------------------------------------- timeline (bundle trace) */
.trace { position: relative; padding-left: 1.6rem; }
.trace::before { content: ""; position: absolute; left: .46rem; top: .3rem; bottom: .3rem; width: 2px; background: #e2e8f0; }
.trace-item { position: relative; padding: 0 0 1rem .2rem; }
.trace-item .dot {
    position: absolute; left: -1.4rem; top: .15rem;
    width: 14px; height: 14px; border-radius: 50%;
    background: #fff; border: 3px solid var(--dot, var(--wip-primary));
}
.trace-item .t-title { font-size: .85rem; font-weight: 650; }
.trace-item .t-meta { font-size: .73rem; color: var(--wip-muted); }
.trace-item .t-body { font-size: .79rem; color: #475569; }

/* -------------------------------------------------------------- alerts / flash */
.alert { border-radius: var(--wip-radius-sm); border: 1px solid transparent; font-size: .85rem; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* -------------------------------------------------------------- DataTables tidy-up */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border-radius: var(--wip-radius-sm);
    border: 1px solid #dfe5ee;
    padding: .25rem .5rem;
    font-size: .82rem;
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { font-size: .8rem; padding-top: .6rem; }
.page-link { border-radius: 8px !important; margin: 0 2px; border-color: var(--wip-border); font-size: .8rem; }
.page-item.active .page-link { background: var(--wip-primary); border-color: var(--wip-primary); }

/* ==========================================================================
   SHOP FLOOR MODE (TS-13 / NF-06)
   Gloved hands, standing, poor light. Everything gets bigger and louder.
   ========================================================================== */
body.shop-floor {
    background: #0b1220;
    color: #e2e8f0;
    font-size: 1rem;
}
.shop-floor .sf-shell { max-width: 1100px; margin: 0 auto; padding: 1rem; }

.shop-floor .sf-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    background: #111a2e; border: 1px solid #1e293b;
    border-radius: 16px; padding: .85rem 1.1rem; margin-bottom: 1rem;
}
.shop-floor .sf-bar .sf-title { font-size: 1.15rem; font-weight: 700; color: #fff; }
.shop-floor .sf-bar .sf-sub { font-size: .8rem; color: #94a3b8; }

.shop-floor .sf-card {
    background: #111a2e;
    border: 1px solid #1e293b;
    border-radius: 18px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.shop-floor .sf-scan {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-align: center;
    padding: 1.1rem;
    height: auto;
    border-radius: 16px;
    background: #0b1220;
    border: 2px dashed #334155;
    color: #fff;
}
.shop-floor .sf-scan:focus {
    border-color: #3b82f6;
    border-style: solid;
    box-shadow: 0 0 0 5px rgba(59,130,246,.22);
    background: #0f1729;
}

.shop-floor .sf-btn {
    min-height: 74px;
    font-size: 1.15rem;
    font-weight: 700;
    border-radius: 16px;
    border: 0;
    width: 100%;
    display: flex; align-items: center; justify-content: center; gap: .6rem;
    color: #fff;
}
.shop-floor .sf-btn i { font-size: 1.3rem; }
.sf-btn-ok     { background: linear-gradient(135deg, #16a34a, #22c55e); }
.sf-btn-warn   { background: linear-gradient(135deg, #d97706, #f59e0b); }
.sf-btn-danger { background: linear-gradient(135deg, #b91c1c, #ef4444); }
.sf-btn-blue   { background: linear-gradient(135deg, #1d4ed8, #3b82f6); }
.sf-btn-dark   { background: #1e293b; border: 1px solid #334155; }
.shop-floor .sf-btn:active { transform: translateY(2px); }

.shop-floor .sf-num {
    font-size: 2rem; font-weight: 800; text-align: center;
    background: #0b1220; border: 2px solid #334155; color: #fff;
    border-radius: 16px; height: 74px;
}

.shop-floor .sf-list { list-style: none; margin: 0; padding: 0; }
.shop-floor .sf-list li {
    display: flex; align-items: center; justify-content: space-between; gap: .8rem;
    background: #0b1220; border: 1px solid #1e293b;
    border-radius: 12px; padding: .7rem .9rem; margin-bottom: .5rem;
    font-size: 1rem;
}
.shop-floor .sf-list li .bn { font-weight: 700; letter-spacing: .04em; }
.shop-floor .sf-list li .meta { font-size: .78rem; color: #94a3b8; }

.shop-floor label { color: #94a3b8; font-size: .85rem; }
.shop-floor label.error { color: #fca5a5; font-size: .9rem; }

.shop-floor .sf-feedback {
    border-radius: 14px; padding: .9rem 1.1rem; font-size: 1rem; font-weight: 600;
    display: none; margin-bottom: 1rem;
}
.sf-feedback.ok   { background: #052e16; color: #86efac; border: 1px solid #166534; }
.sf-feedback.bad  { background: #450a0a; color: #fca5a5; border: 1px solid #991b1b; }
.sf-feedback.warn { background: #422006; color: #fcd34d; border: 1px solid #92400e; }

/* --------------------------------------------------------------------------
   NF-02 - the offline / queued indicator.
   An operator has to be able to tell, without asking anyone, whether what they
   just entered is on the server or still sitting on the tablet.
   -------------------------------------------------------------------------- */
.offline-badge {
    display: inline-flex; align-items: center; gap: .45rem;
    margin-top: .45rem; padding: .28rem .6rem;
    border-radius: 999px; font-size: .78rem; font-weight: 700;
    background: rgba(37,99,235,.14); color: #93c5fd; border: 1px solid rgba(59,130,246,.4);
    cursor: pointer;
}
.offline-badge .ob-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96,165,250,.2);
}
.offline-badge .ob-spin { display: none; font-size: .7rem; }

.offline-badge.is-offline {
    background: rgba(245,158,11,.16); color: #fcd34d; border-color: rgba(245,158,11,.45);
}
.offline-badge.is-offline .ob-dot { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.2); }

.offline-badge.has-queue .ob-spin { display: inline-block; animation: ob-turn 1.4s linear infinite; }
@keyframes ob-turn { to { transform: rotate(360deg); } }

/* the same indicator in the back office, next to the bell */
.navbar .offline-badge { margin-top: 0; background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.navbar .offline-badge .ob-dot { background: #f59e0b; }

/* ==========================================================================
   RESPONSIVE (NF-11 / TS-19)

   This system is used on a phone more than on a desk, so the phone layout is the
   one that has to be right - not a shrunken desktop. Three rules drive the rest:
     1. nothing scrolls sideways, at any width down to 320px;
     2. anything you tap is at least 44px tall;
     3. a form field is never smaller than 16px, because below that iOS zooms the
        page on focus and the operator loses their place.
   ========================================================================== */
@media (max-width: 991.98px) {
    .content-header h1 { font-size: 1.15rem; }
    .stat-tile .value { font-size: 1.5rem; }
    .content-wrapper { padding-bottom: 5rem; }   /* room for the mobile action bar */
}

@media (max-width: 767.98px) {
    body { font-size: .92rem; }

    .card { border-radius: 12px; }
    .card-body { padding: .75rem; }

    /* a header with actions wraps them onto their own line instead of squeezing the title */
    .card-header { padding: .6rem .75rem; flex-wrap: wrap; row-gap: .4rem; }
    .card-header > .ml-auto, .card-header > form.ml-auto {
        margin-left: 0 !important;
        flex: 1 1 100%;
    }
    .card-header > .ml-auto .btn { width: 100%; }
    .content-header { padding: .8rem .35rem .2rem; }
    .container-fluid { padding-left: .6rem; padding-right: .6rem; }

    .navbar-search { display: none; }

    /* the page actions move to a fixed bar at the bottom, in thumb reach */
    .content-header .btn-group-toolbar { display: none; }

    /* 16px stops iOS zooming the whole page when a field takes focus */
    .form-control, .custom-select,
    .select2-container--bootstrap4 .select2-selection--single {
        font-size: 16px;
        min-height: 44px;
    }
    .form-control-sm { font-size: 16px; min-height: 40px; }
    textarea.form-control { min-height: 88px; }

    .btn { min-height: 44px; padding: .55rem .9rem; font-size: .88rem; }
    .btn-sm { min-height: 38px; padding: .4rem .7rem; font-size: .82rem; }
    .btn-icon { min-width: 38px; }

    .custom-control-label { padding-top: .15rem; min-height: 24px; }
    .custom-control { padding-left: 1.8rem; }
    .custom-control-label::before,
    .custom-control-label::after { width: 1.15rem; height: 1.15rem; top: .18rem; }

    /*
     * A bare checkbox renders around 13px, which is a pointer target and not a finger
     * one. Enlarging the box alone is not enough either - margin around an input is not
     * tappable, so the hit area stays the size of the box. .tap-toggle wraps the input
     * in a label, and a label toggles the control it contains, so the whole padded cell
     * becomes the target while the box itself stays a reasonable size.
     */
    input[type="checkbox"]:not(.custom-control-input),
    input[type="radio"]:not(.custom-control-input) {
        width: 22px;
        height: 22px;
        vertical-align: middle;
    }

    .tap-toggle {
        display: block;
        min-height: 44px;
        padding: 11px 0;
        cursor: pointer;
    }

    /* wide tables collapse into stacked cards rather than scrolling sideways.
       The table element itself must stop being a table, or it keeps sizing to its
       widest cell and pushes every other value off the right of the screen. */
    .table-stack, .doc-lines {
        display: block;
        width: 100%;
        min-width: 0 !important;
        table-layout: auto;
    }
    .table-stack > tbody, .doc-lines > tbody { display: block; width: 100%; }

    .table-stack thead { display: none; }
    .table-stack tbody tr {
        display: block;
        border: 1px solid var(--wip-border);
        border-radius: var(--wip-radius-sm);
        margin-bottom: .6rem;
        padding: .35rem .1rem;
        background: #fff;
        box-shadow: 0 1px 2px rgba(16,24,40,.04);
    }
    .table-stack tbody tr:last-child { margin-bottom: 0; }
    .table-stack tbody td {
        display: flex; justify-content: space-between; align-items: baseline;
        flex-wrap: wrap; gap: .25rem .8rem;
        border: 0; padding: .35rem .75rem; text-align: right; min-height: 30px;
        min-width: 0; word-break: break-word;
    }
    .table-stack tbody td::before {
        content: attr(data-label);
        font-size: .68rem; text-transform: uppercase; letter-spacing: .05em;
        color: var(--wip-muted); font-weight: 700; text-align: left;
        flex: 0 0 auto; white-space: nowrap;
    }
    /* a cell whose value is wide (chips, a route path) gets the full row to itself */
    .table-stack tbody td > * { max-width: 100%; }
    /* a cell with no label is an action cell: give it the full width */
    .table-stack tbody td:not([data-label]) {
        justify-content: flex-end;
        border-top: 1px solid #f1f5f9;
        margin-top: .25rem;
        padding-top: .5rem;
    }
    .table-stack tbody td.num { text-align: right; }
    .table-stack tfoot { display: none; }

    /* tables that genuinely need columns scroll inside their own box, not the page */
    .table-responsive { -webkit-overflow-scrolling: touch; }

    /* --------------------------------------------------------------------
       Document line editors (requisition, GRN, issue, transfer, adjustment).
       A row of narrow inputs is unusable on a phone, so each line becomes a
       card with the field label above a full-width control. The labels come
       from the table head, filled in by wip.js, so no form repeats them.
       -------------------------------------------------------------------- */
    /* a desk-width min-width would force a sideways scroll; the cards do not need it */
    .doc-lines { min-width: 0 !important; }
    .doc-lines thead { display: none; }
    .doc-lines tbody tr {
        display: block;
        position: relative;
        border: 1px solid var(--wip-border);
        border-radius: 12px;
        background: #fff;
        padding: .6rem .7rem 2.9rem;
        margin-bottom: .55rem;
        box-shadow: 0 1px 2px rgba(16,24,40,.04);
    }
    .doc-lines tbody td {
        display: block;
        border: 0;
        padding: 0 0 .5rem;
        text-align: left;
        min-height: 0;
    }
    .doc-lines tbody td::before {
        content: attr(data-label);
        display: block;
        font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
        color: var(--wip-muted); margin-bottom: .15rem;
    }
    .doc-lines tbody td:empty,
    .doc-lines tbody td[data-label=""] { display: none; }

    /* the row number becomes a badge in the corner rather than a column */
    .doc-lines tbody td.line-no {
        position: absolute; top: .55rem; right: .6rem;
        padding: 0; width: 22px; height: 22px; border-radius: 50%;
        background: var(--wip-primary-soft); color: var(--wip-primary);
        font-size: .7rem; font-weight: 700; display: grid; place-items: center;
    }
    .doc-lines tbody td.line-no::before { content: ""; display: none; }

    /* the remove button gets a full-width footer strip inside the card.
       The class is added by wip.js rather than using :has(), which older Android
       WebViews on the floor do not support. */
    .doc-lines tbody td.line-actions {
        position: absolute; left: .7rem; right: .7rem; bottom: .6rem;
        padding: 0; text-align: right;
    }
    .doc-lines tbody td.line-actions::before { content: ""; display: none; }

    /* an icon-only button is too quiet once it is the only thing in a footer strip,
       so the stacked layout gives it a word as well */
    .doc-lines .line-remove {
        width: 100%; height: 38px; min-height: 38px;
        border: 1px solid #fecaca; background: #fef2f2; color: var(--wip-danger);
        display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    }
    .doc-lines .line-remove::after { content: "Remove line"; font-size: .8rem; font-weight: 600; }

    .doc-lines tbody td .form-control,
    .doc-lines tbody td .select2-container { width: 100% !important; }
    .doc-lines tfoot { display: table-footer-group; }
    .doc-lines tfoot th { display: inline-block; font-size: .78rem; padding: .4rem .3rem; }

    /* filter rows: one field per line reads better than four squashed ones */
    .card-body > form .form-group { margin-bottom: .6rem; }

    .dataTables_wrapper .dataTables_filter { float: none; text-align: left; }
    .dataTables_wrapper .dataTables_length { display: none; }

    .modal-dialog { margin: .5rem; }
    .stat-tile { padding: .8rem .85rem; }
    .stat-tile .tile-icon { width: 32px; height: 32px; font-size: .85rem; }
    .stat-tile .value { font-size: 1.35rem; }
    .stat-tile .label { font-size: .68rem; }

    .flow-node { flex: 1 1 calc(50% - .3rem); }

    dl.row dt { font-size: .78rem; }
    dl.row dd { margin-bottom: .45rem; }
}

@media (max-width: 767.98px) {
    /* two flow nodes per row keeps the whole line visible without a long scroll */
    .flow-strip { gap: .4rem; }
    .flow-node { flex: 1 1 calc(50% - .2rem); padding: .5rem .6rem; }
    .flow-node .n-val { font-size: 1.15rem; }
    .flow-node .n-name { font-size: .74rem; }
    .flow-node .n-sub { font-size: .66rem; }
}

@media (max-width: 340px) {
    .container-fluid { padding-left: .4rem; padding-right: .4rem; }
    .stat-tile .value { font-size: 1.15rem; }
    .flow-node { flex: 1 1 100%; }
    .content-header h1 { font-size: 1.02rem; }
}

/* --------------------------------------------------------------------------
   Mobile action bar - the page's primary buttons, fixed in thumb reach.
   Populated from the page's own actions by wip.js, so no screen defines it twice.
   -------------------------------------------------------------------------- */
.mobile-actions {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1035;
    background: rgba(255,255,255,.97);
    backdrop-filter: saturate(180%) blur(10px);
    border-top: 1px solid var(--wip-border);
    padding: .5rem .6rem calc(.5rem + env(safe-area-inset-bottom));
    gap: .45rem;
    box-shadow: 0 -4px 20px -8px rgba(16,24,40,.18);
}
.mobile-actions .btn { flex: 1 1 0; min-height: 46px; font-size: .85rem; }
.mobile-actions .btn i { margin-right: .3rem; }

@media (max-width: 767.98px) {
    .mobile-actions:not(:empty) { display: flex; }
    .main-footer { margin-bottom: 4rem; }
}

/* the sidebar behaves as an overlay drawer on a phone, never a squeeze */
@media (max-width: 991.98px) {
    .main-sidebar { box-shadow: 8px 0 30px -12px rgba(0,0,0,.6); }

    /*
     * Dim AdminLTE's own #sidebar-overlay rather than adding a layer of our own.
     * AdminLTE already closes the menu when that element is tapped; a separate
     * dimmer stacked on top would swallow the tap and leave the menu stuck open.
     */
    body.sidebar-open #sidebar-overlay {
        display: block;
        background: rgba(15, 23, 42, .5);
    }
}

/* ==========================================================================
   PRINT (NF-12) - reports and bundle labels
   ========================================================================== */
@media print {
    .main-sidebar, .main-header, .main-footer, .no-print, .btn { display: none !important; }
    .content-wrapper { margin-left: 0 !important; background: #fff; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    body { background: #fff; font-size: 11px; }
    .table thead th { background: #f2f2f2 !important; -webkit-print-color-adjust: exact; }
}

/* bundle QR ticket, sized for a 50x75mm label */
.bundle-ticket {
    width: 50mm;
    border: 1px solid #000;
    padding: 3mm;
    font-size: 9px;
    page-break-inside: avoid;
    display: inline-block;
    margin: 2mm;
    vertical-align: top;
}
.bundle-ticket .bt-no { font-size: 13px; font-weight: 800; letter-spacing: .04em; text-align: center; }
.bundle-ticket .bt-qr { text-align: center; margin: 2mm 0; }
.bundle-ticket .bt-qr img, .bundle-ticket .bt-qr svg { width: 28mm; height: 28mm; }
.bundle-ticket table { width: 100%; border-collapse: collapse; }
.bundle-ticket td { padding: .4mm 0; vertical-align: top; }
.bundle-ticket td:first-child { color: #555; width: 38%; }
.bundle-ticket .bt-qty { font-size: 16px; font-weight: 800; text-align: center; border-top: 1px solid #000; margin-top: 1mm; padding-top: 1mm; }

/* NF-11 / TS-19 : every screen is usable on a phone - see the mobile block above. */
