/* ── Glow Card ── */
.glow-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    overflow: visible;
    border-bottom: 1px solid transparent;
    border-image: linear-gradient(90deg, transparent, rgba(var(--glow-rgb), .75), transparent) 1;
}

.glow-card::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: calc(var(--radius) + 1px);
    background: radial-gradient(var(--glow-size) circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb), .35), transparent 40%);
    z-index: -2;
    opacity: 0;
    transition: opacity .35s;
    pointer-events: none;
}

.glow-card::after {
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: calc(var(--radius) - 1px);
    background: var(--bg-card);
    z-index: -1;
    pointer-events: none;
}

.glow-card:hover::before {
    opacity: 1;
}

/* ── Glow Input ── */
.glow-input {
    margin-bottom: 16px;
    width: 100%;
    z-index: 1;
    position: relative;
}

.glow-input::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 9px;
    background: radial-gradient(220px circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb), .4), transparent 40%);
    z-index: -2;
    opacity: 0;
    transition: opacity .35s;
    pointer-events: none;
}

.glow-input::after {
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: 7px;
    background: var(--bg-input);
    z-index: -1;
    pointer-events: none;
}

.glow-input:hover::before,
.glow-input:focus-within::before {
    opacity: 1;
}

.glow-input input {
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: .95rem;
    outline: none;
    position: relative;
    z-index: 1;
}

.glow-input input:focus {
    color: #fff;
}

/* Global autofill override — prevent white flash on every input/select/textarea.
   Do NOT put -webkit-text-fill-color in the long transition: Chrome interpolates it over 99999s,
   so text stays the UA default (black) and looks invisible on dark fields. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
input:-internal-autofill-selected,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus,
select:-webkit-autofill:active,
select:-internal-autofill-selected,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
textarea:-webkit-autofill:active,
textarea:-internal-autofill-selected,
input:autofill,
input:autofill:hover,
input:autofill:focus,
textarea:autofill,
textarea:autofill:hover,
textarea:autofill:focus,
select:autofill,
select:autofill:hover,
select:autofill:focus {
    -webkit-text-fill-color: var(--text) !important;
    -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset !important;
    box-shadow: 0 0 0 1000px var(--bg-input) inset !important;
    caret-color: var(--text) !important;
    transition: background-color 99999s ease-out 0s !important;
    background-color: var(--bg-input) !important;
    color: var(--text) !important;
}

.glow-input:focus-within input:-webkit-autofill,
.glow-input:focus-within input:-webkit-autofill:hover,
.glow-input:focus-within input:-webkit-autofill:focus,
.glow-input:focus-within input:-internal-autofill-selected,
.glow-input:focus-within input:autofill,
.glow-input:focus-within input:autofill:hover,
.glow-input:focus-within input:autofill:focus {
    -webkit-text-fill-color: #fff !important;
    caret-color: #fff !important;
    color: #fff !important;
    -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset !important;
    box-shadow: 0 0 0 1000px var(--bg-input) inset !important;
}

.glow-input input[type="date"] {
    color-scheme: dark;
    text-align: center;
    font-family: inherit;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.glow-input.field-error::after {
    all: unset;
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: 7px;
    background: rgba(255, 82, 82, 0.06);
    z-index: -1;
    pointer-events: none;
    border: 1px solid rgba(255, 82, 82, 0.3);
}

.glow-input.field-error:hover::before,
.glow-input.field-error:focus-within::before {
    opacity: 0;
}

.glow-input.field-error input:focus {
    color: #ff8a80;
}

/* ── Custom Color Picker (Pickr nano; swatch element hosts the button) ── */
.glow-input.color-picker-wrap {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1;
}

.glow-input.color-picker-wrap input[type="text"] {
    flex: 1;
    min-width: 0;
    padding-left: 12px;
}

/* Swatch must sit above the hex field (input uses z-index: 1) so clicks open Pickr on all layouts. */
.glow-input.color-picker-wrap .custom-color-swatch {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    min-width: 30px;
    min-height: 30px;
}

/*
 * Pickr nano: closed panels lose .visible — hide fully so no ghost box (e.g. top-left).
 * Open panel: .visible + high z-index above admin sidebar / modals.
 */
