/* RISEN IT Support — screens: dashboard, ticket lists, ticket detail, forms; plus pages restyled later (chat, inbox, admin). */

/* ---------- Dashboard: heat-map count grid ---------- */
.heat-card { padding: 0; overflow: hidden; }
.heat-card .card-head { padding: var(--sp-5) var(--sp-6) 0; margin-bottom: var(--sp-4); }
.heat-legend { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--text-muted); }
.heat-legend i { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }
.heat-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0 var(--sp-3) var(--sp-3); }
.table.counts { border-collapse: separate; border-spacing: 4px; min-width: 860px; font-size: var(--fs-13); table-layout: fixed; }
.table.counts th, .table.counts td { border: 0; padding: 0; }
.table.counts thead th { position: static; background: transparent; padding: 0 6px 6px; font-weight: 600; font-size: 11.5px; color: var(--text-muted); white-space: normal; vertical-align: bottom; line-height: 1.25; text-align: center; min-width: 84px; }
.table.counts thead th:first-child { text-align: left; width: 128px; }
.table.counts thead th:last-child { width: 72px; }
.table.counts thead th.num { text-align: center !important; }
.table.counts tbody tr:hover { background: transparent; }
.table.counts tbody th { text-align: left; font-weight: 600; font-size: var(--fs-13); padding: 0 var(--sp-3); white-space: nowrap; }
.table.counts tbody th a { color: var(--gray-900); }
.table.counts td.num { text-align: center !important; }
.heat {
  display: flex; align-items: center; justify-content: center; height: 42px; border-radius: 8px;
  font-weight: 600; font-variant-numeric: tabular-nums; color: var(--gray-800); background: var(--gray-25);
  border: 1px solid var(--gray-150); transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), outline-color var(--t);
}
a.heat:hover { text-decoration: none; box-shadow: var(--sh-md); transform: translateY(-1px); color: inherit; position: relative; z-index: 1; }
.heat-0 { color: var(--gray-400); background: var(--surface); border-style: dashed; font-weight: 500; }
.heat-1 { background: var(--blue-50); border-color: var(--blue-100); color: var(--blue-800); }
.heat-2 { background: var(--blue-100); border-color: var(--blue-200); color: var(--blue-800); }
.heat-3 { background: var(--blue-200); border-color: var(--blue-300); color: var(--blue-800); }
.heat-4 { background: var(--blue-300); border-color: var(--blue-300); color: var(--navy-900); }
.heat-5 { background: var(--blue-600); border-color: var(--blue-700); color: var(--white); }
.heat-total { background: transparent; border: 0; color: var(--gray-900); font-weight: 700; }
.table.counts tr.total th, .table.counts tr.total td { background: transparent; }
.table.counts tr.total .heat { background: var(--gray-100); border-color: var(--gray-200); color: var(--gray-900); font-weight: 700; }
.table.counts tr.total .heat-total { background: transparent; border: 0; }
.table.counts tr.total th { color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 11.5px; letter-spacing: .05em; }

/* ---------- Toolbar filters ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4); margin-bottom: var(--sp-4); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-sm);
}
.toolbar .tb-search { flex: 1 1 320px; min-width: 220px; }
.toolbar .tb-break { flex-basis: 100%; height: 0; }
.toolbar select, .toolbar input { min-height: 38px; font-size: var(--fs-13); }
.toolbar input[type="checkbox"] { min-height: 0; width: 16px; height: 16px; margin: 0; padding: 0; flex: none; }
.toolbar select { flex: 1 1 150px; width: auto; min-width: 0; max-width: 230px; }
.toolbar select[name="status"] { flex-grow: 1.6; max-width: 300px; }
.toolbar .tb-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px var(--sp-1); }
.toolbar .tb-actions { display: flex; gap: var(--sp-2); }
.toolbar .tb-break { margin: 0; }
.toolbar .btn-sm { min-height: 38px; }
.toolbar label.tb-field { display: contents; }

/* ---------- Ticket list rows ---------- */
.ticket-table td { padding-top: 13px; padding-bottom: 13px; }
.ticket-table .col-status { width: 1%; white-space: nowrap; }
.ticket-table .col-prio { width: 1%; white-space: nowrap; }
.ticket-table .col-updated { width: 1%; white-space: nowrap; }
.ticket-table td.col-updated { color: var(--text-muted); font-size: var(--fs-13); }
.ticket-table .col-person { max-width: 0; width: 20%; }
.ticket-table .cell-subject { width: 36%; }
.ticket-table .col-assignee { max-width: 0; width: 17%; }
.ticket-table td .badge[class*="status-"] { white-space: nowrap; }
.assignee { display: flex; align-items: center; gap: var(--sp-2); max-width: 100%; min-width: 0; color: var(--gray-800); font-size: var(--fs-13); }
.assignee span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assignee.none { color: var(--text-muted); }
.cell-mobile-only { display: none; }

