/* File: TicketSys/css/user_portal.css
 *
 * The authenticated end-user portal: dashboard, tickets, requests, notifications,
 * knowledge base, announcements, feedback and profile.
 *
 * Builds on portal-shell.css (buttons, pills, queue rows) and the ECVALLA identity
 * tokens. Layout is a fixed sidebar on wide screens that becomes a bottom tab bar on
 * phones — the desktop UI is not merely shrunk: tables collapse into cards, the New
 * Ticket CTA moves from the sidebar into a floating action button, and hit targets
 * grow to touch size.
 */

/* The portal toggles visibility with the `hidden` attribute throughout. Several of its
 * layout classes set display:grid/flex, which outranks the UA's bare `display: none`
 * for [hidden] — this restores the attribute's meaning everywhere on these pages. */
[hidden] {
    display: none !important;
}

/* --- Frame ------------------------------------------------------------- */

.up-shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100svh;
}

/* --- Sidebar ------------------------------------------------------------ */

.up-sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 18px;
    height: 100svh;
    padding: 22px 16px;
    background-color: var(--ecv-ink);
    color: #fff;
}

.up-sidebar .brand-wordmark {
    height: 38px;
    width: auto;
    filter: invert(1);
    mix-blend-mode: screen;
    object-position: center;
}

.up-brand {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: center;
    text-align: center;
    padding: 8px 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.up-brand small {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .24em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .55);
}

.up-new-ticket {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 46px;
    border-radius: var(--ecv-radius-control);
    background-color: #fff;
    color: var(--ecv-ink);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .11em;
    text-transform: uppercase;
    text-decoration: none;
    transition: transform var(--ecv-quick), box-shadow var(--ecv-quick);
}

.up-new-ticket:hover {
    transform: translateY(-1px);
    box-shadow: var(--ecv-shadow-press);
}

.up-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow-y: auto;
}

.up-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--ecv-radius-control);
    color: rgba(255, 255, 255, .72);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color var(--ecv-quick), color var(--ecv-quick);
}

.up-nav a i {
    width: 18px;
    text-align: center;
    font-size: 14px;
}

.up-nav a:hover {
    background-color: rgba(255, 255, 255, .08);
    color: #fff;
}

.up-nav a.is-active {
    background-color: rgba(255, 255, 255, .14);
    color: #fff;
}

.up-nav-badge {
    margin-inline-start: auto;
    min-width: 20px;
    padding: 2px 7px;
    border-radius: var(--ecv-radius-pill);
    background-color: #fff;
    color: var(--ecv-ink);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.up-nav-badge[hidden] {
    display: none;
}

.up-sidebar-foot {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, .12);
}

.up-sidebar-foot .up-user {
    padding: 4px 12px 10px;
    font-size: 11px;
    color: rgba(255, 255, 255, .55);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.up-foot-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--ecv-radius-control);
    color: rgba(255, 255, 255, .72);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color var(--ecv-quick), color var(--ecv-quick);
}

.up-foot-link i {
    width: 18px;
    text-align: center;
}

.up-foot-link:hover,
.up-foot-link.is-active {
    background-color: rgba(255, 255, 255, .1);
    color: #fff;
}

.up-signout {
    background: none;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    text-align: start;
}

/* --- Main column --------------------------------------------------------- */

.up-main {
    padding: 26px clamp(16px, 3vw, 48px) 96px;
    width: 100%;
    min-width: 0;
}

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

.up-page-head h1 {
    margin: 0 0 4px;
    font-size: clamp(20px, 2.6vw, 28px);
    letter-spacing: -.01em;
}

.up-page-head p {
    margin: 0;
    font-size: 13px;
    color: var(--text-light);
    max-width: 60ch;
}

/* --- Cards & sections ----------------------------------------------------- */

.up-card {
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--ecv-radius-card);
    padding: 20px;
}

.up-section {
    margin-top: 26px;
}

