/* ----------------------------------------------------------
   Inventory ERP - shared styles
   Restrained, neutral palette. No accent colours.
   ---------------------------------------------------------- */

* { box-sizing: border-box; }

:root {
    --bg:        #f4f5f7;
    --surface:   #ffffff;
    --border:    #e2e4e8;
    --border-in: #cfd3d9;
    --text:      #1f2430;
    --text-soft: #6b7280;
    --text-mute: #9aa0aa;
    --ink:       #2b3440;   /* buttons / dark elements */
    --ink-hover: #3a4552;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Lato', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* Login screen styling lives in assets/login.css (page-specific, like
   dashboard.css) - login.php links it directly. */

/* ---- App shell (dashboard) ---------------------------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-left  { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.topbar-mark {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    background: var(--ink);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.topbar-name { font-weight: 600; }

.topbar-user { font-size: 13px; color: var(--text-soft); }

.btn-plain {
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    padding: 6px 12px;
    border: 1px solid var(--border-in);
    border-radius: 5px;
}

.btn-plain:hover { background: var(--bg); }

.page {
    max-width: 760px;
    margin: 0 auto;
    padding: 32px 20px;
}

.page-title {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 600;
}

.page-note {
    margin: 0 0 24px;
    font-size: 13px;
    color: var(--text-soft);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.card-title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
}

.card p { margin: 0; color: var(--text-soft); }

/* ====================================================================
   Inventory Master — application UI
   ==================================================================== */

:root {
    --danger:      #8a3b3b;
    --danger-bg:   #f8eeee;
    --danger-bd:   #e6cfcf;
    --ok-bg:       #eef2ee;
    --ok-bd:       #d3ded3;
    --ok-text:     #3a5a3a;
    --radius:      6px;
    --focus:       #2f5fb0;   /* keyboard focus ring */
}

/* ---- Keyboard focus: visible on every interactive element -------- */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.module-card:focus-visible,
.nav-link:focus-visible,
.nav-brand:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}
/* Mouse clicks should not leave a ring; keyboard focus still does. */
:focus:not(:focus-visible) { outline: none; }
.module-card:focus-visible { outline-offset: 3px; }
#main:focus, .modal:focus { outline: none; }
.modal-x:focus-visible { outline-offset: -2px; }

/* ---- Skip link (first Tab stop) -------------------------------- */
.skip-link {
    position: absolute;
    left: 8px;
    top: -60px;
    z-index: 100;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: var(--ink);
    border-radius: 0 0 6px 6px;
    text-decoration: none;
    transition: top 0.15s ease;
}
.skip-link:focus { top: 0; }

/* Visually hidden but still read by screen readers. Lives here because the
   shared header (layout.php) uses it on every page. */
.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---- Top navigation (no sidebar) --------------------------------- */
.nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.nav-inner {
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 20px;
    height: 56px;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}
/* ---- organisation logo, top-left on every page ---- */
.nav-org-logo {
    display: flex;
    align-items: center;
    height: 100%;
}
.nav-org-logo img {
    display: block;
    height: 40px;
    width: auto;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}
.nav-link {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-soft);
    text-decoration: none;
    border-radius: 5px;
    white-space: nowrap;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.is-active { color: var(--text); background: var(--bg); font-weight: 600; }
.nav-user { display: flex; align-items: center; gap: 12px; }

/* ---- live clock, top-right next to the account avatar on every page --
   ships hidden and JS reveals it on the first tick (see app.js) - values
   come from the browser so it shows the viewer's own local time -------- */
.nav-clock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.25;
    text-align: right;
    white-space: nowrap;
}
/* the author `display` above always beats the browser's own [hidden] rule
   regardless of specificity, so restore it explicitly */
.nav-clock[hidden] { display: none; }
.nav-clock-time {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.nav-clock-date {
    font-size: 11px;
    color: var(--text-soft);
}
@media (max-width: 560px) {
    .nav-clock-date { display: none; }
}

/* ---- account menu ---- */
.nav-profile { position: relative; }
.nav-avatar {
    width: 32px; height: 32px; padding: 0;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--ink);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; letter-spacing: 0.3px;
    font-family: inherit;
    cursor: pointer;
    transition: box-shadow .12s ease, transform .12s ease;
}
.nav-avatar:hover { box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12); }
.nav-avatar:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.nav-avatar[aria-expanded="true"] { box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.18); }
.nav-avatar-lg { width: 38px; height: 38px; font-size: 13px; cursor: default; flex: none; }
/* generic account-silhouette glyph inside the avatar circle - fill for the
   head/shoulders, stroke none, so it reads as a solid icon on the dark
   circle background (matches the plain "no photo" avatar look) */
