/* ════════════════════════════════════════════════════════════════════════
   FiberX B2G Portal
   The Dashboard's design language — the purple/orange pair, white cards on a
   tinted gradient with the concentric-ring backdrop — carried over and
   tightened: one spacing scale, status colours as tokens, visible focus, and
   layout written in logical properties so the same rules serve English (LTR)
   and Arabic (RTL).
   Prefix: b2g-
   ════════════════════════════════════════════════════════════════════════ */

:root {
    --fx-primary-orange: #FF7B53;
    --fx-secondary-orange: #FF9575;
    --fx-orange-ink: #C6472A;
    --fx-purple: #4B3E7B;
    --fx-light-purple: #7B68B8;
    --fx-dark: #2D2350;

    --fx-bg-1: #E8E5F0;
    --fx-bg-2: #F5F3F8;
    --fx-bg-3: #FFF5F0;

    --fx-text: #2D2350;
    --fx-body: #374151;
    --fx-muted: #6B7280;
    --fx-faint: #9CA3AF;
    --fx-border: rgba(0, 0, 0, .06);
    --fx-line: rgba(75, 62, 123, .16);
    --fx-tint: rgba(75, 62, 123, .06);
    --fx-card: #ffffff;
    --fx-danger: #B91C1C;

    /* Status colours: ink, wash and outline for each, used by badges AND stat tiles. */
    --st-new: #1D4ED8;        --st-new-bg: rgba(59, 130, 246, .12);   --st-new-line: rgba(59, 130, 246, .3);
    --st-progress: #B45309;   --st-progress-bg: rgba(245, 158, 11, .13); --st-progress-line: rgba(245, 158, 11, .34);
    --st-hold: #4B5563;       --st-hold-bg: rgba(107, 114, 128, .12); --st-hold-line: rgba(107, 114, 128, .3);
    --st-resolved: #047857;   --st-resolved-bg: rgba(16, 185, 129, .12); --st-resolved-line: rgba(16, 185, 129, .3);
    --st-closed: #4B3E7B;     --st-closed-bg: rgba(75, 62, 123, .12); --st-closed-line: rgba(75, 62, 123, .3);

    --fx-radius-lg: 20px;
    --fx-radius: 14px;
    --fx-radius-sm: 10px;

    --fx-shadow-lg: 0 30px 80px rgba(0, 0, 0, .10);
    --fx-shadow: 0 14px 44px rgba(45, 35, 80, .07);

    --fx-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --fx-mono: ui-monospace, 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

/* Arabic: Cairo. It sits larger on its baseline than Inter and has no true uppercase, so the
   small-caps label style used in English (uppercase + tracking) is switched off below. */
html[lang="ar"] {
    --fx-font: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: var(--fx-font);
    color: var(--fx-text);
    background: linear-gradient(135deg, var(--fx-bg-1) 0%, var(--fx-bg-2) 50%, var(--fx-bg-3) 100%);
    background-attachment: fixed;
    -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font-family: inherit; }

/* Alpine hides elements with x-cloak until it has initialised. */
[x-cloak] { display: none !important; }

:focus-visible {
    outline: 2px solid var(--fx-primary-orange);
    outline-offset: 2px;
}

/* Visible to assistive tech only (also hides native file inputs behind their styled labels). */
.b2g-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.b2g-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Directional glyphs (back arrow, chevron, send, sign-out) point the other way in RTL. */
[dir="rtl"] .b2g-flip { transform: scaleX(-1); }

.b2g-mono { font-family: var(--fx-mono); font-size: .95em; }
.b2g-muted { color: var(--fx-faint); font-weight: 600; }
.b2g-mt { margin-top: 10px; }
.b2g-req { color: var(--fx-orange-ink); }

/* ── Ring backdrop, matching the Dashboard's ── */
.b2g-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.b2g-wave {
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    opacity: .30;
}

.b2g-wave-1 {
    background: repeating-radial-gradient(circle at 50% 50%,
        transparent 0, transparent 30px,
        rgba(123, 104, 184, .12) 32px, rgba(123, 104, 184, .12) 34px);
}

.b2g-wave-2 {
    background: repeating-radial-gradient(circle at 50% 50%,
        transparent 0, transparent 40px,
        rgba(255, 123, 83, .10) 42px, rgba(255, 123, 83, .10) 44px);
}

.b2g-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

/* ════════════════════════════════════════════════════════════════════════
   Auth screens
   ════════════════════════════════════════════════════════════════════════ */

.b2g-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.b2g-auth-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--fx-card);
    border: 1px solid var(--fx-border);
    border-radius: var(--fx-radius-lg);
    box-shadow: var(--fx-shadow-lg);
    padding: 52px 30px 30px;
}