.up-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.up-section-head h2 {
    margin: 0;
    font-size: 15px;
}

.up-section-head a {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-color);
}

/* --- KPI row --------------------------------------------------------------- */

.up-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.up-kpi {
    display: block;
    padding: 16px 18px;
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--ecv-radius-card);
    text-decoration: none;
    color: inherit;
    transition: transform var(--ecv-quick), box-shadow var(--ecv-quick), border-color var(--ecv-quick);
}

.up-kpi:hover {
    transform: translateY(-2px);
    box-shadow: var(--ecv-shadow-raise);
    border-color: var(--ecv-ink-soft);
}

.up-kpi b {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--text-light);
}

.up-kpi strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
    line-height: 1;
    letter-spacing: -.02em;
}

/* --- Pending actions -------------------------------------------------------- */

.up-pending {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.up-pending-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    padding: 14px 16px;
    border: 1px solid var(--ecv-red-line);
    background-color: var(--ecv-red-wash);
    border-radius: var(--ecv-radius-card);
}

.up-pending-row .up-pending-body {
    flex: 1;
    min-width: 220px;
}

.up-pending-row b {
    font-size: 13px;
}

.up-pending-row p {
    margin: 3px 0 0;
    font-size: 12px;
    color: var(--text-light);
}

.up-allcaught {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px;
    border: 1px solid var(--border-color);
    background-color: var(--ecv-green-wash);
    border-radius: var(--ecv-radius-card);
    font-size: 13px;
}

.up-allcaught i {
    color: var(--ecv-green);
    font-size: 18px;
}

/* --- Ticket table / cards ----------------------------------------------------- */

.up-table-wrap {
    overflow-x: auto;
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--ecv-radius-card);
}

table.up-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.up-table th {
    padding: 12px 16px;
    text-align: start;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--text-light);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.up-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.up-table tbody tr:last-child td {
    border-bottom: 0;
}

.up-table tbody tr {
    cursor: pointer;
    transition: background-color var(--ecv-quick);
}

.up-table tbody tr:hover {
    background-color: var(--hover-bg);
}

.up-table .up-ref {
    font-weight: 700;
    white-space: nowrap;
}

.up-table .up-sub {
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Activity feed --------------------------------------------------------------- */

.up-feed {
    display: flex;
    flex-direction: column;
}

.up-feed-item {
    display: flex;
    gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.up-feed-item:last-child {
    border-bottom: 0;
}

.up-feed-item i {
    margin-top: 2px;
    width: 18px;
    text-align: center;
    color: var(--text-light);
}

.up-feed-item time {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-light);
}

.up-feed-item.is-unread {
    font-weight: 600;
}

/* --- Filters / toolbar --------------------------------------------------------------- */

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

.up-chiprow {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.up-chip {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--ecv-radius-pill);
    background-color: var(--bg-white);
    color: var(--text-color);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--ecv-quick), color var(--ecv-quick), border-color var(--ecv-quick);
}

.up-chip:hover {
    border-color: var(--ecv-ink-soft);
}

.up-chip.is-active {
    background-color: var(--ecv-ink);
    border-color: var(--ecv-ink);
    color: #fff;
}

.up-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 200px;
    max-width: 380px;
    padding: 0 14px;
    min-height: 42px;
    border: 1px solid var(--border-color);
    border-radius: var(--ecv-radius-control);
    background-color: var(--bg-white);
}

.up-search i {
    color: var(--text-light);
    font-size: 13px;
}

.up-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: none;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-color);
}

.up-select {
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--ecv-radius-control);
    background-color: var(--bg-white);
    font-family: inherit;
    font-size: 12px;
    color: var(--text-color);
}

/* --- Tickets: list + detail split ------------------------------------------------------ */

.up-split {
    display: grid;
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.up-detail {
    position: sticky;
    top: 20px;
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--ecv-radius-card);
    padding: 22px;
    min-height: 320px;
}