.pcr-app:not(.visible) {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.pcr-app.visible {
    z-index: 2147483646 !important;
}

.pcr-app {
    background: #111827 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55) !important;
    border-radius: 14px !important;
    color: #e2e8f0 !important;
    padding: 14px !important;
}

.pcr-app::before {
    content: '';
    position: absolute;
    inset: 0;
    background: #111827;
    border-radius: 14px;
    z-index: -1;
    pointer-events: none;
}

.pcr-app .pcr-interaction {
    display: none !important;
}

.pcr-app .pcr-selection .pcr-color-palette {
    border-radius: 10px !important;
    overflow: hidden !important;
}

.pcr-app .pcr-selection .pcr-color-preview {
    width: 28px !important;
    min-width: 28px !important;
    border-radius: 8px !important;
    margin-right: 12px !important;
    overflow: hidden !important;
    flex-shrink: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.pcr-app .pcr-selection .pcr-color-preview .pcr-last-color {
    display: none !important;
}

.pcr-app .pcr-selection .pcr-color-preview .pcr-current-color {
    border-radius: 8px !important;
    width: 100% !important;
    height: 100% !important;
}

.pcr-app .pcr-selection .pcr-color-chooser {
    height: 14px !important;
    border-radius: 8px !important;
    margin-top: 10px !important;
    overflow: hidden !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.pcr-app .pcr-color-opacity {
    display: none !important;
}

/* ── Glow Date Select ── */
.glow-date-select {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    width: 100%;
    position: relative;
}

.glow-date-select .date-display {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    letter-spacing: 1px;
    flex: 1;
}

.glow-date-select svg {
    color: var(--text-muted);
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.glow-date-select input[type="date"] {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    opacity: 0 !important;
    cursor: pointer;
    z-index: 2;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    color: transparent !important;
    font-size: 0 !important;
    text-align: left !important;
    font-weight: 400 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    border: none !important;
    outline: none !important;
    -webkit-appearance: none;
    appearance: none;
}

/* ── Glow Button ── */
.glow-btn {
    position: relative;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 10px 20px;
    border: none;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    font-size: .9rem;
    transition: background .2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 0;
}

.glow-btn::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 9px;
    background: radial-gradient(200px circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb), .6), transparent 100%);
    z-index: -2;
    opacity: 0;
    transition: opacity .35s;
    pointer-events: none;
}

.glow-btn::after {
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: 7px;
    background: var(--bg-card);
    z-index: -1;
    transition: background .2s;
    pointer-events: none;
}

.glow-btn:hover::before {
    opacity: 1;
}

.glow-btn:hover::after {
    background: #131a24;
}

.glow-btn.success {
    color: #000;
    font-weight: 700;
}

.glow-btn.success::after {
    background: var(--glow);
}

.glow-btn.success:hover::after {
    filter: brightness(1.1);
}

.glow-btn:disabled,
.glow-btn:disabled::before,
.glow-btn:disabled::after {
    cursor: not-allowed;
    opacity: 1;
}

.glow-btn:disabled {
    color: var(--text-muted);
}

.glow-btn:disabled::before {
    opacity: 0;
}

.glow-btn:disabled::after {
    background: var(--border);
    filter: none;
}

.glow-btn.success:disabled {
    color: var(--text-muted);
}

.glow-btn:disabled:hover::before {
    opacity: 0;
}

.glow-btn:disabled:hover::after {
    filter: none;
}

.glow-btn.danger {
    color: #ff5252;
}

.glow-btn.danger::after {
    background: rgba(255, 82, 82, 0.1);
}

/* ── FAB ── */
.fab {
    position: fixed;
    bottom: 35px;
    right: 35px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--glow);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(var(--glow-rgb), 0.4);
    cursor: pointer;
    z-index: 90;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
}

.fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(var(--glow-rgb), 0.6);
}

.fab svg {
    width: 28px;
    height: 28px;
    stroke: #000;
    stroke-width: 2.5;
}

/* ── Actions ── */
.icon-action-btn {
    background: transparent;
    border: none;
    padding: 6px;
    cursor: pointer;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.icon-action-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

.icon-action-btn.edit svg {
    stroke: var(--glow);
}

.icon-action-btn.delete svg {
    stroke: #ff5252;
}

.icon-action-btn.print svg {
    stroke: var(--glow);
}

.icon-action-btn.approve svg {
    stroke: var(--glow);
}

.icon-action-btn.suspend svg {
    stroke: #ffab40;
}

/* ── Modals ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 8, .88);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 200;
    justify-content: center;
    align-items: center;
    padding: 20px 15px;
    overflow-y: auto;
}

.modal-box {
    background: var(--bg-card);
    padding: 32px;
    border-radius: 18px;
    width: 100%;
    max-width: 480px;
    position: relative;
    border-bottom: 1px solid transparent;
    border-image: linear-gradient(90deg, transparent, rgba(var(--glow-rgb), .85), transparent) 1;
    margin: auto;
    overflow: visible;
}

.modal-box::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 19px;
    background: radial-gradient(600px circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb), .4), transparent 40%);
    z-index: -2;
    opacity: 0;
    transition: opacity .35s;
    pointer-events: none;
}

.modal-box::after {
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: 17px;
    background: var(--bg-card);
    z-index: -1;
    pointer-events: none;
}

.modal-box:hover::before {
    opacity: 1;
}

.popup-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color .2s, background .2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Pinned upper-right on table cards; inline styles also set in EJS so layout is correct before/without CSS bundle edge cases */
.card-sync-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    left: auto;
    margin: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    cursor: help;
    line-height: 0;
    direction: ltr;
}

