/* ==========================================================================
   Immutec Support — design system
   Extracted from the real Immutec dashboard (test.ccc.immutec.eu).
   ========================================================================== */

/* --- Fonts (self-hosted; CSP font-src 'self') ---------------------------- */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/assets/fonts/inter-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/assets/fonts/inter-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/assets/fonts/inter-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/assets/fonts/inter-700.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/assets/fonts/jetbrains-mono-400.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/assets/fonts/jetbrains-mono-500.woff2') format('woff2');
}

/* --- Tokens -------------------------------------------------------------- */
:root {
    --color-primary: #002B49;
    --color-secondary: #00A19A;
    --color-accent: #951B81;
    --color-warning: #E07C1F;
    --color-danger: #D03D4B;
    --color-surface: #EFEFEF;
    --color-surface-card: #FFFFFF;
    --color-border: #BCCAD8;
    --color-text: #002B49;
    --color-text-muted: #6b7a88;

    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --radius: 4px;
    --radius-input: 2px;
    --shadow-card: 0 1px 3px rgba(0, 43, 73, 0.08), 0 1px 2px rgba(0, 43, 73, 0.06);
    --shadow-hover: 0 4px 12px rgba(0, 43, 73, 0.12);
    --nav-width: 216px;
    --topbar-height: 64px;
}

/* --- Base ---------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    margin: 0;
    font-weight: 700;
    line-height: 1.3;
}

p {
    margin: 0 0 8px;
}

a {
    color: var(--color-secondary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.link {
    color: var(--color-secondary);
    font-weight: 500;
}

.mono {
    font-family: var(--font-mono);
    font-size: 0.93em;
}

.muted {
    color: var(--color-text-muted);
}

code {
    font-family: var(--font-mono);
    font-size: 0.93em;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    padding: 1px 5px;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--color-primary);
    color: #fff;
    padding: 8px 14px;
    border-radius: 0 0 var(--radius) 0;
    z-index: 100;
}

.skip-link:focus {
    left: 0;
}

:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 1px;
}

/* --- Top bar ------------------------------------------------------------- */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--theme-topbar, var(--color-primary));
    border-bottom: none;
    box-shadow: var(--shadow-card);
    z-index: 40;
}

.topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 24px;
}

.topbar__logo {
    display: flex;
    align-items: center;
}

.topbar__logo img {
    max-height: 24px;
    width: auto;
    display: block;
}

.usermenu {
    display: flex;
    align-items: center;
    gap: 10px;
}

.usermenu .pill {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.65);
    color: #ffffff;
    font-weight: 600;
}

.usermenu .btn--secondary {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.55);
    color: #ffffff;
    font-weight: 600;
}

.usermenu .btn--secondary:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: #ffffff;
    color: #ffffff;
}

.usermenu__name {
    font-weight: 600;
    font-size: 13px;
    color: #ffffff;
}

.usermenu__name:hover {
    text-decoration: underline;
}
.usermenu .pill {
    border: 1px solid rgba(255, 255, 255, 0.35);
}

/* --- Side nav ------------------------------------------------------------ */
.sidenav {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    width: var(--nav-width);
    background: #fff;
    border-right: 1px solid var(--color-border);
    padding: 14px 0;
    overflow-y: auto;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidenav__link {
    display: block;
    padding: 9px 20px;
    color: var(--color-primary);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border-left: 3px solid transparent;
}

.sidenav__link:hover {
    background: var(--color-surface);
    text-decoration: none;
}

.sidenav__link.is-active {
    background: rgba(0, 161, 154, 0.10);
    border-left-color: var(--color-secondary);
    color: var(--color-primary);
    font-weight: 600;
}

.sidenav__section {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 20px 6px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--color-primary);
    white-space: nowrap;
    min-width: 0;
}

.sidenav__section::after {
    min-width: 12px;
}

.sidenav__section::before {
    content: '';
    width: 14px;
    height: 3px;
    border-radius: 2px;
    background: var(--color-secondary);
    flex: none;
}