.up-detail-head h2 {
    margin: 4px 0 10px;
    font-size: 18px;
}

.up-facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px 18px;
    margin: 16px 0;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--ecv-radius-card);
    background-color: var(--ecv-soft);
}

.up-facts div {
    min-width: 0;
}

.up-facts dt {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text-light);
}

.up-facts dd {
    margin: 3px 0 0;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Lifecycle bar ------------------------------------------------------------------------ */

.up-lifecycle {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 16px 0;
    overflow-x: auto;
    padding-bottom: 4px;
}

.up-stage {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-light);
}

.up-stage::after {
    content: '';
    width: 26px;
    height: 1px;
    margin: 0 10px;
    background-color: var(--border-color);
}

.up-stage:last-child::after {
    display: none;
}

.up-stage .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background-color: var(--bg-white);
}

.up-stage.is-done { color: var(--text-color); }
.up-stage.is-done .dot { background-color: var(--ecv-ink); border-color: var(--ecv-ink); }

.up-stage.is-current { color: var(--ecv-ink); }
.up-stage.is-current .dot {
    background-color: var(--bg-white);
    border-color: var(--ecv-ink);
    box-shadow: 0 0 0 3px rgba(23, 25, 27, .12);
}

/* --- Conversation thread --------------------------------------------------------------------- */

.up-thread {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 18px 0;
}

.up-msg {
    display: flex;
    gap: 10px;
    max-width: 82%;
    align-self: flex-start;
    font-size: 13px;
    line-height: 1.6;
}

.up-msg.is-follow {
    margin-top: -6px;
}

.up-msg.is-mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.up-msg-avatar {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    margin-top: 2px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
    background-color: var(--ecv-ink);
    color: #ffffff;
}

.up-msg.is-mine .up-msg-avatar {
    background-color: var(--ecv-soft);
    color: var(--ecv-ink);
    border: 1px solid var(--border-color);
}

.up-msg-avatar.is-spacer {
    background: none;
    border: 0;
}

.up-msg-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.up-msg.is-mine .up-msg-main {
    align-items: flex-end;
}

.up-msg header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--text-light);
}

.up-msg.is-mine header {
    flex-direction: row-reverse;
}

.up-msg header b {
    color: var(--text-color);
    font-size: 12px;
}

.up-msg-bubble {
    position: relative;
    padding: 10px 14px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-white);
    box-shadow: 0 1px 2px rgba(23, 25, 27, .05);
}

/* The corner nearest the avatar is squared on the first message of a run — the
 * "speech tail" chat apps use to bind a bubble to its author. */
.up-msg.is-first .up-msg-bubble {
    border-start-start-radius: 6px;
}

.up-msg.is-mine .up-msg-bubble {
    background-color: var(--ecv-ink);
    border-color: var(--ecv-ink);
    color: #f4f4f2;
}

.up-msg.is-mine.is-first .up-msg-bubble {
    border-start-start-radius: 16px;
    border-start-end-radius: 6px;
}

.up-msg-bubble time {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-light);
    text-align: end;
}

.up-msg.is-mine .up-msg-bubble time {
    color: rgba(244, 244, 242, .6);
}

.up-msg p {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.up-msg.is-mine .up-msg-attachments a {
    background-color: rgba(255, 255, 255, .12);
    border-color: rgba(255, 255, 255, .25);
    color: #f4f4f2;
}

.up-msg .up-msg-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.up-msg .up-msg-attachments a,
.up-attachments a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--ecv-radius-pill);
    background-color: var(--bg-white);
    font-size: 12px;
    text-decoration: none;
    color: var(--text-color);
}

.up-reply {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.up-reply textarea {
    width: 100%;
    min-height: 84px;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--ecv-radius-control);
    background-color: var(--bg-white);
    color: var(--text-color);
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
}

.up-reply-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.up-reply-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
    color: var(--text-light);
}

