/* ==========================================================
   TXF shared base + components (admin AND client portal)

   No Bootstrap / Porto: this file provides the element base
   that Bootstrap's reboot used to give us, plus every shared
   component. Every colour reads a theme token, so the same
   rules serve the admin light, admin dark and client themes.

   Load order
   Admin : joint-extras.css → admin-layout.css → admin-light|dark.css
           → notifications-light|dark.css → animations.css
   Client: joint-extras.css → client-light.css
           → notifications-light.css → animations.css
   Tokens live in :root of the theme file, so the theme file can
   load last and still feed these rules.
   ========================================================== */


/* ==========================================================
   1. Base elements (replaces Bootstrap reboot)
   ========================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--app-bg);
    color: var(--app-text-main);
    font-family: var(--app-font);
    font-size: var(--fs-value);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 .5rem;
    color: var(--app-text-main);
    font-weight: 600;
    line-height: 1.25;
}

h1 { font-size: var(--fs-display); }
h2 { font-size: var(--fs-h1); }
h3 { font-size: var(--fs-h1); }
h4 { font-size: var(--fs-h3); }
h5 { font-size: var(--fs-value); }
h6 { font-size: var(--fs-body); }

p,
ul,
ol,
dl,
blockquote,
pre {
    margin-top: 0;
    margin-bottom: 1rem;
}

a {
    color: inherit;
    text-decoration: none;
}

strong,
b {
    font-weight: 600;
}

small {
    font-size: var(--fs-xs);
}

img,
svg {
    vertical-align: middle;
}

img {
    max-width: 100%;
    height: auto;
}

hr {
    margin: 1rem 0;
    border: 0;
    border-top: 1px solid var(--app-border);
}

table {
    border-collapse: collapse;
}

th {
    text-align: inherit;
}

label {
    display: inline-block;
}

button,
input,
select,
textarea {
    margin: 0;
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
}

code,
kbd,
pre {
    font-family: var(--app-font-mono);
    font-size: var(--fs-xs);
}

:focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}


/* ==========================================================
   2. Helpers (deliberately small; not a utility framework)
   ========================================================== */
.mono { font-family: var(--app-font-mono); }

.muted { color: var(--app-text-muted); }

/* Small muted line under a field or value */
.hint {
    font-size: var(--fs-small);
    color: var(--app-text-muted);
}

/* Small inline validation message */
.error-text {
    font-size: var(--fs-small);
    color: var(--st-danger-text);
}

.eyebrow {
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--app-text-muted);
}

.link-app {
    color: var(--app-accent-text);
    font-weight: 500;
}

.link-app:hover {
    color: var(--app-accent-text);
    text-decoration: underline;
}

/* Text only for screen readers */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Vertical stack with consistent gaps */
.stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stack > .ticket-panel { margin-bottom: 0; }

/* Two equal columns that stack on narrow screens */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
}


/* ==========================================================
   3. Buttons
   Existing class names (.btn-primary-pill / .btn-outline-pill)
   are kept; they now render as 10px-radius buttons.
   ========================================================== */
.btn-primary-pill,
.btn-outline-pill,
.btn-strong,
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: var(--app-radius-sm);
    font: inherit;
    font-size: var(--fs-body);
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.btn-primary-pill {
    background: var(--app-accent);
    border: 1px solid var(--app-accent);
    color: #fff;
}

.btn-primary-pill:hover {
    background: var(--app-accent-hover);
    border-color: var(--app-accent-hover);
    color: #fff;
}

.btn-outline-pill {
    background: var(--app-surface);
    border: 1px solid var(--app-border-strong);
    color: var(--app-text-main);
    font-weight: 500;
}

.btn-outline-pill:hover {
    background: var(--app-surface-2);
    border-color: var(--app-text-muted);
    color: var(--app-text-main);
}

/* High-contrast button (e.g. "Update ticket") */
.btn-strong {
    background: var(--app-strong-bg);
    border: 1px solid var(--app-strong-bg);
    color: var(--app-strong-text);
}

.btn-strong:hover {
    opacity: .9;
    color: var(--app-strong-text);
}

/* Text-style button */
.btn-ghost {
    padding: 0 12px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--app-text-body);
    font-weight: 500;
}

.btn-ghost:hover {
    background: var(--app-segment-bg);
    color: var(--app-text-main);
}

/* Destructive variant, combine with .btn-outline-pill */
.btn-outline-pill.is-danger {
    border-color: var(--st-danger-border);
    color: var(--st-danger-text);
}

.btn-outline-pill.is-danger:hover {
    background: var(--st-danger-bg);
}

/* Smaller size for dense areas */
.btn-sm {
    min-height: 32px;
    padding: 0 12px;
    font-size: var(--fs-small);
}

/* Square icon button */
.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    background: var(--app-surface);
    color: var(--app-text-body);
    cursor: pointer;
}

.btn-icon:hover {
    background: var(--app-surface-2);
    color: var(--app-text-main);
}

.btn-icon.borderless {
    width: 32px;
    height: 32px;
    border-color: transparent;
    background: transparent;
    color: var(--app-text-muted);
}

.btn-icon.borderless:hover { background: var(--app-segment-bg); }

.btn-block {
    width: 100%;
    text-align: center;
}

:is(.btn-primary-pill, .btn-outline-pill, .btn-strong, .btn-ghost, .btn-icon):focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--app-accent-ring);
}

:is(.btn-primary-pill, .btn-outline-pill, .btn-strong, .btn-ghost, .btn-icon):disabled {
    opacity: .55;
    cursor: not-allowed;
}


/* ==========================================================
   4. Segmented control (toolbar tabs)
   ========================================================== */
.segmented {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: var(--app-radius-sm);
    background: var(--app-segment-bg);
}

.segmented > a,
.segmented > button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--app-text-body);
    font: inherit;
    font-size: var(--fs-body);
    font-weight: 500;
    cursor: pointer;
}

.segmented > a:hover,
.segmented > button:hover { color: var(--app-text-main); }

.segmented > .active,
.segmented > [aria-current="page"],
.segmented > [aria-current="true"] {
    background: var(--app-surface);
    color: var(--app-text-main);
    box-shadow: var(--app-shadow-xs);
}


/* ==========================================================
   5. Chips, badges and counts
   ========================================================== */
.chip-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.chip-row > .eyebrow { margin-right: 4px; }

.chip {
    --chip-dot: var(--st-neutral-dot);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--st-neutral-border);
    background: var(--st-neutral-bg);
    color: var(--st-neutral-text);
    font-size: var(--fs-small);
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
}

.chip.has-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chip-dot);
}

.chip--success { --chip-dot: var(--st-success-dot); background: var(--st-success-bg); border-color: var(--st-success-border); color: var(--st-success-text); }
.chip--info    { --chip-dot: var(--st-info-dot);    background: var(--st-info-bg);    border-color: var(--st-info-border);    color: var(--st-info-text); }
.chip--warning { --chip-dot: var(--st-warning-dot); background: var(--st-warning-bg); border-color: var(--st-warning-border); color: var(--st-warning-text); }
.chip--danger  { --chip-dot: var(--st-danger-dot);  background: var(--st-danger-bg);  border-color: var(--st-danger-border);  color: var(--st-danger-text); }
.chip--violet  { --chip-dot: var(--st-violet-dot);  background: var(--st-violet-bg);  border-color: var(--st-violet-border);  color: var(--st-violet-text); }

/* Coloured square behind an icon (panel headers, metric cards) */
.icon-tile {
    --tile-bg: var(--app-segment-bg);
    --tile-fg: var(--app-text-body);
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--tile-bg);
    color: var(--tile-fg);
    font-size: var(--fs-value);
}

.icon-tile--info    { --tile-bg: var(--st-info-bg);    --tile-fg: var(--st-info-text); }
.icon-tile--success { --tile-bg: var(--st-success-bg); --tile-fg: var(--st-success-text); }
.icon-tile--warning { --tile-bg: var(--st-warning-bg); --tile-fg: var(--st-warning-text); }
.icon-tile--danger  { --tile-bg: var(--st-danger-bg);  --tile-fg: var(--st-danger-text); }
.icon-tile--violet  { --tile-bg: var(--st-violet-bg);  --tile-fg: var(--st-violet-text); }

