/* =====================================================================
   Inventory daily flow — Purchase Lists, Quick Receive, Night Closing.
   Simple, touch-friendly screens built around right-side drawers.
   ===================================================================== */

:root {
    --ebf-navy: #2c3e50;
    --ebf-navy-2: #34495e;
    --ebf-green: #27ae60;
    --ebf-green-dark: #1e8c4e;
    --ebf-green-soft: #e8f6ee;
    --ebf-amber: #f39c12;
    --ebf-amber-soft: #fff4e0;
    --ebf-red: #e74c3c;
    --ebf-red-soft: #fdecea;
    --ebf-blue: #2f80ed;
    --ebf-blue-soft: #e8f1fd;
    --ebf-ink: #1f2d3a;
    --ebf-muted: #6b7a89;
    --ebf-line: #e3e8ee;
    --ebf-bg: #f4f6f9;
    --ebf-card: #ffffff;
    --ebf-radius: 12px;
    --ebf-shadow: 0 1px 2px rgba(31, 45, 58, 0.06), 0 4px 14px rgba(31, 45, 58, 0.06);
}

/* ---------- Drawer ---------- */

.ebd-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 40, 0.38);
    z-index: 1060;
    animation: ebd-fade 0.18s ease-out;
}

.ebd-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(var(--ebd-width, 760px), 100vw);
    background: var(--ebf-card);
    z-index: 1061;
    display: flex;
    flex-direction: column;
    box-shadow: -12px 0 32px rgba(20, 30, 40, 0.18);
    animation: ebd-slide 0.22s ease-out;
}

.ebd-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    background: var(--ebf-card);
    color: var(--ebf-ink);
    border-bottom: 1px solid var(--ebf-line);
}