.nav-avatar-ic {
    width: 20px; height: 20px;
    fill: currentColor;
    stroke: none;
}
.nav-avatar-lg .nav-avatar-ic { width: 24px; height: 24px; }

.nav-profile-menu {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
    min-width: 210px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(11, 28, 48, 0.14);
    overflow: hidden;
}
.nav-profile-menu[hidden] { display: none; }
.nav-profile-head {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
}
.nav-profile-id { min-width: 0; }
.nav-profile-id b {
    display: block; font-size: 13px; font-weight: 600; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-profile-id span {
    display: block; font-size: 11px; color: var(--text-soft);
    font-family: var(--font-mono);
}
.nav-profile-item {
    display: block;
    padding: 11px 14px;
    font-size: 13px; color: var(--text); text-decoration: none;
}
.nav-profile-item:hover { background: var(--bg); }
.nav-profile-item:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }

.wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

/* ---- Page header ------------------------------------------------- */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.page-title { margin: 0; font-size: 20px; font-weight: 600; }
.page-sub { margin: 4px 0 0; font-size: 13px; color: var(--text-soft); }

/* ---- Dashboard cards ------------------------------------------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}
.module-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.module-card:hover {
    border-color: var(--border-in);
    box-shadow: 0 6px 20px rgba(16, 24, 40, 0.07);
    transform: translateY(-2px);
}
.module-card-kicker { font-size: 12px; color: var(--text-mute); font-weight: 600; letter-spacing: 1px; }
.module-card-title { margin: 0; font-size: 16px; font-weight: 600; }
.module-card-text { margin: 0; font-size: 13px; color: var(--text-soft); flex: 1; }
.module-card-go { font-size: 13px; font-weight: 600; color: var(--ink); }

/* ---- Toolbar -------------------------------------------------- */
.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.toolbar #search { flex: 1; min-width: 220px; }

/* ---- Form controls ------------------------------------------ */
.control {
    width: 100%;
    padding: 11px 14px;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border-in);
    border-radius: 5px;
    outline: none;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
select.control { max-width: 220px; }
.toolbar select.control { max-width: none; width: auto; }
.control:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(43, 52, 64, 0.10);
}
.control.is-readonly, .control[readonly] {
    background: var(--bg);
    color: var(--text-soft);
}
textarea.control { resize: vertical; min-height: 68px; }

/* ---- Buttons ---------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    /* same padding/font-size as .pill ("+ Create Item"), not just the same
       border-radius - so every button in the app is the same size, not
       just the same shape */
    padding: 8px 16px;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: var(--ink-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border-in); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger-bd); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* ---- Data grid ------------------------------------------ */