@media (max-width: 760px) {
  .ticket-table thead { display: none; }
  .ticket-table, .ticket-table tbody, .ticket-table tr, .ticket-table td { display: block; width: 100%; max-width: none; }
  .ticket-table tr { position: relative; padding: var(--sp-4); border-bottom: 1px solid var(--border); }
  .ticket-table tbody tr:last-child { border-bottom: 0; }
  .ticket-table td, .ticket-table td.cell-subject, .ticket-table td.col-person { border: 0; padding: 0; max-width: none; }
  .ticket-table td.cell-subject { width: 100%; margin: 0 0 var(--sp-3); padding-right: 92px; }
  .ticket-table .t-meta { flex-wrap: wrap; white-space: normal; }
  .ticket-table .t-link { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: var(--fs-15); }
  .ticket-table td.col-person { width: 100%; margin-bottom: var(--sp-3); }
  .ticket-table td.col-status, .ticket-table td.col-prio, .ticket-table td.col-assignee { display: inline-flex; width: auto; margin-right: var(--sp-2); vertical-align: middle; }
  .ticket-table td.col-prio .sla { display: none; }
  .ticket-table td.col-updated { position: absolute; top: var(--sp-4); right: var(--sp-4); width: auto; font-size: var(--fs-12); }
  .cell-mobile-only { display: inline; }
  .toolbar select { flex: 1 1 calc(50% - 8px); max-width: none; }
  .toolbar .tb-search { flex-basis: 100%; }
  .toolbar .tb-actions { width: 100%; order: 5; }
  .toolbar .tb-actions .btn { flex: 1; }
}

/* ---------- Ticket detail ---------- */
.ticket-head { margin-bottom: var(--sp-6); }
.ticket-kicker { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; font-size: var(--fs-13); color: var(--text-muted); margin-bottom: var(--sp-2); }
.ticket-kicker .mono { color: var(--gray-700); font-weight: 600; }
.ticket-head h1 { font-size: var(--fs-24); line-height: 1.25; overflow-wrap: anywhere; margin-bottom: var(--sp-3); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-6); align-items: start; }
.detail-main { min-width: 0; }
.detail-side { position: sticky; top: calc(var(--topbar-h) + var(--sp-5)); display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.detail-side .card { margin-bottom: 0; padding: var(--sp-5); }
.desc-card .comment-head { margin-bottom: var(--sp-3); }
.thread-title { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin: var(--sp-8) 0 var(--sp-4); }
.thread-title h2 { font-size: var(--fs-15); font-weight: 600; display: flex; align-items: center; gap: var(--sp-2); }
.thread-title .count { font-size: var(--fs-12); color: var(--text-muted); font-weight: 500; }
.composer { margin-top: var(--sp-6); padding: 0; overflow: hidden; }
.composer-head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5) 0; }
.composer-head h2 { font-size: var(--fs-15); font-weight: 600; margin: 0; }
.composer form { padding: var(--sp-3) var(--sp-5) var(--sp-5); }
.composer textarea { min-height: 128px; border-radius: var(--r-md); }
.composer .field { margin-bottom: var(--sp-3); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-4); }
.composer-foot .hint { flex: 1 1 260px; }
.composer-foot .actions { margin-left: auto; }
.props-card h2 { font-size: var(--fs-13); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; margin: 0 0 var(--sp-4); display: flex; align-items: center; gap: var(--sp-2); }
.props-card .field { margin-bottom: var(--sp-3); }
.props-card .field > span { font-size: var(--fs-12); color: var(--text-muted); font-weight: 560; }
.props-card select { min-height: 36px; font-size: var(--fs-13); }
.props-card .btn-block { margin-top: var(--sp-2); }
.props-card .hint { display: block; margin-top: var(--sp-2); text-align: center; }
.props-divider { height: 1px; background: var(--border); margin: var(--sp-5) calc(var(--sp-5) * -1); }
.closed-note { display: flex; gap: var(--sp-3); align-items: flex-start; margin-top: var(--sp-6); }