/* Small solid tag (product / area label) */
.badge-solid {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--app-accent);
    color: #fff;
    font-size: var(--fs-label);
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.count-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 6px;
    background: var(--app-segment-bg);
    color: var(--app-text-body);
    font-size: var(--fs-xs);
    font-weight: 500;
}

/* Legacy .badge markup (Ticket::get*Badge, table cells).
   Colour usually comes from an inline style; this keeps
   un-coloured badges readable until they move to .chip. */
.badge {
    display: inline-block;
    padding: .25em .6em;
    border-radius: 999px;
    background: var(--app-segment-bg);
    color: var(--app-text-body);
    font-size: var(--fs-xs);
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    vertical-align: baseline;
}


/* ==========================================================
   6. Alerts (inline page messages)
   Usage: <div class="alert alert-success">…</div>
   ========================================================== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid var(--st-neutral-border);
    border-radius: var(--app-radius-sm);
    background: var(--app-surface);
    color: var(--app-text-body);
    font-size: var(--fs-body);
}

.alert > i { margin-top: .2rem; }

.alert-success { border-color: var(--st-success-border); background: var(--st-success-bg); color: var(--st-success-text); }
.alert-info    { border-color: var(--st-info-border);    background: var(--st-info-bg);    color: var(--st-info-text); }
.alert-warning { border-color: var(--st-warning-border); background: var(--st-warning-bg); color: var(--st-warning-text); }
.alert-danger  { border-color: var(--st-danger-border);  background: var(--st-danger-bg);  color: var(--st-danger-text); }


/* ==========================================================
   7. Panels (cards)
   ========================================================== */
.ticket-panel {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-xs);
    margin-bottom: 24px;
}

.ticket-panel-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--app-border-soft);
    border-radius: var(--app-radius) var(--app-radius) 0 0;
    font-size: var(--fs-h3);
    font-weight: 600;
    color: var(--app-text-main);
}

.ticket-panel-header.borderless {
    border-bottom: 0;
    padding-bottom: 0;
}

.ticket-panel-header h2,
.ticket-panel-header h3 {
    margin: 0;
    font-size: var(--fs-h3);
    font-weight: 600;
}

.ticket-panel-header .panel-icon { color: var(--app-text-muted); }

.ticket-panel-header .panel-sub {
    font-size: var(--fs-body);
    font-weight: 400;
    color: var(--app-text-muted);
}

.ticket-panel-header .panel-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-body);
    font-weight: 500;
}

.ticket-panel-body {
    padding: 16px 20px 20px;
    color: var(--app-text-body);
}

/* Panel whose body is a full-bleed table */
.ticket-panel-body.flush { padding: 0; }

/* Title + subtitle stacked next to an icon tile */
.panel-title-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.panel-title-block h2 {
    display: flex;
    align-items: center;
    gap: 8px;
}


/* ==========================================================
   8. Page header (title + actions inside <main>)
   ========================================================== */
.app-main-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 20px;
}

.app-main-header h2 {
    margin: 0;
    font-size: var(--fs-h1);
    font-weight: 600;
}

.app-main-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.app-subtitle {
    margin-top: .15rem;
    font-size: var(--fs-body);
    color: var(--app-text-muted);
}

/* Greeting banner at the top of dashboard-style pages */
.page-hero {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding: 24px 28px;
    border: 1px solid var(--hero-border);
    border-radius: var(--app-radius);
    background: linear-gradient(120deg, var(--hero-from) 0%, var(--hero-to) 100%);
}

/* Soft decorative circles on the right */
.page-hero::before,
.page-hero::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.page-hero::before {
    right: -60px;
    top: -80px;
    width: 240px;
    height: 240px;
    background: radial-gradient(circle, var(--st-violet-border) 0%, transparent 70%);
    opacity: .6;
}

.page-hero::after {
    right: 140px;
    bottom: -100px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, var(--st-info-border) 0%, transparent 70%);
    opacity: .5;
}

.page-hero-text {
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 0;
}

.page-hero-title {
    margin: 4px 0;
    font-size: var(--fs-display);
    font-weight: 600;
    letter-spacing: -.01em;
}

.page-hero-sub {
    margin: 0;
    font-size: var(--fs-value);
    color: var(--app-text-body);
}

.page-hero-actions {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}


/* ==========================================================
   9. Shared topbar pieces (portal files add the shell layout)
   ========================================================== */
.app-topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
}

.topbar-spacer { flex: 1; }

.topbar-title {
    margin: 0;
    font-size: var(--fs-h2);
    font-weight: 600;
    color: var(--app-text-main);
}

/* Logo mark + organisation name (sidebar header, client topbar) */
.brand-block {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: inherit;
}

.brand-mark {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: 10px;
    background: var(--app-surface);
}

.brand-mark img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.brand-text { min-width: 0; }

.brand-name {
    display: block;
    font-size: var(--fs-value);
    font-weight: 600;
    line-height: 1.25;
    color: var(--app-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-sub {
    display: block;
    font-size: var(--fs-xs);
    color: var(--app-text-muted);
}

/* Logo swap: theme files hide the wrong variant */
.brand-logo {
    height: 32px;
    width: auto;
}


/* ==========================================================
   10. Ticket page layout
   ========================================================== */
.ticket-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
    align-items: start;
    margin-bottom: 16px;
}

.ticket-layout.stretch { align-items: stretch; }

.ticket-layout > * { min-width: 0; }

.ticket-layout > .ticket-panel { margin-bottom: 0; }

@media (max-width: 1100px) {
    .ticket-layout { grid-template-columns: 1fr; }
}

.section-label {
    margin: 8px 0 16px;
    padding: 8px 0;
    border-bottom: 1px solid var(--app-border);
    font-size: var(--fs-body);
    font-weight: 500;
    color: var(--app-text-body);
}

/* Title block inside the General info card */
.ticket-hero-title {
    margin: 14px 0 6px;
    font-size: var(--fs-display);
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -.01em;
    color: var(--app-text-main);
    overflow-wrap: anywhere;
}

.ticket-hero-meta {
    margin: 0;
    font-size: var(--fs-value);
    color: var(--app-text-body);
}

.ticket-hero-id {
    margin: 6px 0 0;
    font-size: var(--fs-body);
    color: var(--app-text-muted);
}

.ticket-hero-id .mono { color: var(--app-text-main); }


/* ==========================================================
   11. Field grid (grey inset with uppercase labels)
   ========================================================== */
.field-grid {
    margin-top: 18px;
    padding: 18px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px 20px;
    background: var(--app-surface-2);
    border: 1px solid var(--app-border);
    border-radius: 12px;
}

@media (max-width: 1280px) {
    .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .field-grid { grid-template-columns: 1fr; }
    .field-grid .span-2 { grid-column: auto; }
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field.span-2 { grid-column: span 2; }

.field-divider {
    grid-column: 1 / -1;
    height: 1px;
    background: var(--app-border);
}

.field-label {
    margin: 0;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--app-text-muted);
}

.field-value {
    font-size: var(--fs-value);
    font-weight: 500;
    color: var(--app-text-main);
    overflow-wrap: anywhere;
}


/* ==========================================================
   12. Forms
   .form-control (admin) and .form-input/.form-select/
   .form-textarea (client) share one look.
   ========================================================== */
.form-row { margin-bottom: 1rem; }

.form-label {
    display: block;
    margin-bottom: .35rem;
    font-size: var(--fs-body);
    font-weight: 600;
    color: var(--app-text-main);
}

.form-hint {
    margin-top: .35rem;
    font-size: var(--fs-small);
    color: var(--app-text-muted);
}

.form-control,
.form-input,
.form-select,
.form-textarea {
    display: block;
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--app-border-strong);
    border-radius: 8px;
    background-color: var(--app-surface);
    color: var(--app-text-main);
    font: inherit;
    font-size: var(--fs-body);
    line-height: 1.4;
    outline: none;
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

textarea.form-control,
.form-textarea {
    min-height: 140px;
    line-height: 1.5;
    resize: vertical;
}

.form-control::placeholder,
.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--app-text-muted);
}

.form-control:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--app-accent);
    box-shadow: 0 0 0 3px var(--app-accent-ring);
}

.form-control:disabled,
.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background-color: var(--app-surface-2);
    color: var(--app-text-muted);
}

