/* IT Help Desk — module-specific layout. Shared shell/titlebar/chrome/resize/
   footer/toast come from aceComponents.css; class prefix 'tk-' to avoid
   collisions with the shared vocabulary. Two-pane: ticket list + detail. */

.workspace { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

.tk-offline { display: flex; align-items: center; gap: 10px; margin: 12px 14px 0; padding: 10px 14px;
  border-radius: 10px; background: var(--danger-bg); border: 1px solid var(--danger); color: var(--danger-tx);
  font-size: 12.5px; font-weight: 650; }
.tk-offline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); flex: 0 0 auto; }

.tk-layout { flex: 1 1 auto; min-height: 0; display: flex; gap: 0; }
.tk-left { flex: 0 0 340px; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
/* Chat layout: fixed header, scrolling message list, fixed composer. */
.tk-detail { flex: 1 1 auto; min-width: 0; min-height: 0; overflow: hidden; padding: 0;
  display: flex; flex-direction: column; }
#tkHead { flex: 0 0 auto; padding: 16px 18px 0; }
.tk-thread-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 18px 6px; }
#tkComposer { flex: 0 0 auto; padding: 0 18px 14px; }
/* "New replies" jump pill: sticks near the bottom of the message list when the
   user has scrolled up; hidden while they're at the bottom. */
.tk-newpill-anchor { position: sticky; bottom: 6px; height: 0; overflow: visible;
  display: flex; justify-content: center; pointer-events: none; }
.tk-newpill { pointer-events: auto; transform: translateY(-4px); font-size: 12px; font-weight: 800;
  color: var(--on-accent); background: var(--accent); border: 1px solid var(--accent);
  border-radius: 999px; padding: 5px 15px; cursor: pointer; box-shadow: 0 6px 18px var(--shadow); }
.tk-newpill:hover { background: var(--accent2); border-color: var(--accent2); }

/* body flags drive who sees the worker-only nav/filters (set by the JS). */
body:not([data-canqueue="1"]) .tk-work-only { display: none !important; }
body:not([data-canreport="1"]) .tk-report-only { display: none !important; }

.tk-nav { display: flex; gap: 4px; padding: 10px 12px 0; flex: 0 0 auto; }
.tk-nav-btn { position: relative; font-size: 13px; font-weight: 750; color: var(--muted); background: transparent;
  border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; cursor: pointer; border-radius: 8px 8px 0 0; }
.tk-nav-btn:hover { color: var(--soft); background: var(--card2); }
.tk-nav-btn.on { color: var(--ink); border-bottom-color: var(--accent); }
.tk-nav-count { display: inline-block; min-width: 18px; text-align: center; font-size: 11px; font-weight: 800;
  color: var(--gold-tx); background: var(--gold-bg); border: 1px solid var(--gold); border-radius: 999px; padding: 0 6px; margin-left: 6px; }

.tk-list-head { display: flex; gap: 6px; align-items: center; padding: 10px 12px 8px; }
.tk-filter { flex: 1 1 auto; min-width: 0; box-sizing: border-box; padding: 7px 11px; border-radius: 9px;
  border: 1px solid var(--line2); background: var(--field); color: var(--ink); font-size: 12.5px; }