/* --- Stars ------------------------------------------------------------------------------------- */

.up-stars {
    display: inline-flex;
    gap: 4px;
    font-size: 22px;
}

.up-stars button {
    background: none;
    border: 0;
    padding: 2px;
    cursor: pointer;
    color: var(--border-color);
    transition: color var(--ecv-quick), transform var(--ecv-quick);
}

.up-stars button:hover {
    transform: scale(1.15);
}

.up-stars button.is-on {
    color: var(--ecv-ink);
}

.up-stars.is-readonly button {
    cursor: default;
    transform: none;
}

/* --- Announcements / KB / notification rows ------------------------------------------------------ */

.up-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.up-list-row {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px 18px;
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--ecv-radius-card);
    text-align: start;
    width: 100%;
    font-family: inherit;
    color: inherit;
    cursor: pointer;
    transition: border-color var(--ecv-quick), box-shadow var(--ecv-quick);
}

.up-list-row:hover {
    border-color: var(--ecv-ink-soft);
}

.up-list-row.is-unread {
    border-inline-start: 3px solid var(--ecv-ink);
}

.up-list-row .up-row-icon {
    margin-top: 2px;
    width: 20px;
    text-align: center;
    color: var(--text-light);
}

.up-list-row .up-row-body {
    flex: 1;
    min-width: 0;
}

.up-list-row b {
    font-size: 13.5px;
}

.up-list-row p {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--text-light);
    line-height: 1.6;
}

.up-list-row time {
    font-size: 11px;
    color: var(--text-light);
    white-space: nowrap;
}

.up-row-open {
    max-height: 0;
    overflow: hidden;
}

.up-list-row.is-open .up-row-open {
    max-height: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    white-space: pre-wrap;
    font-size: 13px;
    color: var(--text-color);
    line-height: 1.7;
}

/* --- Forms (profile) -------------------------------------------------------------------------------- */

.up-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.up-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-light);
}

.up-field input,
.up-field select {
    width: 100%;
    min-height: 44px;
    padding: 0 13px;
    border: 1px solid var(--border-color);
    border-radius: var(--ecv-radius-control);
    background-color: var(--bg-white);
    color: var(--text-color);
    font-family: inherit;
    font-size: 13px;
}

.up-field input:read-only {
    background-color: var(--ecv-soft);
    color: var(--text-light);
}

.up-check {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.up-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--ecv-ink);
}

/* --- States ---------------------------------------------------------------------------------------------- */

.up-empty {
    padding: 36px 20px;
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
    border: 1px dashed var(--border-color);
    border-radius: var(--ecv-radius-card);
}

.up-empty i {
    display: block;
    margin-bottom: 10px;
    font-size: 22px;
}

.up-error {
    padding: 14px 16px;
    border: 1px solid var(--ecv-red-line);
    background-color: var(--ecv-red-wash);
    border-radius: var(--ecv-radius-card);
    color: var(--ecv-red);
    font-size: 13px;
}

.up-skeleton {
    border-radius: var(--ecv-radius-card);
    background: linear-gradient(90deg, var(--ecv-soft) 25%, var(--bg-white) 50%, var(--ecv-soft) 75%);
    background-size: 200% 100%;
    animation: up-shimmer 1.4s infinite;
    min-height: 74px;
}

@keyframes up-shimmer {
    to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .up-skeleton { animation: none; }
    .up-kpi:hover, .up-new-ticket:hover, .up-stars button:hover { transform: none; }
}

.up-toast {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    padding: 12px 20px;
    border-radius: var(--ecv-radius-control);
    background-color: var(--ecv-ink);
    color: #fff;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--ecv-quick), transform var(--ecv-quick);
    z-index: 60;
}

.up-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Mobile: bottom tab bar + FAB ---------------------------------------------------------------------------- */

.up-fab {
    display: none;
}