.card-sync-indicator > span {
    display: inline-flex;
    align-items: center;
}

.card-sync-indicator svg {
    display: block;
}

/* ── Tables ── */
.table-responsive {
    overflow-x: auto;
    margin: 0 -24px;
    padding: 0 24px;
    width: calc(100% + 48px);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    min-width: 500px;
}

th {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    color: var(--text);
    font-size: 0.85rem;
    vertical-align: middle;
    white-space: nowrap;
}

.stock-tag {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    white-space: nowrap;
}

.stock-high {
    color: var(--glow);
    background: rgba(var(--glow-rgb), 0.15);
}

.stock-low {
    color: #ff5252;
    background: rgba(255, 82, 82, 0.15);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* ── Switch Toggle ── */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-dropdown);
    border: 1px solid var(--border);
    border-radius: 20px;
    transition: .3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    border-radius: 50%;
    transition: .3s;
}

input:checked+.slider {
    background-color: rgba(var(--glow-rgb), 0.15);
    border-color: var(--glow);
}

input:checked+.slider:before {
    transform: translateX(16px);
    background-color: var(--glow);
}

/* ── Dropdowns ── */
.ri-dropdown {
    position: relative;
    display: inline-block;
    width: 100%;
    z-index: 1;
}

.ri-dropdown:has(.ri-dropdown-menu.open) {
    z-index: 5000;
}

.ri-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    background: transparent;
    border: none;
    outline: none;
    border-radius: 11px;
    color: var(--text);
    font-size: 0.95rem;
    cursor: pointer;
    transition: color 0.2s;
    min-height: 44px;
    position: relative;
    z-index: 1;
    width: 100%;
    text-align: left;
    display: flex;
}

/* Glow hover effect matching .glow-input */
.ri-dropdown::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 13px;
    background: radial-gradient(220px circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb), .4), transparent 40%);
    z-index: -2;
    opacity: 0;
    transition: opacity .35s;
    pointer-events: none;
}

.ri-dropdown::after {
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: 11px;
    background: var(--bg-input);
    z-index: -1;
    pointer-events: none;
}

.ri-dropdown:hover::before,
.ri-dropdown-trigger:focus::before {
    opacity: 1;
}

.ri-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    min-width: 100%;
    background: var(--bg-dropdown);
    border: 1px solid var(--border);
    border-radius: 12px;
    z-index: 5000;
    max-height: min(50vh, 280px);
    overflow-y: auto;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.ri-dropdown-menu.open {
    display: block;
}

.ri-dropdown-menu.open--above {
    top: auto;
    bottom: calc(100% + 4px);
}

/* When .ri-dropdown is nested inside .glow-input, the glow-input already handles glow pseudo-elements */
.glow-input.ri-dropdown::before {
    border-radius: 9px;
}

.glow-input.ri-dropdown::after {
    border-radius: 7px;
    background: var(--bg-input);
}

.glow-input.ri-dropdown:hover::before,
.glow-input.ri-dropdown:focus-within::before {
    opacity: 1;
}

.ri-dropdown-item {
    padding: 11px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.ri-dropdown-item:not(.disabled-item):hover {
    background: rgba(var(--glow-rgb), 0.08);
    color: var(--glow);
    padding-left: 20px;
}

.ri-dropdown-item.active:not(.disabled-item) {
    color: var(--glow);
    font-weight: 600;
}

.ri-dropdown-item.disabled-item {
    opacity: 0.5;
    cursor: not-allowed;
}

.ri-multi-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ri-multi-dot {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--text-muted);
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    flex-shrink: 0;
    box-sizing: border-box;
}

.ri-multi-item:not(.disabled-item):hover .ri-multi-dot {
    border-color: rgba(var(--glow-rgb), 0.7);
    opacity: 1;
}

.ri-multi-dot.checked {
    border-color: var(--glow);
    opacity: 1;
}

.ri-multi-dot.checked::after {
    content: "";
    display: block;
    width: 9px;
    height: 9px;
    background-color: var(--glow);
    border-radius: 2.5px;
    border: none;
}

/* ── Custom Checkbox (Rounded Square) ── */
.custom-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;
    user-select: none;
    width: 100%;
    border-radius: 6px;
}

.custom-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.custom-checkbox .checkmark {
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted);
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    flex-shrink: 0;
}

.custom-checkbox:hover .checkmark {
    border-color: rgba(var(--glow-rgb), 0.7);
    opacity: 1;
}

.custom-checkbox input:checked~.checkmark {
    background-color: var(--glow);
    border-color: var(--glow);
    opacity: 1;
}

.custom-checkbox input:checked~.checkmark::after {
    content: "";
    display: block;
    width: 4px;
    height: 8px;
    border: solid #000;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

ul.ri-dropdown-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}