/* Native multi-select needs room for several rows */
select[multiple].form-control,
select[multiple].form-select {
    min-height: 140px;
    padding: 6px;
}

/* Checkbox + label on one line */
.check-line,
.form-checkline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: var(--fs-body);
    color: var(--app-text-body);
    cursor: pointer;
}

.check-line input,
.form-checkbox {
    width: 16px;
    height: 16px;
    margin: 0;
    flex-shrink: 0;
    accent-color: var(--app-accent);
}

.form-checklabel {
    margin: 0;
    font-size: var(--fs-body);
    font-weight: 600;
}

.form-actions { margin-top: 1.1rem; }

/* Checkbox on the left, buttons on the right */
.action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.action-row .spacer { flex: 1; }

/* Inline form that should not add its own spacing */
form.inline { margin: 0; }

/* Disclosure (<details>) used for small inline forms */
.disclosure > summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    list-style: none;
    cursor: pointer;
}

.disclosure > summary::-webkit-details-marker { display: none; }


/* ==========================================================
   13. Steps (Timeline card)
   ========================================================== */
.phase-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding: 10px 12px;
    border: 1px solid var(--app-accent-border);
    border-radius: 10px;
    background: var(--app-accent-soft);
}

.phase-box .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--app-accent);
}

.phase-box .eyebrow { font-size: var(--fs-label); }

.phase-box strong {
    font-size: var(--fs-body);
    color: var(--app-accent-text);
}

.steps {
    list-style: none;
    margin: 0;
    padding: 0;
}

.step {
    position: relative;
    display: flex;
    gap: 12px;
    padding-bottom: 16px;
}

.step:last-child { padding-bottom: 0; }

/* Vertical connector between markers */
.step:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 11.5px;
    top: 28px;
    bottom: 4px;
    width: 1px;
    background: var(--app-border);
}

.step-marker {
    position: relative;
    z-index: 1;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-label);
    border-radius: 50%;
    border: 1px solid var(--app-border-strong);
    background: var(--app-surface);
}

.step--current .step-marker {
    background: var(--app-accent);
    border-color: var(--app-accent);
    box-shadow: 0 0 0 4px var(--app-accent-ring);
}

.step-body {
    flex: 1;
    min-width: 0;
}

.step-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.step-title {
    font-size: var(--fs-body);
    font-weight: 500;
    color: var(--app-text-main);
}

.step--current .step-title {
    font-weight: 600;
    color: var(--app-accent-text);
}

.step-time,
.step-sub {
    font-size: var(--fs-small);
    color: var(--app-text-muted);
}

.step-time { white-space: nowrap; }


/* ==========================================================
   14. Thread (activity list)
   Each entry is a white card next to a round avatar. Colour comes
   from the avatar and the role pill: Customer = green,
   Support = blue, System = amber (same as the colour key).
   ========================================================== */
.thread {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.thread-item {
    --role-solid: var(--st-neutral-dot);
    --role-soft-bg: var(--app-segment-bg);
    --role-soft-text: var(--app-text-body);
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.thread-item--client  { --role-solid: var(--role-client-dot);  --role-soft-bg: var(--st-success-bg); --role-soft-text: var(--st-success-text); }
.thread-item--support { --role-solid: var(--role-support-dot); --role-soft-bg: var(--st-info-bg);    --role-soft-text: var(--st-info-text); }
.thread-item--system  { --role-solid: var(--role-system-dot);  --role-soft-bg: var(--st-warning-bg); --role-soft-text: var(--st-warning-text); }

/* Round avatar: solid role colour with white initials */
.thread-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--role-solid);
    color: #fff;
    font-size: var(--fs-xs);
    font-weight: 600;
}

/* System: soft amber circle with an amber gear */
.thread-item--system .thread-avatar {
    background: var(--st-warning-bg);
    color: var(--st-warning-dot);
    border: 1px solid var(--st-warning-border);
}

/* The card */
.thread-main {
    flex: 1;
    min-width: 0;
    padding: 16px 20px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-xs);
}

.thread-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.thread-author {
    font-size: var(--fs-value);
    font-weight: 600;
    color: var(--app-text-main);
}

/* Role pill (Customer / Support) in the soft role colour */
.thread-role,
.thread-tag {
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--role-soft-bg);
    color: var(--role-soft-text);
    font-size: var(--fs-xs);
    font-weight: 600;
}

.thread-meta {
    font-size: var(--fs-small);
    color: var(--app-text-muted);
}

.thread-time {
    margin-left: auto;
    font-size: var(--fs-small);
    color: var(--app-text-muted);
    white-space: nowrap;
}

.thread-head form { margin: 0; }

.thread-body {
    font-size: var(--fs-value);
    line-height: 1.6;
    color: var(--app-text-main);
    overflow-wrap: anywhere;
}

.thread-body p { margin: 0 0 .6em; }
.thread-body p:last-child { margin-bottom: 0; }

.thread-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Quoted text inside a message (e.g. email history) */
.thread-body blockquote {
    margin: .6em 0;
    padding: 6px 12px;
    border-left: 3px solid var(--role-solid);
    background: var(--app-surface-2);
    border-radius: 0 8px 8px 0;
    color: var(--app-text-body);
}

/* Links inside customer/support content must look like links */
.thread-body a,
.timeline-entry-body a {
    color: var(--app-accent-text);
    text-decoration: underline;
}

/* System notes: the label itself is the amber pill */
.thread-item--system .thread-author {
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--st-warning-bg);
    color: var(--st-warning-text);
    font-size: var(--fs-xs);
    font-weight: 600;
}

.thread-item--system .thread-role { display: none; }

/* Original request: green outline so it reads as "where it started" */
.thread-item--origin .thread-main { border-color: var(--st-success-border); }

.thread-empty {
    padding: 16px 0;
    color: var(--app-text-muted);
}

@media (max-width: 600px) {
    .thread-avatar { display: none; }
}

/* ==========================================================
   15. Legacy timeline (.timeline-*) – kept for pages not yet
   migrated to .thread
   ========================================================== */
.ticket-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: var(--fs-body);
}

.timeline-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.timeline-entry {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.timeline-entry-side {
    width: 90px;
    flex-shrink: 0;
    padding-top: .2rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    font-size: var(--fs-xs);
    color: var(--app-text-muted);
}

.timeline-date { opacity: .85; }
.timeline-time { font-weight: 500; color: var(--app-text-body); }

.timeline-dot {
    width: 9px;
    height: 9px;
    margin-top: .3rem;
    border-radius: 999px;
    border: 2px solid var(--app-surface);
    box-shadow: 0 0 0 1px var(--app-border-strong);
}

.timeline-dot--client  { background: var(--role-client-dot); }
.timeline-dot--support { background: var(--role-support-dot); }
.timeline-dot--system  { background: var(--role-system-dot); }

.timeline-entry-content {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 12px;
}

.timeline-entry-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: .3rem;
}

.timeline-author {
    font-size: var(--fs-body);
    font-weight: 600;
    color: var(--app-text-main);
}

.timeline-role {
    font-size: var(--fs-xs);
    color: var(--app-text-muted);
}

.timeline-tag {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--app-segment-bg);
    color: var(--app-text-body);
    font-size: var(--fs-xs);
    font-weight: 500;
    white-space: nowrap;
}

.timeline-tag--client  { background: var(--role-client-bg);  color: var(--role-client-text); }
.timeline-tag--support { background: var(--role-support-bg); color: var(--role-support-text); }
.timeline-tag--system  { background: var(--role-system-bg);  color: var(--role-system-text); }

.timeline-entry-body {
    margin-bottom: .35rem;
    line-height: 1.5;
    color: var(--app-text-body);
    overflow-wrap: anywhere;
}

.timeline-entry-body p { margin: 0; }
.timeline-entry-body.client-entry { font-size: var(--fs-value); }

.timeline-edit-button {
    margin-top: .35rem;
    padding: .15rem .6rem;
    border-radius: 999px;
    border: 1px solid var(--app-border-strong);
    background: var(--app-surface);
    color: var(--app-text-muted);
    font-size: var(--fs-xs);
    line-height: 1.2;
    cursor: pointer;
}

.timeline-edit-button:hover {
    border-color: var(--app-accent-border);
    background: var(--app-accent-soft);
    color: var(--app-text-main);
}

