/* Help desk agent workspace (prefix hd-): ticket list, My work, the ticket page with its three columns, views, macros, calls.
   Phone-friendly: every grid child can shrink, wide tables sit in .ct-tablewrap, nothing scrolls sideways at 390px. */

.hd-ws, .hd-layout > *, .hd-head > *, .hd-msg, .hd-sys, .hd-props, .hd-main, .hd-side { min-width: 0; }
.hd-note { font-size: 12px; margin: 0; }
.hd-p { margin: 0; font-size: 12.5px; color: #2f4559; }
.nowrap { white-space: nowrap; }
.mut { color: var(--muted); }

/* ---- list: views, filters, bulk bar, rows */
.hd-viewbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hd-viewbar .lbl { font-size: 12px; font-weight: 700; color: #2f4559; margin-right: 4px; }
.hd-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #c7d2dd; background: #fff; color: #22517a; border-radius: 14px; padding: 3px 10px;
    font-size: 12px; font-weight: 600; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hd-chip b { font-weight: 700; color: var(--muted); }
.hd-chip.on { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.hd-chip.on b { color: #fff; opacity: .85; }
.hd-chip.add { border-style: dashed; }
.hd-filters { flex-wrap: wrap; }
.hd-more { position: relative; }
.hd-more summary { list-style: none; }
.hd-more summary::-webkit-details-marker { display: none; }
.hd-more[open] .hd-more-body { display: flex; }
.hd-more-body { display: none; flex-wrap: wrap; gap: 6px; padding: 8px 0 2px; width: 100%; }
.hd-bulk { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid #e0e7ed; background: #f7fafc; }
.hd-bulk select, .hd-bulk input { max-width: 260px; min-width: 0; }
.hd-bulk .sub { font-size: 11px; color: var(--muted); margin-left: 6px; }
.hd-tick { width: 30px; }
.hd-list .hd-subj a { color: #12385e; }
.ct-tbl td.hd-subj { white-space: normal; min-width: 240px; max-width: 460px; overflow-wrap: anywhere; }
.ct-tbl td.hd-wrap { white-space: normal; min-width: 200px; }
.hd-ref { white-space: nowrap; font-variant-numeric: tabular-nums; }
.hd-statusbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hd-statusbar .ct-seg { max-width: 100%; }
.hd-qn { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.hd-qn .tb { width: 54px; height: 6px; border-radius: 999px; background: #e8eef4; overflow: hidden; display: inline-block; }
.hd-qn .tb i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #7fb1ef, #2083ee); }
.hd-qn b { min-width: 22px; text-align: right; }
.hd-dbtbl td.hd-subj { min-width: 220px; max-width: 360px; }
.hd-dbtbl .hd-ref { font-weight: 700; }
.db-panel .ct-pfoot a, .ct-pfoot a { font-size: 12px; font-weight: 700; }
.hd-tkpis { margin: 10px 0 0; }
.hd-tkpis .ct-kpi { min-height: 96px; }
.hd-tkpis .ct-kpi strong { font-size: 21px; }
.hd-viewgrid > div { min-width: 0; }
.hd-extpanels { margin-top: 0; }
.hd-list tr.hd-unread .hd-subj a { font-weight: 700; }
.hd-list tr.hd-unread { background: #f3f9ff; }
.hd-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-primary); margin-right: 6px; vertical-align: middle; }
.hd-tag { display: inline-block; background: #eef3f8; color: #2f5f88; border-radius: 3px; padding: 0 5px; margin-right: 3px; font-size: 11px; }
.hd-urg { font-size: 14px; }
.hd-urg.hot { color: #c32a43; }
.hd-urg.warm { color: #b06a00; }
.hd-density { display: flex; gap: 6px; align-items: center; justify-content: flex-end; font-size: 12px; flex-wrap: wrap; }
.hd-compact .ct-tbl td, .hd-compact .ct-tbl th { padding-top: 4px; padding-bottom: 4px; }
.hd-compact .ct-tbl .sub { display: none; }
.hd-compact .hd-msg { padding: 7px 9px; }
.hd-compact .hd-sys { padding: 2px 0; }
.hd-compact .ct-pbody { padding: 9px 10px; }

/* ---- recent ticket tabs and sub-tabs */
.hd-tabbar { display: flex; gap: 4px; overflow-x: auto; position: relative; padding-bottom: 2px; margin-bottom: 8px; border-bottom: 2px solid #d5dfe8; }
.hd-tab { display: flex; align-items: center; background: #eef3f8; border: 1px solid #cbd7e2; border-bottom: 0; border-radius: 4px 4px 0 0; flex: 0 0 auto; max-width: 220px; }
.hd-tab a { padding: 6px 4px 6px 10px; font-size: 12px; color: #22517a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-tab.on { background: #fff; border-color: var(--brand-primary); }
.hd-tab.on a { font-weight: 700; color: #12385e; }
.hd-tab form { margin: 0; }
.hd-tab .x, .hd-person .x { border: 0; background: none; color: #6b7f93; font-size: 16px; line-height: 1; padding: 4px 8px; cursor: pointer; }
.hd-tab .x:hover, .hd-person .x:hover { color: #c32a43; }
.hd-subtabs { margin: 10px 0; max-width: 100%; }

/* ---- ticket header */
.hd-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; background: #fff; border: 1px solid #d5dfe8; border-radius: 4px; padding: 12px 14px; }
.hd-head-main { flex: 1 1 420px; }
.hd-title { margin: 0 0 6px; font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
.hd-title .num { color: var(--muted); font-weight: 600; }
.hd-pills { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.hd-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.hd-presence { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; font-size: 12px; flex: 0 1 260px; }
.hd-who { background: #fff7e6; color: #8a5a00; border: 1px solid #f1d49b; border-radius: 12px; padding: 2px 9px; }
.hd-who.typing { background: #fdecef; color: #a8203a; border-color: #f2b8c2; }
.hd-who.none { background: #eef8f3; color: #0a7a52; border-color: #bfe5d3; }
.hd-newreply, .hd-special { margin-top: 8px; }

/* ---- three columns: properties | conversation | tools */
.hd-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr) 300px; gap: 12px; align-items: start; }
.hd-props, .hd-side, .hd-main { display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 1280px) { .hd-layout { grid-template-columns: 260px minmax(0, 1fr); } .hd-side { grid-column: 1 / -1; } }
@media (max-width: 860px) { .hd-layout { grid-template-columns: minmax(0, 1fr); } .hd-main { order: -1; } .hd-presence { align-items: flex-start; } }

.hd-propform .ct-field select, .hd-propform .ct-field input, .hd-propform .ct-field textarea { width: 100%; }
.hd-propfields { border-top: 1px dashed #d5dfe8; padding-top: 10px; display: grid; gap: 10px; }
.hd-resolution summary { cursor: pointer; font-size: 12px; font-weight: 700; color: #2f4559; margin-bottom: 8px; }
.hd-resolution[open] { display: grid; gap: 10px; }
.hd-needs { font-size: 12px; color: #8a5a00; background: #fff7e6; border-radius: 3px; padding: 6px 8px; margin: 0; }
.hd-suggest { font-size: 12px; margin: -4px 0 0; color: #2f5f88; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hd-people { margin-bottom: 8px; font-size: 12.5px; }
.hd-person { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 2px 0; }
.hd-person .sub { display: block; font-size: 11px; color: var(--muted); }
.hd-relhead { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 8px 0 4px; }
.hd-relhead:first-child { margin-top: 0; }
.hd-btnrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hd-actions { display: flex; flex-direction: column; gap: 6px; }
.hd-actions .ct-btn, .hd-actions form .ct-btn { width: 100%; justify-content: flex-start; }
.hd-actions form { margin: 0; }

/* ---- conversation */
.hd-convo { display: flex; flex-direction: column; gap: 8px; }
.hd-msg { border: 1px solid #d5dfe8; border-radius: 5px; padding: 10px 12px; background: #fff; }
.hd-msg.cust { border-left: 4px solid #8a9bb0; }
.hd-msg.agent { background: #eef6ff; border-color: #c2d9f5; border-left: 4px solid var(--brand-primary); }
.hd-msg.note { background: #fffaeb; border-color: #f1d49b; border-left: 4px solid #d99a06; }
.hd-msg header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; margin-bottom: 6px; }
.hd-msg header time { margin-left: auto; color: var(--muted); }
.hd-role { color: var(--muted); }
.hd-av { width: 24px; height: 24px; border-radius: 50%; background: #dbe6f1; color: #2f5f88; display: grid; place-items: center; font-size: 10px; font-weight: 700; flex: none; }
.hd-body { font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.hd-files { list-style: none; margin: 8px 0 0; padding: 6px 0 0; border-top: 1px dashed #d5dfe8; font-size: 12px; display: grid; gap: 3px; }
.hd-files .sub { color: var(--muted); }
.hd-msg-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
/* system events read as a timeline: icon dot on a rail, text beside it */
.hd-sys { display: grid; grid-template-columns: 22px minmax(0, 1fr); column-gap: 8px; align-items: start; font-size: 12px; color: #4a5f74; padding: 2px 0; position: relative; }
.hd-sys::before { content: ""; position: absolute; left: 10px; top: 0; bottom: 0; width: 2px; background: #e3eaf1; }
.hd-sys > i { position: relative; z-index: 1; width: 22px; height: 22px; border-radius: 50%; background: #eef3f8; border: 1px solid #d5dfe8; color: #5b7189; display: grid; place-items: center; font-size: 11px; }
.hd-sys .tx { min-width: 0; padding-top: 3px; overflow-wrap: anywhere; }
.hd-sys .tx > span:first-child { margin-right: 6px; }
.hd-sys .sub { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ---- reply box and macros */
.hd-macrobar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid #e6edf3; }
.hd-macrobar select { min-width: 0; max-width: 100%; flex: 1 1 220px; }
.hd-suggested { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; width: 100%; font-size: 12px; }
.hd-macroprev { width: 100%; background: #f4f9ff; border: 1px solid #c2d9f5; border-radius: 4px; padding: 8px 10px; font-size: 12px; }
.hd-macroprev ul { margin: 4px 0; padding-left: 18px; }
.hd-macroprev .sub { color: var(--muted); }
.hd-mode { display: flex; gap: 0; border: 1px solid #9fb2c6; border-radius: 3px; overflow: hidden; width: max-content; max-width: 100%; }
.hd-mode label { padding: 6px 12px; font-size: 12px; font-weight: 700; color: #2f5f88; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; background: #fff; }
.hd-mode label input { position: absolute; opacity: 0; pointer-events: none; }
.hd-mode label.on { background: var(--brand-primary); color: #fff; }
.hd-mode label.note.on { background: #d99a06; }
.hd-composer.is-note textarea { background: #fffaeb; border-color: #f1d49b; }
.hd-send { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---- related, tasks, side conversations */
.hd-rel { display: flex; flex-direction: column; gap: 2px; padding: 7px 0; border-bottom: 1px solid #edf2f6; font-size: 12.5px; color: #12385e; min-width: 0; flex: 1; }
.hd-rel span { font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hd-relrow { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.hd-relrow form { margin: 0; }
.hd-task { display: flex; gap: 8px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid #edf2f6; flex-wrap: wrap; }
.hd-task .body { flex: 1 1 200px; min-width: 0; font-size: 12.5px; }
.hd-task .sub { display: block; font-size: 11.5px; color: var(--muted); }
.hd-task.done b { text-decoration: line-through; color: var(--muted); }
.hd-task.late > i { color: #c32a43; }
.hd-task .bad, .hd-late td:first-child b { color: #c32a43; }
.hd-add { margin-top: 10px; }
.hd-add summary { list-style: none; cursor: pointer; width: max-content; }
.hd-add summary::-webkit-details-marker { display: none; }
.hd-add[open] summary { margin-bottom: 10px; }
.hd-side-conv { border: 1px solid #d5dfe8; border-radius: 4px; padding: 8px 10px; margin-bottom: 10px; }
.hd-side-conv.closed { opacity: .75; }
.hd-side-conv header { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.hd-side-conv header .sub { font-size: 11.5px; color: var(--muted); flex: 1 1 200px; }
.hd-side-conv header form { margin: 0 0 0 auto; }
.hd-sidemsg { border-left: 3px solid #c2d9f5; padding: 4px 8px; margin: 6px 0; font-size: 12.5px; }
.hd-sidemsg.in { border-left-color: #12a079; }
.hd-sidemsg .sub { font-size: 11px; color: var(--muted); }
.hd-sidereply { display: flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; }
.hd-sidereply textarea { flex: 1 1 220px; min-width: 0; }
.hd-hist td { vertical-align: top; }

/* ---- right column */
.hd-mini { display: flex; flex-direction: column; gap: 2px; padding: 7px 12px; border-bottom: 1px solid #edf2f6; font-size: 12.5px; color: #12385e; }
.hd-mini span { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.hd-mini.more { font-weight: 700; }
.hd-pick { position: relative; }
.hd-pick-results { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid #9fb2c6; border-radius: 4px; box-shadow: 0 6px 18px rgba(13, 38, 66, .14);
    max-height: 320px; overflow-y: auto; }
.hd-pick-results a { display: flex; gap: 8px; padding: 7px 10px; font-size: 12.5px; color: #12385e; border-bottom: 1px solid #edf2f6; }
.hd-pick-results a:hover, .hd-pick-results a:focus { background: #eef6ff; }
.hd-pick-results a span { min-width: 0; }
.hd-pick-results small { display: block; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.hd-pick-results .grp { font-size: 10.5px; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: 6px 10px 2px; background: #f7fafc; }
.hd-pick-results .none { padding: 8px 10px; font-size: 12px; color: var(--muted); }
.hd-dupes { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; }

/* ---- forms: new ticket, views, macros, calls */
.hd-fs { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; min-width: 0; }
.hd-fs legend { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 6px; padding: 0; }
.hd-fs + .hd-fs { border-top: 1px solid #e6edf3; padding-top: 12px; }
.hd-submit { display: flex; gap: 8px; }
.hd-steps { margin: 0; padding-left: 18px; font-size: 12.5px; display: grid; gap: 6px; }
.hd-condrow { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 6px; margin-bottom: 6px; align-items: center; }
@media (max-width: 640px) { .hd-condrow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .hd-condrow input { grid-column: 1 / -1; } }
.hd-conds .hd-cond, .hd-cond { display: inline-block; background: #eef3f8; border-radius: 3px; padding: 1px 6px; margin: 1px 3px 1px 0; font-size: 11.5px; color: #2f4559; }
.hd-conds .sub { display: block; font-size: 11px; color: var(--muted); }
.hd-pos { width: 70px; }
.hd-hints { font-size: 12px; margin-top: 10px; }
.hd-hints code { font-size: 11.5px; }
.hd-viewcount { font-size: 13px; }
.hd-viewcount b { font-size: 26px; display: block; }
.hd-viewsample { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: #2f4559; }
.hd-inlineform { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.hd-inlineform input { width: 120px; min-width: 0; }
.hd-statuslinks { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; margin-top: 8px; }
.hd-medians { margin-top: 12px; }
.hd-medians .sub { font-size: 11px; color: var(--muted); display: block; }

@media (max-width: 560px) {
    .hd-title { font-size: 16px; }
    .hd-tab { max-width: 160px; }
    .hd-bulk select, .hd-bulk input { max-width: 100%; flex: 1 1 100%; }
    .hd-macrobar select { flex-basis: 100%; }
    .hd-msg header time { margin-left: 0; width: 100%; }
}

/* ---- list cells that may wrap, so the whole row fits the panel at desktop widths */
.ct-tbl td.hd-who-cell { white-space: normal; min-width: 120px; max-width: 190px; }
.ct-tbl td.hd-who-cell .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hd-filters select.ct-input { width: auto; max-width: 190px; }
.hd-filters input[type=search].ct-input { width: 220px; max-width: 100%; }
.hd-list td, .hd-list th { padding-left: 8px; padding-right: 8px; }
@media (max-width: 560px) { .hd-filters select.ct-input, .hd-filters input[type=search].ct-input { max-width: 100%; flex: 1 1 100%; } }
.hd-pad { padding: 12px; display: grid; gap: 10px; border-top: 1px solid #e3eaf0; }
.ct-tbl td.hd-acts { white-space: normal; min-width: 96px; } .hd-acts .ct-btn, .hd-acts form { margin: 2px 0; }
.ct-input.hd-pos { width: 58px; min-width: 0; padding-left: 6px; padding-right: 4px; } .hd-viewgrid .ct-s8 .hd-qn .tb { width: 34px; } .hd-viewgrid .ct-tbl td, .hd-viewgrid .ct-tbl th { padding-left: 8px; padding-right: 8px; }