.b2g-auth-logo {
    display: block;
    height: 44px;
    margin: 0 auto 10px;
}

.b2g-auth-badge,
.b2g-brand-tag {
    font-family: 'Inter', sans-serif;
    font-weight: 900;
    letter-spacing: 1px;
    color: #fff;
    background: var(--fx-purple);
    border-radius: 6px;
}

.b2g-auth-badge {
    width: fit-content;
    margin: 0 auto 18px;
    padding: 2px 10px;
    font-size: 11px;
}

.b2g-auth-title {
    font-size: 21px;
    font-weight: 800;
    text-align: center;
    color: var(--fx-dark);
    margin: 0 0 6px;
}

.b2g-auth-sub {
    font-size: 13.5px;
    font-weight: 500;
    text-align: center;
    color: var(--fx-muted);
    margin: 0 0 22px;
    line-height: 1.6;
}

.b2g-auth-card .b2g-dialog-icon { margin-bottom: 14px; }

/* ════════════════════════════════════════════════════════════════════════
   Form controls
   ════════════════════════════════════════════════════════════════════════ */

.b2g-field { margin-bottom: 16px; }

.b2g-label {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--fx-dark);
    margin-bottom: 7px;
}

.b2g-input,
.b2g-select {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid rgba(75, 62, 123, .22);
    border-radius: var(--fx-radius-sm);
    background: #fff;
    font-size: 14px;
    font-weight: 500;
    color: var(--fx-text);
    transition: border-color .15s, box-shadow .15s;
}

.b2g-input::placeholder { color: var(--fx-faint); font-weight: 400; }

.b2g-input:focus,
.b2g-select:focus,
.b2g-search:focus {
    outline: none;
    border-color: var(--fx-purple);
    box-shadow: 0 0 0 3px rgba(75, 62, 123, .14);
}

.b2g-textarea {
    resize: vertical;
    min-height: 84px;
    line-height: 1.6;
}

.b2g-hint {
    display: block;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--fx-muted);
    margin-top: 5px;
}

.b2g-hint-inline { margin-top: 0; }

.b2g-fielderror {
    font-size: 12px;
    font-weight: 600;
    color: var(--fx-danger);
    margin-top: 6px;
    line-height: 1.5;
}

.b2g-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 14px;
}

/* ── Buttons ── */
.b2g-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 17px;
    border: 1px solid transparent;
    border-radius: var(--fx-radius-sm);
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: .4px;
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: transform .12s, box-shadow .15s, opacity .15s, background .15s;
}

html[lang="ar"] .b2g-btn { letter-spacing: 0; font-size: 13.5px; font-weight: 700; }

.b2g-btn:disabled { opacity: .55; cursor: not-allowed; }
.b2g-btn:not(:disabled):hover { transform: translateY(-1px); }

.b2g-btn-primary {
    background: linear-gradient(135deg, var(--fx-primary-orange), var(--fx-secondary-orange));
    color: #fff;
    box-shadow: 0 10px 24px rgba(255, 123, 83, .28);
    /* The orange is light, so the label gets a hairline of shade to hold its edge. */
    text-shadow: 0 1px 0 rgba(170, 60, 30, .35);
}

.b2g-btn-purple {
    background: var(--fx-purple);
    color: #fff;
    box-shadow: 0 10px 24px rgba(75, 62, 123, .22);
}

.b2g-btn-ghost {
    background: #fff;
    color: var(--fx-purple);
    border-color: rgba(75, 62, 123, .26);
}

.b2g-btn-ghost:not(:disabled):hover { background: var(--fx-tint); }

.b2g-btn-block { width: 100%; }
.b2g-btn-sm { padding: 8px 13px; font-size: 11.5px; }
html[lang="ar"] .b2g-btn-sm { font-size: 12.5px; }