@media (max-width: 768px) {
    .timeline-entry-side { display: none; }
}


/* ==========================================================
   16. Tables
   ========================================================== */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: var(--app-surface);
}

/* A table-wrap inside a panel body uses the panel's border instead */
.ticket-panel .table-wrap {
    border: 0;
    border-radius: 0 0 var(--app-radius) var(--app-radius);
}

.table-ticket {
    width: 100%;
    margin-bottom: 0;
    border-collapse: collapse;
    color: var(--app-text-main);
    font-size: var(--fs-body);
}

.table-ticket th,
.table-ticket td {
    padding: .85rem 1rem;
    border: 0;
    vertical-align: middle;
}

.table-ticket thead th {
    background: var(--app-surface-2);
    border-bottom: 1px solid var(--app-border);
    color: var(--app-text-muted);
    font-size: var(--fs-label);
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table-ticket tbody tr { background: var(--app-surface); }
.table-ticket tbody tr + tr td { border-top: 1px solid var(--app-border-soft); }
.table-ticket tbody tr:hover { background: var(--app-accent-soft); }

.table-ticket .badge {
    padding: .25rem .55rem;
    font-size: var(--fs-label);
}

/* Secondary line in a cell (client / submitter) */
.cell-sub {
    margin-top: 2px;
    font-size: var(--fs-small);
    color: var(--app-text-muted);
}

/* Ticket title link in list tables */
.ticket-subject {
    font-size: var(--fs-body);
    font-weight: 600;
    color: var(--app-text-main);
}

.ticket-subject:hover {
    color: var(--app-accent-text);
    text-decoration: underline;
}

/* "3 hrs" with a clock icon */
.age-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    color: var(--app-text-body);
}

.age-label i { color: var(--app-text-muted); }

/* Person = avatar + name (assignee, author) */
.person {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--app-accent-soft);
    color: var(--app-accent-text);
    font-size: var(--fs-label);
    font-weight: 600;
}

.person.is-empty { color: var(--app-text-muted); }

.person.is-empty .avatar {
    border: 1px dashed var(--app-border-strong);
    background: transparent;
    color: var(--app-text-muted);
}

/* Friendly message when a list has no rows */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 36px 16px;
    text-align: center;
    color: var(--app-text-muted);
}

.empty-state > i {
    margin-bottom: 6px;
    font-size: var(--fs-display);
    color: var(--st-success-dot);
}

.empty-state-title {
    font-weight: 600;
    color: var(--app-text-main);
}

.empty-state-text { font-size: var(--fs-body); }

.table-ticket tbody tr:hover:has(.empty-state) { background: var(--app-surface); }


/* ==========================================================
   17. Metric cards
   Tone modifiers (.metric-card--info|success|warning|violet|danger)
   tint the card and colour its top edge.
   ========================================================== */
.metric-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.metric-card {
    --metric-bg: var(--app-surface);
    --metric-border: var(--app-border);
    --metric-accent: transparent;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding: 1.15rem 1.25rem;
    background: linear-gradient(180deg, var(--metric-bg) 0%, var(--app-surface) 140px);
    border: 1px solid var(--metric-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-xs);
}

/* Coloured top edge */
.metric-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--metric-accent);
}

.metric-card--info    { --metric-bg: var(--st-info-bg);    --metric-border: var(--st-info-border);    --metric-accent: var(--st-info-dot); }
.metric-card--success { --metric-bg: var(--st-success-bg); --metric-border: var(--st-success-border); --metric-accent: var(--st-success-dot); }
.metric-card--warning { --metric-bg: var(--st-warning-bg); --metric-border: var(--st-warning-border); --metric-accent: var(--st-warning-dot); }
.metric-card--violet  { --metric-bg: var(--st-violet-bg);  --metric-border: var(--st-violet-border);  --metric-accent: var(--st-violet-dot); }
.metric-card--danger  { --metric-bg: var(--st-danger-bg);  --metric-border: var(--st-danger-border);  --metric-accent: var(--st-danger-dot); }

.metric-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Number on top, label in smaller text underneath, beside the icon */
.metric-head-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

/* Solid icon tile inside a toned card, sized to the two-line number + label */
.metric-card .icon-tile {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--metric-accent);
    color: #fff;
    font-size: var(--fs-h1);
}

.metric-label {
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--app-text-muted);
}

.metric-value {
    display: flex;
    align-items: baseline;
    gap: .45rem;
    font-size: var(--fs-display);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -.02em;
    color: var(--app-text-main);
}

.metric-stat-list {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    margin-top: .35rem;
    padding-top: .45rem;
    border-top: 1px solid var(--app-border);
    color: var(--app-text-muted);
    font-size: var(--fs-xs);
}

.metric-stat-row {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
}

.metric-stat-row strong {
    color: var(--app-text-main);
    font-weight: 600;
}


/* ==========================================================
   18. Attachments
   ========================================================== */
.dropzone-app {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 28px 16px;
    border: 1.5px dashed var(--app-border-strong);
    border-radius: 12px;
    background: var(--app-surface-2);
    color: var(--app-text-body);
    font-size: var(--fs-body);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

.dropzone-app .dz-icon {
    font-size: var(--fs-h1);
    color: var(--app-text-muted);
}

.dropzone-app .dz-link {
    color: var(--app-accent-text);
    font-weight: 600;
}

.dropzone-app.is-dragover {
    border-color: var(--app-accent);
    background: var(--app-accent-soft);
}

.file-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ticket-file {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: var(--fs-body);
    color: var(--app-text-main);
    overflow-wrap: anywhere;
}

.file-list .ticket-file { margin-bottom: 0; }

.ticket-file i { color: var(--app-text-muted); }

.ticket-file a:hover { color: var(--app-accent-text); }


/* ==========================================================
   19. Info strip / support hours
   ========================================================== */
.info-strip,
.support-hours {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 20px;
    padding: .75rem 1rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    background: var(--app-surface-2);
    color: var(--app-text-body);
    font-size: var(--fs-body);
}

.info-strip i { color: var(--app-accent); }

.support-hours-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--app-segment-bg);
    color: var(--app-text-muted);
}

.support-hours-content { min-width: 0; }

.support-hours-title {
    margin-bottom: .1rem;
    font-weight: 600;
    color: var(--app-text-main);
}

.support-hours-text {
    font-size: var(--fs-body);
    color: var(--app-text-muted);
}

.support-hours-time {
    margin-left: .35rem;
    white-space: nowrap;
}

.support-hours--core     { border-color: var(--st-success-border); background: var(--st-success-bg); }
.support-hours--core     .support-hours-icon { color: var(--st-success-text); background: var(--app-surface); }
/* Extended hours are information, not a warning: blue */
.support-hours--extended { border-color: var(--st-info-border); background: var(--st-info-bg); }
.support-hours--extended .support-hours-icon { color: var(--st-info-text); background: var(--app-surface); }
.support-hours--off      { border-color: var(--st-neutral-border); background: var(--app-surface-2); }
.support-hours--off      .support-hours-icon { color: var(--app-text-muted); background: var(--app-segment-bg); }


/* ==========================================================
   20. Footer
   ========================================================== */
.app-footer {
    padding: .75rem 1rem;
    border-top: 1px solid var(--app-border);
    text-align: center;
    font-size: var(--fs-small);
    color: var(--app-text-muted);
}


/* ==========================================================
   21. Ticket view extras (admin + client ticket pages)
   ========================================================== */
.ticket-chip-row { margin-bottom: 16px; }

/* Header row placed inside a panel body (General info card) */
.ticket-panel-header.flush-header { padding: 0; }

/* "Add recipient" disclosure in the Notifications field */
.recipient-box > summary { font-size: var(--fs-body); }

.recipient-form {
    display: flex;
    gap: 8px;
    margin: 10px 0 6px;
}

.recipient-form .form-control { flex: 1; }

/* Upload area: keyboard focus lands on the hidden file input */
.dropzone-app:focus-within {
    border-color: var(--app-accent);
    box-shadow: 0 0 0 3px var(--app-accent-ring);
}

.dropzone-app label.dz-link { cursor: pointer; }

.upload-status:empty { display: none; }

@media (max-width: 768px) {
    /* Toolbar tabs take too much room on phones */
    .toolbar-tabs { display: none; }
}