.grid-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}
.grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.grid th, .grid td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.grid thead th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-soft);
    background: var(--bg);
}
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr:hover td { background: #fafbfc; }
.grid-empty { text-align: center; color: var(--text-soft); padding: 28px 14px; }
.grid-actions { text-align: right; }
.grid-actions .btn { margin-left: 4px; }

/* ---- Status badge -------------------------------------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid transparent;
}
.badge-on  { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-bd); }
.badge-off { background: var(--bg); color: var(--text-mute); border-color: var(--border-in); }

/* ---- Modal -------------------------------------------- */
.modal {
    border: none;
    border-radius: 8px;
    padding: 0;
    width: min(760px, 94vw);
    max-height: 90vh;
    box-shadow: 0 20px 60px rgba(16, 24, 40, 0.25);
    color: var(--text);
    background: var(--surface);
}
.modal::backdrop { background: rgba(16, 24, 40, 0.45); }
.modal-inner { display: flex; flex-direction: column; max-height: 90vh; }
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-head-actions { display: flex; align-items: center; gap: 10px; }
.modal-x {
    border: none; background: none; cursor: pointer;
    font-size: 22px; line-height: 1; color: var(--text-mute);
}
.modal-x:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

/* ---- Form layout ------------------------------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 22px 24px;
}
/* Single-box create/edit forms: every field in ONE grid, in row order, so
   Tab moves left-to-right across the row instead of down one card and
   then the next. .form-part splits the rest of the same box (item lines,
   summary) with a divider instead of a separate headed card. */
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-part { margin-top: 22px; padding-top: 20px; border-top: 1px solid #eef2f9; }
.form-part-toolbar { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.form-part-toolbar .sec-head-actions { margin-left: 0; }
@media (max-width: 1100px) {
    .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.form-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.form-field.col-2 { grid-column: span 2; }
.form-field.col-full { grid-column: 1 / -1; }
.form-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-soft);
}
.field-help { font-size: 12px; color: var(--text-mute); }
.field-err { font-size: 12px; color: var(--danger); }
.form-field.has-error .control { border-color: var(--danger-bd); box-shadow: 0 0 0 3px rgba(138, 59, 59, 0.10); }
.form-error {
    margin: 0 0 14px;
    padding: 9px 12px;
    font-size: 12px;
    color: var(--danger);
    background: var(--danger-bg);
    border: 1px solid var(--danger-bd);
    border-radius: 5px;
}
.file-current { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline-check { font-size: 12px; color: var(--text-soft); display: flex; align-items: center; gap: 5px; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.thumb-lg { max-width: 160px; border-radius: 6px; border: 1px solid var(--border); }
.doc-list { margin: 4px 0 0; padding-left: 18px; font-size: 12px; }
.doc-list li { margin: 2px 0; }

/* ---- View panel ------------------------------------- */
.view-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 20px;
}
.view-cell { min-width: 0; }
.view-cell dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-mute); margin: 0 0 2px; }
.view-cell dd { margin: 0; font-size: 13px; word-break: break-word; }

/* ---- Toast ----------------------------------------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    padding: 10px 18px;
    font-size: 13px;
    border-radius: 6px;
    background: var(--ink);
    color: #fff;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.2);
    z-index: 60;
}
.toast-err { background: var(--danger); }
.toast-ok  { background: #15803d; }

@media (max-width: 640px) {
    .form-grid, .view-grid { grid-template-columns: 1fr; }
    .form-field.col-2 { grid-column: auto; }
    .nav-links { overflow-x: auto; }
    .page-head { flex-direction: column; align-items: flex-start; }
}


/* ---- Global header search (all app pages) ------------------------ */
.nav-links { flex: none; }

.gsearch {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 520px;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.gsearch:focus-within {
    background: #fff;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}
.gsearch-ic {
    width: 15px; height: 15px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
    color: var(--text-mute);
}
.gsearch-input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 12.5px;
    color: var(--text);
    outline: none;
    padding: 0;
}
.gsearch-input::placeholder { color: var(--text-mute); }
.gsearch-input::-webkit-search-cancel-button { cursor: pointer; }
.gsearch-kbd {
    flex: none;
    padding: 1px 6px;
    font-size: 10px;
    font-family: 'Lato', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-mute);
    background: #fff;
    border: 1px solid var(--border-in);
    border-radius: 4px;
}
.gsearch:focus-within .gsearch-kbd { display: none; }

.gsearch-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 60;
    max-height: 62vh;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border-in);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(16, 24, 40, 0.16);
    padding: 6px;
}
.gsearch-group + .gsearch-group { margin-top: 4px; }
.gsearch-gl {
    display: block;
    padding: 7px 10px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-mute);
}
.gsearch-opt {
    display: block;
    padding: 7px 10px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    cursor: pointer;
}
.gsearch-opt:hover,
.gsearch-opt.is-active { background: var(--bg); }
.gsearch-opt.is-active { box-shadow: inset 2px 0 0 var(--ink); }
.gsearch-opt b { display: block; font-size: 12.5px; font-weight: 600; }
.gsearch-opt span { display: block; font-size: 11px; color: var(--text-soft); margin-top: 1px; }
.gsearch-note { padding: 12px 10px; font-size: 12px; color: var(--text-mute); text-align: center; }

@media (max-width: 900px) {
    .gsearch { display: none; }
}

/* ======================================================================
   Compact create/edit forms - every master + transaction form
   (.item-form: Item, Warehouse, Rack, UOM, GRN, Stock Transfer) and the
   inline "+ Create ..." forms inside the picker popups (.wh-create-view).
   Smaller, soft-rounded boxes and small labels so the page reads less
   crowded; field order (and so Tab order) is unchanged.
   ====================================================================== */