.sidenav__section::after {
    content: '';
    height: 1px;
    background: var(--color-border);
    flex: 1;
}
.sidenav__badge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(0, 161, 154, 0.12);
    color: #006b67;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.6;
    vertical-align: 1px;
}

/* --- Content area -------------------------------------------------------- */
.content {
    margin-top: var(--topbar-height);
    margin-left: var(--nav-width);
    padding: 24px 28px 60px;
    min-height: calc(100vh - var(--topbar-height));
}

.footer {
    margin-left: var(--nav-width);
    padding: 14px 28px;
    font-size: 12px;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    background: #fff;
}

/* --- Page head ----------------------------------------------------------- */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.page-head__title {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-primary);
}

.page-head__sub {
    margin: 4px 0 0;
    color: var(--color-text-muted);
    font-size: 13px;
}

.page-head__eyebrow {
    margin: 0 0 2px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.84px;
    text-transform: uppercase;
    color: var(--color-secondary);
}

.page-head__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* --- Cards --------------------------------------------------------------- */
.card {
    background: var(--color-surface-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 18px 20px;
    margin-bottom: 16px;
}

.card--form {
    max-width: 100%;
}

.card__label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.84px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

/* --- Section labels ------------------------------------------------------ */
.section-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.84px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 10px;
}

/* --- Buttons ------------------------------------------------------------- */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
    text-decoration: none;
}

.btn--primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.btn--primary:hover {
    background: #00223a; /* 85% mix of #002B49 with black */
    border-color: #00223a;
    color: #fff;
}

.btn--secondary {
    background: #fff;
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn--secondary:hover {
    background: #e6e9ec; /* subtle surface tint */
    border-color: #00223a;
    color: #00223a;
}

.btn--danger {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: #fff;
}

.btn--danger:hover {
    background: #b13440; /* 85% mix of #D03D4B with black */
    border-color: #b13440;
    color: #fff;
}

.btn--sm {
    padding: 5px 11px;
    font-size: 12.5px;
}

.btn--block {
    display: block;
    width: 100%;
}

/* --- Forms --------------------------------------------------------------- */
.form {
    margin: 0;
}

.form--row {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}

.form__field {
    margin-bottom: 14px;
}

.form__field--grow {
    flex: 1 1 220px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    margin-bottom: 0;
}

.form__field--inline {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.form__field--small {
    max-width: 180px;
}

.form__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0 14px;
}

.form__label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.84px;
    text-transform: uppercase;
    color: var(--color-primary);
    margin-bottom: 5px;
}

.form__input {
    display: block;
    width: 100%;
    height: 38px;
    padding: 6px 10px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-text);
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    outline: none;
}

.form__input--area {
    height: auto;
    min-height: 80px;
    resize: vertical;
}

.form__input--select {
    appearance: auto;
    width: 100%;
    min-width: 160px;
    height: 38px;
    padding: 6px 10px;
}

.form__hint {
    margin: 5px 0 0;
    font-size: 12px;
    color: var(--color-text-muted);
}

.form__check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 14px;
    color: var(--color-text);
    cursor: pointer;
}

.form__check input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--color-secondary);
}

.form__check--inline {
    display: inline-flex;
    margin: 0 14px 8px 0;
}

.form__check--sub {
    margin-left: -6px;
}

.form__fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin: 0 0 14px;
    padding: 10px 12px 2px;
}

.form__fieldset .form__label {
    margin-bottom: 8px;
}

.form__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.form__actions--inline {
    margin-top: 0;
}

.inline-form {
    display: inline;
    margin: 0;
}

/* --- Flash + alerts ------------------------------------------------------ */
.flash {
    background: rgba(0, 161, 154, 0.12);
    border: 1px solid var(--color-secondary);
    color: var(--color-primary);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-weight: 500;
}

.alert {
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 13.5px;
}