@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr) 300px; gap: var(--sp-5); }
}
@media (max-width: 899px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-side { position: static; order: -1; }
  .ticket-head h1 { font-size: var(--fs-20); }
}

/* ---------- New ticket form ---------- */
.form-card { max-width: 860px; padding: 0; overflow: hidden; }
.form-section { padding: var(--sp-6); border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: 0; }
.form-section-search { padding-bottom: 0; }
.form-section-search + form .employee-picker { padding-top: var(--sp-2); }
.form-section-head { margin-bottom: var(--sp-4); }
.form-section-head h2 { font-size: var(--fs-15); font-weight: 600; margin-bottom: 2px; }
.form-section-head p { color: var(--text-muted); font-size: var(--fs-13); margin: 0; }
.form-card .form-actions { padding: var(--sp-4) var(--sp-6); margin: 0; background: var(--surface-sunken); border-top: 1px solid var(--border); }
.employee-picker select[size] { min-height: 220px; }
@media (max-width: 640px) {
  .form-section { padding: var(--sp-4); }
  .form-card .form-actions { padding: var(--sp-4); }
  .form-card .form-actions .btn { flex: 1; }
}

/* ---------- Inbox / admin (restyled in a later phase) ---------- */
.inbox-new { --b-bg: var(--blue-100); --b-fg: var(--blue-700); }
.inbox-converted { --b-bg: var(--green-50); --b-fg: var(--green-600); }
.inbox-dismissed { --b-bg: var(--slate-100); --b-fg: var(--slate-600); }
.table.responsive td .muted.small { display: block; }
@media (max-width: 640px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { border-bottom: 1px solid var(--border); padding: var(--sp-2) 0; }
  .table.responsive td { border: 0; padding: 6px var(--sp-4); }
  .table.responsive td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: .04em; font-weight: 600; }
  .table.responsive td.right { text-align: left; }
}