.b2g-linkbtn {
    padding: 2px 0;
    border: none;
    background: none;
    color: var(--fx-purple);
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.b2g-linkbtn:hover { color: var(--fx-orange-ink); }
.b2g-linkbtn:disabled { opacity: .5; cursor: default; }
.b2g-linkbtn-danger { color: var(--fx-danger); }
.b2g-auth-card .b2g-linkbtn { display: block; margin-inline: auto; }

.b2g-iconbtn {
    position: relative;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border: 1px solid rgba(75, 62, 123, .2);
    border-radius: 10px;
    background: #fff;
    color: var(--fx-purple);
    cursor: pointer;
    transition: background .15s;
}

.b2g-iconbtn:hover { background: var(--fx-tint); }
.b2g-iconbtn-sm { width: 30px; height: 30px; border-radius: 8px; }
.b2g-iconbtn-sm .b2g-icon { width: 15px; height: 15px; }

/* ── Language switch ── */
.b2g-lang {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid rgba(75, 62, 123, .2);
    border-radius: 10px;
    background: #fff;
    color: var(--fx-purple);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
}

/* The switch names the OTHER language, so it is set in that language's face. */
html[lang="en"] .b2g-lang span { font-family: 'Cairo', sans-serif; }
html[lang="ar"] .b2g-lang span { font-family: 'Inter', sans-serif; }

.b2g-lang:hover { background: var(--fx-tint); }
.b2g-lang .b2g-icon { width: 16px; height: 16px; }

.b2g-lang-corner {
    position: absolute;
    top: 14px;
    inset-inline-end: 14px;
    height: 32px;
}

/* ── Inline messages ── */
.b2g-error {
    border-radius: var(--fx-radius-sm);
    padding: 10px 13px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    line-height: 1.55;
    background: rgba(242, 28, 13, .07);
    border: 1px solid rgba(242, 28, 13, .24);
    color: var(--fx-danger);
}

/* ════════════════════════════════════════════════════════════════════════
   App bar
   ════════════════════════════════════════════════════════════════════════ */

.b2g-appbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 22px;
    background: rgba(255, 255, 255, .93);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--fx-border);
    box-shadow: 0 6px 24px rgba(0, 0, 0, .05);
}

.b2g-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.b2g-appbar-logo { height: 30px; display: block; }
.b2g-brand-tag { padding: 1px 7px; font-size: 10px; }

.b2g-appbar-titles {
    line-height: 1.25;
    min-width: 0;
    padding-inline-start: 12px;
    border-inline-start: 1px solid var(--fx-line);
}

.b2g-appbar-title {
    font-size: 14.5px;
    font-weight: 800;
    color: var(--fx-dark);
    white-space: nowrap;
}

.b2g-appbar-sub {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--fx-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 340px;
}

.b2g-appbar-spacer { flex: 1; }

/* Live-connection indicator */
.b2g-live {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 11px;
    height: 30px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
    color: var(--fx-muted);
    background: rgba(107, 114, 128, .1);
}

.b2g-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.b2g-live-on { color: var(--st-resolved); background: var(--st-resolved-bg); }
.b2g-live-on .b2g-live-dot { animation: b2g-pulse 2.4s ease-out infinite; }
.b2g-live-connecting { color: var(--st-progress); background: var(--st-progress-bg); }

@keyframes b2g-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, .55); }
    70%  { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.b2g-badge {
    position: absolute;
    top: -6px;
    inset-inline-end: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--fx-primary-orange);
    border: 2px solid #fff;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}

.b2g-user {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 38px;
    padding-block: 0;
    padding-inline: 5px 13px;
    border-radius: 999px;
    background: rgba(75, 62, 123, .08);
    border: 1px solid var(--fx-line);
    cursor: pointer;
}

.b2g-user:hover { background: rgba(75, 62, 123, .13); }

.b2g-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--fx-purple);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
}

.b2g-user-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--fx-dark);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Popovers (notifications, user menu) ── */
.b2g-pop-anchor { position: relative; }

.b2g-pop {
    position: absolute;
    top: calc(100% + 10px);
    inset-inline-end: 0;
    z-index: 40;
    width: 240px;
    background: #fff;
    border: 1px solid var(--fx-border);
    border-radius: var(--fx-radius);
    box-shadow: 0 24px 60px rgba(45, 35, 80, .2);
    overflow: hidden;
}

.b2g-pop-wide { width: min(360px, calc(100vw - 24px)); }

.b2g-pop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--fx-border);
    font-size: 13px;
    font-weight: 800;
    color: var(--fx-dark);
}

.b2g-pop-empty {
    padding: 26px 18px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--fx-muted);
    line-height: 1.6;
}

.b2g-pop-user { padding: 13px 14px; border-bottom: 1px solid var(--fx-border); }
.b2g-pop-user-name { font-size: 13.5px; font-weight: 800; color: var(--fx-dark); }
.b2g-pop-user-sub { font-family: var(--fx-mono); font-size: 12px; color: var(--fx-muted); text-align: start; }

.b2g-menuitem {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 14px;
    border: none;
    background: none;
    color: var(--fx-dark);
    font-size: 13px;
    font-weight: 600;
    text-align: start;
    cursor: pointer;
}

.b2g-menuitem:hover { background: var(--fx-tint); }
.b2g-menuitem-danger { color: var(--fx-danger); }
.b2g-menuitem .b2g-icon { width: 16px; height: 16px; }

.b2g-notif-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 380px;
    overflow-y: auto;
}

.b2g-notif {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    padding: 11px 14px;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, .04);
    background: none;
    text-align: start;
    cursor: pointer;
}

.b2g-notif:hover { background: var(--fx-tint); }

