@font-face {
    font-family: Onest;
    src: url('../fonts/Onest-VariableFont_wght.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: TwidGrotesk;
    src: url('../fonts/TwidGrotesk-Regular.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: Icomoon;
    src: url('../fonts/icomoon.woff') format('woff');
    font-display: block;
}

:root {
    --ink: #1a1c1e;
    --muted: #565c64;
    --border: #ededed;
    --control-border: #ccc;
    --canvas: #fff;
    --surface: #fff;
    --surface-muted: #f2f2f2;
    --accent: #e70000;
    --accent-hover: #af161d;
    --accent-soft: #fff5f5;
    --nav: #191b1c;
    --nav-text: #adb3bc;
    --sidebar-width: 254px;
    --panel-radius: 10px;
    --panel-shadow: none;
    color: var(--ink);
    font: 400 14px / 1.5 Onest, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.icon {
    flex: none;
    font: normal 1rem / 1 Icomoon;
}

.icon-exit::before { content: "\e900"; }
.icon-wrench::before { content: "\e901"; }
.icon-user::before { content: "\e903"; }
.icon-form::before { content: "\e904"; }
.icon-shop::before { content: "\e905"; }
.icon-box::before { content: "\e906"; }
.icon-pin::before { content: "\e907"; }
.icon-pages::before { content: "\e908"; }
.icon-media::before { content: "\e909"; }
.icon-phone::before { content: "\e90c"; }
.icon-home::before { content: "\e90f"; }
.icon-big-media::before { content: "\e911"; }
.icon-big-customer::before { content: "\e913"; }
.icon-document::before { content: "\e914"; }
.icon-calendar::before { content: "\e918"; }
.icon-status::before { content: "\e919"; }
.icon-map-pin::before { content: "\e91a"; }
.icon-eye::before { content: "\e91d"; }
.icon-eye-off::before { content: "\e91e"; }
.icon-right::before { display: inline-block; content: "\f107"; transform: rotate(-90deg); }

.chat-icon {
    position: relative;
    display: inline-block;
    flex: none;
    width: 16px;
    height: 13px;
    border: 1.5px solid currentColor;
    border-radius: 4px;
}

.chat-icon::after {
    position: absolute;
    bottom: -3px;
    left: 3px;
    width: 5px;
    height: 5px;
    border-left: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    background: inherit;
    transform: skewY(-32deg);
    content: '';
}

.brand {
    display: inline-block;
    position: relative;
    width: 171px;
    overflow: hidden;
    vertical-align: middle;
}

.brand svg { display: block; width: 171px; height: auto; }
.brand-label, .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.admin-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar-left {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: 25px 16px 16px;
    overflow: auto;
    background: var(--nav);
    color: var(--nav-text);
}

.sidebar-left :focus-visible { outline-color: #ff9ba7; }
.sidebar-brand { flex: none; margin: 0 0 30px; padding: 4px 6px; color: white; text-decoration: none; }
.nav-main { display: grid; gap: 5px; }
.sidebar-account {
    display: grid;
    flex: none;
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
    margin-block-start: auto;
    padding-block-start: 12px;
}
.sidebar-account .nav-link { gap: 12px; }
.sidebar-account .nav-link > .icon { width: 34px; font-size: 18px; text-align: center; }
.sidebar-account-avatar {
    display: grid;
    flex: 0 0 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    background: #d6d7d8;
    color: #565c64;
}
.sidebar-account-avatar .icon { font-size: 17px; }
.sidebar-account-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 45px;
    padding: 8px 9px;
    font-size: 1rem;
}

.nav-link {
    position: relative;
    width: 100%;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    text-align: start;
    text-decoration: none;
}

.nav-link:hover { background: #292c2f; color: white; }
.nav-main .nav-link > .icon { width: 20px; font-size: 18px; text-align: center; }
.nav-main .nav-link > .chat-icon { margin-inline: 2px; }
.nav-link[aria-current="page"] { color: white; font-weight: 620; }
.nav-link[aria-current="page"] > :is(.icon, .chat-icon) { color: #ff545a; }

.content-body {
    width: 100%;
    margin-inline: auto;
    padding: 0 clamp(20px, 2.4vw, 40px) 36px;
}

.page-header { margin-bottom: 24px; padding: 22px 0 18px; border-bottom: 1px solid var(--border); }

.page-header h1, .body-sign h1 {
    margin: 0;
    font-family: TwidGrotesk, Onest, sans-serif;
    font-size: 28px;
    font-weight: 400;
    letter-spacing: -.02em;
    line-height: 1.18;
}

.body-sign {
    display: grid;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
    place-items: center;
    background: #101010;
}

.sign-card {
    width: min(100%, 430px);
    padding: clamp(24px, 5vw, 40px);
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 20px 60px #0003;
}

.sign-card .brand { margin-bottom: 24px; }
.body-sign h1 { margin-bottom: 22px; font-size: 1.75rem; }
.login-form { display: grid; gap: 16px; }
.login-form > .button { margin-top: 4px; }

.field { min-width: 0; }
.field label { display: block; margin-bottom: 5px; font-weight: 670; font-size: .83rem; }

.field :is(input, select, textarea) {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 8px 11px;
    border: 1px solid var(--control-border);
    border-radius: 8px;
    background: var(--surface);
    color: inherit;
}

.select-control { position: relative; }

.select-control > select {
    appearance: none;
    padding-inline-end: 34px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.select-control::after {
    position: absolute;
    inset-block-start: 50%;
    inset-inline-end: 14px;
    width: 7px;
    height: 7px;
    border: solid var(--ink);
    border-width: 0 1.5px 1.5px 0;
    transform: translateY(-65%) rotate(45deg);
    pointer-events: none;
    content: '';
}

@supports (appearance: base-select) and (anchor-scope: --crm-select) and selector(::picker(select)) {
    .select-control { anchor-scope: --crm-select; }

    .select-control > select { anchor-name: --crm-select; }

    .select-control > select,
    .select-control > select::picker(select) {
        position-anchor: --crm-select;
        appearance: base-select;
    }

    .select-control > select::picker-icon { display: none; }

    .select-control > select::picker(select) {
        position-area: block-end span-all;
        inset: auto;
        inset-inline-start: anchor(start);
        align-self: start;
        position-try-order: normal;
        position-try-fallbacks: flip-inline, flip-block, flip-block flip-inline;
        inline-size: max-content;
        min-inline-size: anchor-size(width);
        max-inline-size: min(28rem, calc(100vw - 24px));
        min-block-size: 40px;
        max-block-size: min(18rem, calc(100% - 8px));
        margin: 4px 0;
        border: 1px solid var(--control-border);
        border-radius: 8px;
        background: var(--surface);
        color: var(--ink);
        box-shadow: 0 4px 12px #0002;
    }

    .select-control option { padding: 8px 11px; white-space: normal; overflow-wrap: anywhere; }
    .select-control option:is(:hover, :focus-visible) { background: var(--surface-muted); }
}

@media (forced-colors: active) {
    .select-control::after { display: none; }
    .select-control > select { appearance: auto; padding-inline-end: 11px; }
}

.field textarea { min-height: 64px; max-height: 180px; resize: vertical; }
.field ::placeholder { color: var(--muted); }
.field [aria-invalid="true"] { border-color: var(--accent); }

.field-error {
    margin: 6px 0 0;
    color: var(--accent);
    font-size: .86rem;
}

.password-field { position: relative; }
.password-field input { padding-right: 50px; }

.password-toggle {
    position: absolute;
    inset: 3px 3px 3px auto;
    width: 40px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
}

.password-toggle:hover { background: var(--canvas); }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 8px 15px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: .9rem;
    font-weight: 680;
    text-decoration: none;
}

.button-primary { background: #151515; color: white; }
.button-primary:hover:not(:disabled) { background: #393939; }
.button-secondary { border-color: var(--control-border); background: var(--surface); color: var(--ink); }
.button-secondary:hover:not(:disabled) { background: var(--canvas); }

.dashboard-title { margin: 0; font-size: 1.75rem; font-weight: 720; line-height: 1.2; }

.admin-dashboard {
    display: grid;
    gap: clamp(16px, 1.65vw, 24px);
    padding-block-start: 20px;
}
.dashboard-actions { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.dashboard-actions .button { gap: 8px; padding-inline: 18px; }
.dashboard-summaries,
.dashboard-panels { display: grid; gap: clamp(12px, 1.4vw, 24px); }
.dashboard-summaries { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dashboard-panels { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.dashboard-summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: clamp(8px, 1.5vw, 26px);
    min-height: 112px;
    padding: 14px clamp(12px, 1.75vw, 28px);
    border-radius: 8px;
    background: var(--surface-muted);
    color: var(--muted);
    text-decoration: none;
}
.dashboard-summary:hover { background: var(--border); }
.dashboard-summary > .icon:first-child { font-size: clamp(32px, 3.7vw, 64px); }
.dashboard-summary .icon-right,
.dashboard-summary-value { color: var(--accent); }
.dashboard-summary-value { display: block; font-size: 1.55rem; font-weight: 750; line-height: 1.2; }
.dashboard-summary-label { display: block; margin-block-start: 4px; text-transform: uppercase; overflow-wrap: anywhere; }

.dashboard-panel { padding: 16px; }
.dashboard-panel .panel-header { flex-wrap: wrap; min-height: 0; margin-bottom: 14px; padding: 0; border: 0; }
.dashboard-panel h2 { text-transform: uppercase; }
.dashboard-panel .button-primary { gap: 10px; }
.dashboard-panel .button-secondary { gap: 10px; border-color: transparent; background: var(--surface-muted); }
.dashboard-panel .button-secondary:hover { background: #e8e8e8; }
.dashboard-panel .chat-notice { padding: 8px 0 0; }
.dashboard-table { width: 100%; border-spacing: 0; text-align: start; }
.dashboard-table th {
    padding: 13px 10px;
    background: var(--surface-muted);
    font-size: .72rem;
    font-weight: 740;
    text-align: start;
    text-transform: uppercase;
}
.dashboard-table th:first-child { border-start-start-radius: 6px; border-end-start-radius: 6px; }
.dashboard-table th:last-child { border-start-end-radius: 6px; border-end-end-radius: 6px; }
.dashboard-table td { padding: 24px 10px; color: var(--muted); text-align: center; }

@media (max-width: 1080px) {
    .dashboard-summaries { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-panels { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
    .dashboard-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .dashboard-actions .button { padding-inline: 8px; text-align: center; }
    .dashboard-summary { min-height: 84px; padding-inline: 9px; }
    .dashboard-summary > .icon:first-child { font-size: 26px; }
    .dashboard-summary-label { font-size: .73rem; }
    .admin-dashboard .dashboard-panel { padding: 10px; }
    .dashboard-table th { padding-inline: 4px; font-size: .65rem; }
}

.dashboard-list-heading, .dashboard-row {
    display: grid;
    grid-template-columns: minmax(85px, 1fr) minmax(0, 1.3fr) minmax(80px, .8fr);
    align-items: center;
    gap: 12px;
    padding: 12px;
    overflow-wrap: anywhere;
}

.dashboard-list-heading {
    border-radius: 6px;
    background: var(--surface-muted);
    font-size: .72rem;
    font-weight: 740;
    text-transform: uppercase;
}

.dashboard-row { min-height: 56px; text-decoration: none; }
.dashboard-row:hover { background: var(--surface-muted); }
.dashboard-row:focus-visible { outline-offset: -3px; }

.chat-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px 12px;
    margin-bottom: 17px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--panel-radius);
    background: var(--surface);
    box-shadow: var(--panel-shadow);
}

.chat-filters .field { flex: 0 1 auto; }
.chat-filters .chat-search { flex: 1 1 240px; max-width: 420px; }
.filter-actions { display: flex; flex-wrap: wrap; gap: 7px; }

.chat-tabs, .back-link { margin-bottom: 20px; }
.chat-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); }
.chat-tabs a, .back-link { display: inline-block; color: var(--muted); text-decoration: none; }
.chat-tabs a { padding: 0 0 12px; border-bottom: 2px solid transparent; font-weight: 600; }
.chat-tabs a[aria-current], .chat-tabs a:hover { color: var(--ink); border-color: var(--accent); }
.back-link:hover { color: var(--accent-hover); }
.queue-overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.queue-overview a { display: grid; padding: 14px 18px; border: 1px solid transparent; border-radius: 8px; background: var(--surface-muted); color: var(--muted); text-decoration: none; }
.queue-overview a:hover { background: #eaeaea; }
.queue-overview a[aria-current] { border-color: var(--control-border); box-shadow: inset 0 -2px var(--accent-hover); }
.queue-overview a[aria-current] span { color: var(--ink); font-weight: 680; }
.content-body:has(.ai-chat-workspace) { background: #f7f7f8; }
.ai-chat-workspace { max-width: 1380px; margin-inline: auto; padding-top: 28px; }
.ai-chat-workspace > .dashboard-title { margin-bottom: 16px; }
.queue-toolbar { padding: 12px; margin-bottom: 16px; }
.queue-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 7px; background: var(--surface-muted); }
.queue-tabs a { padding: 7px 10px; border-radius: 5px; color: var(--muted); font-weight: 620; text-decoration: none; }
.queue-tabs a:hover { color: var(--ink); }
.queue-tabs a[aria-current] { color: var(--ink); background: var(--surface); }
.chat-filters.queue-filters { border: 0; margin: 0; padding: 10px 0 0; }
.queue-filters .chat-search { max-width: none; }
.queue-results-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.queue-results-header h2 { margin: 0; font-size: 1rem; }
.queue-results-header .button { min-height: 36px; }
.queue-card-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.queue-card {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-inline-start: 3px solid #d6d9dd;
}
.queue-card-active { border-inline-start-color: #83a693; }
.queue-card-waiting { border-inline-start-color: #bd923f; }
.queue-card:hover, .queue-card:focus-within { background: #fcfcfd; border-block-color: var(--control-border); border-inline-end-color: var(--control-border); }
.queue-card-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; background: var(--surface-muted); color: var(--muted); }
.queue-card-icon .chat-icon { background: var(--surface-muted); }
.queue-dialog-link { font-weight: 700; text-decoration: none; }
.queue-dialog-link::after { position: absolute; inset: 0; border-radius: var(--panel-radius); content: ''; }
.queue-dialog-link:focus-visible { outline: none; }
.queue-dialog-link:focus-visible::after { outline: 2px solid var(--accent); outline-offset: -2px; }
.queue-card-preview { margin: 4px 0 6px; color: var(--ink); overflow-wrap: anywhere; }
.queue-card-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: .81rem; overflow-wrap: anywhere; }
.queue-card-meta time { font-size: inherit; }
.queue-row-action { position: relative; z-index: 1; min-height: 34px; padding: 5px 10px; font-size: .8rem; }
.queue-row-chevron { align-self: center; color: var(--accent-hover); font-size: 1.4rem; line-height: 1; }
.queue-results .chat-pagination { margin-top: 8px; }

.history-columns { grid-template-columns: minmax(96px, .8fr) minmax(0, .9fr) minmax(0, 1.5fr) minmax(0, 2.4fr) minmax(90px, 1fr); }
.dashboard-row.history-columns { align-items: start; padding-block: 14px; }
.history-agent small { display: block; color: var(--muted); }
.history-mobile-label { display: none; }
.history-columns .chat-status { justify-self: start; }
.chat-empty { display: grid; justify-items: center; align-content: center; gap: 12px; min-height: 150px; text-align: center; color: var(--muted); }
.chat-empty .chat-icon { background: var(--surface); }
.dialog-top { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; margin-bottom: 18px; }
.dialog-top .back-link { margin: 0; }
.ai-before-handoff { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-muted); }
.ai-before-handoff summary { cursor: pointer; font-weight: 700; color: var(--muted); }
.ai-before-handoff[open] summary { margin-bottom: 12px; }
.ai-chat-workspace .chat-message-user { justify-self: start; margin-inline-start: 0; --bubble-bg: var(--surface); --bubble-border: var(--border); }
.ai-chat-workspace :is(.chat-message-ai, .chat-message-operator) { justify-self: end; }
.ai-chat-workspace .chat-message-ai { --bubble-bg: #f7f8fa; --bubble-border: #dfe3e8; }
.ai-chat-workspace .chat-message-operator { --bubble-bg: #edf5ef; --bubble-border: #d0e3d7; }
.ai-chat-workspace :is(.chat-message-ai, .chat-message-operator) .chat-bubble { border-radius: 12px 4px 12px 12px; }
.ai-chat-workspace .chat-message-user .chat-bubble { border-radius: 4px 12px 12px; }

.queue-overview strong { color: var(--accent-hover); font-size: 24px; }
.dialog-grid {
    display: grid;
    grid-template-columns: minmax(200px, 242px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    max-width: 1260px;
}

.dialog-context {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--panel-radius);
    background: var(--surface);
    overflow-wrap: anywhere;
}

.dialog-context-header {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 16px;
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
    color: var(--ink);
}

.dialog-context-header > div { min-width: 0; }
.dialog-context-header h2 { margin: 0; font-size: 1.15rem; font-weight: 720; line-height: 1.25; }
.dialog-context-header p { margin: 4px 0 0; color: var(--muted); font-size: .84rem; }

.dialog-context-icon {
    display: grid;
    place-items: center;
    flex: 0 0 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--accent-hover);
}

.dialog-context-icon .chat-icon { background: var(--surface); }
.dialog-facts { margin: 0; padding: 12px 16px 16px; }
.dialog-facts dt { margin-top: 10px; color: var(--muted); font-size: .76rem; }
.dialog-facts dt:first-child { margin-top: 0; }
.dialog-facts dd { margin: 2px 0 0; font-size: .92rem; overflow-wrap: anywhere; }
.dialog-facts .dialog-session { color: var(--muted); font: .77rem / 1.55 ui-monospace, monospace; }

.chat-panel {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--panel-radius);
    background: var(--surface);
    box-shadow: var(--panel-shadow);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 52px;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 { margin: 0; font-size: 1rem; font-weight: 740; letter-spacing: -.02em; }

.chat-list, .chat-turns { margin: 0; padding: 0; list-style: none; }

.chat-list {

    overflow: auto;
    scrollbar-width: thin;
}

.chat-list-item {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) minmax(180px, 2fr) minmax(130px, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 15px 14px 11px 16px;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.chat-list li + li { border-top: 1px solid var(--border); }
.chat-list-item:hover { background: var(--surface-muted); }
.chat-list-item[aria-current] { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
.chat-list-item:focus-visible { outline-offset: -3px; }
.chat-list-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 8px; }
.chat-list-meta { color: var(--muted); font-size: .8rem; }
.chat-list-meta { font-variant-numeric: tabular-nums; }
.chat-preview { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: .88rem; }
.chat-notice { padding: 12px 15px; margin: 0; color: var(--muted); overflow-wrap: anywhere; }

.chat-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 6px;
    background: #efedf0;
    color: #58515e;
    font-size: .73rem;
    font-weight: 690;
    line-height: 1.35;
}

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

.chat-status-active, .chat-status-answered { background: #e6f5ec; color: #226545; }
.chat-status-waiting { background: #fff0d7; color: #80570e; }
.chat-status-error { background: var(--accent-soft); color: var(--accent-hover); }

.chat-thread {
    display: flex;
    flex-direction: column;
    border-color: var(--border);
    background: var(--surface);
}

.thread-header { padding: 13px clamp(14px, 2vw, 23px); border-color: var(--border); }
.thread-header h2 { font-size: 1.13rem; }

.thread-transcript {
    min-height: min(240px, 38dvh);
    max-height: max(260px, calc(100dvh - 330px));
    padding: 16px clamp(12px, 2vw, 23px) 20px;
    overflow: auto;
    background: var(--surface-muted);
    scrollbar-width: thin;
}

.thread-transcript:last-child { border-radius: 0 0 var(--panel-radius) var(--panel-radius); }

.transcript-heading {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 11px;
    margin-block: 0 12px;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 720;
}

.transcript-heading::after { flex: 1 1 28px; height: 1px; background: var(--control-border); content: ''; }

.chat-operator-thread { margin-block: 19px 0; }
.chat-operator-thread:first-child { margin-top: 0; }
.chat-turns { display: grid; gap: 10px; }

.chat-message {
    --bubble-bg: var(--surface);
    --bubble-border: var(--border);
    --bubble-meta: var(--muted);
    justify-self: start;
    width: fit-content;
    max-width: min(86%, 42rem);
    min-width: 0;
}

.chat-bubble,
.chat-message:not(:has(> .chat-bubble)) {
    padding: 8px 12px;
    border: 1px solid var(--bubble-border);
    border-radius: 4px 12px 12px;
    background: var(--bubble-bg);
    color: var(--ink);
    overflow-wrap: anywhere;
}

.chat-message:not(:has(> .chat-bubble)) { margin-top: 7px; }
.chat-turns > li > time, .operator-assignment { color: var(--muted); font-size: .8rem; }
.operator-assignment { margin: 0 0 10px; overflow-wrap: anywhere; }

.chat-bubble-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 2px 12px;
    color: var(--bubble-meta);
    font-size: .8rem;
}

.chat-bubble-meta time { font-size: .74rem; font-variant-numeric: tabular-nums; }
.chat-message p { margin: 3px 0 0; white-space: pre-wrap; }

.chat-message-user {
    --bubble-bg: #e5e7e9;
    --bubble-border: #d6d9dc;
    --bubble-meta: var(--muted);
    justify-self: end;
    margin-inline-start: auto;
}

.chat-message-user .chat-bubble,
.chat-message-user:not(:has(> .chat-bubble)) { border-radius: 12px 4px 12px 12px; }

.chat-message-operator {
    --bubble-bg: var(--surface);
    --bubble-border: var(--border);
    --bubble-meta: #226545;
}

.chat-message-error {
    --bubble-bg: #fff1ef;
    --bubble-border: #edc4c5;
    --bubble-meta: #8c2027;
}

.chat-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 9px 15px;
    border-top: 1px solid var(--border);
    font-size: .82rem;
}

.chat-pagination a { color: var(--accent-hover); text-underline-offset: 3px; }

.thread-actions {
    flex: none;
    padding: 12px clamp(12px, 2vw, 23px);
    border-top: 1px solid var(--border);
}

.thread-actions textarea { background: #fff; border-color: var(--control-border); }
.thread-primary-action { gap: 8px; padding-inline: 18px; }
.operator-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 9px; }

@media (min-width: 851px) {
    .page-header { position: sticky; top: 0; z-index: 2; background: var(--canvas); }
    .sidebar-left { overflow: hidden; box-shadow: inset -1px 0 #333; }
    .sidebar-left .nav-main {
        min-height: 0;
        align-content: start;
        overflow-y: auto;
        margin-inline: -4px;
        padding: 4px;
        scrollbar-width: thin;
        scrollbar-color: #515457 transparent;
    }
}

@media (max-width: 1150px) {
    .chat-list-item { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 850px) {
    .admin-layout { grid-template-columns: minmax(0, 1fr); }
    .sidebar-left {
        position: static;
        display: grid;
        grid-template-columns: 1fr auto;
        height: auto;
        gap: 9px;
        padding: 10px 15px;
    }
    .sidebar-brand { align-self: center; margin: 0; }
    .nav-main { grid-row: 2; grid-column: 1 / -1; display: flex; flex-wrap: wrap; }
    .nav-main .nav-link { width: auto; }
    .sidebar-account {
        grid-column: 1 / -1;
        grid-template-columns: minmax(0, 1fr) auto;
        padding-block-start: 0;
    }
    .dialog-grid { grid-template-columns: minmax(180px, 220px) minmax(0, 1fr); }
}

@media (max-width: 620px) {
    .content-body { padding: 0 14px 24px; }
    .queue-overview { grid-template-columns: 1fr 1fr; }
    .dialog-grid { grid-template-columns: minmax(0, 1fr); }
    .chat-filters .field { flex: 1 1 40%; }
    .chat-filters .chat-search { flex-basis: 100%; }
    .chat-list-item { grid-template-columns: 1fr; gap: 5px; }
    .chat-filters .chat-search { max-width: none; }
    .thread-transcript { max-height: 55dvh; min-height: 160px; }
    .chat-message { max-width: 94%; }
    .chat-bubble, .chat-message:not(:has(> .chat-bubble)) { padding: 7px 10px; }
}

@media (max-width: 900px) {
    .dashboard-list-heading.history-columns { display: none; }
    .dashboard-row.history-columns { grid-template-columns: minmax(0, 1fr); gap: 6px; padding-inline: 10px; }
    .history-mobile-label { display: block; font-size: .75rem; font-weight: 700; color: var(--muted); }
}

.calls-workspace { display: grid; gap: 16px; max-width: 1320px; margin-inline: auto; }
.content-body:has(.calls-workspace) { background: #f7f7f8; }
.calls-index { padding-top: 28px; }
.calls-workspace :is(.calls-tabs, .back-link, .chat-filters) { margin-bottom: 0; }
.calls-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.calls-header-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.calls-header-actions [hidden], .calls-upload-panel[hidden] { display: none; }
.calls-controls { padding: 10px; }
.chat-filters.calls-filters { margin: 0; padding: 10px 0 0; border: 0; }
.calls-upload-fields, .calls-operator-form { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; }
.calls-upload-panel .panel-header { margin-bottom: 12px; }
.calls-upload-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 16px;
    padding: 12px 14px;
    border: 1px dashed var(--control-border);
    border-radius: 8px;
    background: #fafafa;
}
.calls-file-field { min-width: 0; }
.calls-file-field input { width: 100%; color: var(--muted); font: inherit; }
.calls-file-field input::file-selector-button {
    margin-inline-end: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}
.calls-file-field input::file-selector-button:hover { background: var(--surface-muted); }
.calls-upload-main small { grid-column: 1; color: var(--muted); overflow-wrap: anywhere; }
.calls-upload-main > .button { grid-area: 1 / 2 / span 2; }
.calls-upload > details { margin-top: 12px; }
.calls-upload > details > summary { width: fit-content; color: var(--muted); font-weight: 650; }
.calls-filters > .field { flex: 1 1 124px; }
.calls-filters > .calls-sort { flex-basis: 11rem; }
.calls-filters > .chat-search { flex: 2 1 220px; max-width: none; }
.calls-filters .field :is(select, input) { width: 100%; }
.calls-filters .filter-actions { margin-inline-start: auto; }
.calls-filters .filter-actions { align-items: center; }
.calls-filters .calls-checkbox { padding-inline: 4px; color: var(--muted); }
.calls-checkbox input { accent-color: var(--accent-hover); }
.calls-empty { display: flex; align-items: center; gap: 10px; min-height: 66px; padding: 12px 14px; border-radius: 8px; background: #f7f7f8; color: var(--muted); }
.calls-empty p { margin: 0; }
.calls-empty .chat-icon { background: #f7f7f8; }
.calls-upload-fields, .calls-operator-form { margin-top: 10px; }
.calls-checkbox { display: flex; align-items: center; gap: 5px; min-height: 42px; }
.calls-workspace summary { cursor: pointer; }
.calls-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px; margin: 0; }
.calls-metrics > div { padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.calls-metrics > .calls-metric-alert { border-color: #efcbd0; background: var(--accent-soft); }
.calls-metric-alert dd { color: var(--accent-hover); }
.calls-metrics dt, .calls-facts dt { color: var(--muted); font-size: .85rem; }
.calls-metrics dd { margin: 4px 0 0; font-size: 1.65rem; font-weight: 720; line-height: 1.2; }
.calls-list-panel { overflow: hidden; }
.calls-list-panel .calls-empty { margin: 12px; }
.calls-table-wrap { overflow-x: auto; }
.calls-table { width: 100%; min-width: 510px; border-collapse: separate; border-spacing: 0; text-align: start; }
.calls-analysis-table { min-width: 850px; }
.calls-table th { background: var(--surface-muted); font-size: .77rem; text-transform: uppercase; }
.calls-table th, .calls-table td { padding: 12px; text-align: start; overflow-wrap: anywhere; }
.calls-table td { border-bottom: 1px solid var(--border); }
.calls-table tbody tr:last-child td { border-bottom: 0; }
.calls-table td a { text-underline-offset: 3px; font-weight: 650; }
.calls-table td small { display: block; margin-top: 2px; color: var(--muted); }
.calls-table-row { position: relative; }
.calls-table-row:hover, .calls-table-row:focus-within { background: #f7f7f8; }
.calls-row-link { text-decoration: none; }
.calls-row-link::after { position: absolute; inset: 0; content: ''; }
.calls-row-link:focus-visible { outline: none; }
.calls-row-link:focus-visible::after { outline: 2px solid var(--accent); outline-offset: -2px; }
.calls-table-type { display: inline-block; padding: 3px 7px; border-radius: 5px; background: var(--surface-muted); font-size: .8rem; }
.call-score { display: inline-block; padding: 3px 7px; border-radius: 999px; font-size: .8rem; font-weight: 680; white-space: nowrap; }
.call-score-high { background: #e6f5ec; color: #226545; }
.call-score-mid { background: #fff0d7; color: #80570e; }
.call-score-low { background: var(--accent-soft); color: var(--accent-hover); }
.call-detail { gap: 20px; padding-top: 24px; }
.call-detail-heading { display: grid; gap: 8px; justify-items: start; }
.call-detail-panel { min-width: 0; padding: clamp(16px, 2vw, 24px); overflow-wrap: anywhere; }
.call-detail-panel h2 { margin: 0; font-size: 1.2rem; line-height: 1.3; }
.call-recording { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 18px; }
.call-recording h2 { font-size: 1.25rem; }
.call-recording audio { display: block; width: min(100%, 560px); margin-top: 16px; }
.calls-facts { display: flex; flex-wrap: wrap; gap: 10px 24px; margin: 12px 0 0; }
.calls-facts dd { margin: 3px 0 0; font-weight: 650; }
.call-rating { display: grid; justify-items: start; gap: 8px; min-width: 154px; padding: 12px 16px; border-radius: 8px; background: var(--surface-muted); }
.call-rating dl, .call-rating dd { margin: 0; }
.call-rating dt, .call-category-scores dt { color: var(--muted); font-size: .83rem; font-weight: 620; }
.call-rating dd { margin-top: 4px; font-size: 1.8rem; font-weight: 730; line-height: 1.15; }
.call-rating .call-score { padding: 0; background: transparent; font-size: inherit; }
.calls-actions { display: flex; align-items: start; flex-wrap: wrap; gap: 8px 16px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.calls-actions > form { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.calls-actions > form span:empty { display: none; }
.calls-actions summary { width: fit-content; padding: 7px 0; color: var(--muted); font-weight: 620; }
.calls-actions summary:hover { color: var(--ink); }
.calls-actions details[open] { flex-basis: 100%; }
.calls-actions details > form { margin-top: 4px; padding: 12px; border-radius: 8px; background: var(--surface-muted); }
.calls-actions details > form p { margin: 0 0 8px; }
.call-delete-action :is(summary:hover, button) { color: var(--accent-hover); }

.call-results { display: grid; gap: 20px; align-items: start; grid-template-columns: repeat(auto-fit, minmax(min(100%, 415px), 1fr)); }
.call-analysis-summary { margin: 12px 0 0; line-height: 1.65; }
.call-category-scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(115px, 100%), 1fr)); gap: 8px; margin: 16px 0 0; }
.call-category-scores > div { display: grid; align-content: space-between; justify-items: start; gap: 8px; min-width: 0; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.call-category-scores dd { margin: 0; font-weight: 680; }
.call-category-scores .call-score { font-size: .98rem; }
.call-analysis-section { margin-top: 18px; }
.call-analysis-section h3 { margin: 0 0 8px; font-size: 1rem; }
.call-analysis-section :is(p, ul, ol) { margin: 0; }
.call-analysis-section ul, .call-checklist { padding-inline-start: 1.55rem; }
.call-analysis-section li + li { margin-top: 9px; }
.call-checklist li::marker { color: var(--muted); font-weight: 680; }
.call-critical, .call-recommendation, .call-review-note { padding: 10px 12px; border-radius: 8px; }
.call-critical { background: var(--accent-soft); }
.call-critical h3 { color: var(--accent-hover); }
.call-recommendation { border-inline-start: 2px solid var(--control-border); background: var(--surface-muted); }
.call-review-note { background: #fff0d7; color: #80570e; }

.calls-transcript { display: grid; gap: 8px; list-style: none; margin: 14px 0 0; padding: 0; }
.calls-transcript li { display: grid; grid-template-columns: 4.6rem minmax(0, 1fr); align-items: start; gap: 8px; }
.calls-transcript .button { min-height: 34px; padding: 4px; border-color: var(--border); font-variant-numeric: tabular-nums; }
.calls-transcript .button:hover { background: var(--surface-muted); }
.call-turn { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; }
.call-turn-operator .call-turn { background: var(--surface-muted); }
.call-turn strong { color: var(--muted); font-size: .84rem; }
.call-turn-operator strong { color: var(--ink); }
.calls-transcript p, .calls-transcript-text { margin: 3px 0 0; white-space: pre-wrap; }
.calls-transcript-text { margin-top: 14px; }


@media (max-width: 620px) {
    .calls-upload-main { grid-template-columns: minmax(0, 1fr); }
    .calls-upload-main > .button { grid-area: auto; justify-self: start; margin-top: 4px; }
    .calls-filters > .chat-search { flex-basis: 100%; }
    .calls-filters > .field { min-width: 0; }
    .calls-filters .filter-actions { margin-inline-start: 0; }
    .call-recording { grid-template-columns: minmax(0, 1fr); }
    .call-rating { grid-template-columns: 1fr auto; align-items: center; }
}


@media (max-width: 620px) {
    .queue-card { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
    .queue-card:has(.queue-row-chevron) { grid-template-columns: auto minmax(0, 1fr) auto; }
    .queue-card form { grid-column: 2; }
    .queue-card-icon { width: 34px; height: 34px; }
}

.admin-main { display: flex; flex-direction: column; min-width: 0; }
.admin-main > .content-body { flex: 1; }
.account-presence { display: inline-flex; align-items: center; gap: 5px; }
.account-presence::before { flex: 0 0 7px; height: 7px; border-radius: 50%; background: var(--presence-color, #878d97); content: ''; }
[data-presence="online"] { --presence-color: #228151; }
[data-presence="busy"] { --presence-color: #b47722; }
[data-presence="break"] { --presence-color: #5975a5; }

.profile-workspace { display: grid; gap: 24px; padding-block-start: 24px; }
.profile-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding-block-end: 18px;
    border-bottom: 1px solid var(--border);
}
.profile-header h1 { flex: 1 1 400px; min-width: 0; margin: 0; font-size: clamp(20px, 2vw, 28px); line-height: 1.25; overflow-wrap: anywhere; }
.profile-back {
    display: grid;
    width: 32px;
    height: 36px;
    flex: none;
    place-items: center;
    border-radius: 50%;
    text-decoration: none;
}
.profile-back:hover { background: var(--surface-muted); }
.profile-back .icon { transform: rotate(180deg); }
.profile-header-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-save { background: #b71921; color: #fff; }
.profile-save:hover { background: #96171d; }
.profile-header-actions .button-secondary,
.profile-side > .button { border-color: var(--border); }
.profile-editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(215px, 19%);
    align-items: start;
    gap: clamp(16px, 2vw, 26px);
}
.profile-editor-main { display: grid; min-width: 0; gap: 12px; }
.profile-editor { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-block-end: 10px; }
.profile-editor .field { position: relative; }
.profile-editor .field > label {
    position: absolute;
    z-index: 1;
    inset-block-start: 0;
    inset-inline-start: 11px;
    margin: 0;
    padding-inline: 4px;
    transform: translateY(-50%);
    background: var(--canvas);
    color: var(--muted);
    font-weight: 500;
}
.profile-editor .field :is(input, select) {
    min-height: 54px;
    padding-inline-start: 14px;
    border-color: var(--border);
    background: var(--canvas);
}
.profile-side { display: grid; gap: 8px; }
.profile-info,
.profile-activity { border-radius: 8px; }
.profile-info { border: 1px solid var(--border); background: var(--surface); }
.profile-activity { background: var(--surface-muted); }
:is(.profile-info, .profile-activity) > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 15px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}
:is(.profile-info, .profile-activity) > summary::-webkit-details-marker { display: none; }
:is(.profile-info, .profile-activity) > summary::after { flex: none; font: normal 1rem / 1 Icomoon; content: "\f107"; }
:is(.profile-info, .profile-activity)[open] > summary::after { transform: rotate(180deg); }
.profile-info dl { margin: 0; padding: 4px 14px; border-block-start: 1px solid var(--border); }
.profile-info dl > div { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 5px 10px; padding-block: 12px; }
.profile-info dl > div + div { border-block-start: 1px solid var(--border); }
.profile-info dt { color: var(--muted); }
.profile-info dt .icon { margin-inline-end: 3px; }
.profile-info dd { margin: 0; }
.profile-metrics, .profile-notifications { margin: 0; padding: 0 15px 15px; }
.profile-notifications p { margin: 0 0 10px; color: var(--muted); }

@media (max-width: 1050px) {
    .profile-editor-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
    .profile-header { gap: 10px; }
    .profile-header h1 { flex-basis: calc(100% - 42px); }
    .profile-editor { grid-template-columns: minmax(0, 1fr); }
}

.profile-card { padding: 16px; }
.profile-card h2 { margin: 0 0 14px; font-size: 1.05rem; }
.profile-card p { margin: 0 0 12px; color: var(--muted); }
.profile-form { display: grid; justify-items: start; gap: 12px; }
.profile-form .field { width: 100%; }
.profile-form input[readonly] { background: var(--surface-muted); color: var(--muted); }
.profile-fieldset { width: 100%; min-width: 0; margin: 0; padding: 0; border: 0; }
.profile-fieldset legend { margin-bottom: 6px; font-size: .83rem; font-weight: 670; }
.profile-theme-options, .profile-notification-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-theme-options label { display: flex; align-items: center; gap: 6px; min-height: 38px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.profile-form input[type="radio"] { accent-color: var(--accent-hover); }
.profile-notification-actions [hidden] { display: none; }
.profile-feedback { margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink); }

:root[data-theme="dark"] {
    color-scheme: dark;
    --ink: #eceef1;
    --muted: #b0b7c1;
    --border: #373c44;
    --control-border: #505760;
    --canvas: #17191d;
    --workspace: #1c1f24;
    --surface: #23262c;
    --surface-muted: #2b2f36;
    --accent: #ff747a;
    --accent-hover: #ff9ca1;
    --accent-soft: #41292e;
}

[data-theme="dark"] .content-body:has(.ai-chat-workspace, .calls-workspace) { background: var(--workspace); }
[data-theme="dark"] :is(.queue-overview a, .dashboard-panel .button-secondary):hover,
[data-theme="dark"] :is(.queue-card:hover, .queue-card:focus-within, .calls-table-row:hover, .calls-table-row:focus-within, .calls-upload-main, .calls-empty, .calls-empty .chat-icon) { background: var(--surface-muted); }
[data-theme="dark"] .thread-actions textarea { background: var(--surface); }
[data-theme="dark"] .call-detail :is(.call-score-high, .chat-status-active) { background: #263a33; color: #a9d4ba; }
[data-theme="dark"] .call-detail :is(.call-score-mid, .chat-status-waiting, .call-review-note) { background: #403424; color: #f2ce90; }
[data-theme="dark"] .call-detail .call-rating .call-score { background: transparent; }
[data-theme="dark"] .ai-chat-workspace .chat-message-ai { --bubble-bg: #2d3541; --bubble-border: #434c59; }
[data-theme="dark"] .ai-chat-workspace .chat-message-operator { --bubble-bg: #263a33; --bubble-border: #40554a; --bubble-meta: #a9d4ba; }
[data-theme="dark"] .chat-message-error { --bubble-bg: #41292e; --bubble-border: #75444a; --bubble-meta: #ffb3b8; }

.messenger-form { margin-top: 14px; }
.page-publishing-access > summary { width: fit-content; font-weight: 680; cursor: pointer; }
.page-publishing-access > form { margin-block-start: 12px; }
.messenger-help { padding: 10px 14px; }
.messenger-help summary { width: fit-content; font-weight: 680; }
.messenger-help ol { margin: 10px 0 2px; padding-inline-start: 1.4rem; }
.messenger-help li + li { margin-top: 6px; }
.messenger-help button[hidden] { display: none; }
.messenger-help > details { margin-top: 10px; }
.messenger-channel-help { margin-top: 12px; border-radius: 8px; background: var(--surface-muted); }
.messenger-thread { width: 100%; max-width: 900px; }
.messenger-messages { display: grid; gap: 10px; margin: 12px 0; padding: 0; list-style: none; }
.messenger-messages > li { width: fit-content; max-width: min(100%, 42rem); }
.messenger-messages p { margin: 4px 0; white-space: pre-wrap; }
.messenger-outgoing { justify-self: end; background: var(--surface-muted); }

/* Shared navigation */
.nav-divider { height: 1px; margin: 7px 4px; background: #81858d; }
.nav-link[aria-current="page"] { background: #252829; }
@media (max-width: 850px) {
    .nav-divider { display: none; }
}

.team-header, .team-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
}
.team-header { align-items: center; justify-content: space-between; }
.team-header + .profile-feedback { margin: 0; }
.team-filters .field { flex: 1 1 140px; }
.team-filters .field:first-child { flex-grow: 2; }
.team-list { overflow-x: auto; }
.team-table { width: 100%; text-align: start; border-collapse: collapse; }
.team-table :is(th, td) { padding: 12px; text-align: start; border-bottom: 1px solid var(--border); }
.team-table thead { background: var(--surface-muted); }
.team-table .team-account-actions td { padding-block: 8px; }
.team-account-actions form { padding: 10px 0; }
.team-account-actions .profile-form { max-width: 420px; }
#team-create:target { outline: 2px solid var(--accent); outline-offset: 3px; }

.nav-section { min-width: 0; }
.nav-section > summary { list-style: none; cursor: pointer; }
.nav-section > summary::-webkit-details-marker { display: none; }
.nav-section > summary::after {
    content: "\f107";
    margin-inline: auto 3px;
    font: normal 1rem / 1 Icomoon;
    transition: transform .2s ease;
}
.nav-section[open] > summary::after { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) {
    .nav-section > summary::after { transition: none; }
}
.nav-section:has([aria-current="page"]) > summary { color: white; }
.nav-section:has([aria-current="page"]) > summary > .icon { color: #ff545a; }
.nav-section-links {
    min-block-size: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}
@supports selector(::details-content) {
    @media (prefers-reduced-motion: no-preference) {
        .nav-section::details-content {
            display: grid;
            grid-template-rows: 0fr;
            overflow: clip;
            transition: grid-template-rows .2s ease, content-visibility .2s allow-discrete;
        }
        .nav-section[open]::details-content { grid-template-rows: 1fr; }
        .nav-section-links .nav-link:focus-visible { outline-offset: -2px; }
    }
    @media (max-width: 850px) and (prefers-reduced-motion: no-preference) {
        /* Keep the closing submenu on its own row until the slide finishes. */
        .nav-section { transition: flex-basis 0s .2s allow-discrete; }
        .nav-section[open] { transition-delay: 0s; }
    }
}
.nav-section-links > li { position: relative; }
.nav-section-links > li::before,
.nav-section-links > li::after {
    position: absolute;
    inset-inline-start: 19px;
    z-index: 1;
    background: #454647;
    pointer-events: none;
    content: '';
}
.nav-section-links > li::before { inset-block: 0; width: 2px; }
.nav-section-links > li:last-child::before { inset-block-end: calc(50% - 1px); }
.nav-section-links > li::after { inset-block-start: calc(50% - 1px); width: 10px; height: 2px; }
.nav-section-links .nav-link {
    min-height: 31px;
    padding: 4px 9px 4px 43px;
    font-size: .9rem;
    overflow-wrap: anywhere;
}
.section-template { max-width: 1400px; margin-inline: auto; }
.section-template-header, .section-template-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.section-template-header { position: static; }
.section-template-header h1 { font-family: inherit; font-weight: 740; }
.section-template-parent { margin: 0 0 3px; color: var(--muted); font-size: .9rem; }
.section-template-panel { padding: clamp(14px, 2vw, 22px); }
.section-template-table { overflow-x: auto; }
.section-template-empty { height: 95px; color: var(--muted); }
.section-template-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 0 0 16px;
    padding: 0;
    border: 0;
}
.section-template-fields legend { padding: 0 0 14px; color: var(--muted); }
.section-template-wide { grid-column: 1 / -1; }
.section-template-fields :is(input, textarea):disabled { background: var(--surface-muted); }

@media (max-width: 850px) {
    .nav-section[open] { flex-basis: 100%; }
}
@media (max-width: 480px) {
    .section-template-fields { grid-template-columns: minmax(0, 1fr); }
}

.workspace {
    min-width: 0;
}

.workspace .dashboard-title {
    overflow-wrap: anywhere;
}

.workspace h2,
.workspace h3,
.workspace p,
.workspace dl {
    margin: 0;
}

.workspace summary {
    cursor: pointer;
    font-weight: 600;
}

.workspace details > form,
.workspace details > .workspace-scroll {
    margin-top: 1rem;
}

.workspace-form,
.workspace-grid,
.task-board,
.task-column,
.task-events,
.report-charts {
    display: grid;
    gap: 1rem;
    min-width: 0;
}

.workspace-form > .button {
    justify-self: start;
}

.workspace-grid,
.report-charts {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
}

.workspace-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: .65rem;
}

.workspace-actions .field {
    flex: 1 1 7rem;
}

.workspace-scroll {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
}

.workspace-scroll .team-table {
    min-width: 32rem;
}

.workspace .field select,
.workspace .field textarea {
    width: 100%;
}

.workspace-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.workspace-errors {
    color: var(--danger, #b92939);
    padding-inline-start: 2.25rem;
}

.workspace-warning {
    font-size: .8em;
    font-weight: 700;
    margin-inline-start: .25em;
}

.task-board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
}

.task-column h2 span {
    font-size: .8em;
    opacity: .75;
}

.task-card,
.task-events li {
    border: 1px solid var(--border, #d4d7db);
    border-radius: .5rem;
    padding: .85rem;
    overflow-wrap: anywhere;
}

.task-card {
    display: grid;
    gap: .5rem;
}

.task-events {
    list-style: none;
    margin: 0;
    padding: 0;
}

.task-events time {
    display: inline-block;
    margin-inline-start: .5rem;
    opacity: .8;
}

.order-lines {
    border: 1px solid var(--border, #d4d7db);
    border-radius: .5rem;
    margin: 0;
    min-width: 0;
}

.order-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(6rem, .35fr) auto;
    align-items: end;
    gap: .75rem;
}

.workspace [hidden] {
    display: none;
}

.return-quantity {
    width: 6rem;
}

.report-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
    gap: .75rem;
}

.report-metrics > div {
    border-inline-start: 2px solid var(--border, #d4d7db);
    min-width: 0;
    padding-inline-start: .85rem;
}

.report-metrics dd {
    font-size: clamp(1.1rem, 1.7vw, 1.5rem);
    font-weight: 700;
    margin: .3rem 0 0;
    overflow-wrap: anywhere;
}

.report-bars {
    display: flex;
    gap: .55rem;
    min-width: max-content;
    padding: .55rem .3rem;
}

.report-bar {
    display: grid;
    flex: 1 0 2.3rem;
    gap: .35rem;
    text-align: center;
    color: inherit;
    text-decoration: none;
}

.report-bar-track {
    position: relative;
    height: 7rem;
    background: color-mix(in srgb, currentColor 8%, transparent);
    border-radius: .25rem;
}

.report-bar-track > span {
    position: absolute;
    inset-inline: 15%;
    bottom: 0;
    height: var(--bar-size);
    background: #bc4050;
    border-radius: .2rem;
}

.report-bar:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.report-bar-track.rating > span,
.report-bar-track.margin > span {
    background: #41827e;
}

.workspace .report-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: .5rem 0;
}

.report-legend span::before {
    content: '';
    display: inline-block;
    width: .65em;
    height: .65em;
    border-radius: 50%;
    margin-inline-end: .35em;
    background: #bc4050;
}

.report-legend span + span::before {
    background: #41827e;
}

.report-trade-bars {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .2rem;
    background: linear-gradient(transparent calc(50% - .5px), var(--border, #d4d7db) calc(50% - .5px) calc(50% + .5px), transparent calc(50% + .5px));
}

.report-trade-bars .report-bar-track {
    background: none;
}

.report-trade-bars .report-bar-track > span {
    bottom: 50%;
}

.report-trade-bars .report-bar-track > .is-negative {
    top: 50%;
    bottom: auto;
}

@media (max-width: 900px) {
    .task-board {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 540px) {
    .order-line {
        grid-template-columns: 1fr;
    }
}
