/* ════════════════════════════════════════════════════════════════════════
   NHẬP HÀNG — Goods Receiving kiosk (tablet, cân điện tử)
   Industrial-precision operational console. Theme-aware via --ag-* tokens.
   Class prefixes: gr- (layout/page), rcv- (receiving status semantics).
   ════════════════════════════════════════════════════════════════════════ */

.gr-root {
    /* Screen-local design tokens */
    --gr-accent:        #16a34a;   /* emerald — fresh-produce action color   */
    --gr-accent-strong: #15803d;
    --gr-accent-rgb:    22, 163, 74;

    --rcv-none:  #ef4444;          /* Chưa nhận */
    --rcv-short: #f59e0b;          /* Thiếu     */
    --rcv-ok:    #16a34a;          /* Đủ        */
    --rcv-over:  #f97316;          /* Vượt      */

    --gr-surface:  var(--ag-surface, var(--mud-palette-surface));
    --gr-sunken:   rgba(var(--ag-fg-rgb, 255,255,255), 0.04);
    --gr-line:     rgba(var(--ag-fg-rgb, 255,255,255), 0.10);
    --gr-line-soft:rgba(var(--ag-fg-rgb, 255,255,255), 0.06);
    --gr-text:     var(--mud-palette-text-primary);
    --gr-muted:    var(--mud-palette-text-secondary);
    --gr-radius:   18px;

    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(1200px 600px at 85% -10%, rgba(var(--gr-accent-rgb), 0.10), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(6, 182, 212, 0.07), transparent 55%),
        var(--ag-bg, var(--mud-palette-background));
    color: var(--gr-text);
    font-family: var(--mud-typography-default-family, "Roboto", system-ui, sans-serif);
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.gr-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ── Top bar ─────────────────────────────────────────────────────────── */
.gr-topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 22px;
    background: linear-gradient(180deg, var(--gr-surface), transparent);
    border-bottom: 1px solid var(--gr-line);
}
.gr-back {
    display: inline-flex; align-items: center; justify-content: center;
    width: 52px; height: 52px; flex: 0 0 auto;
    border-radius: 14px; border: 1px solid var(--gr-line);
    background: var(--gr-sunken); color: var(--gr-text);
    cursor: pointer; transition: background .15s, transform .1s;
}
.gr-back:active { transform: scale(.94); }
.gr-back:hover { background: rgba(var(--ag-fg-rgb,255,255,255),0.09); }