.b2g-notif-unread {
    background: rgba(255, 123, 83, .07);
    box-shadow: inset 3px 0 0 var(--fx-primary-orange);
}

[dir="rtl"] .b2g-notif-unread { box-shadow: inset -3px 0 0 var(--fx-primary-orange); }

.b2g-notif-top { display: flex; justify-content: space-between; gap: 10px; }
.b2g-notif-number { font-family: var(--fx-mono); font-size: 12px; font-weight: 700; color: var(--fx-purple); }
.b2g-notif-time { font-size: 11px; font-weight: 500; color: var(--fx-faint); white-space: nowrap; }
.b2g-notif-text { font-size: 13px; font-weight: 700; color: var(--fx-dark); line-height: 1.45; }

.b2g-notif-subject {
    font-size: 12px;
    font-weight: 500;
    color: var(--fx-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ════════════════════════════════════════════════════════════════════════
   Page + cards
   ════════════════════════════════════════════════════════════════════════ */

.b2g-page {
    max-width: 1320px;
    margin: 0 auto;
    padding: 22px 22px 48px;
}

.b2g-card {
    background: var(--fx-card);
    border: 1px solid var(--fx-border);
    border-radius: var(--fx-radius-lg);
    box-shadow: var(--fx-shadow);
    padding: 18px 20px;
    margin-bottom: 14px;
}

.b2g-page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.b2g-page-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--fx-dark);
    margin: 0;
    line-height: 1.25;
}

.b2g-page-sub {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--fx-muted);
    margin: 4px 0 0;
}

.b2g-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Stat tiles ── */
.b2g-stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.b2g-stat {
    --tile: var(--fx-purple);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 14px 16px;
    border: 1px solid var(--fx-border);
    border-top: 3px solid var(--tile);
    border-radius: var(--fx-radius);
    background: var(--fx-card);
    box-shadow: var(--fx-shadow);
    text-align: start;
    cursor: pointer;
    transition: transform .12s, box-shadow .15s;
}

.b2g-stat:hover { transform: translateY(-2px); }

.b2g-stat-active {
    border-color: var(--tile);
    box-shadow: 0 0 0 2px var(--tile), var(--fx-shadow);
}

.b2g-stat-value {
    font-family: 'Inter', sans-serif;
    font-size: 26px;
    font-weight: 800;
    line-height: 1.1;
    color: var(--fx-dark);
    font-variant-numeric: tabular-nums;
}

.b2g-stat-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--tile);
}

.b2g-stat.b2g-status-new        { --tile: var(--st-new); }
.b2g-stat.b2g-status-inprogress { --tile: var(--st-progress); }
.b2g-stat.b2g-status-onhold     { --tile: var(--st-hold); }
.b2g-stat.b2g-status-resolved   { --tile: var(--st-resolved); }
.b2g-stat.b2g-status-closed     { --tile: var(--st-closed); }
.b2g-stat-total                 { --tile: var(--fx-primary-orange); }
.b2g-stat-total .b2g-stat-label { color: var(--fx-orange-ink); }

/* ── Toolbar ── */
.b2g-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 16px;
}

.b2g-search-wrap {
    position: relative;
    flex: 1 1 260px;
    min-width: 200px;
    color: var(--fx-faint);
}

.b2g-search-wrap .b2g-icon {
    position: absolute;
    top: 50%;
    inset-inline-start: 14px;
    transform: translateY(-50%);
    pointer-events: none;
}

.b2g-search {
    width: 100%;
    padding-block: 11px;
    padding-inline: 42px 14px;
    border: 1px solid rgba(75, 62, 123, .22);
    border-radius: 999px;
    background: #fff;
    font-size: 14px;
    font-weight: 500;
    color: var(--fx-text);
}

.b2g-toolbar .b2g-select { flex: 0 1 190px; width: auto; }

.b2g-date {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 700;
    color: var(--fx-muted);
}

.b2g-date .b2g-input { width: auto; padding: 9px 10px; font-size: 13px; }

/* ════════════════════════════════════════════════════════════════════════
   Table
   ════════════════════════════════════════════════════════════════════════ */

.b2g-table-wrap {
    background: var(--fx-card);
    border: 1px solid var(--fx-border);
    border-radius: var(--fx-radius-lg);
    box-shadow: var(--fx-shadow);
    overflow: hidden;
    transition: opacity .15s;
}

/* A reload over existing rows dims them rather than swapping in a spinner. */
.b2g-busy { opacity: .6; }

.b2g-table-scroll { overflow-x: auto; }

.b2g-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.b2g-table thead th {
    background: #FAFAFC;
    border-bottom: 1px solid var(--fx-line);
    padding: 12px 16px;
    text-align: start;
    font-size: 11px;
    font-weight: 800;
    color: var(--fx-purple);
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}