.tk-statusfilter { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 12px 8px; }
.tk-chip { font-size: 10.5px; font-weight: 700; color: var(--muted); background: var(--card2); border: 1px solid var(--line2);
  border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.tk-chip:hover { border-color: var(--accent2); color: var(--accent2); }
.tk-chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.tk-list { flex: 1 1 auto; overflow: auto; padding: 0 8px 10px; }
.tk-group-label { font-size: 10px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--faint); padding: 12px 6px 5px; }
.tk-item { display: flex; flex-direction: column; gap: 3px; padding: 9px 11px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.tk-item:hover { background: var(--card2); }
.tk-item.on { background: var(--accent-bg); border-color: var(--accent); }
.tk-item-top { display: flex; align-items: center; gap: 7px; }
.tk-item-num { font-size: 11px; font-weight: 800; color: var(--faint); }
.tk-item-subj { font-size: 13px; font-weight: 750; color: var(--ink); flex: 1 1 auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-item-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* new-message pill on a sidebar ticket row (gold, matches the dashboard card) */
.tk-item.has-new { border-color: var(--gold); }
.tk-item-newline { margin-top: 2px; }
.tk-item-new { display: inline-block; font-size: 10.5px; font-weight: 800; color: var(--gold-tx);
  background: var(--gold-bg); border: 1px solid var(--gold); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
/* IT-only "internal note" pill - distinct (accent) from the gold public pill */
.tk-item-int { display: inline-block; font-size: 10.5px; font-weight: 800; color: var(--accent2);
  background: var(--accent-bg); border: 1px solid var(--accent); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }

/* status + priority pills */
.tk-pill { display: inline-block; vertical-align: middle; font-size: 9.5px; font-weight: 800; letter-spacing: .2px; text-transform: uppercase; padding: 2px 7px;
  border-radius: 999px; white-space: nowrap; border: 1px solid var(--line2); }
.tk-st-open       { color: var(--accent2);   background: var(--accent-bg); border-color: var(--accent); }
.tk-st-inprogress { color: var(--gold-tx);   background: var(--gold-bg);   border-color: var(--gold); }
.tk-st-resolved   { color: var(--green-tx);  background: var(--green-bg);  border-color: var(--green); }
.tk-st-closed     { color: var(--muted);     background: var(--inset); }
.tk-pri { display: inline-block; vertical-align: middle; font-size: 9.5px; font-weight: 800; padding: 2px 6px; border-radius: 5px; white-space: nowrap; }
.tk-pri-Low    { color: var(--muted);    background: var(--inset); }
.tk-pri-Normal { color: var(--soft);     background: var(--card2); }
.tk-pri-High   { color: var(--gold-tx);  background: var(--gold-bg); }
.tk-pri-Urgent { color: var(--danger-tx);background: var(--danger-bg); }

/* ---- detail pane ---- */
.tk-empty { color: var(--muted); font-weight: 650; font-size: 13px; padding: 40px 24px; text-align: center; }
.tk-d-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 4px; }
.tk-d-title { flex: 1 1 auto; min-width: 0; }
.tk-d-subj { font-size: 18px; font-weight: 850; color: var(--ink); }
.tk-d-meta { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 3px; }
.tk-d-meta b { color: var(--soft); font-weight: 750; }
.tk-d-pills { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }
.tk-d-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tk-d-actions .grow { flex: 1 1 auto; }
.tk-resolved-note { font-size: 12px; font-weight: 650; color: var(--green-tx); align-self: center; }
.tk-d-body { font-size: 13px; color: var(--soft); white-space: pre-wrap; line-height: 1.5; padding: 4px 0 2px; }

/* ---- worker controls (assign / status selects) ---- */
.tk-ctl { display: inline-flex; align-items: center; gap: 6px; }
.tk-ctl label { font-size: 11px; font-weight: 700; color: var(--muted); }
.tk-ctl select { height: 32px; border: 1px solid var(--line2); background: var(--field); color: var(--ink);
  border-radius: 8px; padding: 0 8px; font-size: 12.5px; font-family: inherit; }

/* ---- thread ---- */
/* Cap + center the conversation so it reads as a chat column, not a full-width
   log (the detail pane is ~940px wide by default). */
.tk-thread { display: flex; flex-direction: column; gap: 9px; margin: 14px auto 0; max-width: 780px; }
.tk-c { border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--card); }
.tk-c.mine { background: var(--accent-bg); border-color: var(--accent); }
.tk-c.internal { background: var(--gold-bg); border-color: var(--gold); }
.tk-c.system { background: var(--inset); border-style: dashed; }
.tk-c-head { display: flex; align-items: center; gap: 8px; font-size: 11px; margin-bottom: 3px; }
.tk-c-author { font-weight: 800; color: var(--ink); }
.tk-c-when { color: var(--faint); }
.tk-c-tag { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px; padding: 1px 6px; border-radius: 5px; }
.tk-c-tag.internal { color: var(--gold-tx); background: var(--gold-bg); border: 1px solid var(--gold); }
.tk-c-body { font-size: 12.5px; color: var(--soft); white-space: pre-wrap; line-height: 1.45; }
.tk-c.system .tk-c-body { color: var(--muted); font-style: italic; }

/* ---- chat: avatars + grouped bubbles (Teams-feel) ---- */
.tk-grp { display: flex; align-items: flex-end; gap: 8px; max-width: min(82%, 560px); align-self: flex-start; }
.tk-grp.mine { align-self: flex-end; flex-direction: row-reverse; }
.tk-av { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; color: #fff;
  font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; margin-bottom: 2px; }
.tk-av-img { object-fit: cover; }
.tk-grp-col { min-width: 0; display: flex; flex-direction: column; }
.tk-grp.mine .tk-grp-col { align-items: flex-end; }
.tk-grp-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin-bottom: 3px; }
.tk-grp.mine .tk-grp-head { flex-direction: row-reverse; }
.tk-grp-name { font-weight: 800; color: var(--ink); }
.tk-grp-time { color: var(--faint); }
.tk-bubble { font-size: 16px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  padding: 8px 12px; border-radius: 12px; margin-top: 2px; }
/* Flipped emphasis: the INCOMING (sender's) message carries the accent - it's the
   actionable one in a helpdesk; your own is muted so it doesn't steal focus. */