.gr-doc-id {
    font-size: 1.5rem; font-weight: 800; letter-spacing: .02em;
    line-height: 1; white-space: nowrap;
}
.gr-doc-meta { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.gr-ncc {
    color: var(--gr-accent); font-weight: 700; font-size: 1.05rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gr-dot { color: var(--gr-muted); }
.gr-spacer { flex: 1 1 auto; }

.gr-progress {
    display: flex; align-items: center; gap: 14px;
}
.gr-progress-num { font-size: 1.35rem; font-weight: 800; }
.gr-progress-num b { color: var(--gr-accent); }
.gr-progress-bar {
    width: 180px; height: 10px; border-radius: 999px;
    background: var(--gr-sunken); overflow: hidden; border: 1px solid var(--gr-line-soft);
}
.gr-progress-fill {
    height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, var(--gr-accent), #34d399);
    transition: width .4s cubic-bezier(.2,.8,.2,1);
}

/* ── Workspace grid ──────────────────────────────────────────────────── */
.gr-workspace {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(380px, 5fr) minmax(440px, 7fr);
    gap: 18px;
    padding: 18px;
    min-height: 0;
}
.gr-panel {
    background: var(--gr-surface);
    border: 1px solid var(--gr-line);
    border-radius: var(--gr-radius);
    display: flex; flex-direction: column;
    min-height: 0; overflow: hidden;
    box-shadow: 0 18px 40px -28px rgba(0,0,0,.55);
}

/* ── Product list (left) ─────────────────────────────────────────────── */
.gr-list-head { padding: 16px 18px 10px; border-bottom: 1px solid var(--gr-line-soft); }
.gr-search {
    width: 100%; height: 48px; border-radius: 12px;
    border: 1px solid var(--gr-line); background: var(--gr-sunken);
    color: var(--gr-text); padding: 0 16px; font-size: 1rem; outline: none;
}
.gr-search::placeholder { color: var(--gr-muted); }
.gr-search:focus { border-color: var(--gr-accent); }

.gr-tabs { display: flex; gap: 8px; padding: 12px 18px; flex-wrap: wrap; border-bottom: 1px solid var(--gr-line-soft); }
.gr-tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 14px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--gr-line); background: transparent;
    color: var(--gr-muted); font-weight: 600; font-size: .92rem;
    transition: all .15s; white-space: nowrap;
}
.gr-tab:active { transform: scale(.96); }
.gr-tab.is-active { color: #fff; background: var(--gr-accent); border-color: var(--gr-accent); }
.gr-tab-count {
    min-width: 22px; text-align: center; padding: 1px 7px; border-radius: 999px;
    background: var(--gr-sunken); font-size: .82rem; font-weight: 800;
}
.gr-tab.is-active .gr-tab-count { background: rgba(255,255,255,.25); color: #fff; }

.gr-list { flex: 1 1 auto; overflow-y: auto; padding: 10px; -webkit-overflow-scrolling: touch; }
.gr-item {
    display: flex; align-items: center; gap: 14px;
    padding: 13px 14px; margin-bottom: 8px;
    border-radius: 14px; border: 1px solid var(--gr-line-soft);
    background: var(--gr-sunken); cursor: pointer;
    transition: border-color .12s, background .12s, transform .08s;
}
.gr-item:active { transform: scale(.99); }
.gr-item.is-selected {
    border-color: var(--gr-accent);
    background: rgba(var(--gr-accent-rgb), 0.10);
    box-shadow: inset 0 0 0 1px var(--gr-accent);
}
.gr-item-idx {
    flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px;
    display: grid; place-items: center; font-weight: 800; font-size: .95rem;
    background: var(--gr-surface); border: 1px solid var(--gr-line-soft); color: var(--gr-muted);
}
.gr-item-name { flex: 1 1 auto; min-width: 0; }
.gr-item-name b { display: block; font-size: 1.06rem; font-weight: 700; line-height: 1.25;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gr-item-name small { color: var(--gr-muted); font-size: .8rem; }
.gr-item-qty { flex: 0 0 auto; text-align: right; font-weight: 800; font-size: 1.05rem; white-space: nowrap; }
.gr-item-chev { flex: 0 0 auto; color: var(--gr-muted); }

.rcv-none  .gr-item-qty { color: var(--rcv-none); }
.rcv-short .gr-item-qty { color: var(--rcv-short); }
.rcv-ok    .gr-item-qty { color: var(--rcv-ok); }
.rcv-over  .gr-item-qty { color: var(--rcv-over); }
.gr-item .gr-status-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.rcv-none  .gr-status-dot { background: var(--rcv-none); }
.rcv-short .gr-status-dot { background: var(--rcv-short); }
.rcv-ok    .gr-status-dot { background: var(--rcv-ok); }
.rcv-over  .gr-status-dot { background: var(--rcv-over); }

/* ── Right column: scale + detail ────────────────────────────────────── */
.gr-right { display: flex; flex-direction: column; gap: 18px; min-height: 0; overflow-y: auto; padding-right: 2px; }

.gr-weighbox {
    background: var(--gr-surface); border: 1px solid var(--gr-line); border-radius: var(--gr-radius);
    padding: 18px 22px; position: relative; overflow: hidden;
}
.gr-weighbox::before {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(600px 200px at 90% 0%, rgba(var(--gr-accent-rgb),.10), transparent 60%);
    pointer-events: none;
}
.gr-cap-label { font-size: .8rem; font-weight: 800; letter-spacing: .14em; color: var(--gr-muted); text-transform: uppercase; }
.gr-weight-row { display: flex; align-items: baseline; gap: 12px; margin: 2px 0 4px; }
.gr-weight { font-size: clamp(3rem, 8.5vw, 5.6rem); font-weight: 800; line-height: .95; letter-spacing: -.02em; }
.gr-weight.is-empty { color: var(--gr-muted); opacity: .5; }
.gr-weight-unit { font-size: 1.6rem; font-weight: 700; color: var(--gr-muted); }
.gr-weigh-hint { color: var(--gr-muted); font-size: .92rem; }

/* Numeric keypad */
.gr-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.gr-key {
    height: 60px; border-radius: 14px; border: 1px solid var(--gr-line);
    background: var(--gr-sunken); color: var(--gr-text);
    font-size: 1.5rem; font-weight: 700; cursor: pointer;
    transition: transform .07s, background .12s; touch-action: manipulation;
}
.gr-key:active { transform: scale(.95); background: rgba(var(--ag-fg-rgb,255,255,255),.10); }
.gr-key.gr-key-fn { font-size: 1.1rem; color: var(--gr-muted); }
.gr-key.gr-key-back { color: var(--rcv-over); }

/* Detail / stats */
.gr-detail { background: var(--gr-surface); border: 1px solid var(--gr-line); border-radius: var(--gr-radius); padding: 18px 20px; }
.gr-detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.gr-detail-head b { font-size: 1.25rem; font-weight: 800; }
.gr-detail-empty { display: grid; place-items: center; height: 160px; color: var(--gr-muted); text-align: center; }

.gr-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.gr-stat {
    background: var(--gr-sunken); border: 1px solid var(--gr-line-soft);
    border-radius: 13px; padding: 12px 12px 11px; text-align: center;
}
.gr-stat-label { font-size: .72rem; font-weight: 700; letter-spacing: .04em; color: var(--gr-muted); text-transform: uppercase; }
.gr-stat-val { font-size: 1.6rem; font-weight: 800; line-height: 1.05; margin-top: 4px; }
.gr-stat-val small { font-size: .85rem; font-weight: 700; color: var(--gr-muted); margin-left: 3px; }
.gr-stat.is-after .gr-stat-val { color: var(--gr-accent); }
.gr-stat.is-diff-over  .gr-stat-val { color: var(--rcv-over); }
.gr-stat.is-diff-short .gr-stat-val { color: var(--rcv-short); }
.gr-stat.is-diff-ok    .gr-stat-val { color: var(--rcv-ok); }

.gr-warn {
    display: flex; align-items: center; gap: 10px; margin-top: 14px;
    padding: 12px 14px; border-radius: 12px; font-weight: 600; font-size: .95rem;
}
.gr-warn.is-over  { background: rgba(249,115,22,.12); color: var(--rcv-over);  border: 1px solid rgba(249,115,22,.35); }
.gr-warn.is-short { background: rgba(245,158,11,.12); color: var(--rcv-short); border: 1px solid rgba(245,158,11,.35); }

/* Weighing history */
.gr-history { margin-top: 16px; }
.gr-history-label { font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--gr-muted); margin-bottom: 8px; }
.gr-history-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.gr-chip {
    display: inline-flex; flex-direction: column; align-items: flex-start;
    padding: 7px 12px; border-radius: 11px; background: var(--gr-sunken);
    border: 1px solid var(--gr-line-soft); min-width: 84px;
}
.gr-chip small { font-size: .7rem; color: var(--gr-muted); }
.gr-chip b { font-size: 1rem; font-weight: 800; }
.gr-chip-total {
    margin-left: auto; padding: 9px 16px; border-radius: 11px;
    background: rgba(var(--gr-accent-rgb),.12); border: 1px solid rgba(var(--gr-accent-rgb),.35); color: var(--gr-accent);
    font-weight: 800;
}
.gr-history-empty { color: var(--gr-muted); font-size: .9rem; }

/* Actions */
.gr-actions { display: flex; gap: 12px; margin-top: 18px; }
.gr-btn {
    flex: 1 1 auto; height: 64px; border-radius: 15px; border: none; cursor: pointer;
    font-size: 1.12rem; font-weight: 800; letter-spacing: .01em;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    transition: transform .08s, filter .12s, opacity .12s; touch-action: manipulation;
}
.gr-btn:active { transform: scale(.98); }
.gr-btn:disabled { opacity: .45; cursor: not-allowed; }
.gr-btn-ghost { flex: 0 0 auto; min-width: 150px; background: var(--gr-sunken); color: var(--gr-text); border: 1px solid var(--gr-line); }
.gr-btn-primary { background: linear-gradient(180deg, var(--gr-accent), var(--gr-accent-strong)); color: #fff; box-shadow: 0 14px 30px -14px rgba(var(--gr-accent-rgb),.8); }
.gr-btn-primary:hover:not(:disabled) { filter: brightness(1.05); }

/* ── PR picker ───────────────────────────────────────────────────────── */
.gr-picker { flex: 1 1 auto; overflow-y: auto; padding: 26px clamp(18px, 5vw, 64px); }
.gr-picker-title { font-size: 1.7rem; font-weight: 800; margin-bottom: 4px; }
.gr-picker-sub { color: var(--gr-muted); margin-bottom: 22px; }
.gr-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.gr-card {
    background: var(--gr-surface); border: 1px solid var(--gr-line); border-radius: var(--gr-radius);
    padding: 18px 20px; cursor: pointer; position: relative; overflow: hidden;
    transition: transform .1s, border-color .12s, box-shadow .15s;
}
.gr-card:hover { border-color: var(--gr-accent); box-shadow: 0 20px 44px -26px rgba(var(--gr-accent-rgb),.6); transform: translateY(-2px); }
.gr-card:active { transform: scale(.99); }
.gr-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.gr-card-id { font-size: 1.25rem; font-weight: 800; }
.gr-card-date { color: var(--gr-muted); font-size: .85rem; }
.gr-card-ncc { color: var(--gr-accent); font-weight: 700; margin: 10px 0 14px; }
.gr-card-foot { display: flex; align-items: center; gap: 12px; }
.gr-card-bar { flex: 1 1 auto; height: 8px; border-radius: 999px; background: var(--gr-sunken); overflow: hidden; border: 1px solid var(--gr-line-soft); }
.gr-card-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gr-accent), #34d399); }
.gr-card-foot small { font-weight: 800; white-space: nowrap; }

.gr-center { flex: 1 1 auto; display: grid; place-items: center; color: var(--gr-muted); gap: 14px; text-align: center; }

/* ── Responsive: portrait / narrow tablets ───────────────────────────── */
@media (max-width: 1024px), (orientation: portrait) {
    .gr-workspace { grid-template-columns: 1fr; grid-template-rows: minmax(220px, 2fr) 3fr; }
    .gr-weight { font-size: clamp(2.6rem, 14vw, 4.4rem); }
}
@media (max-width: 560px) {
    .gr-stats { grid-template-columns: repeat(2, 1fr); }
    .gr-progress-bar { width: 96px; }
}

/* ── Multi-scale panel (Phase 1: cân điện tử live) ───────────────────── */
.gr-scalebox {
    background: var(--gr-surface); border: 1px solid var(--gr-line);
    border-radius: var(--gr-radius); padding: 14px 16px;
}
.gr-scalebox-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.gr-scalebox-head b { font-size: .82rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--gr-muted); }
.gr-scalegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; }
.gr-scale-empty { color: var(--gr-muted); font-size: .9rem; padding: 16px; text-align: center; }
.gr-scale-empty code { background: var(--gr-sunken); padding: 1px 6px; border-radius: 6px; }