html[lang="ar"] .b2g-table thead th { font-size: 12.5px; letter-spacing: 0; font-weight: 700; }

.b2g-table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, .045);
    font-weight: 500;
    color: var(--fx-body);
    vertical-align: middle;
}

.b2g-table tbody tr { cursor: pointer; transition: background .12s; }
.b2g-table tbody tr:hover { background: rgba(75, 62, 123, .045); }
.b2g-table tbody tr:focus-visible { outline-offset: -2px; }
.b2g-table tbody tr:last-child td { border-bottom: none; }

.b2g-td-ticket {
    font-family: var(--fx-mono);
    font-size: 13px;
    font-weight: 700;
    color: var(--fx-purple);
    white-space: nowrap;
}

.b2g-td-subject {
    display: block;
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
    color: var(--fx-dark);
}

.b2g-td-date { white-space: nowrap; color: var(--fx-muted); font-size: 12.5px; }

.b2g-td-meta { white-space: nowrap; text-align: end; color: var(--fx-faint); }

.b2g-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-inline-end: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: var(--fx-muted);
    vertical-align: middle;
}

.b2g-count .b2g-icon { width: 14px; height: 14px; }
.b2g-row-arrow { width: 16px; height: 16px; vertical-align: middle; }

.b2g-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 54px 20px;
    text-align: center;
    color: var(--fx-muted);
    font-size: 14px;
    font-weight: 600;
}

.b2g-empty p { margin: 0; }
.b2g-empty-icon { width: 40px; height: 40px; stroke-width: 1.5; color: var(--fx-light-purple); }

/* ── Chips and status badges ── */
.b2g-chip {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    background: rgba(75, 62, 123, .08);
    border: 1px solid rgba(75, 62, 123, .2);
    color: var(--fx-purple);
}

.b2g-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .3px;
    text-transform: uppercase;
    white-space: nowrap;
}

html[lang="ar"] .b2g-status { font-size: 12.5px; letter-spacing: 0; font-weight: 700; }

.b2g-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.b2g-status.b2g-status-new        { color: var(--st-new);      background: var(--st-new-bg);      border-color: var(--st-new-line); }
.b2g-status.b2g-status-inprogress { color: var(--st-progress); background: var(--st-progress-bg); border-color: var(--st-progress-line); }
.b2g-status.b2g-status-onhold     { color: var(--st-hold);     background: var(--st-hold-bg);     border-color: var(--st-hold-line); }
.b2g-status.b2g-status-resolved   { color: var(--st-resolved); background: var(--st-resolved-bg); border-color: var(--st-resolved-line); }
.b2g-status.b2g-status-closed     { color: var(--st-closed);   background: var(--st-closed-bg);   border-color: var(--st-closed-line); }

/* ── Pagination ── */
.b2g-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-top: 1px solid rgba(0, 0, 0, .05);
    background: #FAFAFC;
}

.b2g-pager-info { font-size: 12.5px; font-weight: 600; color: var(--fx-muted); }
.b2g-pager-controls { display: flex; align-items: center; gap: 10px; }

.b2g-pager-pill {
    padding: 5px 13px;
    border-radius: 999px;
    background: rgba(75, 62, 123, .10);
    border: 1px solid var(--fx-line);
    color: var(--fx-purple);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 800;
}

.b2g-pager-btn {
    padding: 7px 14px;
    border: 1px solid rgba(75, 62, 123, .22);
    border-radius: 8px;
    background: #fff;
    color: var(--fx-purple);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
}

.b2g-pager-btn:disabled { opacity: .45; cursor: not-allowed; }
.b2g-pager-btn:not(:disabled):hover { background: var(--fx-tint); }

/* ════════════════════════════════════════════════════════════════════════
   Ticket details
   ════════════════════════════════════════════════════════════════════════ */

.b2g-backlink {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 14px;
    padding: 6px 2px;
    border: none;
    background: none;
    color: var(--fx-purple);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.b2g-backlink:hover { color: var(--fx-orange-ink); }

.b2g-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    border-top: 3px solid var(--fx-primary-orange);
}

.b2g-detail-head-main { min-width: 0; flex: 1 1 320px; }

.b2g-detail-number {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.b2g-detail-subject {
    margin: 0;
    font-size: 21px;
    font-weight: 800;
    color: var(--fx-dark);
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.b2g-detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 14px;
    align-items: start;
}

.b2g-section-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12.5px;
    font-weight: 800;
    color: var(--fx-purple);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--fx-line);
}

html[lang="ar"] .b2g-section-title { font-size: 14.5px; letter-spacing: 0; }

.b2g-section-count {
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(75, 62, 123, .1);
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    letter-spacing: 0;
}

