﻿/* ==========================================================================
   Admin · Access management · Manage User and Manage Customer (2026-12-01).
   List + filters reuse employee-list.css (.ev-*); this file adds the create / edit
   form that opens above the list, the business unit switch and the filter rows.
   ========================================================================== */

/* ---- Create / edit form ---- */
.ma-form { margin-top: 24px; }
.ma-form__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 32px 0; }
.ma-form__title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; color: var(--tb-text-strong); }
.ma-form__alert { margin: 16px 32px 0; }
.ma-form__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 18px 32px 22px; border-top: 1px solid var(--tb-bg); }
.ma-req { color: var(--tb-danger-ink); }
.ma-row--name { display: grid; grid-template-columns: 120px minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }

/* Mobile with its code in front */
.ma-phone { display: flex; min-width: 0; }
.ma-phone__code { display: inline-flex; align-items: center; padding: 0 14px; border: 1px solid var(--tb-border-strong); border-right: 0; border-radius: var(--tb-radius-control) 0 0 var(--tb-radius-control); background: var(--tb-surface-muted); font-weight: 600; color: var(--tb-text-neutral); }
.ma-phone__sel { flex: 0 0 150px; width: 150px; border-right: 0; border-radius: var(--tb-radius-control) 0 0 var(--tb-radius-control); }
html body .ma-phone .tb-input { flex: 1 1 auto; min-width: 0; border-radius: 0 var(--tb-radius-control) var(--tb-radius-control) 0; }

/* Payment mode: two choice tiles */
.ma-pay { margin: 0; padding: 0; border: 0; min-width: 0; }
.ma-pay__opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ma-pay__opt { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1px solid var(--tb-border-strong); border-radius: var(--tb-radius-control); background: var(--tb-surface); cursor: pointer; }
.ma-pay__opt:hover { border-color: var(--tb-border-hover); }
.ma-pay__opt:has(input:checked) { border-color: var(--tb-primary); background: var(--tb-ice); }
.ma-pay__opt input { width: 18px; height: 18px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--tb-primary); }
.ma-pay__opt b { display: block; font-size: 14px; font-weight: 600; color: var(--tb-text-strong); }
.ma-pay__opt small { display: block; margin-top: 2px; font-size: 12.5px; color: var(--tb-text-muted); }
.ma-pay.is-invalid .ma-pay__opt { border-color: var(--tb-danger); }

/* Parts for another business unit stay hidden even where a component sets display */
html body .ma [hidden] { display: none; }

/* ---- B2B customer (2026-12-01): attachments, products, ticketing, tax ---- */
.ma-textarea { min-height: 88px; padding-top: 10px; resize: vertical; }
.ma-file { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ma-file--num .tb-input { flex: 1 1 auto; min-width: 0; }
.ma-file__btn { position: relative; flex-shrink: 0; cursor: pointer; }
.ma-file__btn:focus-within { outline: 2px solid var(--tb-royal); outline-offset: 2px; }
.ma-file__name { flex: 1 1 auto; min-width: 0; min-height: 46px; display: flex; align-items: center; padding: 0 14px; border: 1px dashed var(--tb-border-strong); border-radius: var(--tb-radius-control); font-size: 14px; color: var(--tb-text-neutral); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ma-file__att { margin-top: 6px; font-size: 12.5px; font-weight: 500; color: var(--tb-success); overflow-wrap: anywhere; }
.ma-file__att::before { content: "Attached · "; color: var(--tb-text-muted); font-weight: 400; }
.ma-prods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ma-prod { padding: 14px 16px; border: 1px solid var(--tb-border-strong); border-radius: var(--tb-radius-control); background: var(--tb-surface); }
.ma-prod.is-on { border-color: var(--tb-primary); background: var(--tb-ice); }
.ma-prod__head { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.ma-prod__head input { width: 18px; height: 18px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--tb-primary); }
.ma-prod__head b { display: block; font-size: 14px; font-weight: 600; color: var(--tb-text-strong); }
.ma-prod__head small { display: block; margin-top: 2px; font-size: 12.5px; color: var(--tb-text-muted); }
.ma-prod__cat { margin-top: 12px; }
.ma-feats { margin: 0; padding: 0; border: 0; min-width: 0; }
.ma-feats__opts { display: flex; flex-wrap: wrap; gap: 4px 24px; }
/* Company row: Customer name + B2E Type; full width when Type doesn't apply */
.ma-company:has(> [hidden]) { grid-template-columns: minmax(0, 1fr); }
.ma-tax { display: grid; grid-template-columns: repeat(2, minmax(0, 160px)); gap: 16px; }

/* Roles and permissions of the chosen role */
.ma-perms { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--tb-radius-control); background: var(--tb-surface-muted); }
.ma-perms__icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--tb-surface); border: 1px solid var(--tb-border); color: var(--tb-primary); }
.ma-perms__title { font-size: 14px; font-weight: 600; color: var(--tb-text-strong); }
.ma-perms__text { margin-top: 2px; font-size: var(--tb-fs-meta); color: var(--tb-text-muted); }