/* ---------- Group chat: messenger layout ---------- */
.chat { position: relative; display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 7rem); height: calc(100dvh - var(--topbar-h) - 7rem); min-height: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-sm); overflow: hidden; }
.chat-head { display: flex; gap: var(--sp-3); align-items: center; justify-content: space-between; flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.chat-head p { margin: 0; }
.chat-title { font-size: var(--fs-16); margin: 0; letter-spacing: -.01em; }
.chat-tabs { display: flex; gap: var(--sp-1); flex-wrap: wrap; padding: 3px; background: var(--chip-bg); border-radius: var(--r-full); }
.chat-tab { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 var(--sp-4); border-radius: var(--r-full); color: var(--text-subtle); font-weight: 600; font-size: var(--fs-13); }
.chat-tab:hover { color: var(--text); text-decoration: none; }
.chat-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--sh-sm); }
.chat-tab:focus-visible, .msg-actions button:focus-visible, .msg-quote:focus-visible, .chat-jump:focus-visible, .msg-thumb:focus-visible, .file-chip:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.chat-tab .nav-badge { position: static; }
.chat-members { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; }
.chat-search { display: flex; gap: var(--sp-2); }
.chat-search input { width: 15rem; min-height: 32px; }
.chat-results { max-height: 45%; overflow-y: auto; padding: var(--sp-2) var(--sp-4); border-bottom: 1px solid var(--border); background: var(--surface-sunken); }
.chat-results-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-1); }
.search-hit { padding: var(--sp-2) 0; border-top: 1px solid var(--border); }
.search-meta { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; font-size: var(--fs-13); }
.search-excerpt { font-size: var(--fs-14); overflow-wrap: anywhere; }
.chat-body { position: relative; flex: 1; min-height: 0; background: var(--chat-bg); }
.chat.dragging .chat-body { outline: 3px dashed var(--primary); outline-offset: -8px; }
.chat-scroll { position: absolute; inset: 0; overflow-y: auto; padding: var(--sp-3) var(--sp-4) var(--sp-4); overscroll-behavior: contain; scroll-behavior: smooth; }
.chat-older { text-align: center; margin-bottom: var(--sp-1); }
.chat-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; margin: var(--sp-12) auto 0; max-width: 28ch; color: var(--text-muted); font-size: var(--fs-14); }
.chat-empty[hidden] { display: none; }
.chat-empty strong { color: var(--text); font-size: var(--fs-15); }
.chat-empty-icon { width: 44px; height: 44px; padding: 10px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); margin-bottom: var(--sp-2); }
.day-sep { text-align: center; margin: var(--sp-4) 0 var(--sp-2); position: sticky; top: 0; z-index: 1; pointer-events: none; }
.day-sep span { display: inline-block; background: var(--chip-bg); color: var(--text-subtle); font-size: var(--fs-12); font-weight: 600; padding: 3px var(--sp-3); border-radius: var(--r-full); box-shadow: var(--sh-xs); }
.new-divider { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-3) 0; color: var(--danger); font-size: var(--fs-12); font-weight: 650; }
.new-divider::before, .new-divider::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: .45; }
.msg { display: flex; align-items: flex-end; gap: var(--sp-2); margin: var(--sp-3) 0 0; }
.msg.cont { margin-top: 2px; }
.msg.mine { justify-content: flex-end; }
.msg > .avatar, .avatar-gap { flex: none; width: 26px; height: 26px; align-self: flex-start; }
.bubble { max-width: min(75%, 620px); min-width: 5.5rem; background: var(--bubble-in); color: var(--text); border-radius: 16px; border-bottom-left-radius: 4px; padding: 7px 12px 5px; box-shadow: var(--sh-xs); overflow-wrap: anywhere; transition: box-shadow .3s; }
.msg.cont .bubble { border-top-left-radius: 6px; }
.msg.mine .bubble { background: var(--bubble-out); color: var(--bubble-out-text); border-bottom-left-radius: 16px; border-bottom-right-radius: 4px; }
.msg.mine.cont .bubble { border-top-right-radius: 6px; }
.msg.mine .bubble a { color: inherit; text-decoration: underline; }
.msg.flash .bubble { box-shadow: 0 0 0 3px var(--amber-300); }
.msg-head { display: flex; gap: var(--sp-2); align-items: center; font-size: var(--fs-12); margin-bottom: 2px; }
.msg-author { color: var(--primary); font-weight: 650; }
.msg-head .badge { font-size: 10.5px; padding: 1px 7px; }
.msg-text { font-size: var(--fs-14); line-height: 1.45; }
.msg-deleted { margin: 0; font-style: italic; color: var(--text-muted); font-size: var(--fs-13); }
.msg.deleted .bubble { background: transparent; border: 1px dashed var(--border-strong); box-shadow: none; color: var(--text-muted); }
.msg-quote { display: block; width: 100%; text-align: left; margin: 2px 0 6px; padding: 5px 9px; border: 0; border-left: 3px solid var(--primary); border-radius: 6px; background: rgba(127, 146, 190, .16); font: inherit; font-size: var(--fs-12); color: inherit; cursor: pointer; }
.msg-quote strong { display: block; color: var(--primary); }
.msg.mine .msg-quote strong { color: inherit; }
.msg-quote span { display: block; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-files { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: 6px; }
.msg-thumb { display: block; border-radius: 10px; }
.msg-thumb img { display: block; max-width: 240px; max-height: 190px; border-radius: 10px; object-fit: cover; background: var(--gray-200); }
.file-chip { display: inline-flex; gap: var(--sp-2); align-items: center; max-width: 100%; padding: 6px 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-md); font-size: var(--fs-13); }
.file-chip:hover { border-color: var(--primary); text-decoration: none; }
.file-chip .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-ticket { display: inline-block; margin-top: 4px; font-size: var(--fs-12); font-weight: 650; }
.msg-foot { display: flex; gap: var(--sp-3); justify-content: flex-end; align-items: center; flex-wrap: wrap; margin-top: 2px; font-size: 11px; color: var(--text-muted); }
.msg.mine .msg-foot { color: inherit; opacity: .8; }
.msg-actions { display: inline-flex; gap: var(--sp-3); opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
.msg-actions button, .msg-actions a { padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; border-radius: 4px; }
.msg-actions button:hover, .msg-actions a:hover { text-decoration: underline; }
.msg-system { text-align: center; margin: var(--sp-3) 0 0; }
.msg-system span { display: inline-block; color: var(--text-muted); font-size: var(--fs-12); padding: 2px var(--sp-3); }
.chat-jump { position: absolute; right: var(--sp-4); bottom: var(--sp-4); display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--sp-4); border: 0; border-radius: var(--r-full); background: var(--primary); color: var(--on-primary); font: inherit; font-weight: 650; font-size: var(--fs-13); box-shadow: var(--sh-lg); cursor: pointer; }
.chat-jump[hidden] { display: none; }
.chat-status, .chat-notice { position: absolute; top: var(--sp-3); left: 50%; transform: translateX(-50%); max-width: 90%; padding: 5px var(--sp-4); border-radius: var(--r-full); font-size: var(--fs-13); font-weight: 600; box-shadow: var(--sh-md); z-index: 2; }
.chat-status { background: var(--warning-soft); color: var(--warning); }
.chat-notice { top: 3rem; background: var(--navy-900); color: var(--white); }
.chat-skeleton { display: flex; flex-direction: column; gap: var(--sp-3); }
.chat-skeleton .sk-row { display: flex; align-items: flex-end; gap: var(--sp-2); }
.chat-skeleton .sk-row.mine { justify-content: flex-end; }
.sk-avatar { width: 26px; height: 26px; border-radius: 50%; flex: none; }
.sk-bubble { height: 38px; border-radius: 16px; }
.sk-bubble.w1 { width: 46%; } .sk-bubble.w2 { width: 62%; } .sk-bubble.w3 { width: 38%; }
.chat-composer { padding: var(--sp-3) var(--sp-4) var(--sp-2); padding-bottom: max(var(--sp-2), env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); }
.chat-row { display: flex; gap: var(--sp-2); align-items: flex-end; }
.chat-row textarea { flex: 1; min-height: 40px; max-height: 10rem; resize: none; border-radius: 20px; padding-top: 9px; padding-bottom: 9px; }
.chat-attach { border-radius: 50%; flex: none; cursor: pointer; }
.chat-send { border-radius: var(--r-full); flex: none; }
.chat-send:disabled { opacity: .5; cursor: not-allowed; }
.chat-error { margin-bottom: var(--sp-2); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-13); }
.chat-hint { display: flex; justify-content: space-between; gap: var(--sp-2); margin-top: var(--sp-1); }
.chat-reply { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); padding: 6px var(--sp-3); border-left: 3px solid var(--primary); border-radius: var(--r-sm); background: var(--primary-soft); font-size: var(--fs-13); }
.chat-reply-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-reply-text strong { margin-right: var(--sp-2); }
.chat-reply-text span { color: var(--text-muted); }
.chat-x { display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none; border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); cursor: pointer; }
.chat-x:hover { background: var(--surface-hover); color: var(--text); }
.chat-x:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.chat-pending { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.pending-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 96px; padding: 6px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-sunken); font-size: var(--fs-12); }
.pending-item img { width: 72px; height: 56px; object-fit: cover; border-radius: 4px; }
.pending-item .file-ext { margin: var(--sp-4) 0; }
.pending-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-remove { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; background: var(--navy-900); color: var(--white); }
.pending-remove:hover { background: var(--danger); color: var(--white); }
.chat-lightbox { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-3); padding: var(--sp-4); background: rgba(5, 10, 22, .9); }
.chat-lightbox[hidden] { display: none; }
.chat-lightbox img { max-width: 100%; max-height: 80vh; border-radius: var(--r-sm); background: var(--white); }
.chat-lightbox-bar { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; justify-content: center; color: var(--white); font-size: var(--fs-14); }
@media (hover: none) { .msg-actions { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat-scroll { scroll-behavior: auto; } }
@media (max-width: 800px) {
  .chat { height: calc(100vh - var(--topbar-h) - 4rem); height: calc(100dvh - var(--topbar-h) - 4rem); }
}
@media (max-width: 640px) {
  /* full-screen messenger: the chat is pinned between the top bar and the bottom of the screen, so the message box is always in view
     (it follows the on-screen keyboard where the browser supports interactive-widget=resizes-content) */
  .page-chat .content { padding: 0; }
  .page-chat .shell-footer { display: none; }
  .page-chat .chat { position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: 0; height: auto; min-height: 0; border: 0; border-radius: 0; box-shadow: none; z-index: 5; }
  .page-chat .chat-cards { display: none; }
  .chat-join-link { display: inline-flex; }
  .chat-head { padding: var(--sp-2) var(--sp-3); }
  .chat-search { flex: 1 1 100%; }
  .chat-search input { width: auto; flex: 1 1 0; min-width: 0; }
  .chat-search .btn { flex: none; }
  .chat-scroll { padding: var(--sp-2) var(--sp-3) var(--sp-3); }
  .bubble { max-width: 86%; }
  .msg-thumb img { max-width: 170px; max-height: 140px; }
  .chat-hint > span:first-child { display: none; }
  .chat-titlebox p, .chat-card-body p:not(.muted) { display: none; }
  .chat-card { padding: var(--sp-3) var(--sp-4); }
  .chat-send-label { display: none; }
  .chat-composer { padding-left: var(--sp-3); padding-right: var(--sp-3); }
}

/* Chat subscription (Phase 9B): subscribe cards, system lines */
.chat-cards { display: grid; gap: var(--sp-4); margin: var(--sp-4) 0; } /* shown below an open chat so the message box always fits on screen */
.chat + .chat-cards { margin-bottom: 0; }
.chat-cards:first-child { margin-top: 0; }
.chat-card { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; }
.chat-card-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--blue-100); color: var(--blue-800); flex: none; }
.chat-card-icon .icon { width: 22px; height: 22px; }
.chat-card-body { flex: 1 1 260px; min-width: 0; }
.chat-card-body h2 { margin: 0 0 var(--sp-1); font-size: var(--fs-16, 1rem); }
.chat-card-body p { margin: 0 0 var(--sp-1); }
.chat-titlebox { flex: 1 1 240px; min-width: 0; }
.chat-join-link { display: none; } /* phones only: the join cards are hidden under an open chat there */
fieldset.field .check { margin-bottom: var(--sp-2); }