.b2g-longtext {
    font-size: 14.5px;
    font-weight: 400;
    color: var(--fx-body);
    line-height: 1.75;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 0;
    max-width: 75ch;
}

.b2g-card > .b2g-muted { margin: 0; font-size: 13.5px; }

/* ── Facts list (side column) ── */
.b2g-facts { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.b2g-facts > div { padding-bottom: 11px; border-bottom: 1px dashed rgba(0, 0, 0, .07); }
.b2g-facts > div:last-child { padding-bottom: 0; border-bottom: none; }

.b2g-facts dt {
    font-size: 11px;
    font-weight: 700;
    color: var(--fx-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 4px;
}

html[lang="ar"] .b2g-facts dt { font-size: 12.5px; letter-spacing: 0; }

.b2g-facts dd {
    margin: 0;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--fx-dark);
    overflow-wrap: anywhere;
    text-align: start;
}

.b2g-maplink {
    display: inline-flex;
    align-items: flex-start;
    gap: 8px;
    color: var(--fx-purple);
    text-decoration: none;
}

.b2g-maplink .b2g-icon { margin-top: 2px; color: var(--fx-primary-orange); }
.b2g-maplink > span { display: flex; flex-direction: column; gap: 2px; }

.b2g-maplink-cta {
    font-size: 12px;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.b2g-maplink:hover .b2g-maplink-cta { color: var(--fx-orange-ink); }

/* ── Files ── */
.b2g-files {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
}

.b2g-file,
.b2g-upload {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    padding: 9px 11px;
    border: 1px solid var(--fx-line);
    border-radius: var(--fx-radius-sm);
    background: #fff;
    color: var(--fx-dark);
    text-decoration: none;
}

.b2g-file:hover { background: var(--fx-tint); border-color: var(--fx-light-purple); }

.b2g-file-thumb {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    object-fit: cover;
    background: rgba(75, 62, 123, .08);
    display: grid;
    place-items: center;
    color: var(--fx-purple);
}

.b2g-file-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }

.b2g-file-name {
    font-size: 13px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.b2g-file-size { font-family: 'Inter', sans-serif; font-size: 11.5px; font-weight: 500; color: var(--fx-muted); text-align: start; }

/* ── Comments ── */
.b2g-comments { display: flex; flex-direction: column; gap: 11px; margin-bottom: 16px; }

.b2g-comment {
    max-width: 88%;
    border: 1px solid var(--fx-line);
    border-radius: var(--fx-radius);
    border-start-start-radius: 4px;
    background: #FBFAFD;
    padding: 11px 14px;
}

/* The user's own comments sit on the far side in the brand orange wash, like a chat thread. */
.b2g-comment-mine {
    align-self: flex-end;
    border-color: rgba(255, 123, 83, .32);
    background: rgba(255, 123, 83, .07);
    border-start-start-radius: var(--fx-radius);
    border-start-end-radius: 4px;
}

.b2g-comment-head {
    display: flex;
    align-items: baseline;
    gap: 9px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.b2g-comment-author { font-size: 13px; font-weight: 800; color: var(--fx-dark); }
.b2g-comment-time { font-size: 11.5px; font-weight: 500; color: var(--fx-muted); }

.b2g-comment-tag {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--fx-muted);
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(107, 114, 128, .12);
}

.b2g-comment-body {
    font-size: 14px;
    font-weight: 400;
    color: var(--fx-body);
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 0;
}

.b2g-comment-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }

.b2g-filelink {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--fx-line);
    background: #fff;
    color: var(--fx-purple);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.b2g-filelink:hover { background: var(--fx-tint); }
.b2g-filelink .b2g-icon { width: 13px; height: 13px; }

.b2g-composer { padding-top: 14px; border-top: 1px solid var(--fx-line); }
.b2g-comments + .b2g-composer, .b2g-muted + .b2g-composer { margin-top: 14px; }

.b2g-composer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.b2g-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }

.b2g-filechip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 240px;
    padding-block: 3px;
    padding-inline: 11px 5px;
    border-radius: 999px;
    background: rgba(75, 62, 123, .08);
    border: 1px solid var(--fx-line);
    font-size: 12px;
    font-weight: 600;
    color: var(--fx-dark);
}

.b2g-filechip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.b2g-filechip-x {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--fx-muted);
    cursor: pointer;
}

.b2g-filechip-x:hover { background: rgba(0, 0, 0, .08); color: var(--fx-danger); }
.b2g-filechip-x .b2g-icon { width: 12px; height: 12px; }

/* ── Activity timeline ── */
.b2g-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 340px;
    overflow-y: auto;
}

.b2g-timeline li {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-block: 0 14px;
    padding-inline-start: 20px;
    border-inline-start: 2px solid var(--fx-line);
    margin-inline-start: 5px;
}