.tk-grp.theirs .tk-bubble { background: var(--accent-bg); color: var(--ink); border: 1px solid var(--accent);
  border-bottom-left-radius: 4px; }
.tk-grp.mine .tk-bubble { background: var(--card2); color: var(--ink); border: 1px solid var(--line2);
  border-bottom-right-radius: 4px; }
.tk-grp.internal .tk-bubble { background: var(--gold-bg); color: var(--gold-tx); border-color: var(--gold); }
.tk-bubble-att { padding: 6px; }
.tk-sys { align-self: center; text-align: center; font-size: 11px; color: var(--muted); font-style: italic; margin: 2px 0; }
.tk-sys-t { color: var(--faint); font-style: normal; }
/* optimistic-send states */
.tk-pending-sending .tk-bubble { opacity: .65; }
.tk-send-state { font-size: 10.5px; color: var(--faint); margin-top: 2px; text-align: right; }
.tk-send-state.failed { color: var(--danger-tx); }
.tk-retry { font: inherit; font-size: 10.5px; font-weight: 700; color: var(--accent2);
  background: none; border: none; padding: 0; cursor: pointer; text-decoration: underline; }

/* ---- reply box ---- */
.tk-reply { border-top: 1px solid var(--line); padding-top: 12px; }
.tk-reply textarea { width: 100%; box-sizing: border-box; min-height: 68px; resize: vertical; border: 1px solid var(--line2);
  background: var(--field); color: var(--ink); border-radius: 9px; padding: 9px 11px; font-size: 16px; font-family: inherit; }
.tk-reply-bar { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.tk-reply-bar .grow { flex: 1 1 auto; }
.tk-internal-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--gold-tx); font-weight: 700; cursor: pointer; }
.tk-target-sel { height: 26px; max-width: 140px; border: 1px solid var(--line2); background: var(--field);
  color: var(--ink); border-radius: 7px; padding: 0 6px; font-size: 11.5px; font-family: inherit; }

/* ---- buttons (module-local, mirror sc-btn) ---- */
.tk-btn { font-size: 12px; font-weight: 750; padding: 6px 14px; border-radius: 9px; border: 1px solid var(--line2);
  background: var(--card2); color: var(--ink); cursor: pointer; white-space: nowrap; }
.tk-btn:hover { border-color: var(--accent2); color: var(--accent2); }
.tk-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tk-btn.primary:hover { background: var(--accent2); border-color: var(--accent2); color: var(--on-accent); }
.tk-btn.danger:hover { border-color: var(--danger); color: var(--danger-tx); }
.tk-btn.tiny { font-size: 11px; padding: 4px 10px; }

/* ---- modal (drag-safe: mousedown dismiss + covered by aceShared guard) ---- */
.tk-modal-back { position: fixed; inset: 0; z-index: 90000; display: flex; align-items: center; justify-content: center;
  background: rgba(4, 10, 18, .55); padding: 20px; }