/* Page title with a leading back button or icon tile */
.page-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/* Bulleted tips in a side panel */
.tip-list {
    margin: 0;
    padding-left: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: var(--fs-body);
    color: var(--app-text-body);
}

/* Grid whose columns keep their own height */
.grid-2.align-start { align-items: start; }

/* Row action buttons (edit / delete) */
.cell-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.cell-actions > * {
    display: inline-flex;
    vertical-align: middle;
}

.btn-icon.is-danger:hover {
    background: var(--st-danger-bg);
    color: var(--st-danger-text);
}

/* Row currently open in the edit form */
.table-ticket tbody tr.is-selected { background: var(--app-accent-soft); }

/* Fieldsets used only for grouping */
fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

legend {
    padding: 0;
}

/* Scrollable list of checkboxes (e.g. client restrictions) */
.check-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    background: var(--app-surface-2);
}


/* ==========================================================
   22. Login pages (admin + client)
   ========================================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background:
        radial-gradient(circle at 15% 20%, var(--hero-from) 0%, transparent 45%),
        radial-gradient(circle at 85% 80%, var(--hero-to) 0%, transparent 45%),
        var(--app-bg);
}

.login-card {
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 440px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(16, 24, 40, .14);
}

/* Accent line along the top of the card */
.login-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--app-accent), var(--st-violet-dot));
}

.login-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 28px 28px 0;
}

.login-card-header .brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
}

.login-card-header .brand-mark img {
    width: 34px;
    height: 34px;
}

.login-title {
    margin: 2px 0 0;
    font-size: var(--fs-h1);
    font-weight: 600;
}

.login-card-body {
    padding: 20px 28px 28px;
}

.login-note {
    margin: 14px 0 0;
    text-align: center;
}

/* Larger primary button */
.btn-lg {
    min-height: 46px;
    font-size: var(--fs-value);
}

/* Input with a leading icon */
.input-icon {
    position: relative;
}

.input-icon > i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--app-text-muted);
    pointer-events: none;
}

.input-icon > :is(.form-control, .form-input) {
    padding-left: 36px;
}


/* ==========================================================
   23. Ticket view colour accents
   Tone modifiers: --info | --success | --warning | --danger |
   --violet | --neutral (all read the status tokens)
   ========================================================== */

/* Ticket header card: white, solid icon tile in the ticket colour, owner box on the right */
.ticket-banner {
    --tone-bg: var(--st-info-bg);
    --tone-border: var(--st-info-border);
    --tone-dot: var(--app-accent);
    --tone-text: var(--app-accent-text);
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
    padding: 28px 32px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-xs);
}

.ticket-banner--success { --tone-bg: var(--st-success-bg); --tone-border: var(--st-success-border); --tone-dot: var(--st-success-dot); --tone-text: var(--st-success-text); }
.ticket-banner--warning { --tone-bg: var(--st-warning-bg); --tone-border: var(--st-warning-border); --tone-dot: var(--st-warning-dot); --tone-text: var(--st-warning-text); }
.ticket-banner--danger  { --tone-bg: var(--st-danger-bg);  --tone-border: var(--st-danger-border);  --tone-dot: var(--st-danger-dot);  --tone-text: var(--st-danger-text); }
.ticket-banner--violet  { --tone-bg: var(--st-violet-bg);  --tone-border: var(--st-violet-border);  --tone-dot: var(--st-violet-dot);  --tone-text: var(--st-violet-text); }
.ticket-banner--neutral { --tone-bg: var(--app-surface-2); --tone-border: var(--app-border);        --tone-dot: var(--st-neutral-dot); --tone-text: var(--app-text-muted); }

/* Solid rounded square with the ticket icon */
.ticket-banner-icon {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: var(--tone-dot);
    color: #fff;
    font-size: var(--fs-h1);
}

.ticket-banner-main {
    flex: 1;
    min-width: 0;
}

.ticket-banner-eyebrow {
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--tone-text);
}

.ticket-banner-title {
    margin: 6px 0 8px;
    font-size: var(--fs-display);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -.01em;
    overflow-wrap: anywhere;
}

.ticket-banner-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    margin: 0 0 14px;
    font-size: var(--fs-value);
    color: var(--app-text-body);
}

.ticket-banner-meta i {
    margin-right: 5px;
    color: var(--app-text-muted);
}

/* Owner box: avatar + "OWNER" + name */
.ticket-banner-owner {
    display: flex;
    align-items: center;
    gap: 12px;
    align-self: center;
    min-width: 220px;
    padding: 16px 20px;
    background: var(--app-surface-2);
    border: 1px solid var(--app-border);
    border-radius: 12px;
}

.ticket-banner-owner .avatar {
    background: var(--app-accent);
    color: #fff;
}

.ticket-banner-owner .avatar.is-empty {
    background: transparent;
    border: 1px dashed var(--app-border-strong);
    color: var(--app-text-muted);
}

.ticket-banner-owner-name {
    font-size: var(--fs-h3);
    font-weight: 600;
    color: var(--app-text-main);
}


.avatar--lg {
    width: 36px;
    height: 36px;
    font-size: var(--fs-small);
}

/* "Needs attention" alerts under the header */
.attention-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.attention-list .alert {
    align-items: center;
    margin: 0;
}

.alert-text { flex: 1; min-width: 0; }

.alert-action {
    font-weight: 600;
    white-space: nowrap;
    color: inherit;
    text-decoration: underline;
}

/* Field grid placed first inside a panel body */
.field-grid.flush { margin-top: 0; }

/* Phase box follows the ticket colour */
.phase-box--warning { border-color: var(--st-warning-border); background: var(--st-warning-bg); }
.phase-box--warning .dot { background: var(--st-warning-dot); }
.phase-box--warning strong { color: var(--st-warning-text); }
.phase-box--danger  { border-color: var(--st-danger-border);  background: var(--st-danger-bg); }
.phase-box--danger  .dot { background: var(--st-danger-dot); }
.phase-box--danger  strong { color: var(--st-danger-text); }
.phase-box--violet  { border-color: var(--st-violet-border);  background: var(--st-violet-bg); }
.phase-box--violet  .dot { background: var(--st-violet-dot); }
.phase-box--violet  strong { color: var(--st-violet-text); }
.phase-box--neutral { border-color: var(--app-border);        background: var(--app-surface-2); }
.phase-box--neutral .dot { background: var(--st-neutral-dot); }
.phase-box--neutral strong { color: var(--app-text-body); }

/* Timeline steps: done = green tick, todo = dashed amber */
.step--done .step-marker {
    background: var(--st-success-dot);
    border-color: var(--st-success-dot);
    color: #fff;
}

.step--done:not(:last-child)::before { background: var(--st-success-border); }

.step--todo .step-marker {
    border-style: dashed;
    border-color: var(--st-warning-dot);
    background: var(--st-warning-bg);
}

.step--todo .step-title { color: var(--st-warning-text); }

/* Section label with an icon and a colour legend */
.section-label {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.section-label > i { color: var(--app-accent); }

.section-label-legend {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-xs);
    color: var(--app-text-muted);
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 8px;
    border-radius: 50%;
}

.legend-dot--client  { background: var(--role-client-dot); }
.legend-dot--support { background: var(--role-support-dot); }
.legend-dot--system  { background: var(--role-system-dot); }



/* ==========================================================
   24. Panel colours
   .ticket-panel--info|success|warning|danger|violet: the card stays
   white; only its header icon tile takes the colour.
   ========================================================== */
.ticket-panel--info    .ticket-panel-header .icon-tile { --tile-bg: var(--st-info-bg);    --tile-fg: var(--st-info-dot); }
.ticket-panel--success .ticket-panel-header .icon-tile { --tile-bg: var(--st-success-bg); --tile-fg: var(--st-success-dot); }
.ticket-panel--warning .ticket-panel-header .icon-tile { --tile-bg: var(--st-warning-bg); --tile-fg: var(--st-warning-dot); }
.ticket-panel--danger  .ticket-panel-header .icon-tile { --tile-bg: var(--st-danger-bg);  --tile-fg: var(--st-danger-dot); }
.ticket-panel--violet  .ticket-panel-header .icon-tile { --tile-bg: var(--st-violet-bg);  --tile-fg: var(--st-violet-dot); }