.item-form .form-section {
    padding: 20px 22px 22px;
    border-radius: 14px;
}
.item-form .form-grid,
.wh-create-view .form-grid { gap: 14px 16px; }
.item-form .form-field,
.wh-create-view .form-field { gap: 5px; }
.item-form .form-field label,
.wh-create-view .form-field label {
    font-size: 11.5px;
    font-weight: 600;
    color: #475569;
    letter-spacing: 0.01em;
}
.item-form .control,
.wh-create-view .control {
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.35;
    border: 1px solid #dbe2ee;
    border-radius: 10px;
    background-color: #ffffff;
}
.item-form .control.is-readonly,
.item-form .control[readonly],
.wh-create-view .control.is-readonly,
.wh-create-view .control[readonly] { background-color: #f4f6fa; }
/* selects line up with the inputs beside them instead of stopping at 220px */
.item-form select.control,
.wh-create-view select.control { max-width: none; }
.item-form textarea.control,
.wh-create-view textarea.control { min-height: 58px; }
.item-form .field-help,
.item-form .field-err,
.wh-create-view .field-help { font-size: 11px; }
.item-form .form-part { margin-top: 18px; padding-top: 16px; }
.item-form .form-actions { margin-top: 16px; }
/* keep Item Master's green "Available Stocks" box (item-master.css) */
.item-form .control.stock-field { background-color: #f0fdf4; border-color: #86efac; }

/* read-only boxes that open a popup when clicked (Warehouse, Rack, Supplier...) */
.item-form .picker-input { cursor: pointer; }
.item-form .picker-input:disabled { cursor: not-allowed; opacity: 0.7; }

/* ---- "Summary" block (GRN / Stock Transfer / Stock Adjustment create & edit):
   title + one-line note + a soft card of label/value rows, typed amounts
   in small right-aligned boxes, a divider and a bold blue Grand Total. ---- */
/* compact card on the right-hand side of the form, under the item lines */
.sum-block { width: min(400px, 100%); margin-left: auto; }
.sum-title { margin: 0 0 4px; font-size: 14px; font-weight: 700; color: #0f172a; }
.sum-note { margin: 0 0 10px; font-size: 11.5px; line-height: 1.45; color: #64748b; }
.sum-card {
    padding: 4px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}
.sum-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 38px;
    font-size: 13px;
    color: #475569;
}
.sum-row b { font-weight: 600; color: #0f172a; font-variant-numeric: tabular-nums; }
.sum-row label { font-size: 13px; font-weight: 400; color: #475569; }
.item-form .sum-row .control.sum-input { width: 140px; max-width: 50%; padding-top: 6px; padding-bottom: 6px; text-align: right; font-variant-numeric: tabular-nums; }
.sum-grand { margin-top: 4px; padding-top: 6px; padding-bottom: 4px; border-top: 1px solid #e2e8f0; }
.sum-grand span { font-size: 14px; font-weight: 700; color: #0f172a; }
.sum-grand b { font-size: 16px; font-weight: 700; color: #1d4ed8; }

/* stock-on-hand figures in the item/rack pickers read green */
.stock-avail { color: #15803d; font-weight: 600; }

/* UOM Master filter popup: wider than the shared 340/460px default */
#masterFilterModal.has-uom-filter { width: min(600px, 96vw); max-height: 88vh; }
#masterFilterModal.has-uom-filter .modal-inner { max-height: 88vh; overflow: hidden; }
#masterFilterModal.has-uom-filter .modal-body { overflow-y: auto; overflow-x: hidden; }

/* ---- every popup in the app: soft rounded corners + gentle shadow ----
   The head/foot get the matching corner radius so their tinted
   backgrounds follow the curve (no overflow:hidden, which could clip a
   popup's own scrolling body). */
dialog.modal {
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.28);
}
dialog.modal .modal-head { border-radius: 16px 16px 0 0; }
dialog.modal .modal-foot { border-radius: 0 0 16px 16px; }

/* ---- popup dropdowns (app.js popupSelects): searchable list that opens
   INSIDE the popup instead of spilling out over the page ---- */
.psel-native { display: none !important; }
.psel { position: relative; }
.psel-row { position: relative; }
.psel-row .psel-input { width: 100%; box-sizing: border-box; padding-right: 34px; cursor: pointer; }
.psel.is-open .psel-input { cursor: text; }
.psel-toggle {
    position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
    width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px;
    background: transparent; color: #64748b; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.psel-toggle:hover { background: #f1f5f9; }
.psel-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.psel.is-open .psel-toggle svg { transform: rotate(180deg); }
.psel-list {
    list-style: none; margin: 6px 0 0; padding: 4px;
    max-height: 220px; overflow-y: auto;          /* in the flow: the popup grows/scrolls, nothing overflows it */
    background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
    box-shadow: 0 8px 20px -10px rgba(15, 23, 42, .25);
}
.psel-opt { padding: 8px 10px; border-radius: 7px; font-size: 13px; color: #1e293b; cursor: pointer; }
.psel-opt:hover { background: #f1f5f9; }
.psel-opt.is-active { background: #1e3a8a; color: #fff; }
.psel-opt.is-selected:not(.is-active) { font-weight: 700; color: #1e3a8a; }
.psel-empty { padding: 10px; font-size: 12.5px; color: #94a3b8; text-align: center; }

/* Create Item / Create Warehouse views inside a popup: room for the open list */
dialog.modal:has(.psel) { width: min(720px, 96vw); }
dialog.modal .modal-body:has(.psel.is-open) { min-height: 360px; }
/* ---- Record "View" popup (app.js RecordView, partials/record-view.php):
   Stock Transfer / Adjustment / Reservation. Same look as Item Master's
   View popup - rounded, light head, details grid, item table - defined
   here because item-master.css can't be loaded on other pages. ---- */
dialog.rec-view-modal { width: min(1140px, 96vw); max-height: 90vh; padding: 0; background: #fff; }
.rec-view-modal .modal-inner { max-height: 90vh; display: flex; flex-direction: column; }
.rec-view-modal .modal-head { background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
.rec-view-modal .modal-head h2 { color: #0f172a; }
.rec-view-modal .modal-body { overflow-y: auto; padding: 18px 22px 20px; }
.rec-view-modal::backdrop { background: rgba(11, 28, 48, 0.4); }
.rv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid #eef2f7; }
.rv-head .view-code { margin: 0; font-family: 'Lato', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 13px; color: #64748b; }
.rv-head .view-name { margin: 2px 0 6px; font-size: 17px; color: #0f172a; }
.rv-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 18px; margin: 0; }
.rv-grid .view-cell.col-full { grid-column: 1 / -1; }
.rv-grid .view-cell dd { color: #0f172a; font-weight: 500; white-space: pre-line; }
.rv-subhead { margin: 18px 0 8px; font-size: 13px; font-weight: 700; color: #0f172a; }
.rv-table-wrap { max-height: 320px; overflow: auto; border: 1px solid #e5eaf3; border-radius: 12px; }
.rv-table { width: 100%; margin: 0; border-collapse: collapse; font-size: 12.5px; }
.rv-table th { position: sticky; top: 0; z-index: 1; background: #f8fafc; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: #64748b; white-space: nowrap; }
.rv-table th, .rv-table td { padding: 8px 10px; border-bottom: 1px solid #eef2f7; text-align: left; vertical-align: top; }
.rv-table tbody tr:last-child td { border-bottom: none; }
.rv-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.rv-table .num-c { text-align: center; width: 48px; }
.rv-table .rv-qty { width: 100px; margin-left: auto; display: block; text-align: right; padding: 5px 8px; }
.rv-sub { display: block; font-size: 10.5px; color: #b45309; font-weight: 600; }
.rv-totals { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 22px; margin-top: 10px; font-size: 12.5px; color: #475569; }
.rv-totals b { margin-left: 6px; color: #0f172a; font-variant-numeric: tabular-nums; }
.rv-section { margin-top: 16px; padding-top: 4px; border-top: 1px solid #eef2f7; }
.rv-form .form-error { margin: 8px 0; }
.rv-form-actions, .rv-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.rv-actions { padding-top: 14px; border-top: 1px solid #eef2f7; }
@media (max-width: 760px) { .rv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 440px) { .rv-grid { grid-template-columns: 1fr; } .rec-view-modal .modal-body { padding: 14px; } }

/* ---- every popup + filter popup: soft off-white header instead of the
   old light-blue tint. dialog.modal is more specific than the per-page
   .modal/.wh-modal/.item-modal/.view-modal head rules in erp-ui.css and
   item-master.css, so this one rule covers every popup in the app.
   Table header rows inside popups (item / warehouse / supplier pickers)
   get the same neutral tone. ---- */
dialog.modal .modal-head {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
dialog.modal .modal-head h2 { color: #0f172a; }
dialog.modal .wh-table thead th {
    background: #f8fafc;
    color: #475569;
}

/* ---- the 8 module main (list) pages - Item, Warehouse, Rack, UOM, GRN,
   Stock Transfer, Stock Adjustment, Stock Reservation: list rows read in
   CAPITAL LETTERS (their column headings already are). Display only - the
   saved data keeps its own case; forms, popups and other pages are unchanged.
   .im-grid is used only by those eight list tables. ---- */
.im-grid tbody td:not(.grid-empty) { text-transform: uppercase; }

/* form controls don't inherit the page font by default - make every button,
   input, select and textarea use Lato like the rest of the page */
button, input, select, textarea, optgroup { font-family: inherit; }
