/* Shared Portal UI components — docs/design/PORTAL_UI_STANDARD.md.
 *
 * ModalShell (and ConfirmDialog / HelpModal on it), SidePanel, HelpTip, FormField and Tip. The look is
 * lifted from the approved mockups (plan §U6, portal-ux-mockups: M3, M5, M8, M10). Phones are below
 * 768px, one breakpoint for all of it: @media (max-width: 767.98px). There, a modal is a bottom sheet
 * with full-width 44px buttons, a side panel is a full-screen sheet with a sticky footer, and an ⓘ
 * popover is a bottom sheet. Tooltips do not show on phones at all — they never hold information that
 * is not somewhere else. PortalUiStylesheetTests reads this file. */

/* ── One z-index scale ──────────────────────────────────────────────────────────────────────────────
 * Bootstrap's own modal (1055), popover (1070) and tooltip (1080) sit inside this scale, so a legacy
 * Bootstrap modal and a new one never fight. A confirmation opened from a side panel is above it; an ⓘ
 * popover inside either is above both; toasts stay on top of everything. */
:root {
    --z-dropdown:  1000;
    --z-raised:    1;
    --z-panel:     1045;
    --z-modal:     1060;
    --z-popover:   1070;
    --z-tooltip:   1075;
    --z-toast:     1080;

    /* Colours the shared components need that the house palette (app.css) does not name. Every colour
       in this file is a token: raw values live here and nowhere below (PortalUiStylesheetTests). */
    --cc-scrim:          rgba(17, 26, 20, .5);
    --cc-shadow-modal:   0 24px 60px rgba(17, 26, 20, .3);
    --cc-shadow-panel:   -16px 0 40px rgba(17, 26, 20, .22);
    --cc-shadow-footer:  0 -6px 16px rgba(17, 26, 20, .05);
    --cc-shadow-pop:     0 12px 32px rgba(17, 26, 20, .16), 0 2px 6px rgba(17, 26, 20, .06);
    --cc-shadow-sheet:   0 -12px 36px rgba(17, 26, 20, .25);
    --cc-ring-invalid:   0 0 0 3px rgba(198, 40, 40, .13);
    --cc-help-tint:      #e4eee7;
    --cc-grab-handle:    #d7d0c4;
    --cc-tip-bg:         var(--text-primary);
    --cc-tip-fg:         var(--text-inverse);
    --cc-dg-struck:      #a9b5ac;
    --cc-dg-on-green:    var(--text-inverse);
    --cc-dg-on-green-2:  #cfe3d5;

    /* The space Bootstrap's .form-select chevron takes at the right of a select. TODO(ux-nav-pickers):
       that stream owns the global select padding fix (plan U2 item 3); when it lands, point this at its
       value so an invalid select's error icon keeps clear of the chevron. */
    --cc-select-chevron-space: 2.25rem;
    --cc-panel-width:  640px;
    --cc-sheet-radius: 14px;
    --cc-tap:          44px;
}

/* ── Things outside the scale ──────────────────────────────────────────────────────────────────────
 * The Blazor reconnect overlay (App.razor, 20000) is meant to cover everything, overlays included.
 * The floating chat bubble (ChatPanel.razor, 9999) is not: it would sit on a side panel's Save button,
 * cover a bottom sheet's buttons, and be a clickable way out of a modal's focus trap. So it is hidden
 * while any overlay holds the page lock — js/modal-scroll.js puts .cc-overlay-open on <html>. */
:root.cc-overlay-open .cc-chat-root { visibility: hidden; }

/* ── Focus guards (the focus trap's two ends) ──────────────────────────────────────────────────── */
.cc-focus-guard { position: fixed; width: 1px; height: 1px; overflow: hidden; outline: 0; opacity: 0; }

/* ── Close button (✕) shared by modal, panel and popover headers ───────────────────────────────── */
.cc-x {
    margin-left: auto; flex: 0 0 auto;
    width: 36px; height: 36px; display: grid; place-items: center;
    border: 0; background: none; border-radius: var(--radius-md);
    color: var(--text-muted); font-size: 18px; line-height: 1;
}
.cc-x:hover { background: var(--content-bg); color: var(--text-primary); }
.cc-x:focus-visible { outline: 0; box-shadow: var(--shadow-focus); }
/* The tooltip wrapper around a ✕ takes over the ✕'s own auto margin, and the tip opens BELOW it: a ✕ sits at the
   very top of the dialog, where a tip above it would be off the screen. */