.b2g-timeline li:last-child { padding-bottom: 0; border-color: transparent; }

.b2g-timeline li::before {
    content: '';
    position: absolute;
    top: 4px;
    inset-inline-start: -6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--fx-light-purple);
}

.b2g-timeline li:first-child::before { background: var(--fx-primary-orange); border-color: var(--fx-primary-orange); }

.b2g-timeline-text { font-size: 13px; font-weight: 600; color: var(--fx-dark); line-height: 1.5; overflow-wrap: anywhere; text-align: start; }
.b2g-timeline-time { font-size: 11.5px; font-weight: 500; color: var(--fx-muted); }

/* ════════════════════════════════════════════════════════════════════════
   Dialogs
   ════════════════════════════════════════════════════════════════════════ */

.b2g-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 14px;
    background: rgba(45, 35, 80, .45);
    backdrop-filter: blur(3px);
}

.b2g-dialog {
    width: 100%;
    max-width: 460px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--fx-card);
    border-radius: var(--fx-radius-lg);
    box-shadow: 0 40px 90px rgba(0, 0, 0, .28);
    padding: 26px;
}

.b2g-dialog-lg { max-width: 680px; padding: 0; display: flex; flex-direction: column; overflow: hidden; }

/* The large dialog keeps its title in view while the form scrolls beneath it. */
.b2g-dialog-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--fx-line);
    border-top: 3px solid var(--fx-primary-orange);
}

.b2g-dialog-body { padding: 20px 24px 22px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }

.b2g-dialog-head { text-align: center; margin-bottom: 20px; }

.b2g-dialog-icon {
    width: 46px;
    height: 46px;
    margin: 0 auto 11px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(255, 123, 83, .16), rgba(75, 62, 123, .14));
    color: var(--fx-purple);
}

.b2g-dialog-title { font-size: 18px; font-weight: 800; color: var(--fx-dark); margin: 0 0 4px; }
.b2g-dialog-sub { font-size: 13px; font-weight: 500; color: var(--fx-muted); margin: 0; line-height: 1.55; }

.b2g-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

/* ── Location capture ── */
.b2g-location {
    padding: 12px 14px;
    border: 1px dashed rgba(75, 62, 123, .32);
    border-radius: var(--fx-radius-sm);
    background: var(--fx-tint);
}

.b2g-location-set {
    border-style: solid;
    border-color: var(--st-resolved-line);
    background: var(--st-resolved-bg);
}

.b2g-location-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.b2g-location-pin { color: var(--st-resolved); width: 22px; height: 22px; }
.b2g-location-values { display: flex; flex-direction: column; flex: 1; min-width: 160px; }
.b2g-location-values .b2g-hint { margin-top: 1px; }
.b2g-location-coords { font-size: 14px; font-weight: 700; color: var(--fx-dark); text-align: start; }

/* ── Drop zone ── */
.b2g-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 22px 16px;
    border: 2px dashed rgba(75, 62, 123, .3);
    border-radius: var(--fx-radius);
    background: #FCFBFE;
    text-align: center;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.b2g-drop:hover,
.b2g-drop:focus-within { border-color: var(--fx-light-purple); background: var(--fx-tint); }

.b2g-drop-active {
    border-color: var(--fx-primary-orange);
    border-style: solid;
    background: rgba(255, 123, 83, .08);
}