/* Header without a divider line (title sits straight above the content) */
.ticket-panel-header.borderless { padding-bottom: 4px; }

/* Icon colour in the soft tiles uses the strong colour */
.icon-tile--info    { --tile-fg: var(--st-info-dot); }
.icon-tile--success { --tile-fg: var(--st-success-dot); }
.icon-tile--warning { --tile-fg: var(--st-warning-dot); }
.icon-tile--danger  { --tile-fg: var(--st-danger-dot); }
.icon-tile--violet  { --tile-fg: var(--st-violet-dot); }

/* Field grid straight on the white card (no grey box) */
.field-grid.plain {
    margin-top: 4px;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 0;
}

.field-value--lg {
    font-size: var(--fs-h3);
    font-weight: 600;
    padding-top: 8px;
}

/* Grey footer bar along the bottom of a card (checkbox + main button) */
.action-row.panel-footer {
    margin: 20px -20px -20px;
    padding: 14px 20px;
    background: var(--app-surface-2);
    border-top: 1px solid var(--app-border);
    border-radius: 0 0 var(--app-radius) var(--app-radius);
}

.panel-sub--warning { color: var(--st-warning-text) !important; }

/* "PHASE Resolved" badge on the right of the Timeline header */
.phase-badge {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--st-violet-bg);
    color: var(--st-violet-text);
    font-size: var(--fs-small);
    font-weight: 600;
}

.phase-badge-label {
    font-size: var(--fs-label);
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: .8;
}

/* Activity heading with the colour key on the right */
.activity-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.activity-head h2 {
    margin: 0;
    font-size: var(--fs-h1);
    font-weight: 600;
}

/* Soft amber button (matches the Admin options card) */
.btn-warning-soft {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid var(--st-warning-border);
    border-radius: var(--app-radius-sm);
    background: var(--st-warning-bg);
    color: var(--st-warning-text);
    font: inherit;
    font-size: var(--fs-body);
    font-weight: 600;
    cursor: pointer;
}

.btn-warning-soft:hover { border-color: var(--st-warning-dot); }

.btn-warning-soft:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--app-accent-ring);
}

/* Attachment rows: small card with a file-type badge and uploader pill */
.file-list .ticket-file {
    gap: 10px;
    padding: 10px 12px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 12px;
}

.file-list .ticket-file > a {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    color: var(--app-text-main);
}

.file-ext {
    padding: 4px 6px;
    border-radius: 6px;
    background: var(--st-info-bg);
    color: var(--st-info-text);
    font-size: var(--fs-label);
    font-weight: 600;
    letter-spacing: .02em;
}


/* Section heading (e.g. client "Conversation"): plain bold text */
.section-label {
    margin: 12px 0 16px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--app-text-main);
    font-size: var(--fs-h1);
    font-weight: 600;
}

.section-label > i { color: var(--app-text-muted); }

/* ==========================================================
   25. Rich text editor (Jodit 4, theme/js/txf-editor.js)
   Jodit's colour variables point at our tokens, so the editor
   follows the light / dark theme.
   ========================================================== */
.jodit,
.jodit-popup,
.jodit-dialog {
    --jd-font-default: var(--app-font);
    --jd-color-background-default: var(--app-surface);
    --jd-color-background-light-gray: var(--app-surface-2);
    --jd-color-background-gray: var(--app-segment-bg);
    --jd-color-background-gray-hover: var(--app-segment-bg);
    --jd-color-background-button-hover: var(--app-segment-bg);
    --jd-color-background-button-hover-opacity30: var(--app-segment-bg);
    --jd-color-button-background-hover: var(--app-segment-bg);
    --jd-color-button-background-hover-opacity40: var(--app-segment-bg);
    --jd-color-button-background-hover-opacity60: var(--app-segment-bg);
    --jd-color-background-active: var(--app-accent-soft);
    --jd-color-panel: var(--app-surface-2);
    --jd-color-text: var(--app-text-main);
    --jd-color-default: var(--app-text-main);
    --jd-color-dark: var(--app-text-main);
    --jd-color-label: var(--app-text-muted);
    --jd-color-placeholder: var(--app-text-muted);
    --jd-color-icon: var(--app-text-body);
    --jd-color-text-icons: var(--app-text-body);
    --jd-color-border: var(--app-border-strong);
    --jd-color-border-dark: var(--app-border-strong);
    --jd-color-border-active: var(--app-accent);
    --jd-color-border-selected: var(--app-accent);
    --jd-color-separator: var(--app-border);
    --jd-color-white: var(--app-surface);
    --jd-color-blue: var(--app-accent);
    --jd-border-radius-default: 8px;
}

.jodit-container:not(.jodit_inline) {
    border-color: var(--app-border-strong);
    border-radius: var(--app-radius-sm);
    overflow: hidden;
}

.jodit-container:not(.jodit_inline):focus-within {
    border-color: var(--app-accent);
    box-shadow: 0 0 0 3px var(--app-accent-ring);
}

.jodit-toolbar__box:not(:empty),
.jodit-status-bar {
    background: var(--app-surface-2);
    border-color: var(--app-border);
}

.jodit-icon {
    fill: currentColor;
    stroke: currentColor;
}

.jodit-popup__content,
.jodit-dialog__panel {
    background: var(--app-surface);
    color: var(--app-text-main);
}

.jodit-ui-input__input,
.jodit-ui-input__wrapper,
.jodit-ui-select__input {
    background: var(--app-surface);
    color: var(--app-text-main);
    border-color: var(--app-border-strong);
}

/* Writing area: same look as a shown message */
.jodit-wysiwyg {
    padding: 12px 14px !important;
    background: var(--app-surface);
    color: var(--app-text-main);
    font-size: var(--fs-value);
    line-height: 1.6;
}

.jodit-wysiwyg p { margin: 0 0 .6em; }

.jodit-wysiwyg img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.jodit-wysiwyg h2 { font-size: var(--fs-h1); margin: 1em 0 .5em; }
.jodit-wysiwyg h3 { font-size: var(--fs-h2); margin: 1em 0 .5em; }
.jodit-wysiwyg h4 { font-size: var(--fs-h3);  margin: 1em 0 .5em; }

.jodit-wysiwyg table,
.thread-body table {
    width: 100%;
    border-collapse: collapse;
    margin: .6em 0;
}

.jodit-wysiwyg td,
.jodit-wysiwyg th,
.thread-body td,
.thread-body th {
    padding: 6px 8px;
    border: 1px solid var(--app-border-strong);
}

.jodit-wysiwyg blockquote {
    margin: 0 0 1em;
    padding: 6px 0 6px 14px;
    border-left: 3px solid var(--app-accent-border);
    color: var(--app-text-body);
}

/* Headings inside shown messages stay modest */
.thread-body h2 { font-size: var(--fs-h1); margin: .8em 0 .4em; }
.thread-body h3 { font-size: var(--fs-h3);   margin: .8em 0 .4em; }
.thread-body h4 { font-size: var(--fs-value); margin: .8em 0 .4em; }


/* ==========================================================
   26. Typography (TXF type spec)
   Only the 9 --fs-* sizes from the theme files are used.
   Weight 700 only for the ticket title; headings line-height 1.2;
   body and thread text 1.5-1.55.
   ========================================================== */
html { font-size: 16px; }

