/* TsBot — support tickets: the look of every ticket screen, in ONE sheet.
   Loaded by the two public pages (/support, /ticket: after ds.css, nothing else) and by the panel page (customer ›
   Support and superuser › Tickets: after the panel's own sheets). It only uses the design system's tokens (ds.css) and
   its own classes, all prefixed `tkt-`, so it changes nothing that already exists.
   House rule: no text leaves its card at any width. Every text box here may shrink (min-width: 0) and breaks long words
   (overflow-wrap: anywhere); a message keeps its line breaks (pre-wrap). Strict CSP: no inline style is needed. */
:root {
  --tk-ok: #8fe3b0; --tk-ok-soft: rgba(70, 209, 127, .1); --tk-ok-line: rgba(70, 209, 127, .4);
  --tk-warn: #ffd58a; --tk-warn-soft: rgba(255, 196, 84, .09); --tk-warn-line: rgba(255, 196, 84, .4);
  --tk-acc-text: #ffb9a8;
}

/* ───────── 1. Building blocks (panel and public pages) ───────── */
.tkt { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.tkt > * { min-width: 0; }
.tkt-card { display: flex; flex-direction: column; gap: 14px; padding: 18px; min-width: 0; border-radius: 20px; }
.tkt-card > * { min-width: 0; }
.tkt-card h2 { font-size: 22px; line-height: 1.2; font-weight: 500; letter-spacing: -.02em; overflow-wrap: anywhere; }
.tkt-row-wrap { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; min-width: 0; }
.tkt-row-wrap.is-between { justify-content: space-between; }
.tkt-lead { color: var(--mut); font-size: 15px; line-height: 1.5; max-width: 65ch; margin: 0; overflow-wrap: anywhere; }
.tkt-fine { color: var(--mut); font-size: 13px; line-height: 1.5; margin: 0; overflow-wrap: anywhere; }
.tkt-mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tkt-back { align-self: flex-start; font-size: 13.5px; color: var(--friend); }
.tkt .btn { max-width: 100%; white-space: normal; text-align: center; line-height: 1.2; padding-block: 10px; }
.tkt .btn:disabled { opacity: .5; cursor: not-allowed; }

/* pills: the state of a ticket, its category, where it came from */
.tkt-pill { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, .03); color: var(--mut); font: 500 11px/1.4 var(--mono); letter-spacing: .03em; overflow-wrap: anywhere; }
.tkt-pill.is-open { color: var(--tk-acc-text); border-color: var(--acc-line); background: var(--acc-soft); }
.tkt-pill.is-wait { color: var(--tk-warn); border-color: var(--tk-warn-line); background: var(--tk-warn-soft); }
.tkt-pill.is-done { color: var(--tk-ok); border-color: var(--tk-ok-line); background: var(--tk-ok-soft); }
.tkt-pill.is-info { color: var(--friend); border-color: var(--friend-line); background: var(--friend-soft); }

/* state filters */
.tkt-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tkt-chip { display: inline-flex; align-items: center; min-height: 40px; max-width: 100%; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, .03); color: var(--soft); font: 500 14px/1.25 var(--sans); cursor: pointer; text-align: left; overflow-wrap: anywhere; }
.tkt-chip:hover { border-color: rgba(255, 255, 255, .28); color: var(--strong); }
.tkt-chip[aria-pressed="true"] { background: var(--acc-soft); border-color: var(--acc-line); color: var(--tk-acc-text); }

