/*
 * Fans API Support desk. Plain CSS, no build step.
 *
 * Colour roles, the same in every component:
 *   blue    actions, selection, current place in the navigation
 *   red     a customer is waiting for a person (red text past the 1-hour target)
 *   amber   waiting on the customer, or waiting within the hour
 *   slate   the bot in the queue; violet for its answers in a conversation
 *   dark    people on the team (dark avatars, team replies)
 *
 * Layout steps: 1440+ full · 1280 narrower sidebar · 1100 icon rail, no ticket number ·
 * 960 two-line rows · 720 drawer navigation · under 720 cards.
 */

/* ---------- Tokens ---------- */
:root {
    --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, Inter, Roboto, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

    --side: #0e1016; --side-2: #171a22; --side-3: #1f2430; --side-line: #252a36;
    --side-text: #a3a9b8; --side-muted: #6f778b; --side-strong: #f2f4f8;

    --canvas: #f7f8fa; --surface: #fff; --sunken: #fbfbfd; --hover: #f8f9fb;
    --line: #eceef2; --line-strong: #dfe2e8;
    --text: #0d0f14; --text-2: #4b5263; --text-3: #6b7280; --text-4: #858b98;

    --blue: #2f6bf0; --blue-hover: #2459d6; --blue-soft: #edf3ff; --blue-line: #cfe0ff; --blue-ink: #123a9c;
    --focus: 0 0 0 3px rgba(47, 107, 240, .28);
    --red: #e5484d; --red-ink: #c4343a; --red-soft: #fff1f1; --red-line: #ffd0d1;
    --amber: #b46b00; --amber-soft: #fff7e8; --amber-line: #f5dca6;
    --green: #12805c; --green-soft: #e9f8f1; --green-line: #bfe8d5;
    --bot: #6b7a99;
    --violet: #6b4fd8; --violet-soft: #f4f1ff; --violet-line: #ddd4fd; --violet-ink: #1d1640;
    --team: #1d2230;
    --note: #fff8e6; --note-line: #f2dfab; --note-ink: #7a4b00;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow-card: 0 1px 2px rgba(13, 15, 20, .04);
    --sidebar: 248px;
    --gutter: 28px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--text); background: var(--canvas); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font: 12.5px var(--font-mono); padding: 1px 5px; border-radius: 4px; background: rgba(13, 15, 20, .06); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