.cc-x-host { margin-left: auto; flex: 0 0 auto; }
.cc-x-host > .cc-x { margin: 0; }
.cc-x-host > .cc-tip { bottom: auto; top: calc(100% + 9px); }
.cc-x-host > .cc-tip::after { bottom: auto; top: -5px; border-top-width: 0; border-bottom: 5px solid var(--cc-tip-bg); border-top-color: transparent; }

/* ── ModalShell: centred modal ≥768px, bottom sheet below ──────────────────────────────────────── */
.cc-modal-wrap {
    position: fixed; inset: 0; z-index: var(--z-modal);
    display: flex; align-items: center; justify-content: center;
    padding: 16px; background: var(--cc-scrim);
    overflow-y: auto;
    /* A modal is often rendered inside the button that opens it, e.g. a PortalButton with Confirm in a
       `text-nowrap` table cell. Without this, the dialog inherits nowrap/right-alignment and its message
       scrolls sideways instead of wrapping. */
    white-space: normal; text-align: start;
}
.cc-modal {
    width: min(540px, 100%);
    max-height: calc(100vh - 32px);
    display: flex; flex-direction: column;
    background: var(--card-bg); color: var(--text-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--cc-shadow-modal);
    outline: 0;
}
.cc-modal--lg { width: min(640px, 100%); }
.cc-modal-h { display: flex; gap: 14px; align-items: flex-start; padding: 20px 22px 10px; }
.cc-modal-h .cc-x { margin: -6px -8px 0 auto; }
.cc-modal-h .cc-x-host { margin: -6px -8px 0 auto; }
.cc-modal-h .cc-x-host > .cc-x { margin: 0; }
.cc-modal-htext { min-width: 0; }
.cc-modal-title { font-size: 17px; font-weight: 700; margin: 1px 0 3px; line-height: 1.3; }
.cc-modal-sub { font-size: 12.5px; color: var(--text-secondary); }
.cc-modal-ic {
    width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto;
    display: grid; place-items: center; font-size: 18px;
    background: var(--warning-light); color: var(--warning-text);
}
.cc-modal-ic.cc-tone-danger  { background: var(--danger-light); color: var(--danger-text); }
.cc-modal-ic.cc-tone-help    { background: var(--cc-help-tint); color: var(--cc-green); }
.cc-modal-ic.cc-tone-neutral { background: var(--content-bg); color: var(--text-secondary); }
.cc-modal-b { padding: 4px 22px 14px; overflow-y: auto; font-size: 13.5px; line-height: 1.55; }
.cc-modal-b > p:last-child { margin-bottom: 0; }
.cc-modal-f {
    display: flex; justify-content: flex-end; align-items: center; gap: 8px;
    padding: 14px 22px; background: var(--content-bg);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.cc-modal-f .btn { min-height: 38px; padding-left: 18px; padding-right: 18px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.cc-modal-f .cc-modal-f-note { margin-right: auto; font-size: 12.5px; color: var(--text-muted); }
/* The dismissing button is white on the tinted footer (mockups M3, M4), not transparent. */
.cc-modal-f .btn-secondary, .cc-panel-f .btn-secondary { background: var(--card-bg); }
.cc-modal-f .btn-secondary:hover, .cc-panel-f .btn-secondary:hover { background: var(--border); }

/* ConfirmDialog: the consequence list (money / the box / the member / undo). */
.cc-confirm-msg { margin: 0; }
.cc-fx { display: grid; grid-template-columns: 30px 1fr; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); }
.cc-fx-ic {
    width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
    background: var(--content-bg); border: 1px solid var(--border); color: var(--cc-green-md); font-size: 14px;
}
.cc-fx-k { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 1px; }
.cc-fx-v { font-size: 13.5px; color: var(--text-primary); line-height: 1.45; }

/* ── SidePanel: 640px from the right ≥768px, full-screen sheet below ───────────────────────────── */
.cc-panel-wrap { position: fixed; inset: 0; z-index: var(--z-panel); background: var(--cc-scrim); }
.cc-panel {
    position: absolute; top: 0; right: 0; bottom: 0;
    width: min(var(--cc-panel-width), 100%);
    display: flex; flex-direction: column;
    background: var(--card-bg); color: var(--text-primary);
    box-shadow: var(--cc-shadow-panel);
    outline: 0;
}
.cc-panel-h { display: flex; align-items: flex-start; gap: 12px; padding: 18px 24px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.cc-panel-eb { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 2px; }
.cc-panel-title { margin: 0; font-size: 19px; font-weight: 700; line-height: 1.3; }
.cc-panel-sub { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.cc-panel-b { flex: 1 1 auto; overflow-y: auto; padding: 20px 24px 8px; overscroll-behavior: contain; }
.cc-panel-sum { flex: 0 0 auto; margin: 0 24px 16px; }
.cc-panel-f {
    flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
    padding: 14px 24px; border-top: 1px solid var(--border);
    background: var(--card-bg); box-shadow: var(--cc-shadow-footer);
}
.cc-panel-f .cc-panel-hint { margin-right: auto; font-size: 12.5px; color: var(--text-muted); }
.cc-panel-f .cc-panel-cancel-host { margin-left: auto; }
.cc-panel-f .cc-panel-hint + .cc-panel-cancel-host { margin-left: 0; }
.cc-panel-f .btn { min-height: 38px; padding-left: 18px; padding-right: 18px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

/* A section inside a panel: small caps heading with a rule under it (mockup M5 "THE SHARE"). */
.cc-sec { margin: 0 0 22px; }
.cc-sec-t {
    display: flex; align-items: center; gap: 2px;
    font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary);
    padding-bottom: 8px; margin: 0 0 14px; border-bottom: 1px solid var(--border);
}

/* ── FormField ─────────────────────────────────────────────────────────────────────────────────── */
.cc-ff { margin-bottom: 16px; }
.cc-ff-lbl { display: flex; align-items: center; gap: 2px; min-height: 22px; margin-bottom: 6px; }
.cc-ff-lbl > label { font-size: 13px; font-weight: 600; color: var(--text-primary); margin: 0; }
.cc-ff-req { color: var(--danger); margin-left: 2px; }
.cc-ff-opt { font-weight: 400; color: var(--text-muted); margin-left: 4px; }
.cc-ff-ctl { position: relative; }
.cc-ff .form-control, .cc-ff .form-select { min-height: 38px; }
.cc-ff-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.cc-ff-bad-ic { display: none; }
.cc-ff.is-invalid .cc-ff-lbl > label { color: var(--danger-text); }
.cc-ff.is-invalid .form-control,
.cc-ff.is-invalid .form-select {
    border-color: var(--danger);
    box-shadow: var(--cc-ring-invalid);
    padding-right: 36px;
}
.cc-ff.is-invalid .form-select { padding-right: calc(var(--cc-select-chevron-space) + 1.5rem); }
.cc-ff.is-invalid .cc-ff-bad-ic {
    display: block; position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
    color: var(--danger); font-size: 15px; pointer-events: none;
}
.cc-ff.is-invalid .cc-ff-ctl:has(.form-select) .cc-ff-bad-ic { right: calc(var(--cc-select-chevron-space) + .15rem); }
.cc-ff-err {
    display: flex; gap: 6px; align-items: flex-start; margin-top: 6px;
    font-size: 12.5px; font-weight: 600; line-height: 1.4; color: var(--danger-text);
}
.cc-ff-err i { margin-top: 1px; }
.cc-ff-err a { color: var(--danger-text); text-decoration: underline; }

/* ── HelpTip (ⓘ): popover ≥768px, bottom sheet below ───────────────────────────────────────────── */
.cc-help { position: relative; display: inline-flex; align-items: center; vertical-align: middle; }
.cc-hi {
    display: inline-grid; place-items: center; flex: 0 0 auto;
    position: relative;
    width: 24px; height: 24px; padding: 0; margin: 0 0 0 2px;   /* WCAG 2.5.8: never below 24px */
    border: 0; border-radius: 50%; background: none;
    color: var(--text-muted); font-size: 14px; line-height: 1; cursor: pointer;
}
.cc-hi:hover, .cc-hi.is-open { color: var(--accent-strong); background: var(--accent-light); }
.cc-hi:focus-visible { outline: 0; box-shadow: var(--shadow-focus); }
/* The hit area can be larger than the drawn circle; on a phone it is (see the phone block). */
.cc-hi::after { content: ''; position: absolute; inset: 0; border-radius: 50%; }
/* A transparent layer that catches the click outside an open popover (and dims the page on a phone). */
.cc-help-scrim { position: fixed; inset: 0; z-index: var(--z-popover); background: transparent; }
.cc-pop {
    position: absolute; z-index: var(--z-popover);
    top: calc(100% + 10px); left: -16px;
    width: 300px; max-width: calc(100vw - 24px);
    display: block; padding: 12px 14px;
    background: var(--card-bg); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--cc-shadow-pop);
    font: 400 13px/1.5 var(--font-sans);
    text-align: left; text-transform: none; letter-spacing: normal; white-space: normal;
    outline: 0;
}
.cc-pop::before {
    content: ''; position: absolute; top: -6px; left: var(--cc-arrow-x, 20px);
    width: 11px; height: 11px; background: var(--card-bg);
    border-left: 1px solid var(--border); border-top: 1px solid var(--border);
    transform: rotate(45deg);
}
.cc-pop.cc-pop--end { left: auto; right: -16px; }
.cc-pop.cc-pop--end::before { left: auto; right: 20px; }
.cc-pop.cc-pop--up { top: auto; bottom: calc(100% + 10px); }
.cc-pop.cc-pop--up::before { top: auto; bottom: -6px; transform: rotate(225deg); }
.cc-pop-t { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; font-weight: 700; font-size: 13.5px; margin-bottom: 3px; }
.cc-pop-x {
    display: inline-grid; place-items: center; min-width: 24px; min-height: 24px;
    border: 0; background: none; color: var(--text-muted); font-size: 17px; line-height: 1; padding: 0; margin: -4px -6px 0 0;
}
.cc-pop-b { display: block; }
.cc-pop-b .cc-p { display: block; margin: 0 0 6px; }
.cc-pop-b .cc-p:last-child { margin-bottom: 0; }
.cc-pop-more {
    display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; padding: 0;
    border: 0; background: none; font-weight: 600; font-size: 13px; color: var(--accent-strong);
}
.cc-pop-more:hover { text-decoration: underline; }

/* HelpModal body */
.cc-help-fig { margin: 0 0 14px; padding: 12px 10px 8px; background: var(--content-bg); border: 1px solid var(--border); border-radius: var(--radius-md); }
.cc-help-fig svg { display: block; width: 100%; height: auto; }
.cc-help-fig figcaption { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.cc-help-body p { margin: 0 0 10px; }
.cc-help-body ul { padding-left: 18px; margin: 0 0 8px; }
.cc-help-body li { margin-bottom: 4px; }

/* Diagram classes (inline SVG in HelpModal) — house tokens, so the diagram follows the theme. */
.cc-dg-t  { font: 600 13px var(--font-sans); fill: var(--text-secondary); }
.cc-dg-n  { font: 700 22px var(--font-sans); fill: var(--text-primary); }
.cc-dg-s  { font: 500 11.5px var(--font-sans); fill: var(--text-muted); }
.cc-dg-op { font: 700 26px var(--font-sans); fill: var(--text-muted); }
.cc-dg-box    { fill: var(--card-bg); stroke: var(--border); }
.cc-dg-add    { fill: var(--accent-light); stroke: var(--accent); }
.cc-dg-own    { fill: var(--card-bg); stroke: var(--cc-green-md); }
.cc-dg-gone   { fill: var(--card-bg); stroke: var(--border); stroke-dasharray: 4 3; }
.cc-dg-gone-n { font: 700 22px var(--font-sans); fill: var(--cc-dg-struck); text-decoration: line-through; }
.cc-dg-res    { fill: var(--cc-green); }
.cc-dg-res-n  { font: 700 22px var(--font-sans); fill: var(--cc-dg-on-green); }
.cc-dg-res-s  { font: 500 11.5px var(--font-sans); fill: var(--cc-dg-on-green-2); }

/* ── Tip: hover/focus tooltip on icon-only and state-changing buttons (desktop only) ───────────── */
.cc-tip-host { position: relative; display: inline-flex; }
.cc-tip {
    position: absolute; z-index: var(--z-tooltip);
    bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%);
    width: max-content; max-width: 250px; padding: 7px 10px;
    background: var(--cc-tip-bg); color: var(--cc-tip-fg); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
    font: 500 12px/1.45 var(--font-sans); text-align: left; white-space: normal;
    text-transform: none; letter-spacing: normal;
    visibility: hidden; opacity: 0; transition: opacity .12s ease;
    pointer-events: none;
}
.cc-tip::after {
    content: ''; position: absolute; bottom: -5px; left: 50%; margin-left: -5px;
    border: 5px solid transparent; border-bottom: 0; border-top-color: var(--cc-tip-bg);
}
.cc-tip--start { left: 0; transform: none; }
.cc-tip--start::after { left: 16px; }
.cc-tip--end { left: auto; right: 0; transform: none; }
.cc-tip--end::after { left: auto; right: 11px; }
/* Set by js/portal-ui.js at show time when the centred tip would be clipped (see fitTip). Same geometry as the
   explicit Align classes above; a tip that is never measured (no JS) simply stays centred. */
.cc-tip[data-cc-tip-x="start"] { left: 0; transform: none; }
.cc-tip[data-cc-tip-x="start"]::after { left: 16px; }
.cc-tip[data-cc-tip-x="end"] { left: auto; right: 0; transform: none; }
.cc-tip[data-cc-tip-x="end"]::after { left: auto; right: 11px; }
.cc-tip[data-cc-tip-y="below"] { bottom: auto; top: calc(100% + 9px); }
.cc-tip[data-cc-tip-y="below"]::after { bottom: auto; top: -5px; border-top-width: 0; border-bottom: 5px solid var(--cc-tip-bg); border-top-color: transparent; }
.cc-tip-host:hover > .cc-tip,
.cc-tip-host:has(:focus-visible) > .cc-tip { visibility: visible; opacity: 1; transition-delay: .35s; }
.cc-tip-host:has(:focus-visible) > .cc-tip { transition-delay: 0s; }
/* A PortalButton sits inside its tooltip wrapper, so Bootstrap's `.btn-group > .btn` and `.input-group > .btn`
   joins no longer match it; these restate the join for the wrapper. */
.btn-group > .cc-tip-host:not(:first-of-type), .input-group > .cc-tip-host:not(:first-of-type) { margin-left: calc(var(--bs-border-width, 1px) * -1); }
.btn-group > .cc-tip-host:not(:last-of-type) > .btn, .input-group > .cc-tip-host:not(:last-of-type) > .btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-group > .cc-tip-host:not(:first-of-type) > .btn, .input-group > .cc-tip-host:not(:first-of-type) > .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.btn-group > .cc-tip-host > .btn:hover, .btn-group > .cc-tip-host > .btn:focus { position: relative; z-index: var(--z-raised); }
.input-group > .cc-tip-host > .btn { height: 100%; }
:root.cc-tips-off .cc-tip { visibility: hidden !important; opacity: 0 !important; }
@media (hover: none) { .cc-tip { display: none; } }

/* ── Phones: below 768px ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 767.98px) {
    /* A modal is a bottom sheet: full width, grab handle, buttons stacked full width at 44px with the
       confirming verb on top. The consequence text is never cut. */
    .cc-modal-wrap { align-items: flex-end; padding: 0; }
    .cc-modal, .cc-modal--lg {
        width: 100%; max-height: 94vh;
        border-radius: var(--cc-sheet-radius) var(--cc-sheet-radius) 0 0;
    }
    .cc-modal::before {
        content: ''; display: block; flex: 0 0 auto;
        width: 40px; height: 4px; border-radius: 2px; background: var(--cc-grab-handle); margin: 8px auto 0;
    }
    .cc-modal-h { padding: 16px 16px 8px; }
    .cc-modal-b { padding: 4px 16px 12px; font-size: 14px; }
    .cc-fx-v { font-size: 14px; }
    .cc-modal-f {
        flex-direction: column-reverse; align-items: stretch;
        padding: 12px 16px 16px; border-radius: 0;
    }
    .cc-modal-f .btn { width: 100%; min-height: var(--cc-tap); font-size: 14px; }
    .cc-modal-f .cc-tip-host { width: 100%; }
    .cc-modal-f .cc-modal-f-note { margin: 0; text-align: center; }

    /* A side panel is a full-screen sheet with the page hidden behind it and a sticky footer. */
    .cc-panel-wrap { background: transparent; }
    .cc-panel { width: 100%; box-shadow: none; }
    .cc-panel-h { padding: 14px 16px 12px; }
    .cc-panel-b { padding: 16px 16px 4px; }
    .cc-panel-sum { margin: 0 16px 14px; }
    .cc-panel-f { padding: 12px 16px; }
    .cc-panel-f .cc-panel-hint { display: none; }
    .cc-panel-f .btn { flex: 1 1 0; min-height: var(--cc-tap); font-size: 14px; }
    .cc-panel-f .cc-tip-host { flex: 1 1 0; }
    .cc-panel-f .cc-tip-host > .btn { width: 100%; }
    .cc-panel-f .cc-panel-cancel-host { margin-left: 0; }

    /* An ⓘ popover is a bottom sheet, so it never covers the field it explains. */
    .cc-help-scrim { background: var(--cc-scrim); }
    .cc-pop, .cc-pop.cc-pop--end, .cc-pop.cc-pop--up {
        position: fixed; top: auto; left: 0; right: 0; bottom: 0;
        width: auto; max-width: none; max-height: 80vh; overflow-y: auto;
        border: 0; border-radius: var(--cc-sheet-radius) var(--cc-sheet-radius) 0 0;
        box-shadow: var(--cc-shadow-sheet);
        padding: 8px 18px 20px; font-size: 14.5px; line-height: 1.55;
    }
    .cc-pop::before, .cc-pop.cc-pop--end::before, .cc-pop.cc-pop--up::before {
        position: static; display: block; width: 40px; height: 4px; margin: 0 auto 12px;
        border: 0; border-radius: 2px; background: var(--cc-grab-handle); transform: none;
    }
    .cc-pop-t { font-size: 17px; margin-bottom: 6px; }
    .cc-pop-x { font-size: 24px; min-width: var(--cc-tap); min-height: var(--cc-tap); margin: -10px -12px 0 0; }

    /* 44px targets (plan U7 rule 8). The ⓘ keeps its small drawn circle and gets an invisible 44px hit
       area; the ✕ on every modal, panel and sheet is 44px outright. */
    .cc-hi::after { inset: -10px; }
    .cc-x { width: var(--cc-tap); height: var(--cc-tap); }
    .cc-pop-more {
        display: flex; width: 100%; justify-content: center; min-height: var(--cc-tap);
        margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 14px;
    }

    /* Tooltips never show on a phone. */
    .cc-tip { display: none; }
}

/* ── Product editor (Catalog.razor "What are you selling?" panel) ─────────────────────────────────
   Panel-relative columns: a 6-column grid INSIDE the panel, never the browser's col-md-* breakpoints
   (review C-1: three col-md-4 children needed ~370px in a ~190px cell, so the panel scrolled sideways). */
.pe-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px 14px; }
.pe-grid > * { min-width: 0; }
.pe-6 { grid-column: span 6; } .pe-5 { grid-column: span 5; } .pe-4 { grid-column: span 4; }
.pe-3 { grid-column: span 3; } .pe-2 { grid-column: span 2; } .pe-1 { grid-column: span 1; }
.pe-group { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 16px; }
.pe-group:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
/* The bundle and sizes editors are Bootstrap .row blocks, whose negative gutter margins would push past the panel body. */
.pe-group .row { margin-inline: 0; }
.pe-eb { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.pe-kinds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pe-kind { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: var(--radius-lg);
           padding: 7px 10px; cursor: pointer; background: var(--card-bg); margin: 0; }
.pe-kind input { margin-top: 3px; accent-color: var(--accent); }
.pe-kind b { display: block; font-size: 13px; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.pe-kind > div > span { display: block; font-size: 11.5px; color: var(--text-secondary); line-height: 1.35; }
.pe-kind b .cc-help, .pe-grid .cc-help, .pe-segs .cc-help, .pe-inline-checks .cc-help { margin-left: 4px; }
.pe-segs .cc-help { margin-right: -4px; }
.pe-kind.on { border-color: var(--accent); background: var(--accent-light); box-shadow: inset 3px 0 0 var(--accent); }
.pe-kind.disabled { opacity: .6; cursor: not-allowed; }
.pe-kind.wide { grid-column: span 2; }
.pe-price .input-group-text { font-weight: 600; }
.pe-example { font-size: 12px; color: var(--text-secondary); background: var(--content-bg); border: 1px solid var(--border);
              border-radius: var(--radius-md); padding: 6px 10px; margin-top: 6px; }
.pe-example b { color: var(--text-primary); }
/* Container weight (the empty basket) sits on its own row under the price row: the box on the left half, its hint beside it. */
.pe-container { display: flex; align-items: flex-end; gap: 14px; }
.pe-container-field { flex: 0 1 50%; min-width: 0; }
.pe-container-hint { font-size: 12px; color: var(--text-secondary); padding-bottom: 8px; line-height: 1.35; }
@media (max-width: 767.98px) { .pe-container { flex-direction: column; align-items: stretch; gap: 4px; } .pe-container-field { flex-basis: auto; } .pe-container-hint { padding-bottom: 0; } }
.pe-card { border: 1px solid var(--border); border-left: 3px solid var(--cc-green-md); border-radius: var(--radius-lg);
           background: var(--card-bg); padding: 12px 14px; }
.pe-card.amber { border-left-color: var(--accent); }
.pe-card h4 { font-size: 13.5px; font-weight: 700; margin: 0 0 4px; }
.pe-card p { font-size: 12.5px; color: var(--text-secondary); margin: 0 0 8px; line-height: 1.5; }
.pe-card p:last-child { margin-bottom: 0; }
.pe-used { display: flex; gap: 10px; align-items: center; font-size: 12.5px; padding: 8px 0; border-top: 1px solid var(--border); }
.pe-used:first-of-type { border-top: 0; }
.pe-used .grow { flex: 1 1 auto; min-width: 0; }
.pe-used .name { font-weight: 600; color: var(--text-primary); }
.pe-used .meta { color: var(--text-muted); }
.pe-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px;
           border-radius: var(--radius-full); background: var(--status-locked-bg); color: var(--status-locked-fg); white-space: nowrap; }
.pe-more { border: 1px solid var(--border); border-radius: var(--radius-lg); margin-top: 8px; }
.pe-more-h { display: flex; align-items: center; gap: 10px; white-space: nowrap; padding: 10px 12px; font-size: 13px; font-weight: 600;
             cursor: pointer; width: 100%; text-align: start; color: var(--text-primary); }
.pe-more-h .sum { font-weight: 400; color: var(--text-muted); font-size: 12px; flex: 1 1 auto; min-width: 0;
                  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-more-h i { color: var(--text-muted); }
.pe-more-b { padding: 4px 12px 12px; }
/* No overflow:hidden here: the info popovers inside the choices would be clipped. The end labels carry the rounding. */
.pe-segs { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-md); }
.pe-segs label:first-child { border-radius: calc(var(--radius-md) - 1px) 0 0 calc(var(--radius-md) - 1px); }
.pe-segs label:last-child { border-radius: 0 calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px) 0; }
.pe-segs label { font-size: 12.5px; padding: 6px 12px; border-right: 1px solid var(--border); cursor: pointer; margin: 0; background: var(--card-bg); white-space: nowrap; }
.pe-segs label:last-child { border-right: 0; }
.pe-segs label.on { background: var(--status-locked-bg); color: var(--status-locked-fg); font-weight: 600; }
.pe-segs input { position: absolute; opacity: 0; pointer-events: none; }
.pe-inline-checks { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
/* The star beside Name: a toggle, not a tick. The checkbox stays real (keyboard, screen reader). */
.pe-star { display: flex; align-items: center; justify-content: center; width: 100%; height: 38px; margin: 0;
           border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer; background: var(--card-bg);
           color: var(--text-muted); font-size: 17px; }
.pe-star.on { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }
.pe-star input { position: absolute; opacity: 0; pointer-events: none; }
.pe-star:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Free-text field that looks like (and is) a list. */
.pe-combo { position: relative; }
.pe-combo > .form-control { padding-right: 2.2rem; }
.pe-combo-chevron { position: absolute; top: 0; right: 0; height: 100%; width: 2.2rem; border: 0; background: none;
                    color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.pe-combo-chevron[aria-disabled="true"] { cursor: not-allowed; opacity: .5; }
.pe-combo-list { position: absolute; z-index: var(--z-raised); left: 0; right: 0; top: calc(100% + 2px); margin: 0; padding: 4px 0; list-style: none;
                 max-height: 220px; overflow-y: auto; background: var(--card-bg); border: 1px solid var(--border);
                 border-radius: var(--radius-md); box-shadow: var(--cc-shadow-panel); }
.pe-combo-item { padding: 6px 12px; font-size: 13px; cursor: pointer; }
.pe-combo-item:hover { background: var(--content-bg); }
.pe-combo-new { padding: 6px 12px; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 4px; }
.pe-notice { font-size: 12px; color: var(--text-secondary); background: var(--warning-light); border-radius: var(--radius-md);
             padding: 6px 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