.alert--danger {
    background: rgba(208, 61, 75, 0.12);
    border: 1px solid var(--color-danger);
    color: #8f2833;
}

.alert--ok {
    background: rgba(0, 161, 154, 0.12);
    border: 1px solid var(--color-secondary);
    color: var(--color-primary);
}

.alert--warning {
    background: rgba(224, 124, 31, 0.12);
    border: 1px solid var(--color-warning);
    color: #96530f;
}

/* --- Reply collision warning bar (collision.js) --------------------------- */
.collision-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.collision-bar__text {
    flex-grow: 1;
}

.collision-bar__close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0 2px;
    font-size: 16px;
    line-height: 1;
    color: #96530f;
    cursor: pointer;
}

.collision-bar__close:hover {
    color: var(--color-text);
}

.api-key-reveal {
    display: block;
    margin-top: 8px;
    padding: 10px 12px;
    font-size: 13px;
    word-break: break-all;
    background: #fff;
}

/* --- Toasts (JS-enhanced flash) ------------------------------------------ */
.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 420px;
    background: var(--color-surface-card);
    border: 1px solid var(--color-border);
    border-left-width: 4px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 12px 14px;
    font-size: 13.5px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.toast--ok {
    border-left-color: var(--color-secondary);
    color: var(--color-primary);
}

.toast--error {
    border-left-color: var(--color-danger);
    color: #8f2833;
}

.toast--warn {
    border-left-color: var(--color-warning);
    color: #96530f;
}

.toast__body {
    flex-grow: 1;
    font-weight: 500;
}

.toast__actions {
    flex-shrink: 0;
}

.toast__undo {
    margin: 0;
}

.toast__close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0 2px;
    font-size: 16px;
    line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
}

.toast__close:hover {
    color: var(--color-text);
}

@media (max-width: 767px) {
    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        max-width: none;
    }
}