@media (max-width: 920px) {
    .up-shell {
        grid-template-columns: 1fr;
    }

    .up-sidebar {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 40;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: 0;
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    }

    /* On a phone the brand, the CTA and the footer leave the bar: the CTA becomes the
     * FAB, sign-out lives in Profile, and the nav itself becomes a five-tab bar. */
    .up-brand,
    .up-new-ticket,
    .up-sidebar-foot .up-user,
    .up-nav a span.up-nav-label-long {
        display: none;
    }

    .up-nav {
        flex-direction: row;
        flex: 1;
        justify-content: space-around;
        overflow: visible;
    }

    .up-nav a {
        flex-direction: column;
        gap: 4px;
        padding: 8px 6px;
        font-size: 10px;
        position: relative;
    }

    .up-nav a i {
        font-size: 16px;
    }

    /* Secondary destinations collapse out of the tab bar; they remain reachable from
     * the dashboard sections that reference them. */
    .up-nav a.up-nav-secondary {
        display: none;
    }

    .up-nav-badge {
        position: absolute;
        top: 2px;
        inset-inline-end: 12%;
        margin: 0;
        min-width: 16px;
        padding: 1px 5px;
        font-size: 9px;
    }

    .up-sidebar-foot {
        border-top: 0;
        padding-top: 0;
        flex-direction: row;
    }

    .up-sidebar-foot a.up-nav-profile {
        flex-direction: column;
        gap: 4px;
        padding: 8px 10px;
        font-size: 10px;
    }

    .up-signout {
        display: none;
    }

    .up-main {
        padding-bottom: 150px;
    }

    .up-fab {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        position: fixed;
        inset-inline-end: 16px;
        bottom: calc(74px + env(safe-area-inset-bottom));
        z-index: 41;
        min-height: 52px;
        padding: 0 20px;
        border-radius: var(--ecv-radius-pill);
        background-color: var(--ecv-ink);
        color: #fff;
        font-size: 12px;
        font-weight: 700;
        letter-spacing: .1em;
        text-transform: uppercase;
        text-decoration: none;
        box-shadow: var(--ecv-shadow-float);
    }

    .up-split {
        grid-template-columns: 1fr;
    }

    /* List/detail becomes two screens: pick from the list, the detail takes over. */
    .up-split.is-detail-open .up-list-pane { display: none; }
    .up-split:not(.is-detail-open) .up-detail-pane { display: none; }

    .up-detail {
        position: static;
    }

    /* Wide ticket tables become cards. */
    .up-table thead { display: none; }

    .up-table,
    .up-table tbody,
    .up-table tr,
    .up-table td { display: block; }

    .up-table tr {
        padding: 10px 4px;
        border-bottom: 1px solid var(--border-color);
    }

    .up-table td {
        padding: 3px 12px;
        border-bottom: 0;
    }

    .up-table td[data-label]::before {
        content: attr(data-label);
        display: inline-block;
        min-width: 96px;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: .14em;
        text-transform: uppercase;
        color: var(--text-light);
    }
}

/* --- New Ticket modal ---------------------------------------------------------------------------------------- */

.up-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background-color: rgba(23, 25, 27, .5);
    backdrop-filter: blur(2px);
}

.up-modal-backdrop[hidden] {
    display: none;
}

.up-modal {
    width: min(640px, 100%);
    max-height: min(86svh, 780px);
    display: flex;
    flex-direction: column;
    background-color: var(--bg-white);
    border-radius: var(--ecv-radius-modal);
    box-shadow: var(--ecv-shadow-float);
    overflow: hidden;
}

.up-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color);
}

.up-modal-head h2 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.up-modal-close {
    background: none;
    border: 0;
    padding: 6px;
    font-size: 16px;
    color: var(--text-light);
    cursor: pointer;
}

.up-modal-close:hover {
    color: var(--text-color);
}

.up-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px 22px;
    overflow-y: auto;
}

