.rgft-stock{
    --sk-accent: var(--rgft-primary, #b8963e);
    --sk-ink: #15171b;
    --sk-line: #e3e3e6;
    --sk-muted: #78787b;
    --sk-faint: #969699;
    font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
    color: #15171b;
    background: #f7f7f5;
    -webkit-font-smoothing: antialiased;
}
.rgft-stock *{ box-sizing: border-box; }
.rgft-stock a{ color: var(--sk-accent); text-decoration: none; }
.rgft-stock a:hover{ color: #8a6f23; }

/* ── Header ─────────────────────────────────────────────────────────── */
/* Title/date/logo now uses the shared .rgft-page-head-v2 (rtl.css) — same
   header everywhere. Just position it and keep the page's own hint line
   underneath it. */
.rgft-stock > .rgft-page-head-v2{
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 26px;
}
.rgft-stock__header-hint{
    max-width: 520px;
    margin: 6px auto 0;
    padding: 0 14px;
    font-size: 12.5px;
    color: var(--sk-faint);
    line-height: 1.7;
    text-align: center;
}
@media (max-width: 900px){
    .rgft-stock > .rgft-page-head-v2{ padding-left: 14px; padding-right: 14px; }
}

/* ── Page grid ──────────────────────────────────────────────────────── */
.rgft-stock-grid{
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px 26px 120px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.rgft-stock .rgft-orders__notice{ margin: 0; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.rgft-stock-card{
    background: #fff;
    border: 1px solid var(--sk-line);
    border-radius:16px;box-shadow:0 1px 2px rgba(15,23,42,.04),0 10px 28px -10px rgba(15,23,42,.10);transition:box-shadow .18s ease,transform .18s ease;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}
.rgft-stock-card:hover{transform:translateY(-2px);box-shadow:0 2px 4px rgba(15,23,42,.05),0 16px 36px -12px rgba(15,23,42,.14)}
.rgft-stock-card h2{
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
}
.rgft-stock-card__hint{
    margin: 0;
    font-size: 11.5px;
    color: var(--sk-faint);
    line-height: 1.7;
}

.rgft-stock-recv-grid{
    display: grid;
    grid-template-columns: minmax(0,1.3fr) minmax(0,1fr);
    gap: 16px;
    align-items: start;
}
@media (max-width: 900px){
    .rgft-stock-recv-grid{ grid-template-columns: 1fr; }
}

/* ── Form fields (both cards + receive form) ──────────────────────────── */
.rgft-stock-form{
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 12px;
}
@media (max-width: 900px){ .rgft-stock-form{ grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 560px){ .rgft-stock-form{ grid-template-columns: 1fr; } }

.rgft-stock-field{
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.rgft-stock-field > span{ font-size: 12px; color: var(--sk-muted); }
.rgft-stock-field input,
.rgft-stock-field select{
    font-family: inherit;
    font-size: 13.5px;
    height: 46px;
    padding: 0 12px;
    border: 1px solid var(--sk-line);
    background: #faf9f7;
    border-radius: 10px;
    width: 100%;
    color: #15171b;
}
.rgft-stock-field input[type="file"]{
    padding: 11px 12px;
    border: 1px dashed var(--sk-line);
    font-size: 12px;
}
.rgft-stock-field input:focus,
.rgft-stock-field select:focus{
    outline: none;
    border-color: var(--sk-accent);
    background: #fff;
}
.rgft-stock-balance-pill{
    font-size: 11.5px;
    padding: 5px 10px;
    border-radius: 999px;
    align-self: flex-start;
    background: #e9f5ee;
    color: #0f7a4a;
}

.rgft-stock-submit{
    align-self: flex-start;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    height: 46px;
    padding: 0 24px;
    border: 0;
    border-radius: 11px;
    background: var(--sk-ink);
    color: #fff;
    cursor: pointer;
}
.rgft-stock-submit:hover{ opacity: .92; }
.rgft-stock-submit--outline{
    background: #fff;
    border: 1px solid var(--sk-ink);
    color: var(--sk-ink);
}

/* ── Balance section: category chips + tiles ──────────────────────────── */
.rgft-stock-balance-head{
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.rgft-stock-balance-head span{ font-size: 12px; color: var(--sk-faint); }

.rgft-stock-chips{
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
@media (max-width: 560px){
    .rgft-stock-chips{ flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .rgft-stock-chips::-webkit-scrollbar{ display: none; }
}
.rgft-stock-chip{
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    font-size: 12.5px;
    padding: 9px 16px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--sk-line);
    color: var(--sk-muted);
}
.rgft-stock-chip.is-active{
    background: var(--sk-ink);
    border-color: var(--sk-ink);
    color: #fff;
    font-weight: 500;
}

.rgft-stock-count{ display: block; font-size: 12px; color: var(--sk-faint); margin: -4px 0 2px; }

.rgft-materials-grid{
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 12px;
}
@media (max-width: 900px){ .rgft-materials-grid{ grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 560px){ .rgft-materials-grid{ grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; } }

.rgft-material-tile{
    background: #fff;
    border: 1px solid var(--sk-line);
    border-radius: 13px;
    padding: 14px;
    min-width: 0;
}
.rgft-material-tile:not([hidden]){
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.rgft-material-tile.is-out{ border-color: #f2d4cf; }
/* A live report: this page lets a manager SET a safety-stock threshold
   per material but never actually showed which ones had crossed it --
   only fully-out (zero) had its own visual state. Amber, not red --
   matches the system's own existing "warning but not critical" color
   (dashboard.css's .d2-chip--idle), one step below is-out's red. */
.rgft-material-tile.is-low{ border-color: #f0e0be; }
.rgft-material-tile.is-low .rgft-material-tile__balance{ color: #b26a00; }
.rgft-material-tile.is-low .rgft-material-tile__tag{ background: #eeeef6; color: #b26a00; }
.rgft-material-tile__balance{
    font-size: 22px;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: #15171b;
}
.rgft-material-tile.is-out .rgft-material-tile__balance{ color: #b4372c; }
.rgft-material-tile__name{
    font-size: 13.5px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rgft-material-tile__foot{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.rgft-material-tile__cat{ font-size: 11px; color: var(--sk-faint); }
.rgft-material-tile__tag{
    font-size: 10.5px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    background: #e9f5ee;
    color: #0f7a4a;
}
.rgft-material-tile.is-out .rgft-material-tile__tag{ background: #fbeeec; color: #b4372c; }
.rgft-material-tile__delete-form{ margin: 0; }
.rgft-material-tile__delete{
    font-family: inherit;
    width: 100%;
    font-size: 11.5px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid #f0d8d8;
    background: #fff;
    color: #a83232;
    cursor: pointer;
}
.rgft-material-tile__delete:hover{ background: #f2f2f5; }

.rgft-material-tile__safety-form{
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.rgft-material-tile__safety-label{
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 11px;
    color: var(--sk-faint);
}
.rgft-material-tile__safety-label input{
    width: 64px;
    font-family: inherit;
    font-size: 11.5px;
    padding: 4px 6px;
    border: 1px solid var(--sk-line);
    border-radius: 6px;
    text-align: center;
}
.rgft-material-tile__safety-save{
    font-family: inherit;
    font-size: 11.5px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--sk-line);
    background: #fff;
    color: var(--sk-muted);
    cursor: pointer;
    white-space: nowrap;
}
.rgft-material-tile__safety-save:hover{ border-color: var(--sk-accent); color: #8a6f23; }

/* ── Recent receipts (grid rows, not a <table>) ────────────────────────── */
.rgft-stock-table{
    background: #fff;
    border: 1px solid var(--sk-line);
    border-radius:16px;box-shadow:0 1px 2px rgba(15,23,42,.04),0 10px 28px -10px rgba(15,23,42,.10);transition:box-shadow .18s ease,transform .18s ease;
    overflow: hidden;
}
.rgft-stock-table:hover{transform:translateY(-2px);box-shadow:0 2px 4px rgba(15,23,42,.05),0 16px 36px -12px rgba(15,23,42,.14)}
.rgft-stock-table__title{
    padding: 14px 18px;
    border-bottom: 1px solid #ededef;
    font-size: 14px;
    font-weight: 600;
}
.rgft-stock-row{
    display: grid;
    gap: 12px;
    align-items: center;
    grid-template-columns: minmax(0,1.2fr) 100px 96px 106px minmax(0,1fr) 92px 124px;
    grid-template-areas: "mat qty price total sup inv date";
    padding: 14px 18px;
    border-bottom: 1px solid #f1f1f3;
}
.rgft-stock-row:last-child{ border-bottom: 0; }
.rgft-stock-row--head{
    padding: 11px 18px;
    background: #faf9f7;
    border-bottom: 1px solid #ededef;
    font-size: 11px;
    color: var(--sk-faint);
}
.rgft-stock-row__lbl{ display: none; }
.rgft-stock-row [data-area="mat"]{ grid-area: mat; font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rgft-stock-row [data-area="qty"]{ grid-area: qty; font-size: 12.5px; color: #3d3f45; font-variant-numeric: tabular-nums; }
.rgft-stock-row [data-area="price"]{ grid-area: price; font-size: 12.5px; color: var(--sk-muted); font-variant-numeric: tabular-nums; }
.rgft-stock-row [data-area="total"]{ grid-area: total; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rgft-stock-row [data-area="sup"]{ grid-area: sup; font-size: 12.5px; color: var(--sk-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rgft-stock-row [data-area="inv"]{ grid-area: inv; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rgft-stock-row [data-area="date"]{ grid-area: date; font-size: 11.5px; color: var(--sk-faint); white-space: nowrap; }
.rgft-stock-row--head [data-area]{ font-size: 11px; font-weight: 400; color: var(--sk-faint); }

@media (max-width: 1080px){
    .rgft-stock-row--head{ display: none; }
    .rgft-stock-row{
        grid-template-columns: 1fr auto;
        gap: 5px 10px;
        grid-template-areas: "mat total" "qty qty" "price price" "sup sup" "date date" "inv inv";
        padding: 14px 16px;
    }
    .rgft-stock-row__lbl{ display: inline; color: var(--sk-faint); }
    .rgft-stock-row [data-area="qty"],
    .rgft-stock-row [data-area="price"],
    .rgft-stock-row [data-area="sup"],
    .rgft-stock-row [data-area="inv"],
    .rgft-stock-row [data-area="date"]{ justify-self: start; text-align: right; }
    .rgft-stock-row [data-area="total"]{ justify-self: end; }
}

/* ── Pagination ─────────────────────────────────────────────────────── */
.rgft-stock-pagination{
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    padding-top: 8px;
}
.rgft-stock-page{
    font-family: inherit;
    font-size: 13px;
    min-width: 38px;
    height: 38px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    border: 1px solid var(--sk-line);
    background: #fff;
    color: var(--sk-muted);
    text-decoration: none;
}
.rgft-stock-page:hover{ border-color: var(--sk-accent); color: var(--sk-accent); }
.rgft-stock-page.is-active{
    background: var(--sk-ink);
    border-color: var(--sk-ink);
    color: #fff;
    font-weight: 600;
    cursor: default;
}
.rgft-stock-page--nav{ padding: 0 14px; white-space: nowrap; }
.rgft-stock-page--nav.is-disabled{
    opacity: .4;
    pointer-events: none;
}
.rgft-stock-page--gap{
    border: 0;
    background: transparent;
    color: var(--sk-faint);
    min-width: auto;
    cursor: default;
}

/* LTR (English) override — see the equivalent block in rtl.css for the
   full rationale. Only this file's mobile-stacking text-align:right
   rules need re-declaring. */
.rgft-stock[dir="ltr"] .rgft-stock-row [data-area="qty"],
.rgft-stock[dir="ltr"] .rgft-stock-row [data-area="price"],
.rgft-stock[dir="ltr"] .rgft-stock-row [data-area="sup"],
.rgft-stock[dir="ltr"] .rgft-stock-row [data-area="inv"],
.rgft-stock[dir="ltr"] .rgft-stock-row [data-area="date"]{
    text-align: left;
}

/* ── معايير الخامات (BOM) card (v2.7.270 redesign — live UX report:
   fresh types opened as an empty, unstyled table with no hint that
   "+ إضافة خامة" was the next step, and the controls were tiny browser
   defaults. Rows now use the page's own 46px field system, fresh types
   open with ready rows + a guidance line, and the qty field carries the
   material's unit as an inline chip.) ── */
#rgft-bom-card { margin-top: 20px; }
.rgft-bom-picker { max-width: 340px; margin-bottom: 4px; }
.rgft-bom-fresh-hint {
    font-size: 13px;
    color: #8a6d1f;
    background: #fdf6e3;
    border: 1px solid #ecd9a0;
    border-radius: 10px;
    padding: 10px 14px;
    margin: 12px 0 2px;
}
.rgft-bom-rows { display: flex; flex-direction: column; gap: 10px; max-width: 720px; margin: 14px 0 12px; }
.rgft-bom-rows__head {
    display: grid;
    grid-template-columns: 1fr 200px 46px;
    gap: 10px;
    font-size: 12px;
    color: var(--sk-muted);
    padding: 0 2px;
}
.rgft-bom-row {
    display: grid;
    grid-template-columns: 1fr 200px 46px;
    gap: 10px;
    align-items: center;
}
.rgft-bom-row select,
.rgft-bom-row input[type="number"] {
    font-family: inherit;
    font-size: 13.5px;
    height: 46px;
    padding: 0 12px;
    border: 1px solid var(--sk-line);
    background: #faf9f7;
    border-radius: 10px;
    width: 100%;
    box-sizing: border-box;
    color: #15171b;
}
.rgft-bom-row select:focus,
.rgft-bom-row input[type="number"]:focus { outline: none; border-color: var(--sk-accent); background: #fff; }
.rgft-bom-row__qtywrap { position: relative; display: block; min-width: 0; }
.rgft-bom-row__qtywrap input[type="number"] { padding-inline-end: 58px; }
.rgft-bom-row__unit {
    position: absolute;
    inset-inline-end: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12.5px;
    color: var(--sk-muted);
    pointer-events: none;
    max-width: 44px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rgft-bom-row__remove {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    border: 1px solid var(--sk-line);
    background: #fff;
    color: var(--sk-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}
.rgft-bom-row__remove:hover { border-color: #d9635a; color: #d9635a; }
.rgft-bom-add {
    display: block;
    width: 100%;
    max-width: 720px;
    height: 46px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--sk-muted);
    background: transparent;
    border: 1px dashed var(--sk-line);
    border-radius: 10px;
    cursor: pointer;
    margin-bottom: 16px;
    transition: border-color .15s, color .15s;
}
.rgft-bom-add:hover { border-color: var(--sk-accent); color: var(--sk-accent); }
.rgft-bom-actions { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
@media (max-width: 700px) {
    .rgft-bom-rows__head { grid-template-columns: 1fr 132px 40px; }
    .rgft-bom-row { grid-template-columns: 1fr 132px 40px; gap: 8px; }
    .rgft-bom-row__remove { width: 40px; height: 46px; }
}