[hidden] { display: none !important; }
.icon { flex: none; display: block; }
.muted { color: var(--text-3); }
.link { color: var(--blue); font-weight: 600; }
.link:hover { text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 200; padding: 8px 12px; border-radius: var(--radius); background: var(--text); color: #fff; }
.skip-link:focus { top: 12px; }
main:focus { outline: none; box-shadow: none; }
.kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); color: var(--text-3); font: 600 11px var(--font); }
.kbd--dark { background: transparent; border-color: var(--side-line); color: #7d8498; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius);
    background: var(--surface); color: var(--text); font: 600 13px var(--font); white-space: nowrap;
    cursor: pointer; box-shadow: 0 1px 2px rgba(13, 15, 20, .05);
    transition: background-color .12s, border-color .12s, box-shadow .12s, color .12s;
}
.btn:hover { background: #fafbfc; border-color: #c9ced8; }
.btn:active { background: #f1f3f6; }
.btn:focus-visible { box-shadow: var(--focus); border-color: var(--blue); }
.btn--primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 1px 2px rgba(47, 107, 240, .35), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn--primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.btn--primary:active { background: #1f4fc2; }
.btn--note { background: #fdf0c8; border-color: #ebd38c; color: var(--note-ink); }
.btn--note:hover { background: #fbe7ae; border-color: #e1c574; }
.btn--sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn--block { width: 100%; height: 40px; font-size: 14px; }
.btn.icon { width: 32px; padding: 0; }
.btn.icon.btn--sm { width: 28px; }
.btn--side { background: transparent; border-color: transparent; color: var(--side-muted); box-shadow: none; }
.btn--side:hover { background: var(--side-2); border-color: transparent; color: var(--side-strong); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; box-shadow: none; }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"]::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form controls ---------- */
.input, .select {
    width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 9px;
    background: var(--surface); font-size: 13.5px; box-shadow: 0 1px 1px rgba(13, 15, 20, .03);
    transition: border-color .12s, box-shadow .12s;
}
.input::placeholder { color: #8a909e; }
.input:hover, .select:hover { border-color: #c9ced8; }
.input:focus, .select:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--red); }
.select {
    appearance: none; padding-right: 32px; font-weight: 550; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
}
.select:disabled { opacity: .6; cursor: progress; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.field-hint { margin: 0; font-size: 12px; color: var(--text-3); }
.field-error { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--red-ink); }

/* ---------- Pills, status, avatars ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 12px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill--sm { height: 20px; padding: 0 7px; font-size: 11.5px; gap: 4px; }
.pill--calm { background: var(--green-soft); color: var(--green); box-shadow: inset 0 0 0 1px var(--green-line); }
.wait { background: var(--amber-soft); color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber-line); }
.wait.is-late, .pill.is-late { background: var(--red-soft); color: var(--red-ink); box-shadow: inset 0 0 0 1px var(--red-line); }
.status--needs_human { background: #eff1f4; color: var(--text-2); }
.status--open { background: #eef1f6; color: var(--bot); }
.status--resolved { background: var(--green-soft); color: var(--green); box-shadow: inset 0 0 0 1px var(--green-line); }
.tag { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 5px; font-size: 11px; font-weight: 650; background: #eceef2; color: var(--text-2); }
.tag--amber { background: var(--amber-soft); color: var(--amber); }

.av { --size: 32px; flex: none; display: inline-grid; place-items: center; width: var(--size); height: var(--size); border-radius: 50%; background: #eceff4; color: #4b5263; font-size: calc(var(--size) * .38); font-weight: 700; line-height: 1; user-select: none; }
.av--xs { --size: 22px; font-size: 9.5px; }
.av--sm { --size: 26px; }
.av--lg { --size: 42px; }
.av--team { background: var(--team); color: #fff; }
.av--bot { background: var(--violet-soft); color: var(--violet); box-shadow: inset 0 0 0 1px var(--violet-line); }
.av--empty { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.av--side { background: #2b3140; color: #cfd5e2; }
.av--me { background: var(--blue); color: #fff; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.main { min-width: 0; display: flex; flex-direction: column; }

.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(180deg, #3b77f6, #2459d6); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2); }
.brand-name b { display: block; font-size: 14.5px; font-weight: 650; line-height: 1.15; }
.brand-name small { display: block; font-size: 11.5px; color: var(--text-3); }

.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; padding: 16px 12px 14px; background: var(--side); color: var(--side-text); }
.side .brand { padding: 2px 6px; color: var(--side-strong); }
.side .brand-name small { color: var(--side-text); }
.side-top { display: flex; align-items: center; justify-content: space-between; }
.side-close { display: none; }
.side-search { position: relative; display: flex; align-items: center; gap: 8px; height: 34px; margin: 0; padding: 0 10px; border: 1px solid var(--side-line); border-radius: 8px; background: var(--side-2); color: var(--side-muted); }
.side-search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--side-strong); font-size: 13px; outline: none; }
.side-search input::placeholder { color: var(--side-text); }
.side-search:focus-within { border-color: #4b6fd8; box-shadow: 0 0 0 3px rgba(91, 140, 255, .2); }
.side-search:focus-within .kbd, .side-search input:not(:placeholder-shown) ~ .kbd { display: none; }
.side-label { margin: 0; padding: 0 8px 6px; color: var(--side-muted); font-size: 11.5px; font-weight: 600; }
.side-item { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 8px; border: 0; border-radius: 7px; background: none; color: var(--side-text); font-size: 13.5px; font-weight: 500; text-align: left; cursor: pointer; }
.side-item:hover { background: var(--side-2); color: var(--side-strong); }
.side-item:focus-visible { box-shadow: 0 0 0 2px #5b8cff; }
.side-item[aria-current="page"] { background: var(--side-3); color: var(--side-strong); box-shadow: inset 0 0 0 1px #2b3140; }
.side-item--static { cursor: default; }
.side-item--static:hover { background: none; color: var(--side-text); }
.side-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-you { color: var(--side-muted); }
.side-count { color: #737b8f; font-size: 12px; }
.side-count.is-hot { min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--red); color: #fff; font-weight: 700; line-height: 18px; text-align: center; }
.side-meta { color: #737b8f; font-size: 12px; white-space: nowrap; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.bot-card { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; border: 1px solid var(--side-line); border-radius: 10px; background: var(--side-2); font-size: 12px; line-height: 1.4; }
.bot-card b { display: block; color: var(--side-strong); font-size: 12.5px; font-weight: 600; }
.bot-card code { background: #232836; color: #c8cdd9; font-size: 11px; }
.bot-live { flex: none; width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: #3ccf8e; box-shadow: 0 0 0 3px rgba(60, 207, 142, .18); }
.bot-card.is-off .bot-live { background: #f5a524; box-shadow: 0 0 0 3px rgba(245, 165, 36, .18); }
.side-links { display: flex; gap: 4px; flex-wrap: wrap; }
.side-link { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border: 0; border-radius: 6px; background: none; color: var(--side-text); font-size: 12.5px; cursor: pointer; }
.side-link:hover { background: var(--side-2); color: var(--side-strong); }
.me { display: flex; align-items: center; gap: 10px; padding: 10px 2px 0 8px; border-top: 1px solid var(--side-line); color: var(--side-strong); font-size: 13px; font-weight: 500; }
.me form { margin: 0; }

.mobile-bar, .backdrop { display: none; }

/* ---------- Queue header ---------- */
.top { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px var(--gutter); background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.crumb { color: var(--text-4); font-size: 13px; }
.top-title h1 { font: 650 18px var(--font-display); letter-spacing: -.01em; white-space: nowrap; }
.top-count { color: var(--text-3); font-size: 13px; font-weight: 500; white-space: nowrap; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--green); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #2fbf7f; box-shadow: 0 0 0 3px rgba(47, 191, 127, .18); }
.live.is-off { color: var(--amber); }
.live.is-off .live-dot { background: #f5a524; box-shadow: 0 0 0 3px rgba(245, 165, 36, .2); }
.top-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.head-search { display: none; }
.seg { display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: #f0f2f5; }
.seg a { padding: 5px 12px; border-radius: 7px; color: var(--text-2); font-size: 13px; font-weight: 500; white-space: nowrap; }
.seg a:hover { color: var(--text); }
.seg a[aria-current="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(13, 15, 20, .1); }

.filter { position: relative; }
.filter summary { list-style: none; color: var(--text-2); }
.filter summary::-webkit-details-marker { display: none; }
.filter summary.is-active { border-color: var(--blue-line); background: var(--blue-soft); color: var(--blue-ink); }
.filter-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--blue); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.filter-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; width: 300px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); box-shadow: 0 16px 32px -12px rgba(13, 15, 20, .25); }
.filter-title { padding: 6px 8px; color: var(--text-3); font-size: 12px; font-weight: 600; }
.filter-pop a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 8px; border-radius: 7px; font-size: 13px; }
.filter-pop a:hover { background: var(--hover); }
.filter-pop a[aria-current="true"] { background: var(--blue-soft); color: var(--blue-ink); font-weight: 600; }
.filter-n { color: var(--text-3); font-size: 12px; }

/* KPI cards: the state of the queue in four numbers. */
.scroll { flex: 1; padding: 20px var(--gutter) 32px; }
.kpis { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card); }
.kpi-t { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.kpi-t .icon { color: var(--text-3); }
.kpi-v { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; font: 650 26px/1 var(--font-display); letter-spacing: -.02em; }
.kpi-v small { color: var(--text-3); font: 500 12.5px var(--font); letter-spacing: 0; }
.kpi--alert { border-color: var(--red-line); background: linear-gradient(180deg, #fff6f6, #fff); }
.kpi--alert .kpi-v, .kpi--alert .kpi-t .icon { color: var(--red); }
.kpi-bar { display: flex; height: 6px; margin-top: 10px; overflow: hidden; border-radius: 3px; background: #eef1f6; }
.kpi-bar i { background: var(--blue); }
.filter-note { margin: 0 0 12px; color: var(--text-2); font-size: 13px; }
.filter-note a { color: var(--blue); font-weight: 600; }

/* ---------- Insights ---------- */
.panel { margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card); overflow: hidden; }
.panel-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font: 650 14px/1.3 var(--font-display); }
.panel-head p { margin: 4px 0 0; max-width: 820px; color: var(--text-3); font-size: 12.5px; }
.panel-head code, .panel-foot code { font-size: 12px; }
.panel-empty { margin: 0; padding: 16px; color: var(--text-3); font-size: 13px; }
.panel-foot { margin: 0; padding: 10px 16px 14px; color: var(--text-3); font-size: 12.5px; }
.panel-foot a { color: var(--blue); font-weight: 600; }
.panel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.panel-grid .panel { margin-bottom: 0; }

.gap { display: grid; grid-template-columns: minmax(0, 1.6fr) auto minmax(0, 1fr) 120px; align-items: center; gap: 14px; padding: 11px 16px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.gap:first-of-type { border-top: 0; }
.gap:hover { background: var(--hover); }
.gap-q { min-width: 0; overflow: hidden; color: var(--text); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.gap-doc { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; color: var(--text-2); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.gap-doc .icon { flex: none; color: var(--text-4); }
.gap-cov, .gap-when { color: var(--text-4); font-size: 12px; }
.gap-when { text-align: right; white-space: nowrap; }
.tag--red { background: var(--red-soft); color: var(--red-ink); }

.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 28px; align-items: center; gap: 10px; padding: 9px 16px; border-top: 1px solid var(--line); font-size: 13px; }
.panel-head + .bar-row { border-top: 0; }
.bar-label { min-width: 0; color: var(--text-2); }
.bar { display: flex; height: 6px; overflow: hidden; border-radius: 3px; background: #eef1f6; }
.bar i { background: var(--blue); }
.bar-n { font-weight: 650; text-align: right; }

.facts { margin: 0; padding: 4px 0; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 16px; font-size: 13px; }
.facts dt { color: var(--text-2); }
.facts dd { margin: 0; font-weight: 600; text-align: right; }
.facts .is-ok { color: var(--green); }
.facts .is-bad { color: var(--red-ink); }

/* ---------- Queue list: one card, groups as header rows ---------- */
.list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card); }
.group ul { margin: 0; padding: 0; list-style: none; }
.g-head { display: flex; align-items: center; gap: 10px; width: 100%; height: 40px; padding: 0 16px; border: 0; border-bottom: 1px solid var(--line); background: var(--sunken); color: var(--text); font-size: 13px; font-weight: 600; text-align: left; cursor: pointer; }
.g-head:hover { background: #f4f5f8; }
.g-head:focus-visible { border-radius: 0; box-shadow: inset 0 0 0 2px var(--blue); }
.g-chev { color: var(--text-4); transition: transform .15s; }
.group.is-collapsed .g-chev { transform: rotate(-90deg); }
.group.is-collapsed ul { display: none; }
.g-count { color: var(--text-3); font-weight: 500; }
.g-hint { margin-left: auto; overflow: hidden; color: var(--text-3); font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.g-status { color: var(--text-2); }
.st { flex: none; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 5px; }
.st--waiting { background: var(--red-soft); color: var(--red); }
.st--human { background: var(--amber-soft); color: var(--amber); }
.st--bot { background: #f0f2f6; color: var(--bot); }
.st--done { background: var(--green-soft); color: var(--green); }

.row {
    position: relative; display: grid; align-items: center; column-gap: 14px; min-height: 48px; padding: 0 16px;
    grid-template-columns: 18px 40px minmax(160px, 210px) minmax(0, 1fr) auto 26px 64px 128px;
    grid-template-areas: "st id cust pv tag owner when acts";
    border-bottom: 1px solid var(--line); font-size: 13.5px; transition: background-color .08s;
}
.group:last-child .row:last-child, .group.is-collapsed:last-child .g-head { border-bottom: 0; }
.row > .st { grid-area: st; }
.tid { grid-area: id; color: var(--text-4); font-size: 12.5px; }
.cust { grid-area: cust; display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-link { min-width: 0; overflow: hidden; color: var(--text); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.row-link::after { content: ""; position: absolute; inset: 0; } /* the whole row opens the ticket */
.row-link:focus-visible { box-shadow: none; }
.pv { grid-area: pv; min-width: 0; overflow: hidden; color: var(--text-2); text-overflow: ellipsis; white-space: nowrap; }
.pv b { margin-right: 4px; color: var(--text); font-weight: 600; }
.pv .who-bot { color: var(--bot); }
.pv .pv-error { color: var(--red-ink); font-weight: 600; }
/* Needs action: the customer's own words get a second line. */
.row--waiting { min-height: 64px; padding-top: 10px; padding-bottom: 10px; }
.row--waiting .pv { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--text); white-space: normal; overflow-wrap: anywhere; line-height: 1.45; }
.tag-cell { grid-area: tag; min-width: 0; display: flex; justify-content: flex-end; }
.row-foot { display: contents; } /* reason and action: their own grid cells, one line together on phones */
.tag-cell .tag { display: block; max-width: 260px; height: 22px; padding: 0 8px; line-height: 22px; overflow: hidden; border-radius: 6px; background: #f1f3f6; color: var(--text-2); font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.tag-cell .tag--red { background: var(--red-soft); color: var(--red-ink); }
.owner-cell { grid-area: owner; display: flex; justify-content: center; }
.when { grid-area: when; color: var(--text-3); font-size: 12.5px; text-align: right; white-space: nowrap; }
.when.is-late { color: var(--red); font-weight: 650; }
.when.is-soon { color: var(--amber); font-weight: 650; }
/* One action per group in a reserved column: showing it never moves or covers the row. */
.acts { grid-area: acts; position: relative; z-index: 1; display: flex; justify-content: flex-end; opacity: 0; transition: opacity .1s; }
.acts form { margin: 0; }
.row:hover { background: var(--hover); }
.row:hover .acts, .row:focus-within .acts, .row.is-selected .acts { opacity: 1; }
.row.is-selected, .row:has(.row-link:focus-visible) { background: var(--blue-soft); box-shadow: inset 2px 0 0 var(--blue); }
.row.is-selected .row-link { color: var(--blue-ink); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 2px 0; color: var(--text-3); font-size: 13px; }
.pager-buttons { display: flex; gap: 8px; }
.empty { padding: 64px 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); text-align: center; }
.empty-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; margin-bottom: 14px; border-radius: 12px; background: #eff1f4; color: var(--text-3); }
.empty h2 { margin-bottom: 6px; font: 650 16px var(--font-display); }
.empty p { color: var(--text-2); font-size: 13.5px; }
.empty a { color: var(--blue); font-weight: 600; }

/* ---------- Ticket page ---------- */
.ticket-page { display: flex; flex-direction: column; height: 100vh; }
.t-head { display: flex; align-items: center; gap: 16px; min-height: 72px; padding: 10px var(--gutter); flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--surface); }
.t-title { flex: 1 1 320px; min-width: 0; }
.t-line { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.t-line h1 { font: 650 20px/1.2 var(--font-display); letter-spacing: -.015em; }
.t-line .tid { font-size: 14px; }
.t-sub { margin-top: 3px; color: var(--text-3); font-size: 13px; }
.t-handle { color: var(--text-2); font-weight: 550; }
.t-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.t-actions form { margin: 0; }
.qnav { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.t-divider { width: 1px; height: 24px; margin: 0 4px; background: var(--line); }
.t-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 24px var(--gutter) 12px; }
.thread-col { max-width: 780px; margin: 0 auto; }
.timeline { display: flex; flex-direction: column; gap: 18px; margin: 0; padding: 0; list-style: none; }
.day { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12px; font-weight: 650; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.msg { display: flex; align-items: flex-start; gap: 12px; }
.msg--out { flex-direction: row-reverse; }
.m-body { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: min(580px, calc(100% - 44px)); }
.msg--out .m-body { align-items: flex-end; }
.m-meta { display: flex; align-items: baseline; gap: 8px; margin: 4px 2px 6px; color: var(--text-4); font-size: 12.5px; }
.m-meta b { color: var(--text); font-size: 13.5px; font-weight: 650; }
.msg--bot .m-meta b { color: var(--violet); }
.bubble { padding: 11px 15px; border-radius: 14px; color: var(--text); font-size: 14.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg--customer .bubble { border: 1px solid var(--line-strong); border-top-left-radius: 4px; background: var(--surface); box-shadow: 0 1px 1px rgba(13, 15, 20, .03); }
.msg--bot .bubble { border: 1px solid var(--violet-line); border-top-right-radius: 4px; background: var(--violet-soft); color: var(--violet-ink); }
.msg--agent .bubble { border-top-right-radius: 4px; background: var(--team); color: #f4f6fa; }
.bubble code { background: rgba(255, 255, 255, .75); box-shadow: inset 0 0 0 1px rgba(107, 79, 216, .18); }
.msg--agent .bubble code { background: rgba(255, 255, 255, .14); box-shadow: none; }
.bubble--command { font: 600 13px var(--font-mono); color: var(--text-2); }
.m-foot { display: flex; align-items: center; gap: 14px; margin-top: 7px; flex-wrap: wrap; justify-content: flex-end; font-size: 12.5px; }
.source { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; color: var(--violet); font-weight: 600; }
.source-label { color: var(--text-3); font-weight: 500; white-space: nowrap; }
.source-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source:hover .source-title { text-decoration: underline; }
.why { max-width: 100%; color: var(--text-3); }
.why summary { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px; border-radius: 5px; cursor: pointer; list-style: none; }
.why summary::-webkit-details-marker { display: none; }
.why summary:hover { color: var(--text); }
.why[open] summary .icon { transform: rotate(180deg); }
.why-body { margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left; }
.why-meta { margin-bottom: 8px; font-size: 12px; color: var(--text-3); }
.why-draft { margin: 0 0 10px; padding: 6px 10px; border-left: 2px solid var(--red-line); color: var(--text-2); font-size: 12.5px; white-space: pre-line; }
.why table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.why th { padding: 4px 8px; border-bottom: 1px solid var(--line); color: var(--text-3); font-weight: 600; text-align: left; }
.why td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
.why tr:last-child td { border-bottom: 0; }
.why .num { text-align: right; }
.why a { color: var(--violet); font-weight: 550; }
.m-error { display: inline-flex; align-items: center; gap: 6px; margin-top: 7px; padding: 4px 9px; border-radius: 7px; background: var(--red-soft); color: var(--red-ink); font-size: 12.5px; font-weight: 550; box-shadow: inset 0 0 0 1px var(--red-line); }

.handoff { display: flex; align-items: center; gap: 12px; }
.handoff::before, .handoff::after { content: ""; flex: 1; height: 1px; background: var(--line-strong); }
.handoff-card { display: inline-flex; align-items: center; gap: 10px; max-width: 86%; padding: 6px 14px 6px 8px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 13px; box-shadow: 0 1px 2px rgba(13, 15, 20, .05); }
.handoff-pass { display: inline-flex; align-items: center; gap: 4px; color: var(--text-4); }
.handoff-card b { color: var(--text); font-weight: 650; white-space: nowrap; }
.handoff-card > span:not(.handoff-pass) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.handoff-card time { color: var(--text-4); }
.event { display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--text-3); font-size: 12.5px; text-align: center; }
.event b { color: var(--text-2); font-weight: 600; }
.event--resolved_by_customer { color: var(--green); }
.note { padding: 12px 16px; border: 1px solid var(--note-line); border-radius: 12px; background: var(--note); }
.note-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; color: var(--note-ink); font-size: 12.5px; }
.note-head b { font-weight: 650; }
.note-body { color: #2b2210; font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Composer */
.composer { padding: 0 var(--gutter) 22px; }
.composer > * { max-width: 780px; margin-left: auto; margin-right: auto; }
.paused { display: flex; align-items: center; gap: 9px; padding: 4px 2px 10px; color: var(--text-2); font-size: 13px; }
.paused .icon { color: var(--violet); }
.box { overflow: hidden; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); box-shadow: 0 8px 24px -16px rgba(13, 15, 20, .3); transition: border-color .12s, box-shadow .12s; }
.box:focus-within { border-color: var(--blue); box-shadow: var(--focus), 0 8px 24px -16px rgba(13, 15, 20, .3); }
.box:has(.box-panel--note:not([hidden])) { border-color: var(--note-line); background: #fffcf3; }
.box:has(.box-panel--note:not([hidden])):focus-within { border-color: #d9b75a; box-shadow: 0 0 0 3px rgba(217, 183, 90, .25); }
.box-tabs { display: flex; gap: 20px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.box-tabs button { display: inline-flex; align-items: center; gap: 6px; height: 40px; margin-bottom: -1px; padding: 0 1px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text-3); font-size: 13px; font-weight: 600; cursor: pointer; }
.box-tabs button:hover { color: var(--text); }
.box-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--blue); }
.box-tabs button#tab-note[aria-selected="true"] { color: var(--note-ink); border-bottom-color: #d9a520; }
.box-tabs button:focus-visible { box-shadow: none; outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 3px; }
.box-panel { margin: 0; }
.box-input { display: block; width: 100%; min-height: 88px; max-height: 40vh; padding: 12px 16px; border: 0; background: transparent; font-size: 14.5px; line-height: 1.6; resize: vertical; }
.box-input:focus { outline: none; box-shadow: none; }
.box-input::placeholder { color: #8a909e; }
.box-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 6px 10px 10px 16px; }
.box-foot .hint { margin-right: auto; display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; color: var(--text-3); font-size: 12.5px; }
.box-foot .hint b { color: var(--text-2); font-weight: 600; }

/* Details panel */
.details { min-height: 0; overflow-y: auto; border-left: 1px solid var(--line); background: var(--surface); }
.sec { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.sec-title { margin-bottom: 12px; color: var(--text-3); font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
.wait-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 12px; background: var(--amber-soft); box-shadow: inset 0 0 0 1px var(--amber-line); color: var(--amber); }
.wait-card.is-late { background: linear-gradient(180deg, #fff6f6, #fff); box-shadow: inset 0 0 0 1px var(--red-line); color: var(--red); }
.wait-card-title { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.wait-card-value { font: 700 26px/1.1 var(--font-display); letter-spacing: -.02em; }
.wait-card-sub { color: var(--text-2); font-size: 12.5px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 9px 10px; margin: 4px 0 0; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; }
.hit { margin-bottom: 12px; }
.hit a { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; }
.hit a .icon { color: var(--violet); }
.hit a:hover span { text-decoration: underline; }
.hit-bar { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--text-3); font-size: 12px; }
.hit-bar span { display: flex; flex: 1; height: 5px; overflow: hidden; border-radius: 3px; background: #ebe7fb; }
.hit-bar i { background: var(--violet); }
.cust-card { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cust-text { display: flex; flex-direction: column; min-width: 0; }
.cust-text b { font-size: 15px; font-weight: 650; }
.cust-text a { color: var(--blue); font-size: 13px; font-weight: 550; }

/* ---------- Toasts & dialog ---------- */
/* Bottom right: over the details panel, never over the composer or the queue actions. */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 12px; min-height: 44px; max-width: 360px; padding: 8px 8px 8px 14px; border-radius: 12px; background: #11141b; color: #eef0f5; font-size: 13.5px; box-shadow: 0 16px 32px -12px rgba(13, 15, 20, .45); animation: toast-in .18s ease-out; }
.toast > span { flex: 1; }
.toast form { margin: 0; }
.toast-icon { color: #6ee0a8; }
.toast-action { height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: #2b3140; color: #fff; font-size: 13px; font-weight: 650; cursor: pointer; }
.toast-action:hover { background: #3a4152; }
.toast-close { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 7px; background: none; color: inherit; opacity: .65; cursor: pointer; }
.toast-close:hover { opacity: 1; background: rgba(255, 255, 255, .1); }
.toast--error { background: var(--surface); color: var(--red-ink); box-shadow: 0 0 0 1px var(--red-line), 0 16px 32px -12px rgba(13, 15, 20, .25); }
.toast--error .toast-icon { color: var(--red); }
.toast--error .toast-close:hover { background: var(--red-soft); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.dialog { width: min(460px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 14px; color: var(--text); box-shadow: 0 24px 48px -16px rgba(13, 15, 20, .35); }
.dialog::backdrop { background: rgba(13, 15, 20, .4); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font: 650 16px var(--font-display); }
.dialog-head form { margin: 0; }
.shortcut-list { margin: 0; padding: 6px 20px 14px; }
.shortcut-list div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.shortcut-list div:last-child { border-bottom: 0; }
.shortcut-list dt { color: var(--text-2); }
.shortcut-list dd { display: flex; gap: 4px; margin: 0; }

/* ---------- Sign in ---------- */
.auth { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; min-height: 100vh; padding: 24px 16px; }
.auth-card { width: min(400px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 12px 32px -20px rgba(13, 15, 20, .25); }
.auth-card h1 { margin-top: 26px; font: 650 22px/1.2 var(--font-display); letter-spacing: -.02em; }
.auth-sub { margin: 6px 0 24px; color: var(--text-2); font-size: 13.5px; }
.form .btn--block { margin-top: 6px; }
.auth-foot { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; }
.auth-foot:hover { color: var(--text); }


/* ==========================================================================
   Responsive steps
   1440+ full · 1280 narrower sidebar · 1100 icon rail, no ticket number ·
   960 rows in two lines · 720 drawer navigation · under 720 cards
   ========================================================================== */

/* 1600+: room for long customer names. */
@media (min-width: 1600px) {
    .row { grid-template-columns: 18px 40px minmax(170px, 250px) minmax(0, 1fr) auto 26px 64px 128px; }
}

/* Touch screens have no hover: the row action is always shown, never tapped unseen. */
@media (hover: none) {
    .acts { opacity: 1; }
}

/* 1280–1439: a narrower sidebar and tighter queue columns. */
@media (max-width: 1439px) {
    :root { --sidebar: 232px; --gutter: 24px; }
    .row { grid-template-columns: 18px 40px minmax(140px, 180px) minmax(0, 1fr) auto 26px 64px 128px; column-gap: 12px; }
    .tag-cell .tag { max-width: 240px; }
    .t-body { grid-template-columns: minmax(0, 1fr) 330px; }
}

/* 1100–1279: the sidebar becomes an icon rail, which gives the queue back its width. */
@media (max-width: 1279px) {
    .row { grid-template-columns: 18px minmax(140px, 180px) minmax(0, 1fr) auto 26px 64px 128px; grid-template-areas: "st cust pv tag owner when acts"; }
    .row > .tid { display: none; }
    .kpi-v { font-size: 23px; }
    .t-body { grid-template-columns: minmax(0, 1fr) 300px; }

    .head-search { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--text-4); }
    .head-search input { width: 150px; min-width: 0; border: 0; outline: none; background: transparent; font-size: 13px; }
    .head-search:focus-within { border-color: var(--blue); box-shadow: var(--focus); }
}
@media (min-width: 960px) and (max-width: 1279px) {
    :root { --sidebar: 68px; }
    .side { align-items: center; gap: 14px; padding: 14px 10px; overflow-x: hidden; }
    .side .brand { padding: 0; }
    .side .brand-name, .side-label, .side-text, .side-meta, .side-search, #team, .side-link .kbd, .bot-card > span:last-child { display: none; }
    .side nav { display: flex; flex-direction: column; align-items: center; gap: 2px; }
    .side-item { justify-content: center; width: 44px; height: 40px; padding: 0; }
    .side-count { position: absolute; top: 3px; right: 1px; }
    .side-count:not(.is-hot) { display: none; }
    .side-count.is-hot { min-width: 16px; height: 16px; padding: 0 4px; font-size: 10.5px; line-height: 16px; }
    .side-foot { align-items: center; }
    .bot-card { padding: 10px; }
    .bot-live { margin: 0; }
    .side-links { flex-direction: column; align-items: center; }
    .side-link { justify-content: center; width: 44px; height: 36px; padding: 0; font-size: 0; }
    .me { flex-direction: column; gap: 6px; padding: 10px 0 0; }
}

/* 960–1099: rows take two lines, so the hand-off reason and the wait stay readable. */
@media (max-width: 1099px) {
    .row {
        grid-template-columns: 18px minmax(0, 1fr) auto 26px 64px;
        grid-template-areas: "st cust tag owner when" ". pv acts acts acts";
        row-gap: 4px; padding-top: 9px; padding-bottom: 9px;
    }
    .row--waiting { min-height: 0; }
    .row--waiting .pv { align-self: start; }
    .kpis { gap: 10px; }
    .kpi { padding: 12px 14px; }
    .t-body { grid-template-columns: minmax(0, 1fr) 280px; }
}

/* 720–959: navigation slides in from the left; the ticket's details go under the conversation. */
@media (max-width: 959px) {
    :root { --gutter: 16px; }
    .app { display: block; }
    .mobile-bar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 12px 0 8px; border-bottom: 1px solid var(--line); background: var(--surface); }
    .mobile-attention { margin-left: auto; }
    .side {
        position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(300px, 86vw); height: 100%;
        transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s .2s;
        box-shadow: 0 0 40px rgba(13, 15, 20, .35);
    }
    .nav-open .side { transform: none; visibility: visible; transition: transform .2s ease; }
    .nav-open .backdrop { position: fixed; inset: 0; z-index: 50; display: block; background: rgba(13, 15, 20, .4); }
    .side-close { display: inline-flex; }

    .top-tools { flex: 1 1 100%; margin-left: 0; }
    .head-search { flex: 1; }
    .head-search input { width: 100%; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .ticket-page { height: auto; min-height: calc(100vh - 56px); }
    .t-head { position: sticky; top: 56px; z-index: 20; }
    .t-body { display: block; }
    .thread-scroll { overflow: visible; }
    .details { border-top: 1px solid var(--line); border-left: 0; }
    .hint-keys { display: none; }
}

/* Under 720: rows become small cards. */
@media (max-width: 719px) {
    .top { gap: 10px; }
    .crumb { display: none; }
    .top-title { flex-wrap: wrap; row-gap: 2px; }
    .top-tools { flex-wrap: wrap; gap: 8px; }
    .head-search { flex-basis: 100%; height: 36px; }
    .seg { flex: 1; }
    .seg a { flex: 1; padding: 5px 4px; text-align: center; }
    .filter-pop { width: min(300px, calc(100vw - 32px)); }
    .scroll { padding-top: 14px; }
    .kpis { gap: 8px; margin-bottom: 12px; }
    .kpi { padding: 11px 12px; }
    .kpi-t { font-size: 12px; }
    .kpi-v { flex-wrap: wrap; row-gap: 2px; font-size: 21px; }

    .g-hint { display: none; }
    .g-head { padding: 0 14px; }
    /* Line 1 who and how long, line 2 what they wrote, line 3 why and the next step. */
    .row {
        grid-template-columns: 18px minmax(0, 1fr) auto auto;
        grid-template-areas: "st cust owner when" ". pv pv pv" ". foot foot foot";
        column-gap: 10px; row-gap: 6px; padding: 12px 14px;
    }
    .row .pv { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; }
    .row--bot .pv, .row--done .pv { -webkit-line-clamp: 1; }
    .row-foot { grid-area: foot; display: flex; align-items: center; gap: 10px; min-width: 0; }
    .tag-cell .tag { max-width: none; height: auto; min-height: 22px; padding: 3px 8px; line-height: 16px; white-space: normal; }
    .acts { flex: none; margin-left: auto; }

    .t-head { position: static; gap: 10px; }
    .t-line h1 { font-size: 18px; }
    .t-actions { width: 100%; }
    .qnav { margin-right: auto; }
    .t-divider { display: none; }
    .thread-scroll { padding-top: 16px; }
    .m-body { max-width: calc(100% - 40px); }
    .bubble { font-size: 14px; }
    .box-foot { flex-wrap: wrap; }
    .box-foot .hint { width: 100%; }
    .box-foot .btn { flex: 1; }
    .handoff-card { flex-wrap: wrap; border-radius: 14px; }
    .handoff-card > span:not(.handoff-pass) { white-space: normal; }
    .sec { padding: 18px var(--gutter); }
}

/* Small phones. */
@media (max-width: 400px) {
    :root { --gutter: 12px; }
    .top-count { display: none; }
    .seg a { font-size: 12.5px; }
    .kpi-t .icon { display: none; }
    .t-actions .btn { padding: 0 9px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Insights: the three panels stack below 1100 px; on phones each gap is a card. */
@media (max-width: 1099px) {
    .panel-grid { grid-template-columns: 1fr; }
    .gap { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; }
    .gap-when { text-align: left; }
}

@media (max-width: 719px) {
    .gap { grid-template-columns: minmax(0, 1fr); padding: 12px 14px; }
    .gap-q { white-space: normal; overflow-wrap: anywhere; }
    .bar-row { grid-template-columns: minmax(0, 1fr) 60px 24px; padding: 9px 14px; }
    .facts > div { padding: 7px 14px; }
}