body {
    font-size: var(--fs-body);
    line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 { line-height: 1.2; font-weight: 600; }

/* Ticket header */
.ticket-banner-title {
    font-size: var(--fs-display);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.02em;
}

.ticket-banner-eyebrow {
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.ticket-banner-meta {
    font-size: var(--fs-body);
    font-weight: 400;
    color: var(--app-text-body);
}

.ticket-banner-owner-name {
    font-size: var(--fs-value);
    font-weight: 600;
}

/* Top-bar title: "Ticket" in Inter, the number in mono */
.topbar-title {
    font-size: var(--fs-h1);
    font-weight: 600;
    line-height: 1.2;
}

.topbar-number {
    font-family: var(--app-font-mono);
    font-size: var(--fs-h3);
    font-weight: 500;
}

/* Section headings */
.activity-head h2,
.section-label,
.app-main-header h2 {
    font-size: var(--fs-h1);
    font-weight: 600;
    line-height: 1.2;
}

/* Card titles: right rail and composer 16px, main-column cards 17px */
.ticket-panel-header,
.ticket-panel-header h2,
.ticket-panel-header h3 {
    font-size: var(--fs-h3);
    font-weight: 600;
    line-height: 1.2;
}

.ticket-panel.is-main .ticket-panel-header h2 { font-size: var(--fs-h2); }

/* Card subtitles / helper sentences */
.ticket-panel-header .panel-sub,
.panel-sub {
    font-size: var(--fs-small);
    font-weight: 400;
    line-height: 1.5;
    color: var(--app-text-muted);
}

.panel-sub--warning { color: var(--st-warning-text) !important; }

/* Field labels and values */
.field-label,
.eyebrow,
.metric-label,
.table-ticket thead th {
    font-size: var(--fs-label);
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--app-text-muted);
}

.ticket-banner-eyebrow { color: var(--tone-text); }

.field-value,
.field-value--lg {
    font-size: var(--fs-value);
    font-weight: 600;
}

.form-label { font-size: var(--fs-body); font-weight: 600; }

/* Inputs and selects: 14px, 42px tall */
.form-control,
.form-input,
.form-select,
.form-textarea {
    min-height: 42px;
    font-size: var(--fs-body);
    font-weight: 400;
}

/* Reply editor text */
.jodit-wysiwyg { font-size: var(--fs-value) !important; line-height: 1.55; }

/* Hints */
.hint,
.form-hint,
.cell-sub,
.dropzone-app .hint {
    font-size: var(--fs-xs);
    font-weight: 400;
    color: var(--app-text-muted);
}

/* Buttons: 14px / 600 / 40px; small inline buttons 13px / 34px */
.btn-primary-pill,
.btn-outline-pill,
.btn-strong,
.btn-ghost,
.btn-warning-soft {
    min-height: 40px;
    font-size: var(--fs-body);
    font-weight: 600;
}

.btn-sm,
.btn-primary-pill.btn-sm,
.btn-outline-pill.btn-sm,
.btn-strong.btn-sm {
    min-height: 34px;
    font-size: var(--fs-small);
}

.btn-lg { min-height: 46px; font-size: var(--fs-body); }

/* Tabs */
.segmented > a,
.segmented > button {
    font-size: var(--fs-body);
    font-weight: 500;
}

.segmented > .active,
.segmented > [aria-current="page"],
.segmented > [aria-current="true"] {
    font-weight: 600;
}

/* Chips, badges and counts */
.chip,
.phase-badge {
    font-size: var(--fs-small);
    font-weight: 600;
}

.phase-badge-label,
.count-badge,
.badge-solid,
.file-ext {
    font-size: var(--fs-label);
    font-weight: 600;
}

/* Thread */
.thread-author {
    font-size: var(--fs-body);
    font-weight: 600;
}

.thread-role,
.thread-tag,
.thread-item--system .thread-author {
    font-size: var(--fs-xs);
    font-weight: 600;
}

.thread-time,
.thread-meta {
    font-size: var(--fs-small);
    font-weight: 400;
    color: var(--app-text-muted);
}

.thread-body,
.thread-item--system .thread-body {
    font-size: var(--fs-body);
    font-weight: 400;
    line-height: 1.55;
}

/* Timeline steps */
.step-title,
.step--current .step-title {
    font-size: var(--fs-body);
    font-weight: 600;
}

.step-sub { font-size: var(--fs-small); }

.step-time { font-size: var(--fs-xs); }

/* Colour key next to "Activity" */
.section-label-legend {
    font-size: var(--fs-small);
    font-weight: 400;
}

/* Avatar initials (13px in the larger owner avatar) */
.avatar,
.thread-avatar,
.sidebar-avatar {
    font-size: var(--fs-xs);
    font-weight: 600;
}

.ticket-banner-owner .avatar { font-size: var(--fs-small); }

/* Sidebar brand (also used in the client header and login pages) */
.brand-name {
    font-size: var(--fs-value);
    font-weight: 600;
}

.brand-sub {
    font-size: var(--fs-xs);
    font-weight: 400;
}

/* Mono only for ticket numbers and code */
.mono { font-family: var(--app-font-mono); font-weight: 500; }

/* ==========================================================
   27. Files list rows (TicketAttachments::renderRow)
   [PDF]  name.pdf                      [view][download][delete]
          Customer
   ========================================================== */
.file-list .ticket-file {
    flex-wrap: nowrap;
    align-items: center;
}

.ticket-file-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.ticket-file-name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--fs-body);
    font-weight: 600;
    color: var(--app-text-main);
}

.ticket-file-name:hover {
    color: var(--app-accent-text);
    text-decoration: underline;
}

.ticket-file-main .chip {
    padding: 1px 8px;
    font-size: var(--fs-xs);
}

.ticket-file-actions {
    display: flex;
    flex-shrink: 0;
    gap: 2px;
}

.ticket-file-actions .btn-icon:disabled { opacity: .4; }

/* Right side of the ticket header: owner box with the close / re-open button under it */
.ticket-banner-side {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-self: center;
    min-width: 220px;
}

.ticket-banner-side .ticket-banner-owner { align-self: stretch; }


/* ---------- Ticket page on tablets and phones ---------- */

/* Tablet: the owner box + close button drop under the title as one full-width row */
@media (max-width: 900px) {
    .ticket-banner-side {
        flex: 1 1 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: stretch;
        min-width: 0;
    }

    .ticket-banner-side .ticket-banner-owner {
        flex: 1 1 200px;
        min-width: 0;
    }

    /* Close / re-open button: as tall as the owner box */
    .ticket-banner-side > form {
        flex: 1 1 160px;
        display: flex;
    }

    .ticket-banner-side > form .btn-block { justify-content: center; }
}

/* Phone */
@media (max-width: 600px) {
    /* Header card: less padding, no icon tile, smaller title */
    .ticket-banner {
        gap: 14px;
        padding: 18px 16px;
    }

    .ticket-banner-icon { display: none; }

    .ticket-banner-title {
        margin: 4px 0 8px;
        font-size: 1.25rem;
    }

    .ticket-banner-meta {
        gap: 4px 14px;
        margin-bottom: 12px;
        font-size: var(--fs-small);
    }

    .ticket-banner-owner { padding: 12px 14px; }

    /* Cards: tighter padding (the grey footer bar follows the body padding) */
    .ticket-panel-header { padding: 14px 16px; }
    .ticket-panel-header.borderless { padding-bottom: 4px; }
    .ticket-panel-body { padding: 14px 16px 16px; }

    .action-row.panel-footer {
        margin: 16px -16px -16px;
        padding: 12px 16px;
    }

    /* Footer: checkbox on its own line, full-width save button under it */
    .action-row.panel-footer .spacer { display: none; }

    .action-row.panel-footer > button {
        width: 100%;
        justify-content: center;
    }

    /* Ticket details: one column. ".field.span-2" would otherwise force a
       second column and push the card wider than the screen. */
    .field-grid .field.span-2 { grid-column: auto; }

    /* 16px inputs stop iOS Safari zooming in when a field is tapped */
    .ticket-layout .form-control { font-size: 16px; }

    /* Toolbar buttons (Copy link, Client profile): icon only, text kept for screen readers */
    .app-topbar .btn-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}


/* ==========================================================
   28. Response times card (AdminTicketService::renderResponseTimes)
   [icon] Label                         Value
          sub-line
   Tone: --success (green) | --warning (amber) | --danger (red) | --neutral
   ========================================================== */
.timing-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.timing-item {
    --timing-bg: var(--app-segment-bg);
    --timing-fg: var(--app-text-muted);
    --timing-border: var(--app-border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--timing-border);
    border-radius: 12px;
}

.timing-item--success { --timing-bg: var(--st-success-bg); --timing-fg: var(--st-success-text); --timing-border: var(--app-border); }
.timing-item--warning { --timing-bg: var(--st-warning-bg); --timing-fg: var(--st-warning-text); --timing-border: var(--st-warning-border); }
.timing-item--danger  { --timing-bg: var(--st-danger-bg);  --timing-fg: var(--st-danger-text);  --timing-border: var(--st-danger-border); }

/* Amber / red rows are tinted so they stand out */
.timing-item--warning,
.timing-item--danger {
    background: var(--timing-bg);
}

.timing-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--timing-bg);
    color: var(--timing-fg);
    font-size: var(--fs-small);
}