.b2g-drop-icon { width: 28px; height: 28px; color: var(--fx-light-purple); stroke-width: 1.6; }
.b2g-drop-text { font-size: 13.5px; font-weight: 600; color: var(--fx-dark); }
.b2g-drop-browse { color: var(--fx-orange-ink); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.b2g-drop .b2g-hint { margin-top: 0; }

.b2g-uploads {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 8px;
}

/* ── Status picker ── */
.b2g-statuspick { display: flex; flex-wrap: wrap; gap: 8px; }

.b2g-statusopt {
    padding: 7px 9px;
    border: 2px solid transparent;
    border-radius: 12px;
    background: #F7F6FA;
    cursor: pointer;
}

.b2g-statusopt:hover { background: #EFEDF5; }
.b2g-statusopt-on { border-color: var(--fx-purple); background: #fff; }
.b2g-statusopt:focus-within { outline: 2px solid var(--fx-primary-orange); outline-offset: 2px; }

/* ════════════════════════════════════════════════════════════════════════
   Toasts
   ════════════════════════════════════════════════════════════════════════ */

.b2g-toasts {
    position: fixed;
    z-index: 80;
    bottom: 20px;
    inset-inline-end: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(380px, calc(100vw - 28px));
    pointer-events: none;
}

.b2g-toast {
    --toast: var(--fx-purple);
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    border-radius: var(--fx-radius);
    border: 1px solid var(--fx-border);
    border-inline-start: 4px solid var(--toast);
    background: #fff;
    box-shadow: 0 20px 50px rgba(45, 35, 80, .22);
}

.b2g-toast-success { --toast: var(--st-resolved); }
.b2g-toast-error   { --toast: var(--fx-danger); }
.b2g-toast-info    { --toast: var(--fx-primary-orange); }

.b2g-toast-icon { color: var(--toast); margin-top: 1px; }

.b2g-toast-text {
    flex: 1;
    padding: 0;
    border: none;
    background: none;
    color: var(--fx-dark);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.5;
    text-align: start;
    cursor: pointer;
}

.b2g-toast-x {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--fx-faint);
    cursor: pointer;
}

.b2g-toast-x:hover { background: rgba(0, 0, 0, .06); color: var(--fx-dark); }
.b2g-toast-x .b2g-icon { width: 14px; height: 14px; }

/* ════════════════════════════════════════════════════════════════════════
   Spinner / loading
   ════════════════════════════════════════════════════════════════════════ */

.b2g-spinner {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: b2g-spin .7s linear infinite;
}

.b2g-spinner-purple {
    border-color: rgba(75, 62, 123, .25);
    border-top-color: var(--fx-purple);
}

@keyframes b2g-spin { to { transform: rotate(360deg); } }

.b2g-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    padding: 50px 20px;
    color: var(--fx-muted);
    font-size: 13.5px;
    font-weight: 600;
}

.b2g-loading-full { min-height: 100vh; }
.b2g-loading-full .b2g-spinner { width: 30px; height: 30px; border-width: 3px; }

/* ════════════════════════════════════════════════════════════════════════
   Narrower screens
   ════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1080px) {
    .b2g-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .b2g-detail-layout { grid-template-columns: minmax(0, 1fr); }
    .b2g-live-text { display: none; }
    .b2g-live { padding: 0 11px; }
}

@media (max-width: 760px) {
    .b2g-appbar { padding: 9px 12px; gap: 8px; }
    .b2g-appbar-titles, .b2g-user-name, .b2g-brand-tag { display: none; }
    .b2g-user { padding-inline: 4px; }
    .b2g-lang { padding: 0 9px; }
    .b2g-page { padding: 16px 12px 40px; }
    .b2g-page-title { font-size: 21px; }
    .b2g-head-actions { width: 100%; }
    .b2g-head-actions .b2g-btn { flex: 1; }
    .b2g-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
    .b2g-stat { padding: 11px 13px; }
    .b2g-stat-value { font-size: 22px; }
    .b2g-grid-2 { grid-template-columns: 1fr; }
    .b2g-toolbar .b2g-select, .b2g-date { flex: 1 1 140px; }
    .b2g-date .b2g-input { flex: 1; min-width: 0; }
    .b2g-comment { max-width: 100%; }
    .b2g-dialog { padding: 20px; }
    .b2g-dialog-lg { padding: 0; }
    .b2g-dialog-bar { padding: 16px 16px 13px; }
    .b2g-dialog-body { padding: 16px; }
    .b2g-dialog-actions .b2g-btn { flex: 1; }
    .b2g-detail-head .b2g-btn { width: 100%; }
    .b2g-toasts { inset-inline-end: 14px; bottom: 14px; }

    /* The table becomes a stack of cards: each cell carries its own column name. */
    .b2g-table thead { display: none; }
    .b2g-table, .b2g-table tbody, .b2g-table tr, .b2g-table td { display: block; width: 100%; }
    .b2g-table tbody tr { padding: 12px 14px; border-bottom: 1px solid rgba(0, 0, 0, .07); }
    .b2g-table tbody tr:last-child { border-bottom: none; }

    .b2g-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 14px;
        padding: 4px 0;
        border: none;
        text-align: end;
    }

    .b2g-table tbody td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: 11.5px;
        font-weight: 700;
        color: var(--fx-muted);
    }

    .b2g-td-subject { max-width: 62vw; }
    .b2g-td-meta { justify-content: flex-end; padding-top: 6px; }
    .b2g-td-meta::before { content: none; }
    .b2g-row-arrow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ════════════════════════════════════════════════════════════════════════
   Mixed-direction values
   A Latin value (serial, coordinates, an English entity name) keeps its own
   left-to-right order inside the Arabic UI, but still lines up on the side
   the rest of the column does.
   ════════════════════════════════════════════════════════════════════════ */
html[dir="rtl"] .b2g-facts dd,
html[dir="rtl"] .b2g-detail-subject,
html[dir="rtl"] .b2g-timeline-text,
html[dir="rtl"] .b2g-pop-user-sub,
html[dir="rtl"] .b2g-file-size { text-align: right; }