.up-modal-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.up-modal-body textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--ecv-radius-control);
    background-color: var(--bg-white);
    color: var(--text-color);
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
}

/* Action bar: its own surface, hairline-separated, actions anchored bottom-right with
 * the primary in the corner — the resting place of the eye at the end of the form. */
.up-modal-foot {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin: 8px -22px -20px;
    padding: 16px 22px;
    border-top: 1px solid var(--border-color);
    background-color: color-mix(in srgb, var(--bg-white) 96%, var(--ecv-ink) 4%);
}

.up-modal-foot .dept-btn {
    min-width: 110px;
    justify-content: center;
}

.up-modal-foot .dept-btn-primary {
    box-shadow: 0 8px 22px -10px rgba(23, 25, 27, .55);
    transition: transform var(--ecv-quick), box-shadow var(--ecv-quick);
}

.up-modal-foot .dept-btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 26px -10px rgba(23, 25, 27, .6);
}

@media (max-width: 560px) {
    .up-modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    /* Bottom sheet on phones: full width, rounded top only, footer buttons stacked. */
    .up-modal {
        width: 100%;
        max-height: 92svh;
        border-radius: var(--ecv-radius-modal) var(--ecv-radius-modal) 0 0;
    }

    .up-modal-row {
        grid-template-columns: 1fr;
    }

    /* Bottom sheet: full-width actions, primary on top where the thumb rests. */
    .up-modal-foot {
        flex-direction: column-reverse;
        margin: 8px -22px calc(-20px + env(safe-area-inset-bottom, 0px));
    }

    .up-modal-foot .dept-btn {
        width: 100%;
    }
}

.up-modal-sm {
    width: min(420px, 100%);
}

/* --- Tables: centred cells and sortable headers -------------------------------------------- */

.up-table th,
.up-table td {
    text-align: center;
    vertical-align: middle;
}