/* ---------- Dashboard / list toolbars: date range, presets ---------- */
.date-range { display: flex; align-items: center; gap: var(--sp-2); flex: 0 1 410px; min-width: 0; padding: 0 var(--sp-3); min-height: 38px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); }
.dr-label { flex: none; font-size: var(--fs-12); font-weight: 650; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.date-range input[type="date"] { flex: 1 1 0; min-width: 0; width: auto; border: 0; background: transparent; min-height: 34px; padding: 0 2px; font-size: var(--fs-13); box-shadow: none; }
.date-range:focus-within { box-shadow: var(--focus-ring); border-color: var(--primary); }
@media (max-width: 640px) { .date-range { flex: 1 1 100%; max-width: none; flex-wrap: wrap; padding: 6px var(--sp-3); } .dr-label { flex: 1 1 100%; } }
.toolbar .check-inline { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 38px; padding: 0 var(--sp-3); border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); font-size: var(--fs-13); font-weight: 560; line-height: 1; cursor: pointer; white-space: nowrap; }
.toolbar .check-inline:has(input:checked) { border-color: var(--primary); background: var(--primary-softer); }
.toolbar .check-inline:focus-within { box-shadow: var(--focus-ring); }
.presets { display: inline-flex; align-items: center; gap: var(--sp-1); flex-wrap: wrap; margin-left: auto; }
.tb-ticket { width: 14rem; }