/* ---- Business unit switch (Manage Customer) ---- */
.ma-units { display: inline-flex; gap: 4px; margin-top: 24px; padding: 4px; border-radius: var(--tb-radius-control); background: var(--tb-surface); border: 1px solid var(--tb-border); }
.ma-unit { display: inline-flex; align-items: center; min-height: 36px; padding: 0 18px; border-radius: 7px; font-size: 14px; font-weight: 600; color: var(--tb-text-neutral); }
.ma-unit:hover { color: var(--tb-primary); text-decoration: none; }
.ma-unit.is-on { background: var(--tb-primary); color: var(--tb-on-strong); }
.ma-units + .ma-filters { margin-top: 12px; }

/* ---- Filters: fields and buttons on one row when they fit ---- */
.ma-filters__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 260px)) 1fr; gap: 16px; align-items: end; }
.ma-filters__grid--cust { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.ma-filters__all { display: flex; align-items: center; min-height: 46px; }
.ma-filters__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.ma-filters__grid--cust .ma-filters__actions { grid-column: 1 / -1; padding-top: 16px; border-top: 1px solid var(--tb-bg); }
.ma-filters .tb-err { margin-top: 12px; }
.ma-count { font-size: 14px; color: var(--tb-text-neutral); }
.ma-count .num { font-weight: 700; color: var(--tb-primary); }

/* ---- Tables ---- */
html body .ma .ev-table td { white-space: nowrap; }
html body .ma .ev-table td.ev-emp, html body .ma .ev-table td.ev-empty { white-space: normal; }
.ma .ev-table .ma-r { text-align: right; }
.ma-money { font-weight: 600; color: var(--tb-primary); }
.ma-sl { color: var(--tb-text-muted); }
.ma .ev-table tr.is-editing td { background: var(--tb-ice); }
.ma-tag--block { background: var(--tb-warning-soft); color: var(--tb-warn-ink); }
.ma-tag--deleted { background: var(--tb-danger-soft); color: var(--tb-danger-ink); }

@media (max-width: 900px) {
    .ma-filters__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ma-filters__grid .ma-filters__actions { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    .ma-form__head { padding: 18px 20px 0; }
    .ma-form__alert { margin: 14px 20px 0; }
    .ma-form__actions { padding: 16px 20px 20px; }
    .ma-form__actions .btn { flex: 1 1 auto; }
    .ma-row--name { grid-template-columns: 1fr; }
    .ma-pay__opts { grid-template-columns: 1fr; }
    .ma-prods { grid-template-columns: 1fr; }
    .ma-filters__grid, .ma-filters__grid--cust { grid-template-columns: 1fr; }
    .ma-filters__grid--cust .ma-filters__actions { grid-column: auto; padding-top: 0; border-top: 0; }
    .ma-filters__actions .btn { flex: 1 1 auto; }
    .ma-phone__sel { flex-basis: 128px; width: 128px; }
    .ma-units { display: flex; }
    .ma-unit { flex: 1 1 0; justify-content: center; }
    html body .ma .ev-table td { white-space: normal; }
    .ma .ev-table .ma-r { text-align: left; }
    /* Cards: the row counter adds nothing; the row being edited is tinted as a whole */
    html body .ma .ev-table td.ma-sl { display: none; }
    html body .ma .ev-table tr.is-editing { background: var(--tb-ice); }
    html body .ma .ev-table tr.is-editing td { background: transparent; }
}

/* ==========================================================================
   Manage User · client's screen (2026-12-02): opens on the form, one card,
   fields in two rows (Title · First · Last · Email · Mobile / Code · Role · Status),
   Roles and permissions under them, actions centred. "View details" = the list.
   ========================================================================== */
html body .mu .mu-form { margin-top: 16px; }
.mu-form__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 28px; border-bottom: 1px solid var(--tb-border); }
.mu-form__title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; color: var(--tb-text-strong); }
.mu-form__sub { margin-top: 2px; font-size: var(--tb-fs-meta); color: var(--tb-text-muted); }
.mu-form__head .btn { flex-shrink: 0; }
.mu-form__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; padding: 24px 28px 26px; }
.mu-form__actions .btn { min-width: 160px; }
.mu-banner__link { margin-left: auto; font-weight: 600; white-space: nowrap; }