.up-table th[data-sort] {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.up-table th[data-sort] .up-sort-icon {
    margin-inline-start: 6px;
    font-size: 10px;
    opacity: .45;
}

.up-table th[data-sort].is-sorted .up-sort-icon {
    opacity: 1;
}

/* --- Branded content loader ---------------------------------------------------------------------
 * Covers the content pane only — the sidebar stays put — while a tab's content loads.
 * The mark breathes; the track beneath it sweeps. Pure greyscale, calm, no spinner. */

.up-main {
    position: relative;
}

.up-content-loading {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    background-color: var(--ecv-canvas, #f4f4f2);
    opacity: 1;
    transition: opacity .3s ease;
}

.up-content-loading.is-done {
    opacity: 0;
    pointer-events: none;
}

.up-loading-mark {
    width: 216px;
    height: auto;
    mix-blend-mode: multiply;
    filter: brightness(0);
    animation: up-loading-breathe 2.2s ease-in-out infinite;
}

@keyframes up-loading-breathe {

    0%,
    100% {
        transform: scale(.985);
    }

    50% {
        transform: scale(1.015);
    }
}

.up-loading-track {
    position: relative;
    width: 216px;
    height: 2px;
    overflow: hidden;
    border-radius: 2px;
    background-color: rgba(23, 25, 27, .1);
}

.up-loading-track span {
    position: absolute;
    inset-block: 0;
    width: 40%;
    border-radius: 2px;
    background-color: var(--ecv-ink);
    animation: up-loading-sweep 1.4s cubic-bezier(.45, 0, .2, 1) infinite;
}

@keyframes up-loading-sweep {
    0% {
        inset-inline-start: -40%;
    }

    100% {
        inset-inline-start: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {

    .up-loading-mark,
    .up-loading-track span {
        animation: none;
    }

    .up-loading-mark {
        opacity: 1;
    }
}

/* --- Language control ---------------------------------------------------------------------------
 * Fixed to the top corner of every screen so it is reachable from any page, and positioned
 * with a logical inset so Arabic moves it to the mirrored corner automatically. */

.up-langbar {
    position: fixed;
    top: 14px;
    inset-inline-end: 18px;
    z-index: 55;
}

.i18n-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--ecv-radius-pill);
    background-color: var(--bg-white);
    color: var(--text-color);
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(23, 25, 27, .06);
    transition: border-color var(--ecv-quick), box-shadow var(--ecv-quick);
}

.i18n-toggle:hover {
    border-color: var(--ecv-ink-soft);
    box-shadow: 0 4px 14px rgba(23, 25, 27, .1);
}

.i18n-toggle i {
    font-size: 12px;
    color: var(--text-light);
}

/* On phones the sidebar becomes a bottom tab bar, so the control keeps the top corner
 * but shrinks to the icon plus a compact label. */
@media (max-width: 860px) {
    .up-langbar {
        top: 10px;
        inset-inline-end: 12px;
    }

    .i18n-toggle {
        padding: 6px 11px;
        font-size: 12px;
    }
}

/* Section sub-headings inside the ticket detail. Arabic is never letter-spaced, so the
 * tracking is applied to the Latin case only. */
.up-subhead {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--text-light);
}

[dir="rtl"] .up-subhead {
    letter-spacing: 0;
    text-transform: none;
    font-size: 12.5px;
}

/* --- Right-to-left mirroring ---------------------------------------------------------------------
 *
 * Layout mirrors itself: the shell is CSS Grid and the rows are flexbox, both of which follow
 * the document's writing direction, and every offset in this sheet is a logical inset. What
 * does NOT mirror automatically is artwork — an arrow glyph keeps pointing the same way no
 * matter the direction, so anything that means "forward" or "back" is flipped here.
 *
 * Only directional icons are listed. Icons that carry no direction (bell, star, ticket,
 * paperclip, globe) must not be flipped, or they simply look wrong. */

[dir="rtl"] .fa-arrow-left,
[dir="rtl"] .fa-arrow-right,
[dir="rtl"] .fa-arrow-right-from-bracket,
[dir="rtl"] .fa-arrow-right-to-bracket,
[dir="rtl"] .fa-chevron-left,
[dir="rtl"] .fa-chevron-right,
[dir="rtl"] .fa-angle-left,
[dir="rtl"] .fa-angle-right,
[dir="rtl"] .fa-reply,
[dir="rtl"] .fa-paper-plane,
[dir="rtl"] .fa-arrow-trend-up {
    transform: scaleX(-1);
}

/* "View all →" style links. The arrow is a literal character in the markup, and Unicode
 * does not mirror it, so it is flipped as artwork. */
[dir="rtl"] .up-section-head a,
[dir="rtl"] .up-row-open a {
    unicode-bidi: plaintext;
}

[dir="rtl"] .up-section-head a::after {
    content: '';
}

/* Progress dots read left-to-right as a sequence; in Arabic the sequence starts at the
 * right, which flexbox already does. The connector line between them is drawn with a
 * logical margin so it follows. */
[dir="rtl"] .up-lifecycle {
    flex-direction: row;
}

/* Numbers, ticket references and dates stay left-to-right inside Arabic text: "LB-4K7X2P"
 * must never be reordered, and a date must not have its parts rearranged. */
[dir="rtl"] .up-ref,
[dir="rtl"] .up-kpi strong,
[dir="rtl"] .queue-row b,
[dir="rtl"] time,
[dir="rtl"] code {
    direction: ltr;
    unicode-bidi: embed;
    display: inline-block;
}

/* The email in the sidebar footer is an identifier, not prose. */
[dir="rtl"] .up-user {
    direction: ltr;
    text-align: end;
}

/* Arabic labels are longer than their English equivalents; the filter chips and KPI
 * captions get a little more room so nothing clips. */
[dir="rtl"] .up-chip {
    padding-inline: 15px;
}

[dir="rtl"] .up-kpi b {
    font-size: 11.5px;
}