/* ---------- IT Inbox ---------- */
.inbox-table .cell-subject { min-width: 260px; }
.heartbeat { position: relative; align-self: center; }
.heartbeat > summary { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 32px; padding: 0 var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-full); background: var(--surface); font-size: var(--fs-13); font-weight: 560; color: var(--text-subtle); cursor: pointer; list-style: none; }
.heartbeat > summary::-webkit-details-marker { display: none; }
.heartbeat > summary:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.hb-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gray-400); flex: none; }
.heartbeat-green .hb-dot { background: var(--green-600); box-shadow: 0 0 0 3px var(--green-50); }
.heartbeat-amber .hb-dot { background: var(--amber-700); box-shadow: 0 0 0 3px var(--amber-75); }
.heartbeat-red .hb-dot { background: var(--red-500); box-shadow: 0 0 0 3px var(--red-50); }
.hb-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: min(380px, 86vw); padding: var(--sp-4); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--sh-lg); font-size: var(--fs-13); }
.hb-panel p { margin: 0; }
.side-panel { position: sticky; top: calc(var(--topbar-h) + var(--sp-4)); align-self: start; max-height: calc(100vh - var(--topbar-h) - var(--sp-8)); overflow-y: auto; }
.side-panel .h-sm { display: flex; align-items: center; gap: var(--sp-2); }
@media (max-width: 899px) { .side-panel { position: static; max-height: none; } }