@media (max-width: 640px) {
    .mu-form__head { flex-wrap: wrap; padding: 16px 20px; }
    .mu-form__actions { padding: 20px; }
    .mu-form__actions .btn { flex: 1 1 auto; min-width: 0; }
}

/* ==========================================================================
   Shared by Manage User, Manage Customer, Manage Employee and Employee Upload & Invite
   (professional pass 2026-12-02): page title, tabs with a count ("Create · View details"),
   the form's action bar that stays in view, and the list's person cell with initials.
   ========================================================================== */
.ma-page { margin-top: 8px; }
.ma-tabs { display: flex; gap: 4px; margin-top: 20px; border-bottom: 1px solid var(--tb-border); }
.ma-tab { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; margin-bottom: -1px; border-bottom: 2px solid transparent; font-size: 14px; font-weight: 600; color: var(--tb-text-neutral); white-space: nowrap; }
.ma-tab:hover { color: var(--tb-primary); text-decoration: none; }
.ma-tab:focus-visible { outline: 2px solid var(--tb-royal); outline-offset: -2px; border-radius: 6px 6px 0 0; }
.ma-tab.is-on { border-bottom-color: var(--tb-primary); color: var(--tb-primary); }
.ma-tab__n { min-width: 24px; padding: 1px 8px; border-radius: 999px; background: var(--tb-surface-muted); font-size: 12px; font-weight: 700; text-align: center; color: var(--tb-text-neutral); }
.ma-tab.is-on .ma-tab__n { background: var(--tb-ice); color: var(--tb-primary); }
html body .ma .ma-tabs + .ev-banner { margin-top: 16px; }
html body .mu .ma-tabs ~ .mu-form, html body .mu .ma-tabs ~ .ev-filters, html body .mu .ma-tabs ~ .ma-units { margin-top: 20px; }

/* The Create / Save bar stays in view while a long form scrolls */
html body .mu .mu-form .mu-form__actions { position: sticky; bottom: 0; z-index: 2; justify-content: flex-end; padding: 14px 28px; border-top: 1px solid var(--tb-border); border-radius: 0 0 16px 16px; background: var(--tb-surface); }

/* List: person or company with initials */
.ma-who { display: flex; align-items: flex-start; gap: 12px; }
.ma-avatar { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--tb-ice); font-size: 13px; font-weight: 700; color: var(--tb-primary); }

@media (max-width: 640px) {
    .ma-tabs { overflow-x: auto; }
    .ma-tab { flex: 1 0 auto; justify-content: center; padding: 0 10px; }
    html body .mu .mu-form .mu-form__actions { padding: 12px 20px; }
}

/* ==========================================================================
   List-first layout (2026-12-03; Manage User sample, then every form + list page: the user "Yes, apply to all").
   A page opens on its list; Create / Edit open the same form in a side panel over the list (.lf-drawer, a native
   <dialog>, Scripts/list-first.js). .lf-drawer--wide for long forms. Shared by every page that uses it.
   ========================================================================== */
html body .lf .lf-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-top: 10px; }
.lf-head__actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Status switch + search on one line */
.lf-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; margin-top: 24px; }
.lf-status { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--tb-surface); border: 1px solid var(--tb-border); }
.lf-status__opt { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px 0 10px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--tb-text-neutral); white-space: nowrap; transition: background-color var(--tb-dur-1), color var(--tb-dur-1); }
.lf-status__opt:hover { background: var(--tb-surface-muted); color: var(--tb-text-strong); }
.lf-status__opt.is-on { background: var(--tb-primary); color: var(--tb-on-strong); font-weight: 600; }
.lf-status__n { min-width: 22px; padding: 1px 7px; border-radius: var(--tb-radius-pill); background: var(--tb-surface-muted); font-size: 12px; font-weight: 600; text-align: center; color: var(--tb-text-neutral); }
.lf-status__opt.is-on .lf-status__n { background: rgba(255, 255, 255, .16); color: var(--tb-on-strong); }
.lf-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.lf-dot--active { background: var(--tb-success); }
.lf-dot--block { background: var(--tb-warning); }
.lf-dot--delete { background: var(--tb-danger); }
.lf-status__opt.is-on .lf-dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, .9); }