.timing-item--warning .timing-icon,
.timing-item--danger .timing-icon {
    background: var(--app-surface);
}

.timing-text {
    flex: 1;
    min-width: 0;
}

.timing-label {
    font-size: var(--fs-body);
    font-weight: 600;
    color: var(--app-text-main);
}

.timing-sub {
    font-size: var(--fs-xs);
    color: var(--app-text-muted);
}

.timing-value {
    flex-shrink: 0;
    font-size: var(--fs-body);
    font-weight: 600;
    color: var(--timing-fg);
    white-space: nowrap;
}

.timing-item--neutral .timing-value { color: var(--app-text-body); }



/* ==========================================================
   29. Ticket list rows (admin + client lists)
   Colour only where something needs attention:
   - thin red / amber left edge for Critical / High priority,
   - status: coloured dot + dark text,
   - priority flag coloured only for High / Critical,
   - "Waiting on" bold blue (and subject bold) when it is the viewer's turn.
   ========================================================== */
.table-rows td {
    padding-top: 14px;
    padding-bottom: 14px;
}

.table-rows tbody tr[data-href] { cursor: pointer; }

.table-rows tbody tr:hover { background: var(--app-surface-2); }

/* Thin coloured edge on the left of the row (on the first cell) */
.table-rows tbody tr.row-prio--critical > td:first-child { box-shadow: inset 3px 0 0 var(--st-danger-dot); }
.table-rows tbody tr.row-prio--high > td:first-child     { box-shadow: inset 3px 0 0 var(--st-warning-dot); }

/* Subject: regular weight; bold when it is the viewer's turn */
.table-rows .ticket-subject {
    font-size: var(--fs-body);
    font-weight: 500;
}

.table-rows tr.is-action .ticket-subject { font-weight: 600; }

.cell-right { text-align: right; }

/* Status badge: pill, tinted background, dot + text, 13px / 600 (UiHelper::statusBadge).
   Colours per group (Ticket::statusTone); admin-dark.css overrides the --sb-* values. */
:root {
    --sb-new-bg: #f4f0ff;      --sb-new-text: #6d28d9;      --sb-new-dot: #7c3aed;
    --sb-open-bg: #eff4ff;     --sb-open-text: #1d4ed8;     --sb-open-dot: #2563eb;
    --sb-waiting-bg: #fffaeb;  --sb-waiting-text: #b54708;  --sb-waiting-dot: #f79009;
    --sb-resolved-bg: #ecfdf3; --sb-resolved-text: #067647; --sb-resolved-dot: #17b26a;
    --sb-closed-bg: #f1f3f8;   --sb-closed-text: #475569;   --sb-closed-dot: #94a3b8;

    /* Priority flag colours (the text stays slate) */
    --prio-low: #94a3b8;
    --prio-medium: #f79009;
    --prio-high: #f04438;
}

.status-badge {
    --sb-bg: var(--sb-closed-bg);
    --sb-text: var(--sb-closed-text);
    --sb-dot: var(--sb-closed-dot);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--sb-bg);
    color: var(--sb-text);
    font-size: var(--fs-small);
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.status-badge-dot {
    width: 6px;
    height: 6px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--sb-dot);
}

.status-badge--new      { --sb-bg: var(--sb-new-bg);      --sb-text: var(--sb-new-text);      --sb-dot: var(--sb-new-dot); }
.status-badge--open     { --sb-bg: var(--sb-open-bg);     --sb-text: var(--sb-open-text);     --sb-dot: var(--sb-open-dot); }
.status-badge--waiting  { --sb-bg: var(--sb-waiting-bg);  --sb-text: var(--sb-waiting-text);  --sb-dot: var(--sb-waiting-dot); }
.status-badge--resolved { --sb-bg: var(--sb-resolved-bg); --sb-text: var(--sb-resolved-text); --sb-dot: var(--sb-resolved-dot); }
.status-badge--closed   { --sb-bg: var(--sb-closed-bg);   --sb-text: var(--sb-closed-text);   --sb-dot: var(--sb-closed-dot); }

/* Status group heading row in grouped lists ("● AWAITING FIX 1"),
   AdminTicketService::renderTicketTable($groupByStatus = true) */
.table-rows tbody tr.status-group-row,
.table-rows tbody tr.status-group-row:hover {
    background: var(--sg-bg);
    cursor: default;
}

.table-rows tbody tr.status-group-row > th {
    padding: 10px 1rem;
    border-top: 1px solid var(--app-border-soft);
    font-size: var(--fs-label);
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    text-align: left;
    color: var(--sg-text);
}

/* First group directly under the column headers: no extra line */
.table-rows tbody tr.status-group-row:first-child > th { border-top: 0; }

/* Same colours as the status badge of that group (--sb-*; admin-dark.css overrides them) */
.status-group-row           { --sg-bg: var(--sb-closed-bg);   --sg-text: var(--sb-closed-text);   --sg-dot: var(--sb-closed-dot); }
.status-group-row--new      { --sg-bg: var(--sb-new-bg);      --sg-text: var(--sb-new-text);      --sg-dot: var(--sb-new-dot); }
.status-group-row--open     { --sg-bg: var(--sb-open-bg);     --sg-text: var(--sb-open-text);     --sg-dot: var(--sb-open-dot); }
.status-group-row--waiting  { --sg-bg: var(--sb-waiting-bg);  --sg-text: var(--sb-waiting-text);  --sg-dot: var(--sb-waiting-dot); }
.status-group-row--resolved { --sg-bg: var(--sb-resolved-bg); --sg-text: var(--sb-resolved-text); --sg-dot: var(--sb-resolved-dot); }

.status-group-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--sg-dot);
    vertical-align: middle;
}

.status-group-count {
    margin-left: 6px;
    opacity: .7; /* same colour as the label, a little lighter */
}

/* Priority: flag icon + text; only the flag is coloured */
.prio-flag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-body);
    color: var(--app-text-body);
    white-space: nowrap;
}

.prio-flag i { font-size: var(--fs-xs); }

.prio-flag--low i    { color: var(--prio-low); }
.prio-flag--medium i { color: var(--prio-medium); }
.prio-flag--high i   { color: var(--prio-high); }

/* Waiting on: plain grey text, or a blue badge when the viewer needs to act */
.waiting-on {
    font-size: var(--fs-body);
    color: var(--app-text-muted);
    white-space: nowrap;
}

.waiting-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--sb-open-bg);
    color: var(--sb-open-text);
    font-size: var(--fs-small);
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

/* Chevron at the end of a clickable row */
.table-rows .cell-chevron {
    width: 1%;
    padding-left: 0;
    text-align: right;
    color: var(--app-text-muted);
    font-size: var(--fs-xs);
}

.table-rows tbody tr[data-href]:hover .cell-chevron { color: var(--app-accent-text); }

/* Assignee name a little quieter than the subject */
.table-rows .person-name {
    font-size: var(--fs-body);
    color: var(--app-text-body);
}

.table-rows .age-label {
    font-size: var(--fs-small);
    color: var(--app-text-muted);
}



/* ==========================================================
   Client ticket page fixes (portal-view-ticket.php)
   ========================================================== */

/* Card headers: the title block shrinks next to the icon instead of wrapping
   under it when the subtitle is long (e.g. Files card in the narrow column) */
.ticket-panel-header > .panel-title-block { flex: 1 1 0; }

/* Note after a section label, e.g. "Conversation  Newest first" */
.section-label-note {
    margin-left: 6px;
    font-size: var(--fs-xs);
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--app-text-muted);
}

/* Progress: done = green tick, current = highlighted, upcoming = hollow and quiet */
.steps--progress .step--done .step-marker i { font-size: 10px; }
.steps--progress .step--upcoming .step-title { color: var(--app-text-muted); font-weight: 500; }
.steps--progress .step--current .step-sub { color: var(--app-text-body); }

/* Section headings inside a ticket description ("Steps to reproduce", ...):
   small grey labels rather than big bold text */
.thread-body h3 {
    margin: 1em 0 .3em;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--app-text-muted);
}

.thread-body h3:first-child { margin-top: 0; }

/* Files: uploader pill, then size and upload date */
.ticket-file-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.ticket-file-info {
    font-size: var(--fs-xs);
    color: var(--app-text-muted);
}