/* ---------- Users, import, audit ---------- */
.users-table .inactive .person-name { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--gray-400); }
.audit-table td.small { max-width: 38ch; overflow-wrap: anywhere; color: var(--text-subtle); }
.secret-card { border-color: var(--green-200); background: var(--surface); margin-bottom: var(--sp-5); }
.secret-head { display: flex; gap: var(--sp-4); align-items: flex-start; }
.secret-head h2 { margin: 0 0 2px; font-size: var(--fs-16); }
.secret-head p { margin: 0; }
.secret-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--green-50); color: var(--green-700); }
.secret-warning { margin: var(--sp-4) 0 var(--sp-3); }
.cred { display: grid; grid-template-columns: 11rem minmax(0, 1fr) auto; gap: var(--sp-3); align-items: center; padding: var(--sp-2) 0; border-top: 1px solid var(--border); }
.cred dt { font-size: var(--fs-13); color: var(--text-muted); font-weight: 600; }
.cred dd { margin: 0; overflow-wrap: anywhere; }
.cred .copyable { font-size: var(--fs-15); letter-spacing: .02em; }
.btn.is-copied { color: var(--success); }
@media (max-width: 640px) { .cred { grid-template-columns: 1fr auto; } .cred dt { grid-column: 1 / -1; } }
.notice-once { display: flex; align-items: center; gap: var(--sp-2); margin: 0; font-size: var(--fs-13); color: var(--amber-800); }
.pw-cell { display: inline-flex; align-items: center; gap: var(--sp-2); }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: var(--sp-8) var(--sp-4); border: 2px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-sunken); text-align: center; cursor: pointer; transition: border-color var(--t) var(--ease), background var(--t) var(--ease); }
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: var(--primary-softer); }
.dropzone:focus-within { border-color: var(--primary); box-shadow: var(--focus-ring); }
.dropzone.has-file { border-style: solid; border-color: var(--green-600); }
.dropzone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-icon { width: 36px; height: 36px; color: var(--primary); }
.dropzone-title { font-weight: 650; }
.dropzone-link { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.dropzone-hint { font-size: var(--fs-13); color: var(--text-muted); }
.dropzone-file { font-size: var(--fs-13); font-weight: 650; color: var(--success); min-height: 1.2em; }

/* ---------- Print: the ticket page on paper ---------- */
.print-only { display: none; }
.ticket-head { position: relative; }
.ticket-print { position: absolute; top: 0; right: 0; }
@media (max-width: 640px) { .ticket-print { display: none; } }
@media print {
  @page { margin: 14mm; }
  .app-body, .app-body.sidebar-collapsed { background: #fff !important; }
  .sidebar, .drawer-overlay, .topbar, .shell-footer, .toasts, .skip-link, .composer, .btn, .form-actions, .tl-actions, .side-panel form, .pager, .toolbar, .theme-toggle { display: none !important; }
  .shell-main, .sidebar-collapsed .shell-main { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none !important; }
  .print-only { display: block; margin-bottom: 8mm; font-weight: 700; font-size: 14pt; }
  .detail-grid { display: block !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; background: #fff !important; color: #000 !important; }
  body, .content, .card, .prose { color: #000 !important; background: #fff !important; }
  a { color: #000 !important; text-decoration: none !important; }
  .timeline { break-inside: auto; }
  .tl-item, .tl-event { break-inside: avoid; }
}

/* ---------- IT ticket table (dashboard): compact columns, sortable headers, ETA, overdue rows ---------- */
.it-table { min-width: 1000px; }
.it-table .cell-label, .it-table .cell-mobile-badge { display: none; }
.it-table td { padding-top: 11px; padding-bottom: 11px; vertical-align: middle; }
.it-table .col-no, .it-table .col-portal, .it-table .col-status, .it-table .col-prio, .it-table .col-date, .it-table .col-eta, .it-table .col-updated { white-space: nowrap; }
.it-table .col-no { width: 1%; }
.it-table .col-subject { min-width: 220px; max-width: 300px; }
.it-table .t-link { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text); }
.it-table .t-link:hover { color: var(--primary); }
.it-table .col-person { max-width: 170px; }
.it-table .col-assignee { max-width: 130px; }
.it-table td.col-date, .it-table td.col-updated { font-size: var(--fs-13); color: var(--text-subtle); }
.it-table td.col-date .t { color: var(--text-muted); }
.sort-link { display: inline-flex; align-items: center; gap: 4px; color: inherit; font: inherit; }
.sort-link:hover { color: var(--primary); text-decoration: none; }
.sort-link.is-active { color: var(--primary); }
.sort-link .sort-asc { transform: rotate(180deg); }
.eta { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-13); line-height: 1.3; }
.eta .t, .eta-rel { color: var(--text-muted); font-size: var(--fs-12); }
.eta.is-overdue .eta-rel { color: var(--danger); font-weight: 650; }
.eta-rel.is-met { color: var(--success); font-weight: 600; }
.eta-rel.is-late { color: var(--danger); font-weight: 600; }
.badge-overdue { --b-bg: var(--red-50); --b-fg: var(--red-800); gap: 4px; align-self: flex-start; }
.it-table tr.is-overdue > td:first-child { box-shadow: inset 3px 0 0 var(--red-500); }
.it-table tr.is-overdue { background: color-mix(in srgb, var(--danger-soft) 45%, transparent); }
@media (max-width: 899px) {
  .it-table { min-width: 0; }
  .it-table thead { display: none; }
  .it-table, .it-table tbody, .it-table tr, .it-table td { display: block; width: 100%; max-width: none; }
  .it-table tr { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 6px var(--sp-3); padding: var(--sp-4); border-bottom: 1px solid var(--border); }
  .it-table td { border: 0; padding: 0; white-space: normal; }
  .it-table td.col-no, .it-table td.col-subject, .it-table td.col-person { grid-column: 1 / -1; }
  .it-table td.col-subject { max-width: none; }
  .it-table .cell-label, .it-table .cell-mobile-badge { display: inline; font-size: var(--fs-12); color: var(--text-muted); }
  .it-table .cell-mobile-badge { margin-left: var(--sp-2); }
  .it-table td.col-eta .cell-label, .it-table td.col-date .cell-label, .it-table td.col-updated .cell-label { display: block; }
  .it-table tr.is-overdue > td:first-child { box-shadow: none; }
  .it-table tr.is-overdue { box-shadow: inset 3px 0 0 var(--red-500); }
}
.secret-card dl { margin: 0; }
.dropzone { margin-bottom: var(--sp-4); }
.form .actions { margin-bottom: var(--sp-5); }

/* ---------- "More filters" and tickets per page ---------- */
.more-filters-btn { min-height: 38px; }
.count-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 2px; border-radius: var(--r-full); background: var(--primary); color: var(--on-primary); font-size: 11px; font-weight: 700; line-height: 1; }
.more-panel { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); margin-top: var(--sp-1); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.more-panel[hidden] { display: none; }
.per-page { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-13); color: var(--text-muted); }
.per-page select { width: auto; min-height: 32px; font-size: var(--fs-13); }

/* ---------- Help page ---------- */
.help-nav { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.help-nav a { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-full); background: var(--surface); color: var(--text); font-size: var(--fs-13); font-weight: 600; }
.help-nav a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.help-card { margin-bottom: var(--sp-5); scroll-margin-top: calc(var(--topbar-h) + var(--sp-4)); }
.help-card h2 { margin-top: 0; }
.help-card h3 { margin: var(--sp-6) 0 var(--sp-2); font-size: var(--fs-16); }
.help-card h3:first-of-type { margin-top: var(--sp-4); }
.help-card ol, .help-card ul { padding-left: 1.3rem; margin: 0 0 var(--sp-3); }
.help-card li { margin-bottom: var(--sp-2); line-height: 1.55; }
.help-status li { margin-bottom: var(--sp-1); }
.help-note { display: flex; gap: var(--sp-2); align-items: flex-start; margin: var(--sp-4) 0 0; font-size: var(--fs-13); color: var(--text-muted); }
.help-tablist { display: inline-flex; max-width: 100%; gap: 2px; padding: 3px; margin: var(--sp-3) 0; background: var(--chip-bg); border-radius: var(--r-full); flex-wrap: wrap; }
.help-tablist[hidden] { display: none; }
.help-tablist [role="tab"] { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 var(--sp-4); border: 0; border-radius: var(--r-full); background: transparent; color: var(--text-subtle); font: inherit; font-size: var(--fs-13); font-weight: 600; cursor: pointer; }
.help-tablist [role="tab"][aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--sh-sm); }
.help-tablist { border-radius: var(--r-lg); }
.help-tablist [role="tab"]:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.help-panel[hidden] { display: none; }
.faq details { border-top: 1px solid var(--border); padding: var(--sp-3) 0; }
.faq details:last-child { border-bottom: 1px solid var(--border); }
.faq summary { cursor: pointer; font-weight: 600; list-style-position: outside; }
.faq summary:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
.faq details > p, .faq details > ul { margin: var(--sp-2) 0 0; color: var(--text-subtle); }