.tk-modal { width: min(560px, calc(100vw - 48px)); max-height: calc(100vh - 60px); overflow: auto; border-radius: 14px;
  border: 1px solid var(--line2); background: var(--card); box-shadow: 0 24px 60px var(--shadow); color: var(--ink); }
.tk-modal h3 { margin: 0; padding: 15px 18px; border-bottom: 1px solid var(--line); font-size: 15px; font-weight: 850; }
.tk-modal .tk-modal-body { padding: 16px 18px; }
.tk-modal-actions { display: flex; align-items: center; gap: 9px; padding: 14px 18px; border-top: 1px solid var(--line); }
.tk-modal-actions .grow { flex: 1 1 auto; }
.tk-fld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.tk-fld label { font-size: 11px; font-weight: 700; letter-spacing: .02em; color: var(--muted); }
.tk-fld input, .tk-fld select, .tk-fld textarea { box-sizing: border-box; border: 1px solid var(--line2);
  background: var(--field); color: var(--ink); border-radius: 8px; padding: 9px 11px; font-size: 13.5px; font-family: inherit; outline: none; }
.tk-fld textarea { min-height: 96px; resize: vertical; }
.tk-fld input:focus, .tk-fld select:focus, .tk-fld textarea:focus { border-color: var(--accent2); box-shadow: 0 0 0 2px var(--accent-bg); }
.tk-fld-row { display: flex; gap: 12px; }
.tk-fld-row .tk-fld { flex: 1 1 0; }

/* ---- image attachments ---- */
/* composer: attach bar + picked-image preview strip */
.tk-attach-bar { display: flex; align-items: center; gap: 10px; }
.tk-attach-hint { font-size: 11px; color: var(--faint); font-weight: 600; }
.tk-attach-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.tk-attach-strip:not(:empty) { margin-top: 8px; }
.tk-att-pre { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line2); background: var(--inset); flex: 0 0 auto; }
.tk-att-pre img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tk-att-x { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; line-height: 16px; text-align: center;
  border-radius: 50%; border: none; cursor: pointer; font-size: 13px; font-weight: 800;
  background: rgba(4, 10, 18, .66); color: #fff; }
.tk-att-x:hover { background: var(--danger); }

/* thread: an image-only / images message group + its thumbnail tiles */
.tk-c-att { background: var(--card2); }
.tk-att-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.tk-att { width: 96px; height: 96px; border-radius: 9px; overflow: hidden; border: 1px solid var(--line2);
  background: var(--inset); cursor: zoom-in; flex: 0 0 auto; }
.tk-att img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tk-att:hover { border-color: var(--accent2); }
.tk-att-gone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: default; color: var(--muted); font-size: 10px; font-weight: 700; border-style: dashed; }
.tk-att-gone-i { font-size: 20px; opacity: .7; }

/* reopen / closed-ticket notice that earlier images are gone */
.tk-att-note { margin-top: 12px; padding: 8px 12px; border-radius: 9px; font-size: 12px; font-weight: 650;
  color: var(--gold-tx); background: var(--gold-bg); border: 1px solid var(--gold); }