/* a ticket in a list */
.tkt-list { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tkt-item { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(10, 16, 23, .6);
  min-width: 0; color: inherit; text-decoration: none; }
a.tkt-item:hover { border-color: var(--line-2); background: rgba(13, 20, 28, .85); color: inherit; }
.tkt-item-l { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tkt-item-t { font-weight: 600; color: var(--strong); overflow-wrap: anywhere; }
.tkt-item-s { font-size: 14px; color: var(--soft); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tkt-meta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 13px; color: var(--mut); min-width: 0; }
.tkt-meta > * { min-width: 0; overflow-wrap: anywhere; }
.tkt-item-a { display: flex; flex-wrap: wrap; gap: 8px; }

/* forms */
.tkt-f { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.tkt-f > label, .tkt-f > .tkt-label { font-size: 14px; font-weight: 600; color: var(--soft); overflow-wrap: anywhere; }
.tkt-in { width: 100%; min-width: 0; min-height: 48px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--s1); color: var(--fg);
  font: 400 15px/1.4 var(--sans); }
select.tkt-in { text-overflow: ellipsis; }
textarea.tkt-in { min-height: 150px; resize: vertical; }
.tkt-in:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px rgba(255, 90, 51, .16); }
.tkt-in.is-bad { border-color: var(--acc-line); }
.tkt-in:disabled { opacity: .6; }
.tkt-help { font-size: 13px; color: var(--mut); overflow-wrap: anywhere; }
.tkt-help.is-over { color: var(--tk-acc-text); }
.tkt-err { font-size: 13px; color: var(--tk-acc-text); overflow-wrap: anywhere; }
.tkt-g2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.tkt-check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--soft); min-width: 0; }
.tkt-check input { flex: 0 0 18px; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--acc); }
.tkt-check span { min-width: 0; overflow-wrap: anywhere; }
.tkt-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* boxes */
.tkt-note, .tkt-alert, .tkt-okbox, .tkt-warnbox { padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5; margin: 0; overflow-wrap: anywhere; min-width: 0; }
.tkt-note { border: 1px solid var(--line-2); background: rgba(8, 14, 20, .55); color: var(--soft); }
.tkt-note b { color: var(--strong); font-weight: 600; }
.tkt-note > b { display: block; margin-bottom: 4px; }
.tkt-note > .tkt-help { display: block; margin-top: 6px; }
.tkt-alert { border: 1px solid var(--acc-line); background: rgba(217, 54, 12, .1); color: #ffd9cf; }
.tkt-okbox { border: 1px solid var(--tk-ok-line); background: var(--tk-ok-soft); color: var(--tk-ok); }
.tkt-warnbox { border: 1px dashed var(--tk-warn-line); background: var(--tk-warn-soft); color: var(--tk-warn); }
.tkt-box-a { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* facts: label on the left, value on the right; the value wraps under the label when it does not fit */
.tkt-kv { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; font-size: 14px; padding: 9px 0; border-top: 1px solid var(--line-soft); min-width: 0; }
.tkt-kv:first-child { border-top: 0; padding-top: 0; }
.tkt-kv > span { color: var(--mut); min-width: 0; overflow-wrap: anywhere; }
.tkt-kv > b { color: var(--strong); font-weight: 500; text-align: right; overflow-wrap: anywhere; min-width: 0; margin-left: auto; }
.tkt-kv > span > .tkt-pill { margin-left: 8px; vertical-align: middle; }
.tkt-kv > .tkt-fine { flex: 1 1 100%; }
.tkt-sub { font: 500 11px/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--friend); }

/* a conversation: the newest message first, like every history in TsBot */
.tkt-thread { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tkt-msg { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(10, 16, 23, .7); min-width: 0; }
.tkt-msg.is-me { background: var(--friend-soft); border-color: var(--friend-line); margin-left: 24px; }
.tkt-msg.is-them { margin-right: 24px; }
.tkt-msg.is-note { background: var(--tk-warn-soft); border-color: var(--tk-warn-line); border-style: dashed; }
.tkt-msg-h { display: flex; flex-wrap: wrap; gap: 2px 10px; justify-content: space-between; font-size: 12.5px; color: var(--mut); min-width: 0; }
.tkt-msg-h b { color: var(--strong); font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.tkt-msg-b { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.5; color: var(--fg); }
.tkt-msg-b a { text-decoration: underline; text-underline-offset: 3px; }
.tkt-more { align-self: center; }

/* the empty state */
.tkt-empty { align-items: center; text-align: center; }
.tkt-big { width: 64px; height: 64px; border-radius: 20px; border: 1px solid var(--line-2); background: var(--s1); display: flex; align-items: center; justify-content: center; }
.tkt-big svg { width: 28px; height: 28px; fill: none; stroke: var(--friend); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tkt-loading { color: var(--mut); font-size: 14px; margin: 0; }

/* ───────── 2. Superuser › Tickets ───────── */
.tkt-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tkt-kpi { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(10, 16, 23, .6); min-width: 0; }
.tkt-kpi b { display: block; font-size: 28px; line-height: 1.1; font-weight: 500; letter-spacing: -.02em; color: var(--strong); font-variant-numeric: tabular-nums; }
.tkt-kpi small { display: block; font: 500 10.5px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--mut); overflow-wrap: anywhere; }
.tkt-kpi.is-hot b { color: var(--tk-acc-text); }
.tkt-filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.tkt-two { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.tkt-two > * { min-width: 0; }
.tkt-ctx { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.tkt-cat-n { color: var(--mut); font-variant-numeric: tabular-nums; }
#dlg .tkt-dlg-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; }

/* ───────── 3. The public pages (/support, /ticket) ───────── */
.tkt-page { padding-block: calc(var(--nav-h) + 28px) 64px; }
.tkt-page .wrap { max-width: calc(600px + 2 * var(--gut)); }
.tkt-page h1 { font-size: clamp(2rem, 8vw, 2.6rem); line-height: 1.08; font-weight: 500; letter-spacing: -.03em; overflow-wrap: anywhere; }
.tkt-steps { display: flex; gap: 6px; }
.tkt-steps i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.tkt-steps i.is-on { background: var(--acc); }
.tkt-opts { display: flex; flex-direction: column; gap: 10px; }
.tkt-opt { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 14px; border-radius: 16px; border: 1px solid var(--line-2); background: rgba(10, 16, 23, .6);
  color: inherit; text-align: left; cursor: pointer; min-width: 0; }
.tkt-opt[aria-pressed="true"] { border-color: var(--acc-line); background: var(--acc-soft); }
.tkt-opt > i { flex: 0 0 18px; height: 18px; margin-top: 2px; border-radius: 50%; border: 2px solid var(--line-2); }
.tkt-opt[aria-pressed="true"] > i { border-color: var(--acc); box-shadow: inset 0 0 0 4px var(--acc); }
.tkt-opt > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tkt-opt b { color: var(--strong); font-weight: 600; overflow-wrap: anywhere; }
.tkt-opt small { color: var(--mut); font-size: 13px; overflow-wrap: anywhere; }
.tkt-code { font: 600 24px/1 var(--mono); letter-spacing: .5em; text-align: center; padding-left: calc(14px + .5em); min-height: 60px; }
.tkt-link { display: block; margin-top: 8px; font: 500 13px/1.5 var(--mono); color: var(--friend); overflow-wrap: anywhere; user-select: all; }
.tkt-page h1:focus { outline: none; }
.tkt-page .tkt > .eyebrow { align-self: flex-start; }
.tkt-viewer { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; }
.tkt-linkbtn { background: none; border: 0; padding: 0; color: var(--friend); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.tkt-linkbtn:hover { color: var(--strong); }

@media (min-width: 900px) {
  .tkt-item.is-wide { flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; }
  .tkt-item.is-wide > .tkt-item-l { flex: 1 1 320px; }
  .tkt-item.is-wide > .tkt-meta.is-side, .tkt-item.is-wide > .tkt-item-a { flex: 0 1 auto; justify-content: flex-end; }
  .tkt-g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tkt-msg.is-me { margin-left: 120px; }
  .tkt-msg.is-them { margin-right: 120px; }
  .tkt-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tkt-filters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tkt-two { flex-direction: row; align-items: flex-start; }
  .tkt-two > .tkt { flex: 1.6 1 0; }
  .tkt-two > .tkt-ctx { flex: 1 1 0; }
}
@media (prefers-reduced-motion: reduce) { .tkt * { transition: none !important; animation: none !important; } }