.lf-search { display: flex; align-items: center; gap: 8px; }
html body .ad-content .lf .lf-find { height: 44px; padding: 0 8px 0 14px; background: var(--tb-surface); }
html body .ad-content .lf .lf-find input { width: 300px; }
@media (min-width: 900px) { html body .ad-content .lf .lf-find:focus-within input { width: 340px; } }
.lf-find__key { opacity: 0; transition: opacity var(--tb-dur-1); }
.lf-find:focus-within .lf-find__key { opacity: 1; }

/* The list */
html body .lf .lf-results { margin-top: 14px; }
.lf-tr[data-href] { cursor: pointer; }
html body .ad-content .lf-tr.is-open td { background: var(--tb-ice); }
.lf-edit { gap: 4px; padding: 0 8px; color: var(--tb-royal); }
.lf-edit .ic { width: 15px; height: 15px; transition: transform var(--tb-dur-2) var(--tb-ease); }
.lf-tr:hover .lf-edit .ic { transform: translateX(3px); }

/* Side panel (native <dialog>) */
html.lf-locked { overflow: hidden; }
.lf-drawer { position: fixed; inset: 0 0 0 auto; width: min(520px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0; border: 0; border-left: 1px solid var(--tb-border); background: var(--tb-surface); color: var(--tb-text); box-shadow: -24px 0 48px -24px rgba(10, 31, 61, .35); }
.lf-drawer[open] { display: flex; animation: lf-in var(--tb-dur-3) var(--tb-ease); }
.lf-drawer::backdrop { background: rgba(10, 31, 61, .32); backdrop-filter: blur(1px); animation: tb-fade var(--tb-dur-2) var(--tb-ease); }
.lf-drawer.is-closing { animation: lf-out 180ms var(--tb-ease-in-out) forwards; }
.lf-drawer.is-closing::backdrop { animation: tb-fade-out 180ms var(--tb-ease) forwards; }
@keyframes lf-in { from { transform: translateX(32px); opacity: 0; } }
@keyframes lf-out { to { transform: translateX(32px); opacity: 0; } }
.lf-form { display: flex; flex-direction: column; width: 100%; min-height: 0; }

.lf-drawer__head { display: flex; align-items: flex-start; gap: 14px; padding: 22px 20px 18px 28px; border-bottom: 1px solid var(--tb-border); }
.lf-drawer__avatar { width: 44px; height: 44px; font-size: 15px; }
.lf-drawer__titles { flex: 1; min-width: 0; }
.lf-drawer__eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tb-text-muted); }
.lf-drawer__title { margin-top: 2px; font-size: 21px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; overflow-wrap: anywhere; }
.lf-drawer__sub { margin-top: 2px; font-size: var(--tb-fs-meta); color: var(--tb-text-muted); overflow-wrap: anywhere; }
.lf-drawer__close { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 40px; height: 40px; border: 0; border-radius: 10px; background: none; color: var(--tb-text-muted); cursor: pointer; }
.lf-drawer__close:hover { background: var(--tb-surface-muted); color: var(--tb-primary); }

.lf-drawer__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 28px 24px; }
.lf-drawer__body > .tb-alert { margin-top: 16px; }
.lf-sec { display: flex; flex-direction: column; gap: 16px; padding: 20px 0 22px; }
.lf-sec + .lf-sec { border-top: 1px solid var(--tb-border); }
.lf-sec__title { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--tb-primary); }
.lf-sec__text { margin-top: -10px; font-size: var(--tb-fs-meta); color: var(--tb-text-muted); }
.lf-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.lf-row--name { grid-template-columns: 120px minmax(0, 1fr); }
.lf-perms { margin: 0; }

.lf-drawer__foot { display: flex; align-items: center; gap: 10px; padding: 14px 28px; border-top: 1px solid var(--tb-border); background: var(--tb-surface); }
.lf-drawer__spacer { flex: 1; }