/* --- Pills --------------------------------------------------------------- */
.pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.6;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Statuses: soft 12% background mixes with dark text */
.pill--status-new        { background: rgba(0, 43, 73, 0.12); color: #002B49; }
.pill--status-in_triage  { background: rgba(224, 124, 31, 0.12); color: #96530f; }
.pill--status-triaged    { background: rgba(149, 27, 129, 0.12); color: #6d144f; }
.pill--status-open       { background: rgba(0, 161, 154, 0.12); color: #006b67; }
.pill--status-pending    { background: rgba(224, 124, 31, 0.12); color: #96530f; }
.pill--status-waiting_customer { background: rgba(224, 124, 31, 0.12); color: #96530f; }
.pill--status-resolved   { background: rgba(0, 161, 154, 0.12); color: #006b67; }
.pill--status-closed     { background: rgba(107, 122, 136, 0.18); color: #4d5862; }
.pill--status-spam       { background: rgba(208, 61, 75, 0.12); color: #8f2833; }
.pill--status-active     { background: rgba(0, 161, 154, 0.12); color: #006b67; }

/* Priorities */
.pill--priority-low      { background: rgba(107, 122, 136, 0.14); color: #4d5862; }
.pill--priority-normal   { background: rgba(0, 43, 73, 0.08); color: #002B49; }
.pill--priority-high     { background: rgba(224, 124, 31, 0.12); color: #96530f; }
.pill--priority-urgent   { background: rgba(208, 61, 75, 0.14); color: #8f2833; }

/* Triage verdicts */
.pill--verdict-valid     { background: rgba(0, 161, 154, 0.12); color: #006b67; }
.pill--verdict-spam      { background: rgba(208, 61, 75, 0.12); color: #8f2833; }
.pill--verdict-invalid   { background: rgba(149, 27, 129, 0.12); color: #6d144f; }
.pill--verdict-error     { background: rgba(224, 124, 31, 0.12); color: #96530f; }
.pill--verdict-review    { background: rgba(224, 124, 31, 0.12); color: #96530f; }

/* Misc pills */
.pill--staff             { background: rgba(0, 43, 73, 0.12); color: #002B49; }
.pill--internal          { background: rgba(224, 124, 31, 0.12); color: #96530f; }
.pill--agent             { background: rgba(0, 161, 154, 0.12); color: #00695f; }
.pill--beta              { background: #951B81; color: #ffffff; font-weight: 800; font-size: 10px; letter-spacing: 1px; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }
.sidenav__link .pill--beta { margin-left: 6px; }
.cond-preview            { display: grid; gap: 8px; margin-bottom: 12px; }
.cond-chip               { border: 1px solid var(--color-border); border-radius: 8px; padding: 8px 12px; background: var(--color-surface); font-size: 13px; }
.cond-chip--required     { border-left: 3px solid var(--color-primary); }
.msg__agent-actions      { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.pill--role-2            { background: #00A19A; color: #ffffff; font-weight: 700; }
.pill--role-3            { background: rgba(0, 43, 73, 0.10); color: #002B49; }
.pill--role-4            { background: #E07C1F; color: #ffffff; font-weight: 700; }
.pill--relation          { background: rgba(0, 43, 73, 0.08); color: #3d5568; font-size: 11px; }

/* SLA badges */
.pill--sla-ok   { background: rgba(0, 161, 154, 0.14); color: #006b67; }
.pill--sla-warn { background: rgba(224, 124, 31, 0.16); color: #96530f; }

/* --- Saved view chips ------------------------------------------------------ */
.chipbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border);
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface, #fff);
    font-size: 12.5px;
}
.chip--link:hover,
.chip__link:hover {
    border-color: var(--color-primary, #2563eb);
    color: var(--color-primary, #2563eb);
}
.chip__link {
    color: inherit;
    text-decoration: none;
}
.chip__default {
    color: var(--color-warning, #d97706);
    font-size: 11px;
}
.chip__delete {
    display: inline;
    margin: 0;
}
.chip__delete-btn {
    border: 0;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 0 2px;
}
.chip__delete-btn:hover {
    color: var(--color-danger, #dc2626);
}
.chipbar__save {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}
.chipbar__name {
    width: 140px;
    padding: 4px 8px;
    font-size: 12.5px;
}

.pill--sla-over { background: rgba(208, 61, 75, 0.16); color: #8f2833; }
.pill--sla-resolved   { background: rgba(0, 161, 154, 0.12); color: #006b67; }
.pill--sla-closed     { background: rgba(0, 43, 73, 0.10); color: #002B49; }

/* --- Companies form grid --------------------------------------------------- */
.form__grid--companies {
    grid-template-columns: 2fr 2fr 1.5fr;
}

/* --- Ticket list filter toolbar ------------------------------------------ */
.card--filters {
    padding: 12px 20px;
}
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.filters__search {
    flex: 1 1 220px;
    min-width: 180px;
    width: auto;
}
.filters__select {
    width: auto;
    min-width: 140px;
    flex: 0 1 auto;
}
.filters__clear {
    margin: 6px 2px 0;
    font-size: 12.5px;
}

/* --- Bulk actions panel --------------------------------------------------- */
.bulk {
    margin: 0 0 12px;
}
.bulk__panel {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(0, 161, 154, 0.08);
    border: 1px solid var(--color-secondary);
    border-radius: var(--radius);
}
.bulk__panel[hidden] {
    display: none;
}
.bulk__count {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-primary);
    margin-right: 4px;
}
.bulk__select {
    width: auto;
    min-width: 170px;
    flex: 0 1 auto;
}
.bulk__col {
    width: 28px;
    text-align: center;
    padding-left: 0 !important;
}
.bulk__col input[type="checkbox"] {
    accent-color: var(--color-secondary);
    cursor: pointer;
}

/* --- Pager ---------------------------------------------------------------- */
.pager {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}
.pager__info {
    color: var(--color-text-muted);
    font-size: 12.5px;
}

/* --- Settings table of contents ------------------------------------------- */
.settings-toc {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 2px 0 14px;
}
.settings-toc a {
    display: inline-block;
    padding: 4px 10px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 12.5px;
    color: var(--color-text);
    text-decoration: none;
    background: var(--color-surface-card);
}
.settings-toc a:hover {
    border-color: var(--color-secondary);
    color: var(--color-secondary);
}

.list-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0 2px;
    border-top: 1px solid var(--color-border);
    margin-top: 10px;
    flex-wrap: wrap;
}

.list-footer__label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--color-muted, #6b7a88);
}

.list-footer__note {
    font-size: 12px;
    margin-left: auto;
}

@media (max-width: 720px) {
    .form__grid--companies {
        grid-template-columns: 1fr;
    }
}

/* --- Linked tickets ------------------------------------------------------- */
.linklist {
    list-style: none;
    margin: 0;
    padding: 0;
}

.linklist__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
    min-height: 38px;
}

.linklist__item:last-child {
    border-bottom: none;
}

.linklist__link {
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
    white-space: nowrap;
}

.linklist__link:hover {
    text-decoration: underline;
}

.linklist__subject {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.linklist__remove {
    border: none;
    background: none;
    color: var(--color-muted, #6b7a88);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-input, 4px);
}

.linklist__remove:hover {
    color: #8f2833;
    background: rgba(208, 61, 75, 0.08);
}

.form--tight {
    margin-top: 10px;
}

/* --- Tables -------------------------------------------------------------- */
.table-scroll {
    overflow-x: auto;
}

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

.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.84px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    border-bottom: 2px solid var(--color-border);
    padding: 8px 12px 8px 0;
    white-space: nowrap;
}

.table th .th-sort {
    color: inherit;
    text-decoration: none;
}
.table th .th-sort:hover {
    color: var(--color-primary);
}

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

.table tbody tr:last-child td {
    border-bottom: none;
}
.table__actions {
    white-space: nowrap;
}

.table tbody tr:hover {
    background: rgba(0, 161, 154, 0.04);
}

.table__actions {
    text-align: right;
    white-space: nowrap;
}

/* --- Key/value list ------------------------------------------------------ */
.kv {
    margin: 0;
    font-size: 13px;
}

.kv__row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-surface);
}

.kv__row:last-child {
    border-bottom: none;
}

.kv__row dt {
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.kv__row dd {
    margin: 0;
    text-align: right;
}

/* --- Ticket conversation ------------------------------------------------- */
.ticket-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
    align-items: start;
}

.ticket-grid__main,
.ticket-grid__side {
    min-width: 0;
}

.msg {
    padding: 14px 0;
    border-bottom: 1px solid var(--color-surface);
}

.msg--first {
    padding-top: 2px;
}

.msg:last-child {
    border-bottom: none;
    padding-bottom: 4px;
}

.msg__head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.msg__author {
    font-weight: 600;
    color: var(--color-primary);
    font-size: 13.5px;
}

.msg__date {
    font-size: 12px;
}

.msg__body {
    font-size: 14px;
    white-space: normal;
    word-wrap: break-word;
}

.msg--internal {
    background: rgba(224, 124, 31, 0.06);
    border-left: 3px solid var(--color-warning);
    padding: 12px 14px;
    border-radius: var(--radius);
    margin: 8px 0;
}

.msg__attachments {
    list-style: none;
    margin: 8px 0 0;
    padding: 8px 0 0;
    border-top: 1px dashed var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msg__attachment {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.msg__attachment a {
    color: var(--color-secondary);
    text-decoration: none;
    word-break: break-all;
}

.msg__attachment a:hover {
    text-decoration: underline;
}

.msg__attachment-icon {
    font-size: 13px;
}

/* --- Timeline ------------------------------------------------------------ */
.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}

.timeline__item {
    position: relative;
    padding: 0 0 12px 16px;
    border-left: 2px solid var(--color-border);
    margin-left: 4px;
}

.timeline__item--staff {
    border-left-color: var(--color-secondary);
}

.timeline__item .pill {
    font-size: 10px;
    padding: 1px 6px;
    vertical-align: 1px;
}

.timeline__item:last-child {
    padding-bottom: 2px;
}

.timeline__item::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-secondary);
}

.timeline__event {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-primary);
}

.timeline__detail,
.timeline__date {
    display: block;
    font-size: 12px;
}

/* --- Triage queue cards -------------------------------------------------- */
.triage-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.triage-card__subject {
    font-size: 16px;
    margin: 2px 0 6px;
}

.triage-card__verdict {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.triage-card__body {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    padding: 12px 14px;
    margin: 12px 0;
    font-size: 13.5px;
    max-height: 220px;
    overflow-y: auto;
}

.triage-card__suggest {
    margin-bottom: 12px;
    font-size: 13.5px;
}

.triage-card__actions {
    border-top: 1px solid var(--color-surface);
    padding-top: 12px;
}

.triage-card__row {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}

.triage-card__buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* --- Department cards ---------------------------------------------------- */
.dept-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.dept-head__name {
    font-size: 16px;
    color: var(--color-primary);
}

/* --- Auth pages ---------------------------------------------------------- */
.is-guest .topbar {
    display: none;
}

.is-guest .content {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(1200px 600px at 20% -10%, rgba(255, 255, 255, 0.08), transparent 60%),
        var(--theme-topbar, var(--color-primary));
}

.is-guest .footer {
    display: none;
}

.auth-wrap {
    width: 100%;
    max-width: 480px;
    padding: 24px 16px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 18px;
}

.auth-brand__logo {
    max-height: 48px;
    width: auto;
    display: inline-block;
}

.auth-card {
    background: var(--color-surface-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 26px 26px 22px;
}

.auth-card__title {
    font-size: 19px;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.auth-card__sub {
    color: var(--color-text-muted);
    font-size: 13.5px;
    margin: 4px 0 16px;
}

.auth-card__links {
    margin: 14px 0 0;
    text-align: center;
    font-size: 13px;
}

.auth-foot {
    margin-top: 24px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 12px;
}

/* --- Error cards --------------------------------------------------------- */
.error-card {
    max-width: 520px;
    margin: 40px auto;
    text-align: center;
    padding: 34px 28px;
}

.error-card__code {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.84px;
    text-transform: uppercase;
    color: var(--color-danger);
    margin-bottom: 6px;
}

.error-card__title {
    font-size: 20px;
    color: var(--color-primary);
    margin-bottom: 6px;
}

.error-card__sub {
    color: var(--color-text-muted);
    margin-bottom: 18px;
}

.error-card__actions {
    margin: 0;
}

/* --- Empty states -------------------------------------------------------- */
.empty {
    text-align: center;
    padding: 26px 12px;
}

.empty__title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.empty__sub {
    color: var(--color-text-muted);
    font-size: 13px;
    margin-bottom: 12px;
}

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 1024px) {
    .ticket-grid {
        grid-template-columns: 1fr;
    }
}

/* --- MFA / profile --------------------------------------------------------- */
.mfa-card {
    max-width: 380px;
}

.mfa-code {
    font-family: var(--font-mono);
    font-size: 22px;
    letter-spacing: 8px;
    text-align: center;
    padding: 10px;
}

.mfa-passkey {
    margin-top: 18px;
    border-top: 1px solid var(--color-border);
    padding-top: 14px;
}

.totp-secret {
    font-size: 18px;
    letter-spacing: 2px;
    user-select: all;
}

/* --- Theme editor ---------------------------------------------------------- */
.form__input--color {
    width: 100%;
    height: 38px;
    padding: 2px 4px;
    cursor: pointer;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
}

.theme-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 14px 0 4px;
    padding: 10px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
}

.theme-swatch {
    width: 34px;
    height: 22px;
    border-radius: 3px;
    display: inline-block;
}

.theme-swatch--bordered {
    border: 1px solid var(--color-border);
}

.theme-preview__logo {
    max-height: 28px;
    margin-left: auto;
}

/* --- API screen alignment --------------------------------------------------- */
.form__field--inline .form__input,
.form__field--inline .form__input--select {
    width: 100%;
    min-width: 180px;
    height: 38px;
}

.form__field--inline,
.form__check--inline,
.form__actions--inline {
    align-self: flex-end;
    margin-bottom: 0;
}

.form__check--inline {
    height: 38px;
    align-items: center;
}

.form--row > .form__field--grow,
.form--row > .form__field--inline {
    align-self: stretch;
    justify-content: flex-end;
}

/* --- Responsive ------------------------------------------------------------ */
@media (max-width: 767px) {
    .topbar {
        position: static;
        height: auto;
    }

    .topbar__inner {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 14px;
    }

    .sidenav {
        position: static;
        width: auto;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        padding: 6px 10px;
        gap: 4px;
    }

    .sidenav__link {
        border-left: none;
        border-radius: var(--radius);
        padding: 7px 10px;
        font-size: 13px;
    }

    .sidenav__link.is-active {
        background: var(--color-primary);
        color: #fff;
        border-left-color: transparent;
    }

    .sidenav__section {
        width: 100%;
        margin: 6px 10px 2px;
    }

    .content {
        margin-left: 0;
        padding: 16px 14px 40px;
        min-height: auto;
    }

    .footer {
        margin-left: 0;
        padding: 12px 14px;
    }

    .page-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .form--row,
    .triage-card__row {
        flex-direction: column;
        align-items: stretch;
    }

    .form__actions--inline {
        margin-top: 8px;
    }
}

/* --- Department member picker ---------------------------------------------- */
.dept-picker {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 14px;
}
.dept-picker__col {
    flex: 1 1 240px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.dept-picker__list {
    height: auto;
    min-height: 132px;
}
.dept-picker__flags {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

/* --- MFA setup wizard ------------------------------------------------------- */
.mfa-wizard {
    max-width: 560px;
}
.wizard__options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 16px 0;
}
.wizard__option {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 14px;
}
.wizard__option-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0 0 6px;
}
.wizard__skip {
    margin-top: 16px;
    border-top: 1px solid var(--color-border);
    padding-top: 12px;
}
@media (max-width: 767px) {
    .wizard__options {
        grid-template-columns: 1fr;
    }
}


/* --- Wizard icons + QR ------------------------------------------------------- */
.wizard__option-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.wizard__icon {
    color: var(--color-primary);
    display: inline-flex;
}
.wizard__qr {
    display: flex;
    justify-content: center;
    margin: 12px 0;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    width: fit-content;
}

/* --- Statistics dashboard -------------------------------------------------- */
.statcards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 0 0 14px;
}

.statcard {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.statcard__value {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.2;
}

.statcard__value small {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-muted, #6b7a88);
    margin-left: 3px;
}

.statcard__label {
    font-size: 11px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--color-muted, #6b7a88);
}

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

@media (max-width: 960px) {
    .statgrid2 {
        grid-template-columns: 1fr;
    }
}

.rangewrap {
    display: inline-flex;
    gap: 6px;
}

.btn.is-active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.statchart {
    width: 100%;
    height: auto;
    display: block;
}

.statgrid {
    stroke: var(--color-border);
    stroke-width: 1;
}

.statgrid__label {
    font-size: 9px;
    fill: var(--color-muted, #6b7a88);
    font-family: var(--font-body);
}

.statchart__area {
    fill: rgba(0, 161, 154, 0.10);
}

.statchart__line {
    fill: none;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.statchart__line--new {
    stroke: var(--color-secondary);
}

.statchart__line--res {
    stroke: var(--color-primary);
    stroke-dasharray: 4 3;
}

.statchart__legend {
    display: flex;
    gap: 14px;
    align-items: center;
    font-size: 12px;
    color: var(--color-muted, #6b7a88);
    margin-top: 6px;
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 4px;
}

.legend-dot--new {
    background: var(--color-secondary);
}

.legend-dot--res {
    background: var(--color-primary);
}

.statdonuts {
    display: flex;
    gap: 24px;
    justify-content: center;
    padding: 10px 0;
}

.statdonut {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.statdonut svg {
    width: 110px;
    height: 110px;
}

.statdonut__track {
    fill: none;
    stroke: var(--color-border);
    stroke-width: 9;
}

.statdonut__value {
    fill: none;
    stroke-width: 9;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.statdonut__text {
    font-size: 17px;
    font-weight: 700;
    fill: var(--color-primary);
    font-family: var(--font-body);
}

.statdonut small {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-muted, #6b7a88);
}

.statdonut--empty span {
    font-size: 20px;
    color: var(--color-muted, #6b7a88);
}

.statdonuts__note {
    font-size: 12px;
    text-align: center;
    margin: 0 0 12px;
}

.statrow {
    display: grid;
    grid-template-columns: 90px 1fr 40px;
    align-items: center;
    gap: 10px;
    margin: 0 0 8px;
}

.statrow__label {
    font-size: 13px;
    color: var(--color-text);
    text-transform: capitalize;
}

.statrow__value {
    text-align: right;
    font-size: 13px;
}

.statbar {
    background: rgba(0, 43, 73, 0.06);
    border-radius: 3px;
    height: 10px;
    overflow: hidden;
}

.statbar__fill {
    height: 100%;
    border-radius: 3px;
}

/* --- Locked (closed) ticket cards ------------------------------------------ */
.card--locked > *:not(.card__label):not(.muted) {
    opacity: 0.45;
    pointer-events: none;
}

.card--locked .muted {
    font-style: italic;
}

.btn:disabled,
.linklist__remove:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* --- Mailbox wizard --------------------------------------------------------- */


/* --- Priority confirm overlay ------------------------------------------------ */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 43, 73, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.confirm-overlay__card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    padding: 24px 28px;
    max-width: 460px;
    width: 100%;
}

.confirm-overlay__title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--color-primary);
    margin: 0 0 10px;
}

.confirm-overlay__alt {
    font-size: 13px;
    color: var(--color-muted, #6b7a88);
    margin: 14px 0 0;
}

.linklike {
    background: none;
    border: none;
    padding: 0;
    color: var(--color-muted, #6b7a88);
    text-decoration: underline;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
}

.linklike:hover {
    color: var(--color-primary);
}


/* --- Live polling banners --------------------------------------------------- */
.live-banner {
    position: fixed;
    bottom: 76px;
    right: 20px;
    z-index: 90;
    max-width: 320px;
    margin: 0;
    box-shadow: var(--shadow-hover);
    animation: liveFadeIn 0.4s ease;
}

@keyframes liveFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}


/* --- Foldable activity card -------------------------------------------------- */
.activity-fold > summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.activity-fold > summary::-webkit-details-marker {
    display: none;
}

.activity-fold > summary::after {
    content: '\25BE';
    font-size: 12px;
    color: var(--color-muted, #6b7a88);
}

.activity-fold[open] > summary::after {
    content: '\25B4';
}

.timeline--scroll {
    max-height: 320px;
    overflow-y: auto;
    padding-right: 6px;
}


.card-fold > summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-fold > summary::-webkit-details-marker {
    display: none;
}

.card-fold > summary::after {
    content: '\25BE';
    font-size: 12px;
    color: var(--color-muted, #6b7a88);
}

.card-fold[open] > summary::after {
    content: '\25B4';
}


/* --- Card drag & drop --------------------------------------------------------- */
.card-fold[draggable="true"] {
    cursor: grab;
}

.card-fold.is-dragging {
    opacity: 0.5;
    border-style: dashed;
}

.card-fold.drop-target {
    border-top: 2px solid var(--color-secondary);
}