.gr-scale {
    border: 1px solid var(--gr-line); border-radius: 14px; padding: 12px 13px;
    background: var(--gr-sunken); cursor: pointer; transition: border-color .12s, box-shadow .12s, opacity .12s;
}
.gr-scale.is-active { border-color: var(--gr-accent); box-shadow: inset 0 0 0 1px var(--gr-accent); }
.gr-scale.is-offline { opacity: .5; }
.gr-scale-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.gr-scale-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rcv-none); flex: 0 0 auto; }
.gr-scale.is-online .gr-scale-dot { background: var(--rcv-ok); box-shadow: 0 0 0 4px rgba(22,163,74,.15); }
.gr-scale.is-online:not(.is-stable) .gr-scale-dot { animation: gr-pulse 1s ease-in-out infinite; }
@keyframes gr-pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.gr-scale-name { font-weight: 800; font-size: .95rem; flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gr-scale-weight { font-size: 2rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.gr-scale-weight small { font-size: .85rem; color: var(--gr-muted); font-weight: 700; margin-left: 4px; }
.gr-scale-badge { display: inline-flex; align-items: center; gap: 5px; font-size: .7rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; margin-top: 6px; }
.gr-scale-badge.is-stable { color: var(--rcv-ok); background: rgba(22,163,74,.12); }
.gr-scale-badge.is-unstable { color: var(--rcv-short); background: rgba(245,158,11,.12); }
.gr-scale-badge.is-off { color: var(--gr-muted); background: var(--gr-sunken); }
.gr-scale-bind { margin-top: 8px; font-size: .78rem; color: var(--gr-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gr-scale-bind b { color: var(--gr-accent); }
.gr-scale-actions { display: flex; gap: 8px; margin-top: 10px; }
.gr-scale-btn {
    flex: 1 1 auto; height: 44px; border-radius: 11px; border: 1px solid var(--gr-line);
    background: transparent; color: var(--gr-text); font-weight: 700; font-size: .85rem;
    cursor: pointer; transition: transform .08s, background .12s; touch-action: manipulation;
}
.gr-scale-btn:active { transform: scale(.95); }
.gr-scale-btn.is-primary { background: var(--gr-accent); color: #fff; border-color: var(--gr-accent); }
.gr-scale-btn:disabled { opacity: .4; cursor: not-allowed; }

.gr-undo {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px;
    border-radius: 11px; border: 1px solid var(--gr-line); background: transparent;
    color: var(--gr-muted); font-weight: 700; font-size: .82rem; cursor: pointer;
    transition: transform .08s, color .12s;
}
.gr-undo:active { transform: scale(.95); }
.gr-undo:hover:not(:disabled) { color: var(--rcv-over); }
.gr-undo:disabled { opacity: .4; cursor: not-allowed; }

/* Connection banner */
.gr-conn { display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 999px; font-size: .82rem; font-weight: 700; }
.gr-conn.is-on { color: var(--rcv-ok); background: rgba(22,163,74,.12); }
.gr-conn.is-off { color: var(--rcv-over); background: rgba(249,115,22,.14); }