@media (max-width: 640px) {
    .lf-head__actions { width: 100%; }
    .lf-head__actions .btn { flex: 1; }
    .lf-status { width: 100%; }
    .lf-status__opt { flex: 1; justify-content: center; padding: 0 8px; }
    .lf-search { width: 100%; }
    html body .ad-content .lf .lf-find { flex: 1; }
    html body .ad-content .lf .lf-find input { width: 100%; }
    html body .lf .lf-table td { min-width: 0; overflow-wrap: anywhere; }   /* long email IDs wrap in the phone cards */
    .lf-drawer { width: 100vw; border-left: 0; }
    .lf-drawer__head { padding: 18px 12px 14px 20px; }
    .lf-drawer__body { padding: 4px 20px 20px; }
    .lf-drawer__foot { padding: 12px 20px; }
    .lf-drawer__foot .btn { padding: 0 14px; }
}
@media (max-width: 400px) {
    .lf-row { grid-template-columns: minmax(0, 1fr); }
    .lf-row--name { grid-template-columns: 104px minmax(0, 1fr); }
}
/* Wide side panel for long forms (customer, employee, rules, payment link) */
.lf-drawer.lf-drawer--wide { width: min(760px, 100vw); }
/* A plain side panel body (no Person / Sign-in sections): existing form sections keep their own layout */
.lf-drawer__body > .tb-form-sec, .lf-drawer__body > section:not(.lf-sec) { padding-left: 0; padding-right: 0; }
/* A page's own form card inside the side panel: one scroll area, head stays on top, action bar stays at the bottom */
.lf-drawer > form, .lf-drawer > .lf-panel { display: flex; flex-direction: column; width: 100%; min-height: 0; margin: 0; overflow-y: auto; overscroll-behavior: contain; border: 0; border-radius: 0; box-shadow: none; }
html body .lf .lf-drawer > form.mu-form, html body .ad-content .lf-drawer > form.tb-panel, html body .ad-content .lf-drawer > form.tb-form-card { margin: 0; border: 0; border-radius: 0; box-shadow: none; }
.lf-drawer .mu-form__head { position: sticky; top: 0; z-index: 3; align-items: flex-start; padding: 22px 20px 18px 28px; background: var(--tb-surface); }
.lf-drawer .mu-form__title { font-size: 21px; letter-spacing: -.02em; overflow-wrap: anywhere; }
.lf-drawer .mu-form__head .lf-drawer__close { margin-left: auto; }
html body .lf .lf-drawer .mu-form .mu-form__actions { margin-top: auto; border-radius: 0; padding: 14px 28px; }
.lf-drawer .tb-form-sec { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 22px 28px; }
.lf-drawer .tb-form-sec__title { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--tb-primary); }
.lf-drawer .tb-form-sec__text { margin-top: 2px; }
/* What sits right under the page head */
html body .lf .lf-head ~ .ma-units, html body .lf .lf-head ~ .ev-filters, html body .lf .lf-head ~ .ma-filters { margin-top: 24px; }
@media (max-width: 640px) {
    .lf-drawer .mu-form__head { padding: 18px 12px 14px 20px; }
    .lf-drawer .tb-form-sec { padding: 20px; }
    html body .lf .lf-drawer .mu-form .mu-form__actions { padding: 12px 20px; }
}
/* Panel action bar, same order everywhere: Clear on the left; Cancel and the main button on the right */
html body .lf .lf-drawer .mu-form__actions { flex-wrap: nowrap; justify-content: flex-end; gap: 10px; }
html body .lf .lf-drawer .mu-form__actions .btn { min-width: 0; }
html body .lf .lf-drawer .mu-form__actions .js-lf-clear { order: 0; margin-right: auto; }
html body .lf .lf-drawer .mu-form__actions .js-lf-close { order: 1; }
html body .lf .lf-drawer .mu-form__actions [type="submit"] { order: 2; }
/* Total count beside a page title */
.lf-head__n { display: inline-flex; align-items: center; vertical-align: middle; margin-left: 6px; padding: 2px 10px; border-radius: var(--tb-radius-pill); background: var(--tb-surface); border: 1px solid var(--tb-border); font-size: 13px; font-weight: 600; letter-spacing: 0; color: var(--tb-text-neutral); }
/* Coming back open after a reload: no slide-in */
.lf-drawer.is-instant[open], .lf-drawer.is-instant::backdrop { animation: none; }