/* ---- monthly report (Reports tab) ---- */
.tk-report { flex: 1 1 auto; min-width: 0; min-height: 0; overflow: auto; padding: 16px 18px; }
.tk-report-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.tk-month-nav { display: inline-flex; align-items: center; gap: 8px; }
.tk-month-label { font-size: 15px; font-weight: 850; color: var(--ink); min-width: 140px; text-align: center; }
.tk-kpis { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.tk-kpi { flex: 1 1 140px; min-width: 130px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); padding: 12px 14px; }
.tk-kpi-label { font-size: 10.5px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tk-kpi-value { font-size: 30px; font-weight: 850; color: var(--ink); line-height: 1.1; margin: 4px 0 2px; }
.tk-kpi-sub { font-size: 11px; color: var(--faint); }
.tk-report-charts { display: flex; flex-wrap: wrap; gap: 12px; }
.tk-report-charts .tk-rpanel { flex: 1 1 380px; min-width: 300px; }
.tk-rpanel { border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 12px 14px; margin-bottom: 14px; }
.tk-rpanel-title { font-size: 13px; font-weight: 800; color: var(--ink); margin-bottom: 12px; }
.tk-donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.tk-lg-list { flex: 1 1 200px; display: flex; flex-direction: column; gap: 6px; }
.tk-lg { font-size: 12px; color: var(--soft); display: flex; align-items: center; gap: 8px; }
.tk-lg i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.tk-lg b { color: var(--ink); }
.tk-lg span { color: var(--faint); margin-left: auto; }
.tk-bars { display: flex; flex-direction: column; gap: 8px; }
.tk-bar-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.tk-bar-lbl { flex: 0 0 130px; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-bar-track { flex: 1 1 auto; height: 14px; background: var(--inset); border-radius: 7px; overflow: hidden; }
.tk-bar-fill { display: block; height: 100%; border-radius: 7px; min-width: 2px; }
.tk-bar-val { flex: 0 0 auto; font-weight: 800; color: var(--ink); min-width: 26px; text-align: right; }

/* due date chip in ticket detail meta */
.tk-due { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px;
  font-weight: 800; font-size: 11px; color: var(--gold-tx); background: var(--gold-bg);
  border: 1px solid var(--gold); }
.tk-due.overdue { color: var(--danger-tx); background: var(--danger-bg); border-color: var(--danger); }

/* current-month "real-time" report panels */
.tk-report-live { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.tk-report-live .tk-rpanel.tk-live { flex: 1 1 300px; min-width: 260px; margin-bottom: 0; display: flex; flex-direction: column; }
.tk-live-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.tk-live-row { display: flex; align-items: flex-start; gap: 10px; padding: 7px 4px;
  border-top: 1px solid var(--line); font-size: 12px; }
.tk-live-row:first-child { border-top: 0; }
.tk-live-num { flex: 0 0 auto; font-weight: 800; color: var(--faint); min-width: 38px; }
.tk-live-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tk-live-subj { color: var(--ink); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-live-sub { color: var(--faint); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-live-tag { display: inline-block; padding: 0 6px; border-radius: 999px; font-size: 10px; font-weight: 800;
  vertical-align: middle; margin-left: 4px; }
.tk-live-tag.od { color: var(--danger-tx); background: var(--danger-bg); }
.tk-live-tag.int { color: var(--accent2); background: var(--accent-bg); }
.tk-live-tag.shop { color: var(--gold-tx); background: var(--gold-bg); }

/* clickable report counts (KPI numbers, donut slices/legend, bar rows) */
.tk-kpi-value.tk-clk { cursor: pointer; }
.tk-kpi-value.tk-clk:hover { color: var(--accent2); text-decoration: underline; text-underline-offset: 3px; }
.tk-arc { cursor: pointer; transition: opacity .12s; }
.tk-arc:hover { opacity: .8; }
.tk-lg.tk-clk, .tk-bar-row.tk-clk { cursor: pointer; border-radius: 6px; }
.tk-lg.tk-clk:hover, .tk-bar-row.tk-clk:hover { background: var(--card2); }

/* drill-down modal: quick-view list of the tickets behind a count */
.tk-drill-h { display: flex; align-items: center; gap: 10px; }
.tk-drill-count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px;
  padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 800;
  color: var(--accent2); background: var(--accent-bg); border: 1px solid var(--accent); }
.tk-drill-list { max-height: 60vh; overflow-y: auto; padding: 4px 0; }
.tk-drill-row { display: flex; align-items: center; gap: 10px; padding: 9px 18px; cursor: pointer;
  border-top: 1px solid var(--line); }
.tk-drill-row:first-child { border-top: 0; }
.tk-drill-row:hover { background: var(--card2); }
.tk-drill-num { flex: 0 0 auto; font-weight: 800; color: var(--faint); min-width: 40px; font-size: 12px; }
.tk-drill-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tk-drill-subj { color: var(--ink); font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-drill-sub { color: var(--faint); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-drill-sub b { color: var(--soft); }
.tk-drill-pills { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