.ebd-title {
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ebd-subtitle {
    font-size: 12px;
    color: var(--ebf-muted);
    margin-top: 2px;
}

.ebd-close {
    border: none;
    background: #eef1f5;
    color: var(--ebf-ink);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ebd-close:hover { background: #e1e6ec; }

.ebd-body {
    background: var(--ebf-card);
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px 24px;
}

.ebd-footer {
    border-top: 1px solid var(--ebf-line);
    background: var(--ebf-card);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

@keyframes ebd-slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ebd-fade { from { opacity: 0; } to { opacity: 1; } }

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

.ebf-btn {
    border: 1px solid var(--ebf-line);
    background: var(--ebf-card);
    color: var(--ebf-ink);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
    white-space: nowrap;
}

.ebf-btn:hover { border-color: #c9d2db; background: #f8fafc; }
.ebf-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.ebf-btn-primary {
    background: var(--ebf-green);
    border-color: var(--ebf-green);
    color: #fff;
    box-shadow: 0 2px 6px rgba(39, 174, 96, 0.28);
}

.ebf-btn-primary:hover { background: var(--ebf-green-dark); border-color: var(--ebf-green-dark); color: #fff; }

.ebf-btn-lg { padding: 11px 20px; font-size: 15px; }
.ebf-btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }

.ebf-btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--ebf-muted);
}

.ebf-btn-ghost:hover { background: rgba(31, 45, 58, 0.06); border-color: transparent; }

.ebf-btn-soft {
    background: var(--ebf-blue-soft);
    border-color: transparent;
    color: var(--ebf-blue);
}

.ebf-btn-soft:hover { background: #d9e8fc; border-color: transparent; }

.ebf-icon-btn {
    border: none;
    background: transparent;
    color: var(--ebf-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ebf-icon-btn:hover { background: var(--ebf-red-soft); color: var(--ebf-red); }

/* ---------- Page header ---------- */

.ebf-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 18px 20px;
    border-radius: var(--ebf-radius);
    background: linear-gradient(135deg, var(--ebf-navy) 0%, var(--ebf-navy-2) 100%);
    color: #fff;
    margin-bottom: 14px;
}

.ebf-page-title { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.ebf-page-sub { font-size: 13px; color: rgba(255, 255, 255, 0.72); margin-top: 2px; }

.ebf-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.ebf-search {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 360px;
}

.ebf-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ebf-muted);
}

.ebf-search input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    border: 1px solid var(--ebf-line);
    border-radius: 10px;
    font-size: 14px;
    background: var(--ebf-card);
}

.ebf-search input:focus,
.ebf-input:focus,
.ebf-select:focus {
    outline: none;
    border-color: var(--ebf-green);
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.15);
}

.ebf-segment {
    display: inline-flex;
    background: #e9edf2;
    border-radius: 10px;
    padding: 3px;
}

.ebf-segment button {
    border: none;
    background: transparent;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ebf-muted);
}

.ebf-segment button.active { background: var(--ebf-card); color: var(--ebf-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }

/* ---------- Cards ---------- */

.ebf-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.ebf-card {
    background: var(--ebf-card);
    border: 1px solid var(--ebf-line);
    border-radius: var(--ebf-radius);
    box-shadow: var(--ebf-shadow);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ebf-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.ebf-card-title { font-weight: 700; color: var(--ebf-ink); font-size: 15px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ebf-card-meta { font-size: 13px; color: var(--ebf-muted); }
.ebf-card-amount { font-size: 20px; font-weight: 700; color: var(--ebf-ink); }
.ebf-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }

.ebf-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: #eef1f5;
    color: var(--ebf-ink);
    white-space: nowrap;
}

.ebf-chip-green { background: var(--ebf-green-soft); color: #18794a; }
.ebf-chip-amber { background: var(--ebf-amber-soft); color: #9a5b00; }
.ebf-chip-blue { background: var(--ebf-blue-soft); color: #1f5fb8; }
.ebf-chip-red { background: var(--ebf-red-soft); color: #b3261e; }
.ebf-chip-grey { background: #eef1f5; color: var(--ebf-muted); }

.ebf-progress { height: 6px; background: #edf0f4; border-radius: 999px; overflow: hidden; }
.ebf-progress > span { display: block; height: 100%; background: var(--ebf-green); border-radius: 999px; transition: width 0.3s; }

.ebf-vendor-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.ebf-empty {
    text-align: center;
    padding: 48px 16px;
    background: var(--ebf-card);
    border: 1px dashed #cdd6df;
    border-radius: var(--ebf-radius);
    color: var(--ebf-muted);
}

.ebf-empty i { font-size: 40px; color: #b7c3cf; }
.ebf-empty h5 { color: var(--ebf-ink); margin: 10px 0 4px; font-weight: 700; }

/* ---------- Forms inside drawers ---------- */

.ebf-input,
.ebf-select {
    width: 100%;
    border: 1px solid var(--ebf-line);
    background: var(--ebf-card);
    border-radius: 9px;
    padding: 8px 10px;
    font-size: 14px;
    color: var(--ebf-ink);
}

.ebf-input-num { text-align: right; font-variant-numeric: tabular-nums; }
.ebf-label { font-size: 12px; font-weight: 600; color: var(--ebf-muted); margin-bottom: 4px; display: block; }

.ebf-row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 14px; }

/* Item search with suggestions */
.ebf-picker { position: relative; }

.ebf-picker-input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    border: 2px solid var(--ebf-green);
    border-radius: 12px;
    font-size: 15px;
    background: var(--ebf-card);
}

.ebf-picker-input:focus { outline: none; box-shadow: 0 0 0 4px rgba(39, 174, 96, 0.15); }

.ebf-picker > i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ebf-green);
    font-size: 17px;
}

.ebf-suggest {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    background: var(--ebf-card);
    border: 1px solid var(--ebf-line);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(20, 30, 40, 0.16);
    z-index: 5;
    max-height: 320px;
    overflow-y: auto;
    padding: 4px;
}

.ebf-suggest button {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 9px 10px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.ebf-suggest button:hover,
.ebf-suggest button.active { background: var(--ebf-green-soft); }

.ebf-suggest .name { font-weight: 600; color: var(--ebf-ink); }
.ebf-suggest .meta { font-size: 12px; color: var(--ebf-muted); }

/* Grouped line lists */
.ebf-group {
    background: var(--ebf-card);
    border: 1px solid var(--ebf-line);
    border-radius: var(--ebf-radius);
    margin-bottom: 12px;
    overflow: hidden;
}

.ebf-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: #f8fafc;
    border-bottom: 1px solid var(--ebf-line);
    flex-wrap: wrap;
}

.ebf-group-title { font-weight: 700; color: var(--ebf-ink); display: flex; align-items: center; gap: 8px; }
.ebf-group-warn { border-color: #f5c77e; }
.ebf-group-warn .ebf-group-head { background: var(--ebf-amber-soft); }

.ebf-line {
    display: grid;
    grid-template-columns: 1fr 96px 96px 96px 170px 32px;
    gap: 8px;
    align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid #f0f3f6;
}

.ebf-line:last-child { border-bottom: none; }
.ebf-line-name { font-weight: 600; color: var(--ebf-ink); line-height: 1.25; }
.ebf-line-sub { font-size: 12px; color: var(--ebf-muted); }

/* Receive rows: tick | item | qty | rate | amount | store */
.ebf-recv {
    display: grid;
    grid-template-columns: 34px 1fr 96px 96px 96px 150px;
    gap: 8px;
    align-items: center;
    padding: 9px 14px;
    border-bottom: 1px solid #f0f3f6;
    transition: background 0.12s, opacity 0.12s;
}

.ebf-recv:last-child { border-bottom: none; }
.ebf-recv.off { background: #fafbfc; }
.ebf-recv.off .ebf-line-name { text-decoration: line-through; color: var(--ebf-muted); }
.ebf-recv.off input:not([type=checkbox]),
.ebf-recv.off select { opacity: 0.45; }
.ebf-recv.extra { background: #f3f9ff; }

.ebf-tick {
    width: 22px;
    height: 22px;
    accent-color: var(--ebf-green);
    cursor: pointer;
}

.ebf-col-head {
    display: grid;
    gap: 8px;
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ebf-muted);
}

.ebf-col-head.lines { grid-template-columns: 1fr 96px 96px 96px 170px 32px; }
.ebf-col-head.recv { grid-template-columns: 34px 1fr 96px 96px 96px 150px; }

.ebf-total-big { font-size: 20px; font-weight: 800; color: var(--ebf-ink); }
.ebf-total-sub { font-size: 12px; color: var(--ebf-muted); }

.ebf-note {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 12px;
}

.ebf-note-info { background: var(--ebf-blue-soft); color: #1f4f8f; }
.ebf-note-warn { background: var(--ebf-amber-soft); color: #7a4800; }
.ebf-note-ok { background: var(--ebf-green-soft); color: #145c38; }

.ebf-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--ebf-ink); margin: 0; }

.ebf-switch input {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: #cfd8e1;
    position: relative;
    cursor: pointer;
    transition: background 0.15s;
    margin: 0;
}

.ebf-switch input::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s;
}

.ebf-switch input:checked { background: var(--ebf-green); }
.ebf-switch input:checked::after { transform: translateX(16px); }
.ebf-switch input:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.25); }

.ebf-success {
    text-align: center;
    padding: 24px 8px 8px;
}

.ebf-success .tick {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--ebf-green-soft);
    color: var(--ebf-green);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
}

.ebf-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid #f0f3f6;
    font-size: 14px;
}

.ebf-result-row:last-child { border-bottom: none; }

/* ---------- Night closing count ---------- */

.ebf-count {
    display: grid;
    grid-template-columns: 1fr 100px 170px 110px;
    gap: 10px;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #f0f3f6;
}

.ebf-count:last-child { border-bottom: none; }
.ebf-count.done { background: #fbfdfb; }
.ebf-col-head.count { grid-template-columns: 1fr 100px 170px 110px; }
.ebf-qty { font-variant-numeric: tabular-nums; text-align: right; }
.ebf-used { font-weight: 700; color: var(--ebf-ink); text-align: right; font-variant-numeric: tabular-nums; }
.ebf-used.excess { color: var(--ebf-amber); }

.ebf-store-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.ebf-store-tab {
    border: 1px solid var(--ebf-line);
    background: var(--ebf-card);
    border-radius: 12px;
    padding: 10px 14px;
    min-width: 150px;
    text-align: left;
    cursor: pointer;
}

.ebf-store-tab.active { border-color: var(--ebf-green); box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.15); }
.ebf-store-tab .name { font-weight: 700; color: var(--ebf-ink); }
.ebf-store-tab .meta { font-size: 12px; color: var(--ebf-muted); }

.ebf-sticky-bar {
    position: sticky;
    bottom: 0;
    background: var(--ebf-card);
    border: 1px solid var(--ebf-line);
    border-radius: var(--ebf-radius);
    box-shadow: 0 -6px 20px rgba(20, 30, 40, 0.08);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
    z-index: 2;
}

/* ---------- Phone ---------- */

@media (max-width: 640px) {
    .ebd-body { padding: 12px 12px 20px; }
    .ebd-header, .ebd-footer { padding: 12px; }
    .ebf-col-head.lines, .ebf-col-head.recv, .ebf-col-head.count { display: none; }

    .ebf-line { grid-template-columns: 1fr 1fr 32px; }
    .ebf-line > .ebf-line-main { grid-column: 1 / 3; }
    .ebf-line > .ebf-line-amount { grid-column: 1 / 3; }
    .ebf-line > .ebf-line-vendor { grid-column: 1 / 3; }

    .ebf-recv { grid-template-columns: 34px 1fr 1fr; }
    .ebf-recv > .ebf-line-main { grid-column: 2 / 4; }
    .ebf-recv > .ebf-recv-amount { grid-column: 2 / 4; }
    .ebf-recv > .ebf-recv-store { grid-column: 2 / 4; }
    .ebf-recv > .ebf-recv-qty { grid-column: 2 / 3; }

    .ebf-count { grid-template-columns: 1fr 1fr; }
    .ebf-count > .ebf-line-main { grid-column: 1 / 3; }

    .ebf-card-grid { grid-template-columns: 1fr; }
}

/* Dashboard quick links */
.ebf-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

/* ---------- Radzen dialogs shown as a right-side white drawer ---------- */

.rz-dialog.ebd-radzen-drawer {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: auto !important;
    margin: 0 !important;
    height: 100vh !important;
    max-height: 100vh !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
    /* The workspaces still pass the old "centre it" inline style (left/top 50% + translate(-50%, -50%)).
       left/top are overridden above; the translate has to go too or the drawer slides half off screen. */
    transform: none !important;
    background: var(--ebf-card, #fff) !important;
    box-shadow: -12px 0 32px rgba(20, 30, 40, 0.18) !important;
    display: flex;
    flex-direction: column;
}

.rz-dialog.ebd-radzen-drawer .rz-dialog-titlebar {
    background: var(--ebf-card, #fff) !important;
    color: var(--ebf-ink, #1f2d3a) !important;
    border-bottom: 1px solid var(--ebf-line, #e3e8ee);
}

.rz-dialog.ebd-radzen-drawer .rz-dialog-title { color: var(--ebf-ink, #1f2d3a) !important; font-weight: 700; }

.rz-dialog.ebd-radzen-drawer .rz-dialog-content {
    flex: 1 1 auto;
    height: auto !important;
    overflow-y: auto;
    background: var(--ebf-card, #fff) !important;
}

/* ---------- Quick add (item / vendor) inside purchase drawers ---------- */

.ebf-quick-add {
    border: 1px solid var(--ebf-line);
    border-left: 4px solid var(--ebf-green);
    background: var(--ebf-card);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.ebf-quick-add-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--ebf-ink);
    margin-bottom: 10px;
}

.ebf-quick-add-grid { display: grid; gap: 10px; grid-template-columns: 2fr 1fr 1fr 1fr; }
.ebf-quick-add-error { color: #b42318; font-size: 13px; margin-top: 8px; }
.ebf-quick-add-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* "+ Add new item" row at the bottom of the item search */
.ebf-suggest button.ebf-suggest-add { color: var(--ebf-green); font-weight: 600; justify-content: flex-start; border-top: 1px solid var(--ebf-line); border-radius: 0 0 8px 8px; }
.ebf-suggest .ebf-suggest-empty { padding: 9px 10px; font-size: 13px; color: var(--ebf-muted); }

/* Searchable vendor dropdown */
.ebf-vpick { position: relative; min-width: 0; }
.ebf-vpick-toggle { display: flex; align-items: center; justify-content: space-between; gap: 6px; text-align: left; cursor: pointer; }
.ebf-vpick-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ebf-vpick-value.placeholder { color: var(--ebf-muted); }
.ebf-vpick-backdrop { position: fixed; inset: 0; z-index: 9; }
.ebf-vpick-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    width: max(100%, 260px);
    background: var(--ebf-card);
    border: 1px solid var(--ebf-line);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(20, 30, 40, 0.16);
    z-index: 10;
    padding: 6px;
}
.ebf-vpick-search { margin-bottom: 4px; }
.ebf-vpick-list { max-height: 220px; overflow-y: auto; }
.ebf-vpick-list button,
.ebf-vpick-add {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--ebf-ink);
}
.ebf-vpick-list button:hover,
.ebf-vpick-list button.active { background: var(--ebf-green-soft); }
.ebf-vpick-add { color: var(--ebf-green); font-weight: 600; border-top: 1px solid var(--ebf-line); border-radius: 0 0 8px 8px; }
.ebf-vpick-add:hover { background: var(--ebf-green-soft); }
.ebf-vpick-empty { padding: 8px 10px; font-size: 13px; color: var(--ebf-muted); }
.ebf-vpick-form { padding: 6px; }

/* Let an open vendor menu or item-search dropdown escape the rounded group box (it clips with overflow:hidden) */
.ebf-group:has(.ebf-vpick-menu),
.ebf-group:has(.ebf-suggest) { overflow: visible; }
.ebf-group:has(.ebf-vpick-menu) .ebf-group-head,
.ebf-group:has(.ebf-suggest) .ebf-group-head { border-radius: var(--ebf-radius) var(--ebf-radius) 0 0; }

@media (max-width: 640px) {
    .ebf-quick-add-grid { grid-template-columns: 1fr; }
}
