/* ==========================================================================
   Support Dashboard — "Daylight Desk" design (teal accent, Plus Jakarta Sans)
   Light by default with a matching dark theme. All class and id hooks used by
   app.js / index.html are preserved; this file is the single source of truth
   for the visual design (no stacked override layers).
   ========================================================================== */

:root {
  /* ============ Dark theme — low-glare, same layout and accent family ============ */
  --bg: #0f1417; /* app canvas */
  --surface: #171d21; /* cards, sidebar, header */
  --surface-2: #1b2226; /* subtle inset surfaces */
  --surface-3: #232b31; /* hover / tracks */
  --input-bg: #12181b; /* form fields */
  --chat-bg: #13191c; /* conversation background */
  --border: #2a3238;
  --border-strong: #36414a;
  --text: #e8edf1; /* primary text */
  --text-2: #b9c2ca; /* secondary text */
  --muted: #93a0ab; /* meta text */
  --faint: #6b7782; /* placeholder / axis text */

  --brand: #2dd4bf; /* teal accent (lightened for dark bg) */
  --brand-hover: #5eead4;
  --brand-soft: rgba(45, 212, 191, 0.12);
  --brand-border: rgba(45, 212, 191, 0.32);
  --on-brand: #062a26; /* text/icons on a solid accent fill */
  --pill-text: #0f1417; /* text on solid status pills (light accents here) */

  --blue: #7fb0ff;
  --blue-soft: rgba(46, 110, 255, 0.14);
  --blue-border: rgba(80, 140, 255, 0.35);
  --green: #54d98c;
  --green-soft: rgba(34, 197, 94, 0.13);
  --green-border: rgba(52, 211, 153, 0.32);
  --amber: #f5b94d;
  --amber-soft: rgba(245, 158, 11, 0.13);
  --amber-border: rgba(245, 158, 11, 0.32);
  --red: #ff9b9b;
  --red-soft: rgba(239, 68, 68, 0.14);
  --red-border: rgba(248, 113, 113, 0.34);
  --violet: #c9a3ff;
  --violet-soft: rgba(168, 85, 247, 0.13);
  --violet-border: rgba(192, 132, 252, 0.32);
  --gray-soft: #232b31;
  --gray-border: #36414a;

  --radius: 12px;
  --radius-sm: 9px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.45);
  --focus: 0 0 0 3px rgba(45, 212, 191, 0.25);

  --topbar-h: 58px;
  --viewnav-w: 84px;
}

:root[data-theme="light"] {
  /* ============ Light theme (default) ============ */
  --bg: #f4f6f8; /* app canvas — soft, cool gray */
  --surface: #ffffff; /* cards, sidebar, header */
  --surface-2: #f7f8fa; /* subtle inset surfaces */
  --surface-3: #eef1f4; /* hover / tracks */
  --input-bg: #ffffff; /* form fields */
  --chat-bg: #fafbfc; /* conversation background */
  --border: #e3e7ec;
  --border-strong: #d3d9e0;
  --text: #18212b; /* primary text */
  --text-2: #3d4754; /* secondary text */
  --muted: #5d6876; /* meta text */
  --faint: #8a94a2; /* placeholder / axis text */

  --brand: #0f766e; /* teal accent */
  --brand-hover: #115e59;
  --brand-soft: #ecf8f5;
  --brand-border: #cfe9e3;
  --on-brand: #ffffff;
  --pill-text: #ffffff; /* text on solid status pills (dark accents here) */

  --blue: #1d4ed8;
  --blue-soft: #eef4ff;
  --blue-border: #c7dbff;
  --green: #15803d;
  --green-soft: #effaf3;
  --green-border: #bfe6cd;
  --amber: #9a4a06;
  --amber-soft: #fff4e5;
  --amber-border: #f5dcae;
  --red: #b42318;
  --red-soft: #fdecec;
  --red-border: #f5c1bc;
  --violet: #6d28d9;
  --violet-soft: #f6f1fe;
  --violet-border: #ddd0f7;
  --gray-soft: #f1f3f6;
  --gray-border: #dde1e7;

  --shadow-sm: 0 1px 2px rgba(23, 28, 38, 0.05);
  --shadow-md: 0 4px 14px rgba(23, 28, 38, 0.08);
  --shadow-lg: 0 16px 44px rgba(23, 28, 38, 0.16);
  --focus: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Icons (inline SVG sprite) ---------- */
.ic {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ic-sm {
  width: 14px;
  height: 14px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.2;
  font-family: inherit;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  white-space: nowrap;
}
.btn:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn:active {
  background: var(--surface-3);
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  color: var(--on-brand);
}
.btn-danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.btn-danger:hover {
  background: #9a1c13;
  border-color: #9a1c13;
  color: #fff;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover {
  background: var(--surface-3);
  border-color: transparent;
  color: var(--text);
}
.btn-subtle {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--muted);
}
.btn-subtle:hover {
  background: var(--surface-3);
  color: var(--text);
}
.btn-sm {
  padding: 4px 10px;
  font-size: 12.5px;
}
.btn-ai {
  background: var(--surface);
  border-color: var(--brand-border);
  color: var(--brand);
}
.btn-ai:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-hover);
}

/* ---------- Inputs ---------- */
.input {
  width: 100%;
  padding: 7px 10px;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  font-family: inherit;
  font-size: 14px;
  transition: border-color .12s, box-shadow .12s;
}
.input::placeholder {
  color: var(--faint);
}
.input:focus {
  border-color: var(--brand);
  box-shadow: var(--focus);
}
select.input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236f7a8a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 28px;
}

/* ---------- Topbar ---------- */
.topbar {
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) calc(18px + env(safe-area-inset-right, 0px)) 0
    calc(18px + env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -.01em;
  color: var(--text);
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: var(--on-brand);
}
.brand-mark .ic {
  width: 17px;
  height: 17px;
}
.brand-sub {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--muted);
  margin-left: 2px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.me-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-2);
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  object-fit: cover;
}
.avatar-lg {
  width: 44px;
  height: 44px;
}
.conn {
  color: var(--faint);
  font-size: 12px;
}
.conn.online {
  color: var(--green);
}
.conn.offline {
  color: var(--red);
}
.topbar .btn {
  height: 34px;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(320px, 370px) 1fr;
  height: calc(100vh - var(--topbar-h) - env(safe-area-inset-top, 0px));
  height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top, 0px));
}
.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

/* ---------- Filters ---------- */
.filters {
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.search-wrap {
  position: relative;
}
.search-wrap .ic {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}
.search-wrap .input {
  padding-left: 32px;
  height: 34px;
}
.filters-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.filter-field > span {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.filter-field .input {
  height: 30px;
  font-size: 12.5px;
}
/* status tabs: one tidy segmented row instead of wrapping pills */
.pill-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.pill {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 5px 2px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 550;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .12s, color .12s;
}
.pill:hover {
  background: var(--surface-3);
  color: var(--text);
}
.pill.active {
  background: var(--brand-soft);
  color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand-border);
}

/* ---------- Ticket list ---------- */
.ticket-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 10px;
}
.ticket-item {
  position: relative;
  padding: 10px 12px 10px 15px;
  margin-bottom: 6px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
/* One dominant colour signal per row: a slim left accent bar.
   (urgent < new < replied < on hold — later rules win on ties.) */
.ticket-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 0 3px 3px 0;
  background: transparent;
  transition: background .12s;
}
/* attention rows are unmistakable: tinted background + glowing bar */
.ticket-item.attn-new {
  background: var(--blue-soft);
  border-color: var(--blue-border);
}
.ticket-item.attn-reply {
  background: var(--amber-soft);
  border-color: var(--amber-border);
}
.ticket-item.on-hold-row {
  background: var(--violet-soft);
  border-color: var(--violet-border);
}
.ticket-item.priority-urgent::before {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
}
.ticket-item.attn-new::before {
  background: var(--blue);
  box-shadow: 0 0 8px var(--blue);
}
.ticket-item.attn-reply::before {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}
.ticket-item.on-hold-row::before {
  background: var(--violet);
}
.ticket-item.attn-new .subject,
.ticket-item.attn-reply .subject {
  font-weight: 700;
}
.ticket-item.attn-new .preview .p-text,
.ticket-item.attn-reply .preview .p-text {
  color: var(--text-2);
}
.ticket-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.ticket-item.selected {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  box-shadow: var(--shadow-sm);
}
.ticket-item.selected::before {
  background: var(--brand);
}
/* closed/deleted: quietly de-emphasised so the live queue pops */
.ticket-item.closed-row,
.ticket-item.deleted-row {
  opacity: 0.72;
}
.ticket-item .row1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.ticket-item .row1 .r1-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.ticket-item .row1 .r1-left > * {
  flex: 0 0 auto;
}
.ticket-item .num {
  font-weight: 650;
  font-size: 12.5px;
  color: var(--text);
}
.ticket-item .t-time {
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* tiny status dot: open/claimed/hold/closed/deleted */
.sdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}
.sdot.open {
  background: var(--blue);
}
.sdot.claimed {
  background: var(--amber);
}
.sdot.hold {
  background: var(--violet);
}
.sdot.closed {
  background: var(--faint);
}
.sdot.deleted {
  background: var(--red);
}
.ticket-item .subject {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticket-item .preview {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
}
.ticket-item .p-opener {
  font-weight: 600;
  color: var(--text-2);
  flex: 0 0 auto;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ticket-item .p-sep {
  color: var(--faint);
  flex: 0 0 auto;
}
.ticket-item .p-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.ticket-item .t-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
/* priority + tags: tiny, quiet, uppercase — never a second colour stack */
.plabel {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.plabel.urgent {
  color: var(--red);
}
.plabel.high {
  color: var(--amber);
}
.plabel.low {
  color: var(--muted);
}
.ticket-item .tag-chip {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--gray-soft);
  color: var(--muted);
  border: 1px solid var(--gray-border);
}
.ticket-item.selected .num {
  color: var(--brand);
}

/* attention pills — SOLID and loud: new/replied/unread must be seen instantly */
.attn-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: .04em;
  white-space: nowrap;
  line-height: 1.6;
  border: 1px solid transparent;
}
.attn-pill.new {
  background: var(--blue);
  color: var(--pill-text);
  border-color: var(--blue);
}
.attn-pill.reply {
  background: var(--amber);
  color: var(--pill-text);
  border-color: var(--amber);
}
.attn-pill.unread {
  background: var(--red);
  color: var(--pill-text);
  border-color: var(--red);
}

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2.5px 9px;
  border-radius: 999px;
  letter-spacing: .02em;
  border: 1px solid transparent;
  text-transform: capitalize;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.open {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: var(--blue-border);
}
.badge.claimed {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: var(--amber-border);
}
.badge.on-hold {
  background: var(--violet-soft);
  color: var(--violet);
  border-color: var(--violet-border);
}
.badge.closed {
  background: var(--gray-soft);
  color: var(--muted);
  border-color: var(--gray-border);
}
.badge.deleted {
  background: var(--red-soft);
  color: var(--red);
  border-color: var(--red-border);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 550;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--gray-soft);
  color: var(--text-2);
  border: 1px solid var(--gray-border);
}
.chip.priority-chip {
  text-transform: capitalize;
}
.priority-chip.urgent {
  background: var(--red-soft);
  color: var(--red);
  border-color: var(--red-border);
}
.priority-chip.high {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: var(--amber-border);
}
.priority-chip.normal {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: var(--blue-border);
}
.priority-chip.low {
  background: var(--gray-soft);
  color: var(--muted);
  border-color: var(--gray-border);
}
.tag-chip {
  background: var(--green-soft);
  color: var(--green);
  border-color: var(--green-border);
}
.csat-chip {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: var(--amber-border);
  font-weight: 600;
}
.timing-chip {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--border);
  font-variant-numeric: tabular-nums;
}
.presence-chip {
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
}

/* ---------- Empty state ---------- */
.empty {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
}
.empty-icon .ic {
  width: 28px;
  height: 28px;
  color: var(--faint);
}
.empty p {
  margin: 0;
  font-size: 14px;
  text-align: center;
}

/* ---------- Ticket view ---------- */
.ticket-view {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.drop-overlay {
  position: absolute;
  inset: 12px;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.88);
  border: 2px dashed var(--brand-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(3px);
  pointer-events: none;
}
.drop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px 38px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.drop-card .ic {
  width: 34px;
  height: 34px;
  color: var(--brand);
  margin-bottom: 4px;
}
.drop-card strong {
  font-size: 16px;
}
.drop-card small {
  color: var(--muted);
}

.ticket-header {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  padding: 16px 20px 13px;
  gap: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.ticket-title h2 {
  margin: 0 0 7px;
  font-size: 17.5px;
  font-weight: 650;
  letter-spacing: -.01em;
}
.ticket-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ticket-sub .muted {
  font-size: 12.5px;
}
.ticket-primary-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.ticket-primary-actions .btn,
.ticket-primary-actions .input {
  height: 34px;
}
.assign {
  width: auto;
  min-width: 150px;
}
.priority-select {
  width: auto;
  min-width: 130px;
}
.known-issue-select {
  width: 100%;
  max-width: none;
}

.ticket-workflow {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  min-width: 0;
}
.workflow-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.workflow-field > span {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.workflow-field .btn,
.workflow-field .input,
.ticket-workflow > .btn {
  height: 32px;
  padding-top: 5px;
  padding-bottom: 5px;
}
.workflow-issue {
  flex: 1 1 230px;
  max-width: 330px;
}

.action-menu {
  position: relative;
}
.action-menu > summary {
  list-style: none;
  display: flex;
  align-items: center;
  user-select: none;
}
.action-menu > summary::-webkit-details-marker {
  display: none;
}
.action-menu-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 30;
}
.action-menu-popover .btn {
  width: 100%;
  height: auto;
  text-align: left;
  justify-content: flex-start;
  background: transparent;
  border-color: transparent;
}
.action-menu-popover .btn:hover {
  background: var(--surface-3);
}
.action-menu-popover .btn-danger {
  color: var(--red);
}
.action-menu-popover .btn-danger:hover {
  background: var(--red-soft);
}

/* ---------- Conversation (thread style) ---------- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px clamp(18px, 4vw, 46px) 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}
.msg {
  display: flex;
  gap: 11px;
  max-width: 860px;
}
.msg .m-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
}
.msg .m-body {
  min-width: 0;
  flex: 1;
  max-width: min(720px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 13px 10px;
}
.msg.staff .m-body {
  background: var(--brand-soft);
  border-color: var(--brand-border);
}
.msg .m-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.msg .m-name {
  font-weight: 650;
  font-size: 13px;
  color: var(--text);
}
.msg.staff .m-name {
  color: var(--brand);
}
.msg .m-time {
  font-size: 11.5px;
  color: var(--faint);
}
.msg .m-text {
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 3px;
  font-size: 13.5px;
  line-height: 1.55;
}
.msg .m-attach a {
  color: var(--brand);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  text-decoration: none;
}
.msg .m-attach a:hover {
  text-decoration: underline;
}
.msg .m-img {
  display: inline-block;
  margin-top: 7px;
}
.msg .m-img img {
  max-width: 320px;
  max-height: 260px;
  border-radius: var(--radius-sm);
  display: block;
  border: 1px solid var(--border);
}
.translate-btn {
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 0;
  font-family: inherit;
}
.translate-btn:hover {
  color: var(--brand);
}
.translation {
  margin-top: 7px;
  padding: 8px 11px;
  border-left: 3px solid var(--brand);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
}
.translation .t-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}

/* system event lines */
.msg-system {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 3px 0;
}
.msg-system .sys-text {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 12px;
  border-radius: 999px;
  display: inline-block;
}
.msg-system .sys-time {
  font-size: 10.5px;
  color: var(--faint);
  margin-left: 5px;
}

/* per-message delete (admin) */
.msg {
  position: relative;
}
.msg-del-btn {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  opacity: 0;
  transition: opacity .12s;
  z-index: 2;
}
.msg:hover .msg-del-btn {
  opacity: 1;
}
.msg-del-btn:hover {
  color: var(--red);
  border-color: var(--red-border);
  background: var(--red-soft);
}

/* clickable user names */
.m-name.clickable,
.user-link {
  cursor: pointer;
}
.m-name.clickable:hover,
.user-link:hover {
  text-decoration: underline;
  color: var(--brand);
}

/* ---------- Reply bar ---------- */
.reply-bar {
  display: flex;
  gap: 9px;
  padding: 12px 20px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: flex-end;
}
.reply-bar.disabled {
  opacity: 0.5;
  pointer-events: none;
}
.reply-input {
  flex: 1;
  resize: none;
  max-height: 160px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  outline: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  min-height: 38px;
}
.reply-input:focus {
  border-color: var(--brand);
  box-shadow: var(--focus);
}
.reply-icon {
  height: 38px;
  width: 40px;
  padding: 0;
}
#reply-send {
  height: 38px;
  padding: 0 18px;
}
.staged-file {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 20px;
  padding: 6px 11px;
  background: var(--surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 13px;
  color: var(--text);
  border-bottom: none;
}
.staged-file button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  padding: 2px 4px;
}
.staged-file button:hover {
  color: var(--red);
}
.staged-preview {
  width: 64px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
#staged-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
#staged-replace {
  margin-left: auto;
  padding: 4px 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
#staged-remove {
  margin-left: 0;
  font-size: 14px;
}

/* ---------- AI tools ---------- */
.ai-tools {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 20px 0;
  flex-wrap: wrap;
}
.ai-tools .btn {
  height: 30px;
  padding: 0 11px;
  font-size: 12.5px;
}
.lang-indicator {
  font-size: 12px;
  color: var(--muted);
}
.rewrite-preview {
  margin: 8px 20px 0;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius);
}
.rewrite-preview .rp-head {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
}
.rewrite-preview .rp-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.5px;
  margin-bottom: 9px;
  line-height: 1.55;
}
.rewrite-preview .rp-actions {
  display: flex;
  gap: 8px;
}

/* ---------- Private per-ticket notes ---------- */
.ticket-notes-panel {
  margin: 12px 20px 0;
  padding: 13px 15px;
  max-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--amber-soft);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius);
}
.tn-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.tn-head > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.tn-head strong {
  font-size: 13px;
  color: var(--amber);
}
.tn-head small {
  color: var(--amber);
  opacity: 0.8;
}
.ticket-notes-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  min-height: 0;
}
.ticket-note {
  padding: 8px 11px;
  background: rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.45;
  border: 1px solid rgba(245, 220, 174, 0.6);
}
.ticket-note-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
  color: var(--amber);
  font-size: 11px;
  font-weight: 600;
}
.ticket-note-meta span {
  color: var(--muted);
  font-weight: 400;
}
.ticket-note-meta button {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.ticket-note-meta button:hover {
  color: var(--red);
}
.ticket-note-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.ticket-note-form textarea {
  resize: none;
  min-height: 40px;
}

/* ---------- Notification banner ---------- */
.notif-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 18px;
  background: var(--blue-soft);
  border-bottom: 1px solid var(--blue-border);
  color: var(--text-2);
  font-size: 13.5px;
}
.notif-banner .nb-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--blue-border);
  color: var(--blue);
}
.notif-banner .nb-text {
  flex: 1 1 200px;
  min-width: 0;
}
.notif-banner .nb-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.notif-on {
  color: var(--green) !important;
}

/* ---------- Toasts ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #232a35;
  color: #f4f5f7;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 120;
  font-size: 13.5px;
  max-width: min(460px, 92vw);
  text-align: center;
  line-height: 1.45;
}
.toast.err {
  background: var(--red);
}

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 34, 46, 0.45);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 16px;
}
.modal-card {
  background: var(--surface);
  width: min(560px, 94vw);
  max-height: 88vh;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head .u-id {
  flex: 1;
  min-width: 0;
}
.modal-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 9px;
}
.modal-head .ic {
  color: var(--brand);
}
.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}
.modal-body h4 {
  margin: 0 0 8px;
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

.note-form {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.note {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 13.5px;
  border-left: 3px solid var(--amber);
}
.note .note-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}
.note .note-del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}
.note .note-del:hover {
  color: var(--red);
}
.note-text {
  white-space: pre-wrap;
  word-break: break-word;
}
.empty-note {
  color: var(--muted);
  font-size: 13px;
  padding: 4px 0;
}

.user-tickets {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.uticket {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.uticket:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.uticket .ut-subj {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}
.u-lang-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.u-lang-row .input {
  width: auto;
  min-width: 160px;
}

/* ---------- Settings modal ---------- */
.settings-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.s-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.s-row {
  display: flex;
  gap: 8px;
}
.s-row .input {
  flex: 1;
}
.s-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13.5px;
  cursor: pointer;
}
.s-check input {
  accent-color: var(--brand);
  width: 15px;
  height: 15px;
}
.ac-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.s-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 13px;
}
.s-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0 14px;
}
.s-head {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 650;
}
.dept-note {
  font-size: 12.5px;
  margin: 2px 0 10px;
  color: var(--muted);
  line-height: 1.5;
}
.dept-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.dept-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.dept-emoji {
  width: 54px;
  text-align: center;
  flex: 0 0 auto;
}
.dept-row .d-label {
  flex: 1;
  min-width: 80px;
}
.dept-row .d-desc {
  flex: 1.4;
  min-width: 80px;
}
.dept-row .btn {
  padding: 6px 9px;
}
.dept-add {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.dept-add .input {
  flex: 1;
}
.dept-desc-add {
  margin-top: 6px;
}
.canned-select {
  width: auto;
  max-width: 200px;
}
.canned-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.canned-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
}
.canned-row .c-title {
  font-weight: 600;
  font-size: 13px;
}
.canned-row textarea {
  resize: vertical;
  min-height: 44px;
}
.canned-row .c-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.canned-add {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

/* ---------- Analytics ---------- */
.analytics-card {
  width: min(680px, 96vw);
}
.an-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.an-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.an-card .an-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.an-card .an-lbl {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.an-section {
  margin-top: 16px;
}
.an-section h4 {
  margin: 0 0 8px;
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.an-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  font-size: 13px;
}
.an-bar .an-bl {
  width: 130px;
  flex: 0 0 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-2);
}
.an-bar .an-track {
  flex: 1;
  background: var(--surface-3);
  border-radius: 5px;
  height: 14px;
  overflow: hidden;
}
.an-bar .an-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 5px;
}
.an-bar .an-n {
  width: 34px;
  text-align: right;
  flex: 0 0 34px;
  color: var(--muted);
  font-size: 12.5px;
}
.an-hours {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 70px;
}
.an-hours .an-hr {
  flex: 1;
  background: var(--brand);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  opacity: 0.85;
}
.an-hours .an-hr:hover {
  opacity: 1;
}
.an-hours-axis {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--faint);
  margin-top: 3px;
}

/* ---------- Setup overlay ---------- */
.setup-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: grid;
  place-items: center;
  z-index: 200;
  padding: 20px;
}
.setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 34px;
  max-width: 480px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.setup-card h2 {
  margin: 12px 0 6px;
  font-size: 18px;
}
.setup-cmd {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 19px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  margin: 12px 0;
  color: var(--brand);
}
.setup-steps {
  text-align: left;
  margin: 14px auto;
  max-width: 380px;
  color: var(--text-2);
  line-height: 1.7;
  font-size: 13.5px;
}
.setup-steps code {
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}
.setup-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--brand);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 0.9s linear infinite;
}
.waiting {
  color: var(--muted);
  font-size: 14px;
  margin-top: 16px;
}
.waiting .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

/* ---------- Login ---------- */
.login-body {
  display: grid;
  place-items: center;
  height: 100vh;
  background: var(--bg);
  padding: 16px;
}
.login-card {
  background: var(--surface);
  padding: 40px 44px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-md);
}
.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: var(--on-brand);
}
.login-logo .ic {
  width: 30px;
  height: 30px;
}
.login-card h1 {
  margin: 16px 0 6px;
  font-size: 21px;
  letter-spacing: -.01em;
}
.login-card p {
  margin: 0;
}
.discord-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  background: #5865f2;
  color: #fff;
  text-decoration: none;
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: background .12s;
}
.discord-btn:hover {
  background: #4752c4;
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #d3d8df;
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: #b9c0ca;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* ---------- Dark theme: components with hardcoded light colors ---------- */
:root:not([data-theme="light"]) .drop-overlay {
  background: rgba(12, 14, 18, 0.82);
}
:root:not([data-theme="light"]) .drop-card {
  background: #23262d;
}
:root:not([data-theme="light"]) .ticket-note {
  background: rgba(0, 0, 0, 0.22);
  border-color: var(--amber-border);
}
:root:not([data-theme="light"]) .modal-overlay {
  background: rgba(6, 8, 12, 0.62);
}
:root:not([data-theme="light"]) ::-webkit-scrollbar-thumb {
  background: #3a4150;
  border: 2px solid transparent;
  background-clip: content-box;
}
:root:not([data-theme="light"]) ::-webkit-scrollbar-thumb:hover {
  background: #4a5262;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) and (min-width: 769px) {
  .layout {
    grid-template-columns: 300px 1fr;
  }
  .ticket-header {
    grid-template-columns: 1fr;
  }
  .ticket-primary-actions {
    justify-content: flex-start;
  }
  /* 300px sidebar: tighten the segmented status tabs so no label clips */
  .pill {
    font-size: 11px;
    padding-left: 1px;
    padding-right: 1px;
  }
}

.mobile-only {
  display: none;
}
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: flex;
    border-right: none;
  }
  .content {
    display: none;
  }
  body.viewing .sidebar {
    display: none;
  }
  body.viewing .content {
    display: flex;
  }
  .mobile-only {
    display: inline-flex;
  }
  .me-name {
    display: none;
  }
  .brand-sub {
    display: none;
  }

  .ticket-list {
    padding: 8px;
  }
  .ticket-item {
    padding: 12px 13px;
  }
  .ticket-header {
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 10px;
    align-items: stretch;
  }
  .ticket-title {
    order: 1;
  }
  #mobile-back {
    order: 0;
    align-self: flex-start;
  }
  .ticket-primary-actions {
    order: 2;
    width: 100%;
    justify-content: stretch;
    flex-wrap: wrap;
  }
  .ticket-primary-actions .assign {
    flex: 1 1 130px;
    min-width: 0;
  }
  .ticket-workflow {
    order: 3;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    align-items: flex-end;
    padding: 10px 0 2px;
    scrollbar-width: none;
  }
  .ticket-workflow::-webkit-scrollbar {
    display: none;
  }
  .workflow-field {
    flex: 0 0 auto;
  }
  .workflow-issue {
    flex-basis: 210px;
  }
  .action-menu-popover {
    right: 0;
  }
  .messages {
    padding: 14px 12px;
  }
  .reply-bar {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .ai-tools {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding: 7px 12px 0;
  }
  .ai-tools::-webkit-scrollbar {
    display: none;
  }
  .lang-indicator {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .modal-card {
    width: 96vw;
    max-height: 92vh;
  }
  .an-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  /* 16px on focusable fields stops iOS auto-zoom on tap */
  .reply-input,
  .input,
  #search,
  .assign,
  .canned-select,
  #s-model-select {
    font-size: 16px;
  }
  .messages img {
    max-width: 100%;
    height: auto;
  }
  body.viewing .notif-banner {
    display: none;
  }
}

/* ==========================================================================
   Daylight Desk layout: view rail, carded conversation, chat bubbles
   ========================================================================== */
.layout {
  grid-template-columns: var(--viewnav-w) minmax(320px, 370px) 1fr;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.txt-red {
  color: var(--red);
}

/* view rail (desktop) / bottom tab bar (phones) */
.viewnav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 12px 8px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: 0;
}
.vn-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 58px;
  padding: 8px 4px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  transition: background .12s, color .12s;
}
.vn-item .ic {
  width: 20px;
  height: 20px;
}
.vn-item:hover {
  background: var(--surface-3);
  color: var(--text);
}
.vn-item:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.vn-item.active {
  background: var(--brand-soft);
  color: var(--brand);
}
.vn-badge {
  position: absolute;
  top: 6px;
  right: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.vn-badge.alert {
  background: var(--red);
  color: var(--pill-text);
}

/* tasks pages take over the inbox columns */
.tasks-page {
  grid-column: 2 / -1;
  overflow-y: auto;
  min-height: 0;
  background: var(--bg);
}
body.view-tasks .sidebar,
body.view-tasks .content {
  display: none !important;
}

/* conversation sits in a card on the canvas (desktop) */
@media (min-width: 769px) {
  .content {
    padding: 14px;
  }
  .ticket-view {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
  }
}
.ticket-header {
  border-radius: 0;
}
.ticket-body {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}
.ticket-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--chat-bg);
}
.ticket-main .reply-bar {
  background: var(--surface);
}

/* chat bubbles: customer left, staff right */
.messages {
  background: var(--chat-bg);
}
.msg {
  max-width: 760px;
}
.msg .m-body {
  border-radius: 16px 16px 16px 6px;
  padding: 10px 14px 11px;
}
.msg.staff {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg.staff .m-body {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  border-radius: 16px 16px 6px 16px;
}
.msg.staff .m-name,
.msg.staff .m-time,
.msg.staff .translate-btn {
  color: var(--on-brand);
  opacity: 0.85;
}
.msg.staff .m-name {
  opacity: 1;
}
.msg.staff .m-attach a {
  color: var(--on-brand);
  text-decoration: underline;
}
.msg.staff .translation {
  background: rgba(0, 0, 0, 0.12);
  border-left-color: var(--on-brand);
}
.msg.staff .msg-del-btn {
  right: auto;
  left: -7px;
}
.msg-system .sys-text {
  background: var(--surface);
}

/* ---------- task chips & due chips ---------- */
.task-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 650;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid var(--brand-border);
}
.task-chip .ic {
  width: 12px;
  height: 12px;
}
.task-chip.over {
  background: var(--red-soft);
  color: var(--red);
  border-color: var(--red-border);
}
.due-chip {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 650;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--gray-soft);
  color: var(--text-2);
}
.due-chip.over {
  background: var(--red-soft);
  color: var(--red);
}
.due-chip.today {
  background: var(--amber-soft);
  color: var(--amber);
}
.due-chip.wait {
  background: var(--brand-soft);
  color: var(--brand);
}
.due-chip.done {
  color: var(--muted);
}
#btn-ticket-tasks.has-overdue {
  color: var(--red);
  border-color: var(--red-border);
  background: var(--red-soft);
}

/* due-time quick picks */
.due-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.due-pick {
  height: 32px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
}
.due-pick:hover {
  background: var(--surface-3);
  color: var(--text);
}
.due-pick[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 650;
}
.due-pick:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.due-custom {
  width: auto;
  height: 32px;
  padding: 3px 8px;
  font-size: 12.5px;
  color: var(--text-2);
}
.due-custom.active {
  border-color: var(--brand);
  box-shadow: var(--focus);
}

/* ---------- task rows ---------- */
.task-list {
  display: flex;
  flex-direction: column;
}
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-top: 1px solid var(--border);
  min-width: 0;
}
.task-list > .task-row:first-child {
  border-top: 0;
}
.task-check {
  width: 19px;
  height: 19px;
  margin: 0;
  accent-color: var(--brand);
  flex: 0 0 19px;
  cursor: pointer;
}
.task-check:disabled {
  cursor: not-allowed;
}
.task-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.task-title {
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.4;
  word-break: break-word;
}
.task-row.done .task-title {
  text-decoration: line-through;
  color: var(--muted);
  font-weight: 500;
}
.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.task-ticket {
  border: 0;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-2);
}
.task-ticket:hover {
  background: var(--brand-soft);
  color: var(--brand);
}
.task-who {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
}
.mini-av {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 10.5px;
  font-weight: 700;
  flex: 0 0 auto;
}
.mini-av.lg {
  width: 34px;
  height: 34px;
  font-size: 14px;
}
.task-menu {
  position: relative;
  flex: 0 0 auto;
}
.task-menu > summary {
  list-style: none;
  width: 32px;
  height: 32px;
  padding: 0;
}
.task-menu > summary::-webkit-details-marker {
  display: none;
}
.task-menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  min-width: 180px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.task-menu-pop button {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.task-menu-pop button:hover {
  background: var(--surface-3);
  color: var(--text);
}
.task-menu-pop button.danger {
  color: var(--red);
}
.task-menu-pop button.danger:hover {
  background: var(--red-soft);
}
.task-x {
  width: 32px;
  height: 32px;
  padding: 0;
}

/* ---------- ticket tasks side panel ---------- */
.ticket-side {
  display: none;
  width: 340px;
  flex: 0 0 340px;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--surface);
}
body.tasks-open .ticket-side {
  display: flex;
}
.ts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 6px;
}
.ts-head > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ts-head strong {
  font-size: 14px;
}
.ts-head small {
  color: var(--muted);
  font-size: 12px;
}
.task-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 10px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.tf-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
}
.tf-row {
  display: flex;
  gap: 8px;
}
.tf-row .input {
  flex: 1;
  min-width: 0;
}
.tf-row .btn {
  flex: 0 0 auto;
}
.tf-hint {
  margin: 0;
  font-size: 12px;
}
.ticket-side .task-list .task-row {
  padding: 11px 16px;
}
.ticket-side .empty-note {
  padding: 14px 16px;
}
@media (max-width: 1199px) {
  /* narrower screens: the panel slides over the conversation as a drawer */
  .ticket-side {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    width: min(360px, 100%);
    box-shadow: var(--shadow-lg);
  }
}

/* ---------- My Tasks / Team pages ---------- */
.tp-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 22px 22px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.tp-team {
  max-width: 1280px;
}
.tp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.tp-head h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.tp-head p {
  margin: 3px 0 0;
  font-size: 13.5px;
}
.seg {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
}
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  height: 32px;
  padding: 0 12px;
  border-radius: 7px;
  cursor: pointer;
}
.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 650;
  box-shadow: var(--shadow-sm);
}
.seg-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.tp-add {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}
.tp-add-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tp-add-row .input {
  flex: 1 1 320px;
  height: 40px;
}
.tp-add-row .tp-ticket {
  flex: 0 1 120px;
}
.tp-add-row .btn {
  height: 40px;
}
.task-group {
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: visible;
}
.task-group h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.g-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.g-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}
.g-over .g-dot {
  background: var(--red);
}
.g-today .g-dot {
  background: var(--amber);
}
.g-wait .g-dot {
  background: var(--brand);
}
.g-done .g-dot {
  background: var(--green);
}
.tp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 16px;
  color: var(--muted);
  text-align: center;
}
.tp-empty .ic {
  width: 34px;
  height: 34px;
  color: var(--faint);
}
.tp-empty p {
  margin: 0;
  max-width: 360px;
}
.tp-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
}
.tp-check input {
  accent-color: var(--brand);
  width: 16px;
  height: 16px;
}

.team-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}
.team-main {
  flex: 999 1 560px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.agent-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}
.agent-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  padding: 14px;
  cursor: pointer;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.agent-card:hover {
  border-color: var(--border-strong);
}
.agent-card.flagged {
  border-color: var(--red-border);
}
.agent-card.selected {
  border-color: var(--brand);
  box-shadow: var(--focus);
}
.agent-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.agent-top b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
}
.agent-stats b {
  display: block;
  font-size: 18px;
  color: var(--text);
}
.agent-stats .txt-red b {
  color: var(--red);
}
.team-table-card {
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.team-table-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.team-table-head h2 {
  margin: 0;
  font-size: 15px;
}
.team-table-scroll {
  overflow-x: auto;
}
.team-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
.team-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 12px;
}
.team-table td {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13px;
}
.tt-done {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
}
.tt-actions .input-sm {
  height: 32px;
  padding: 4px 26px 4px 8px;
  font-size: 12.5px;
  width: auto;
  min-width: 120px;
}
.tt-empty {
  text-align: center;
  padding: 24px !important;
}
.team-assign {
  flex: 1 1 280px;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}
.team-assign h2 {
  margin: 0;
  font-size: 16px;
}
.team-assign textarea {
  resize: vertical;
  min-height: 70px;
}

/* hold + close modals */
.hold-card {
  width: min(520px, 94vw);
}
.hold-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hold-body .s-actions {
  margin-top: 4px;
}

/* ---------- phones ---------- */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }
  .viewnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    flex-direction: row;
    gap: 4px;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
    border-right: 0;
    border-top: 1px solid var(--border);
  }
  .vn-item {
    flex: 1;
    min-height: 50px;
  }
  .vn-badge {
    right: calc(50% - 22px);
    top: 3px;
  }
  body.viewing .viewnav {
    display: none;
  }
  body.viewing .layout {
    padding-bottom: 0;
  }
  .tasks-page {
    grid-column: 1;
  }
  .tp-wrap {
    padding: 16px 12px 28px;
  }
  .tp-head h1 {
    font-size: 22px;
  }
  .task-row {
    flex-wrap: wrap;
  }
  .task-row .task-main {
    flex-basis: calc(100% - 40px);
  }
  .task-row .due-chip {
    margin-left: 31px;
  }
  .team-assign {
    max-width: none;
  }
}

/* scheduled close */
.closing-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 650;
  padding: 2px 4px 2px 9px;
  border-radius: 999px;
  background: var(--violet-soft);
  color: var(--violet);
  border: 1px solid var(--violet-border);
}
.closing-chip .ic {
  width: 13px;
  height: 13px;
}
.closing-chip button {
  border: 0;
  border-radius: 999px;
  padding: 2px 9px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  background: var(--surface);
  color: var(--violet);
}
.closing-chip button:hover {
  background: var(--violet);
  color: var(--surface);
}
.closing-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 650;
  color: var(--violet);
}
.closing-mini .ic {
  width: 12px;
  height: 12px;
}

/* side panel is narrow: the due chip drops under the task text */
.ticket-side .task-row {
  flex-wrap: wrap;
  align-items: flex-start;
  row-gap: 6px;
}
.ticket-side .task-row .task-main {
  flex: 1 1 calc(100% - 80px);
}
.ticket-side .task-row .task-menu,
.ticket-side .task-row .task-x {
  order: 2;
  margin-top: -6px;
}
.ticket-side .task-row .due-chip {
  order: 3;
  margin-left: 31px;
}
.ticket-side .task-check {
  margin-top: 1px;
}

/* grid columns must never be widened by their content (long messages, header actions) */
.layout > * {
  min-width: 0;
}
@media (max-width: 768px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  /* phone top bar: icons only so everything fits */
  .topbar {
    padding-left: calc(12px + env(safe-area-inset-left, 0px));
    padding-right: calc(10px + env(safe-area-inset-right, 0px));
  }
  .brand span:last-child {
    display: none;
  }
  .topbar-right {
    gap: 2px;
  }
  .topbar-right .btn span {
    display: none;
  }
  .topbar .btn {
    padding: 0 9px;
  }
}

/* ==========================================================================
   B layout (matches the chosen "Daylight Desk" design): centred search,
   labelled sidebar, carded ticket list + conversation, Customer/Tasks/Notes
   panel, B composer. Later rules here intentionally win over the rail layout.
   ========================================================================== */

/* top bar */
.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
}
.brand-name {
  white-space: nowrap;
}
.top-search {
  justify-self: center;
  width: min(580px, 100%);
}
.top-search .input {
  height: 40px;
  padding-left: 38px;
  border-radius: 10px;
  background: var(--surface-2);
  border-color: var(--border);
}
.top-search .ic {
  left: 13px;
}
.topbar-right {
  gap: 4px;
}
.conn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  margin-right: 6px;
  border-radius: 999px;
  border: 1px solid var(--brand-border);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
}
.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}
.conn .when-off {
  display: none;
}
.conn.offline {
  color: var(--red);
  border-color: var(--red-border);
  background: var(--red-soft);
}
.conn.offline .conn-dot {
  background: var(--red);
}
.conn.offline .when-on {
  display: none;
}
.conn.offline .when-off {
  display: inline;
}
.topbar .icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
}
.icon-btn > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
#notif-btn.notif-on {
  color: var(--green);
}
.topbar .avatar {
  margin-left: 6px;
}

/* three columns on a soft canvas */
.layout {
  grid-template-columns: 236px minmax(320px, 380px) minmax(0, 1fr);
  gap: 14px;
  padding: 14px 16px 16px;
  background: var(--bg);
}
.layout > * {
  min-width: 0;
}

/* left sidebar: labelled views, tasks, departments */
.viewnav {
  background: transparent;
  border-right: 0;
  padding: 0;
  gap: 2px;
  overflow-y: auto;
}
.vn-views,
.vn-depts {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.viewnav .vn-item {
  flex-direction: row;
  justify-content: flex-start;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text-2);
  text-align: left;
}
.viewnav .vn-item .ic {
  width: 17px;
  height: 17px;
  color: var(--muted);
}
.viewnav .vn-item:hover {
  background: var(--surface-3);
  color: var(--text);
}
.viewnav .vn-item.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.viewnav .vn-item.active .ic {
  color: var(--brand);
}
.vn-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.viewnav .vn-badge {
  position: static;
  margin-left: auto;
}
.vn-sep {
  height: 1px;
  background: var(--border);
  margin: 10px 8px;
}
.vn-heading {
  padding: 2px 12px 6px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}
.dept-sq {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: 0 0 9px;
}
.mobile-tabs,
.mobile-views {
  display: none;
}

/* ticket list: cards on the canvas */
.sidebar {
  background: transparent;
  border-right: 0;
}
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 10px;
}
.list-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.list-head h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.sort-mini {
  width: auto;
  height: 32px;
  padding: 0 28px 0 10px;
  font-size: 12.5px;
  border-radius: 9px;
}
.ticket-list {
  padding: 0 4px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ticket-item {
  margin: 0;
  padding: 14px 14px 14px 16px;
  gap: 7px;
  border-radius: 14px;
  background: var(--surface);
}
.ticket-item.attn-new,
.ticket-item.attn-reply,
.ticket-item.on-hold-row {
  background: var(--surface);
}
.ticket-item::before {
  top: 14px;
  bottom: 14px;
  width: 3px;
}
.ticket-item.selected {
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.14);
}
.ticket-item.selected::before {
  background: var(--brand);
}
.ticket-item .row1 {
  justify-content: flex-start;
  gap: 8px;
}
.t-av {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}
.t-user {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}
.r1-right {
  margin-left: auto;
  flex: 0 0 auto;
}
.wait-chip {
  font-size: 11.5px;
  font-weight: 650;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.wait-chip.hot {
  background: var(--red-soft);
  color: var(--red);
}
.ticket-item .subject {
  white-space: normal;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
}
.ticket-item .subject .num {
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
}
.ticket-item .preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}
.dept-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-2);
}

/* conversation card */
.content {
  padding: 0 !important;
}
.ticket-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
}
.ticket-title {
  flex: 1;
  min-width: 0;
}
.t-meta {
  font-size: 12px;
  color: var(--muted);
}
.ticket-title h2 {
  margin: 2px 0 7px;
  font-size: 18px;
  font-weight: 700;
}
.ticket-primary-actions .btn {
  height: 38px;
  border-radius: 10px;
}
.ticket-primary-actions .icon-btn {
  width: 38px;
  padding: 0;
}
.side-toggle {
  position: relative;
}
.side-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}
body.tasks-open .side-toggle {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand);
}

/* Customer / Tasks / Notes panel */
.ticket-side {
  width: 320px;
  flex-basis: 320px;
}
.side-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 12px 12px 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-3);
}
.side-tab {
  flex: 1;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.side-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.side-tab:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.side-tab.has-overdue {
  color: var(--red);
}
.side-close {
  width: 30px;
  height: 30px;
  padding: 0;
  flex: 0 0 30px;
}
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 10px 14px 16px;
}
.side-panel.hidden {
  display: none !important;
}
.cust-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.cust-av {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 18px;
  font-weight: 700;
}
.cust-id {
  min-width: 0;
}
.cust-name {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cust-dl {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  margin: 0;
  font-size: 13px;
  align-items: center;
}
.cust-dl dt {
  color: var(--muted);
}
.cust-dl dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.cust-dl .assign {
  width: 100%;
  min-width: 0;
  height: 34px;
  font-size: 13px;
}
.side-block {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.side-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
}
.prio-seg {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.prio-seg button {
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
}
.prio-seg button:hover {
  background: var(--surface-3);
}
.prio-seg button[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}
.prio-seg button[data-prio="urgent"][aria-pressed="true"] {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}
.prio-seg button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.t-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.t-tags:empty::before {
  content: "No labels yet";
  font-size: 12.5px;
  color: var(--muted);
}
.side-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.side-panel .task-form {
  padding: 0 0 14px;
}
.ticket-side .side-panel .task-list .task-row {
  padding: 11px 0;
}
.ticket-side .side-panel .empty-note {
  padding: 6px 0;
}
.side-panel .ticket-notes-list {
  max-height: none;
}

/* composer */
.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 18px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.composer .reply-bar {
  padding: 0;
  border: 0;
  background: transparent;
  gap: 10px;
  align-items: flex-end;
}
.composer .reply-input {
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 12px;
}
.btn-send {
  height: 48px;
  padding: 0 20px;
  border-radius: 12px;
  border: 0;
  background: var(--text);
  color: var(--surface);
  font-weight: 700;
}
.btn-send:hover {
  background: var(--text-2);
  color: var(--surface);
}
.btn-send .ic {
  width: 15px;
  height: 15px;
}
.composer-links {
  padding: 0;
  gap: 2px 16px;
  flex-wrap: wrap;
}
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-2);
  cursor: pointer;
}
.link-btn:hover {
  color: var(--brand);
}
.link-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: 6px;
}
.link-btn .ic {
  width: 14px;
  height: 14px;
}
.composer-links .canned-select {
  width: auto;
  height: 30px;
  padding: 0 24px 0 0;
  border: 0;
  background-color: transparent;
  font-size: 13px;
  color: var(--text-2);
  background-position: right 4px center;
}
.rewrite-preview {
  margin: 0 18px 10px;
  background: var(--brand-soft);
  border-color: var(--brand-border);
  border-radius: 12px;
}
.rewrite-preview .rp-head {
  color: var(--brand);
}
.staged-file {
  margin: 0 18px;
}

/* phones: full-bleed screens + floating bottom tab bar */
@media (max-width: 768px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
  }
  .brand-name,
  .conn .when-on,
  .conn .when-off,
  #analytics-btn,
  #me-avatar,
  .me-name {
    display: none !important;
  }
  .conn {
    padding: 0 9px;
    margin-right: 0;
  }
  .top-search .input {
    height: 38px;
    font-size: 16px;
  }
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 0 0 calc(84px + env(safe-area-inset-bottom, 0px));
  }
  .viewnav {
    display: none !important;
  }
  .mobile-tabs {
    display: flex;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    z-index: 50;
    gap: 4px;
    padding: 6px;
    border-radius: 18px;
    background: #18212b;
    box-shadow: var(--shadow-lg);
  }
  .mt-item {
    position: relative;
    flex: 1;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    color: #c6cdd6;
    font: inherit;
    font-size: 11.5px;
    font-weight: 650;
    cursor: pointer;
  }
  .mt-item .ic {
    width: 20px;
    height: 20px;
  }
  .mt-item.active {
    background: #0f766e;
    color: #ffffff;
  }
  .mt-item .vn-badge {
    position: absolute;
    top: 3px;
    right: calc(50% - 24px);
  }
  body.viewing .mobile-tabs {
    display: none;
  }
  body.viewing .layout {
    padding-bottom: 0;
  }
  .mobile-views {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 0 12px 10px;
    scrollbar-width: none;
  }
  .mobile-views::-webkit-scrollbar {
    display: none;
  }
  .mv-chip {
    flex: 0 0 auto;
    height: 38px;
    padding: 0 13px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }
  .mv-chip b {
    font-weight: 700;
    opacity: 0.75;
  }
  .mv-chip.active {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--on-brand);
  }
  .list-head {
    padding: 16px 14px 10px;
  }
  .list-head h1 {
    font-size: 24px;
  }
  .ticket-list {
    padding: 0 12px 16px;
  }
  .ticket-view {
    border-radius: 0;
    border: 0;
    box-shadow: none;
  }
  .ticket-header {
    flex-wrap: wrap;
    padding: 12px;
  }
  .ticket-primary-actions {
    width: 100%;
  }
  .ticket-primary-actions .btn:not(.icon-btn) {
    flex: 1 1 auto;
  }
  .composer {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .composer .reply-input {
    font-size: 16px;
  }
}

/* priority lives in the segmented buttons; the old chip is only a data holder */
#t-priority {
  display: none !important;
}
.viewnav .vn-item {
  border: 1px solid transparent;
}
.viewnav .vn-item.active {
  border-color: var(--border);
}

/* ==========================================================================
   Tasks board (To do / In progress / Waiting / Done) + task details drawer
   ========================================================================== */
.tp-wrap.tp-wide {
  max-width: 1480px;
}
.tp-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.tp-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  min-width: 220px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}
.tp-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
}
.tp-search:focus-within {
  border-color: var(--brand);
  box-shadow: var(--focus);
}
.tp-focus {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tp-focus .sw {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background .15s;
}
.tp-focus .sw::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .15s, background .15s;
}
.tp-focus[aria-pressed="true"] {
  border-color: var(--brand-border);
  color: var(--brand);
}
.tp-focus[aria-pressed="true"] .sw {
  background: var(--brand);
}
.tp-focus[aria-pressed="true"] .sw::after {
  transform: translateX(12px);
  background: var(--on-brand);
}
.tp-focus:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.tp-filter {
  align-self: flex-start;
}
.tp-tools .btn {
  height: 38px;
}

/* board */
.kcol-tabs {
  display: none;
}
.kboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 12px;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 4px;
}
.kcol {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border-radius: 16px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  transition: border-color .12s, background .12s;
}
:root[data-theme="dark"] .kcol {
  background: #13191c;
}
.kcol.drag-over {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.kcol-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
}
.kcol-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
.kdot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}
.k-doing .kdot {
  background: var(--brand);
}
.k-waiting .kdot {
  background: var(--violet);
}
.k-done .kdot {
  background: var(--green);
}
.kcount {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.kc-plus {
  margin-left: auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.kc-plus:hover {
  background: var(--surface);
  color: var(--brand);
}
.kc-plus:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.kc-wip {
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--amber-soft);
  color: var(--amber);
}
.kc-add .input {
  height: 38px;
  font-size: 13px;
}
.kcards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}
.kc-empty {
  padding: 14px 8px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
}
.kcard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  cursor: grab;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: border-color .12s, box-shadow .12s, opacity .12s;
}
.kcard:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.kcard:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-color: var(--brand);
}
.kcard.over {
  border-left: 3px solid var(--red);
}
.kcard.dragging {
  opacity: 0.4;
  border-style: dashed;
}
.kcard.done .kc-title {
  text-decoration: line-through;
  color: var(--muted);
  font-weight: 500;
}
.kc-title {
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.4;
  word-break: break-word;
}
.kc-note {
  display: flex;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
  min-width: 0;
}
.kc-note .ic {
  width: 13px;
  height: 13px;
  margin-top: 2px;
  flex: 0 0 13px;
}
.kc-note span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kc-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.kc-bar {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.kc-bar > span {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
}
.kc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.kc-meta .due-chip {
  margin-left: auto;
  font-size: 11.5px;
  padding: 2px 9px;
}
.kc-ticket {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-2);
}
.kc-wait {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--violet-soft);
  color: var(--violet);
}
.kc-move {
  display: none;
}
.kc-drop {
  height: 52px;
  border-radius: 12px;
  border: 2px dashed var(--brand);
  background: var(--brand-soft);
}
.kc-older {
  align-self: flex-start;
  font-size: 12.5px;
  color: var(--brand);
}

/* list rows: title opens the drawer */
.task-title {
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  color: inherit;
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}
button.task-title:hover {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}
button.task-title:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: 4px;
}
.st-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.st-chip.doing {
  background: var(--brand-soft);
  color: var(--brand);
}
.st-chip.waiting {
  background: var(--violet-soft);
  color: var(--violet);
}
.has-note {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.has-note .ic {
  width: 12px;
  height: 12px;
}

/* drawer */
.td-scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 20, 23, 0.22);
}
:root[data-theme="dark"] .td-scrim {
  background: rgba(0, 0, 0, 0.45);
}
.task-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 95;
  width: min(460px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -16px 0 40px rgba(0, 0, 0, 0.16);
}
.td-loading {
  padding: 24px;
}
.td-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 12px 18px;
  border-bottom: 1px solid var(--border);
}
.td-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.td-status select {
  width: auto;
  height: 34px;
  font-weight: 700;
  padding-right: 30px;
}
.td-status select.st-doing {
  border-color: var(--brand);
  background-color: var(--brand-soft);
  color: var(--brand);
}
.td-status select.st-waiting {
  border-color: var(--violet-border);
  background-color: var(--violet-soft);
  color: var(--violet);
}
.td-status select.st-done {
  border-color: var(--green-border);
  background-color: var(--green-soft);
  color: var(--green);
}
.td-saved {
  margin-left: auto;
  font-size: 12px;
}
.td-head .icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
}
.td-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 16px 18px 24px;
}
.td-title {
  width: 100%;
  resize: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 6px 8px;
  margin: -6px -8px 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  outline: none;
}
.td-title:hover:not(:disabled) {
  border-color: var(--border);
}
.td-title:focus {
  border-color: var(--brand);
  box-shadow: var(--focus);
}
.td-dl {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px 12px;
  margin: 0;
  font-size: 13px;
  align-items: center;
}
.td-dl dt {
  color: var(--muted);
}
.td-dl dd {
  margin: 0;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  overflow-wrap: anywhere;
}
.td-dl .input-sm {
  height: 34px;
  font-size: 13px;
}
.td-due {
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.td-ticket {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.td-ticket-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12.5px;
}
.td-ticket-head .link-btn {
  margin-left: auto;
  color: var(--brand);
  font-weight: 700;
}
.td-quote {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
}
.td-sec {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.td-sec-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.td-sec-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
.td-sec-head .kc-bar {
  max-width: 140px;
}
.td-checklist {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.td-ck {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}
.td-ck-text {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
}
.td-ck-text:hover:not(:disabled) {
  border-color: var(--border);
}
.td-ck-text:focus {
  border-color: var(--brand);
  box-shadow: var(--focus);
}
.td-ck.done .td-ck-text {
  text-decoration: line-through;
  color: var(--muted);
}
.td-ck-add {
  height: 36px;
  border-style: dashed;
  font-size: 13px;
}
.td-notes {
  resize: vertical;
  min-height: 130px;
  line-height: 1.55;
  font-size: 13.5px;
}
.td-history .td-ev {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.5;
}
.td-foot {
  display: flex;
  gap: 8px;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
}
.td-foot .btn-primary {
  flex: 1;
  height: 42px;
}
.td-foot .btn {
  height: 42px;
}
.td-delete {
  color: var(--red);
}
.td-delete:hover {
  background: var(--red-soft);
  border-color: var(--red-border);
  color: var(--red);
}

/* phones: one column at a time, Move to… on every card, full-screen drawer */
@media (max-width: 768px) {
  .tp-tools {
    width: 100%;
  }
  .tp-search {
    flex: 1 1 100%;
    min-width: 0;
  }
  .tp-search input {
    font-size: 16px;
  }
  .kcol-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .kcol-tabs::-webkit-scrollbar {
    display: none;
  }
  .kcol-tab {
    flex: 0 0 auto;
    height: 38px;
    padding: 0 13px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }
  .kcol-tab b {
    opacity: 0.75;
  }
  .kcol-tab.active {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--on-brand);
  }
  .kboard {
    display: block;
    overflow: visible;
  }
  .kcol {
    display: none;
    background: transparent;
    border: 0;
    padding: 0;
  }
  .kcol.m-active {
    display: flex;
  }
  .kcol-head h2,
  .kcol-head .kdot,
  .kcol-head .kcount {
    display: none;
  }
  .kcol-head {
    justify-content: flex-end;
  }
  .kcard {
    cursor: default;
    padding: 14px;
    border-radius: 16px;
  }
  .kc-title {
    font-size: 15px;
  }
  .kc-move {
    display: block;
    height: 38px;
    font-size: 14px;
  }
  .task-drawer {
    width: 100vw;
    border-left: 0;
  }
  .td-body {
    padding: 14px 16px 20px;
  }
  .td-title {
    font-size: 19px;
  }
  .td-ck {
    min-height: 44px;
  }
  .td-ck .task-check {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
  }
  .td-notes,
  .td-ck-text,
  .td-ck-add,
  .td-dl .input-sm {
    font-size: 16px;
  }
}

/* drawer sections keep their natural height; the body scrolls instead */
.td-body > * {
  flex-shrink: 0;
}
.td-title {
  min-height: 2.7em;
  field-sizing: content;
}

/* ==========================================================================
   Calmer look: compact ticket tiles, quiet labels, softer dark mode and
   easy-to-read chat bubbles
   ========================================================================== */

/* softer dark palette: less saturated accent and status colours */
:root[data-theme="dark"] {
  --brand: #6fbfb4;
  --brand-hover: #8fd0c6;
  --brand-soft: rgba(111, 191, 180, 0.1);
  --brand-border: rgba(111, 191, 180, 0.26);
  --on-brand: #0c1f1c;
  --blue: #9db8e0;
  --blue-soft: rgba(120, 150, 210, 0.1);
  --blue-border: rgba(120, 150, 210, 0.26);
  --green: #8cc7a3;
  --green-soft: rgba(110, 180, 140, 0.1);
  --green-border: rgba(110, 180, 140, 0.26);
  --amber: #d6b77c;
  --amber-soft: rgba(214, 183, 124, 0.1);
  --amber-border: rgba(214, 183, 124, 0.26);
  --red: #e3a3a3;
  --red-soft: rgba(227, 120, 120, 0.1);
  --red-border: rgba(227, 120, 120, 0.26);
  --violet: #bcaee0;
  --violet-soft: rgba(170, 150, 225, 0.1);
  --violet-border: rgba(170, 150, 225, 0.26);
  --focus: 0 0 0 3px rgba(111, 191, 180, 0.22);
}

/* chat bubbles: a soft tint with normal text instead of a solid fill */
:root {
  --staff-bubble: #1c2a2a;
  --staff-bubble-border: #2b3c3c;
}
:root[data-theme="light"] {
  --staff-bubble: #e9f4f2;
  --staff-bubble-border: #cfe6e1;
}
.msg.staff .m-body {
  background: var(--staff-bubble);
  border-color: var(--staff-bubble-border);
  color: var(--text);
}
.msg.staff .m-name {
  color: var(--brand);
  opacity: 1;
}
.msg.staff .m-time,
.msg.staff .translate-btn {
  color: var(--muted);
  opacity: 1;
}
.msg.staff .m-attach a {
  color: var(--brand);
}
.msg.staff .translation {
  background: var(--surface);
  border-left-color: var(--brand);
}
.msg .m-text {
  font-size: 14px;
  line-height: 1.6;
}

/* compact ticket tiles with almost no gap between them */
.ticket-list {
  gap: 4px;
}
.ticket-item {
  padding: 9px 12px 9px 12px;
  gap: 3px;
  border-radius: 10px;
}
.ticket-item::before {
  display: none;
}
.ticket-item.attn-new,
.ticket-item.attn-reply,
.ticket-item.on-hold-row,
.ticket-item.priority-urgent {
  background: var(--surface);
  border-color: var(--border);
}
.ticket-item.attn-new .subject,
.ticket-item.attn-reply .subject {
  font-weight: 700;
}
.ticket-item.selected {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  box-shadow: none;
}
.ticket-item .row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.ticket-item .t-av {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  font-size: 11px;
  background: var(--surface-3);
  color: var(--text-2);
}
.ticket-item .subject {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
}
.ticket-item .row2 {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding-left: 30px;
  font-size: 12px;
  color: var(--muted);
}
.ticket-item .row2 .t-user {
  flex: 0 1 auto;
  max-width: 40%;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.ticket-item .row2 .num {
  flex: 0 0 auto;
  color: var(--faint);
  font-weight: 500;
  font-size: 12px;
}
.ticket-item .row2 .preview {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-line-clamp: unset;
  font-size: 12px;
  color: var(--muted);
}
.ticket-item .t-meta-row {
  padding-left: 30px;
  gap: 6px;
}
.ticket-item .t-time {
  font-size: 11.5px;
}
.wait-chip {
  padding: 1px 7px;
  font-size: 11px;
  background: transparent;
  color: var(--muted);
}
.wait-chip.hot {
  background: transparent;
  color: var(--red);
}

/* quiet labels instead of loud coloured pills */
.attn-pill,
.attn-pill.new,
.attn-pill.reply,
.attn-pill.unread {
  flex: 0 0 auto;
  padding: 0 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 17px;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-2);
}
.attn-pill.unread {
  border-color: var(--brand-border);
  color: var(--brand);
}
.plabel.high,
.plabel.low {
  color: var(--muted);
}
.plabel.urgent {
  color: var(--red);
}
.task-chip {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
  font-weight: 600;
}
.task-chip.over {
  background: transparent;
  border-color: var(--red-border);
  color: var(--red);
}
.closing-mini {
  color: var(--muted);
}
.ticket-item .tag-chip {
  background: transparent;
}

/* dark mode: fewer bright surfaces */
:root[data-theme="dark"] .mt-item.active {
  background: #2b4744;
}
:root[data-theme="dark"] .btn-send {
  background: #d7dde2;
  color: #0f1417;
}
.ticket-item .row2 .t-user {
  flex: 0 0 auto;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* every ticket tile is the same height: chips sit at the end of line two */
.ticket-item {
  height: 58px;
  justify-content: center;
  overflow: hidden;
}
.ticket-item .row2 {
  min-height: 18px;
}
.row2-chips {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}
.row2-chips .task-chip,
.row2-chips .closing-mini {
  padding: 0 6px;
  font-size: 10.5px;
  line-height: 16px;
}
.row2-chips .plabel {
  font-size: 10px;
}
.row2-chips .tag-chip {
  display: none;
}
.ticket-item .row2 .preview.match {
  color: var(--text-2);
}
.ticket-item .row2 .preview.match::before {
  content: "“";
}
.ticket-item .row2 .preview.match::after {
  content: "”";
}
@media (max-width: 768px) {
  .ticket-item {
    height: 62px;
  }
}

/* tiles keep their height however many tickets there are; the list scrolls */
.ticket-item {
  flex-shrink: 0;
}

/* "New message" jump button, shown when a reply lands while you're scrolled up */
.jump-wrap {
  position: relative;
  height: 0;
  z-index: 6;
}
.jump-latest {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--brand-border);
  background: var(--surface);
  color: var(--brand);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
}
.jump-latest .ic {
  width: 14px;
  height: 14px;
  transform: rotate(90deg);
}
.jump-latest:hover {
  background: var(--brand-soft);
}
.jump-latest:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

/* Discord profile pictures on tiles and the customer card */
img.t-av,
img.cust-av {
  object-fit: cover;
  display: block;
  padding: 0;
  background: var(--surface-3);
}

.m-missing {
  color: var(--muted);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

/* ==========================================================================
   iPhone home-screen app fixes
   ========================================================================== */
/* nothing outside the app ever shows as white */
html {
  background: var(--bg);
}
/* the drawer's header (Status, X) sits below the clock/battery */
.td-head {
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}
/* bottom-pinned layers reach the real bottom when iOS shortens the viewport */
.task-drawer,
.td-scrim,
.modal-overlay {
  bottom: calc(0px - var(--ios-gap, 0px));
}
.td-foot {
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
@media (max-width: 768px) {
  .mobile-tabs {
    bottom: calc(10px + env(safe-area-inset-bottom, 0px) - var(--ios-gap, 0px));
  }
  .layout {
    padding-bottom: max(0px, calc(84px + env(safe-area-inset-bottom, 0px) - var(--ios-gap, 0px)));
  }
  body.viewing .layout {
    padding-bottom: 0;
  }
}

/* ==========================================================================
   Colour-coded ticket tiles: one clear colour per state (bar + soft tint),
   New > Customer replied > On hold > Has task when several apply
   ========================================================================== */
:root[data-theme="light"] {
  --hl-new: #2563eb;
  --hl-reply: #d97706;
  --hl-hold: #7c3aed;
  --hl-task: #0d9488;
  --hl-tint: 7%;
}
:root {
  --hl-new: #7ea6ea;
  --hl-reply: #e2b35f;
  --hl-hold: #b6a3e8;
  --hl-task: #6fc2b7;
  --hl-tint: 11%;
}
:root[data-theme="light"] {
  --hl-tint: 7%;
}
.ticket-item.has-task {
  --hl: var(--hl-task);
}
.ticket-item.on-hold-row {
  --hl: var(--hl-hold);
}
.ticket-item.attn-reply {
  --hl: var(--hl-reply);
}
.ticket-item.attn-new {
  --hl: var(--hl-new);
}
.ticket-item.has-task,
.ticket-item.on-hold-row,
.ticket-item.attn-reply,
.ticket-item.attn-new {
  background: color-mix(in srgb, var(--hl) var(--hl-tint), var(--surface));
  border-color: color-mix(in srgb, var(--hl) 35%, var(--border));
  box-shadow: inset 4px 0 0 var(--hl);
}
.ticket-item.selected {
  box-shadow: inset 4px 0 0 var(--brand), 0 0 0 1px var(--brand-border);
}
.ticket-item.attn-new .attn-pill.new {
  border-color: var(--hl-new);
  color: var(--hl-new);
}
.ticket-item.attn-reply .attn-pill.reply {
  border-color: var(--hl-reply);
  color: var(--hl-reply);
}
.ticket-item.has-task .task-chip:not(.over) {
  border-color: color-mix(in srgb, var(--hl-task) 50%, transparent);
  color: var(--hl-task);
}
.tile-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 0 2px 8px;
  font-size: 11.5px;
  color: var(--muted);
}
.tile-legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.tile-legend .lg::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.lg-new::before {
  background: var(--hl-new);
}
.lg-reply::before {
  background: var(--hl-reply);
}
.lg-hold::before {
  background: var(--hl-hold);
}
.lg-task::before {
  background: var(--hl-task);
}
@media (max-width: 768px) {
  .tile-legend {
    padding: 0 14px 8px;
  }
}

/* ==========================================================================
   AI agents: suggested-reply cards + the AI agents page
   ========================================================================== */
.draft-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 18px;
}
.draft-cards:empty {
  display: none;
}
.draft-cards:not(:empty) {
  padding-bottom: 10px;
}
.draft-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--violet) 7%, var(--surface));
  border: 1px solid var(--violet-border);
}
.draft-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--violet);
}
.draft-head .ic {
  width: 14px;
  height: 14px;
}
.draft-head b {
  font-weight: 700;
}
.draft-note {
  font-size: 12.5px;
  color: var(--text-2);
}
.draft-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.5px;
  line-height: 1.55;
  max-height: 220px;
  overflow-y: auto;
}
.draft-edit {
  resize: vertical;
  min-height: 90px;
  font-size: 13.5px;
  line-height: 1.5;
}
.draft-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.draft-actions .btn {
  height: 34px;
}
.draft-hint {
  font-size: 12px;
  margin-left: auto;
}
.draft-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 0 6px;
  line-height: 16px;
  border-radius: 999px;
  border: 1px solid var(--violet-border);
  color: var(--violet);
}
.draft-chip .ic {
  width: 11px;
  height: 11px;
}

.ag-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}
.ag-card h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.ag-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ag-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ag-form .input {
  max-width: 420px;
}
.ag-form .btn {
  align-self: flex-start;
}
.ag-scopes {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}
.ag-scope {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
}
.ag-scope input {
  margin-top: 3px;
  accent-color: var(--brand);
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}
.ag-scope span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}
.ag-scope small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.ag-new {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.ag-warn {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13px;
}
.ag-warn .ic {
  flex: 0 0 16px;
  margin-top: 2px;
}
.ag-copyrow {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.ag-copyrow .input {
  flex: 1;
  min-width: 0;
  resize: none;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}
.ag-tokens {
  display: flex;
  flex-direction: column;
}
.ag-token {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.ag-tokens > .ag-token:first-child {
  border-top: 0;
}
.ag-token.revoked {
  opacity: 0.55;
}
.ag-token-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ag-token-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.ag-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
}
.ag-audit {
  overflow-x: auto;
}
.ag-table td {
  font-size: 12.5px;
}
.ag-detail {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ag-fail td {
  background: var(--red-soft);
}

/* ==========================================================================
   Tasks board: fills the screen; every column scrolls on its own so all four
   drop zones stay in view however many tasks there are (desktop/tablet)
   ========================================================================== */
.kcol {
  --col-bg: var(--surface-3);
}
:root[data-theme="dark"] .kcol {
  --col-bg: #13191c;
}
@media (min-width: 769px) {
  .tasks-page.board-mode {
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .tasks-page.board-mode .tp-wrap {
    flex: 1;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
    padding-bottom: 16px;
  }
  .tasks-page.board-mode #tp-list {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .tasks-page.board-mode .kboard {
    flex: 1;
    min-height: 0;
    align-items: stretch;
    padding-bottom: 0;
  }
  .tasks-page.board-mode .kcol {
    min-height: 0;
    max-height: 100%;
  }
  .tasks-page.board-mode .kcards {
    flex: 1;
    min-height: 60px;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 0 -6px;
    padding: 2px 6px 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
    /* soft shadows at the top/bottom edge only while there's more to scroll */
    background:
      linear-gradient(var(--col-bg) 30%, transparent) top / 100% 28px no-repeat local,
      linear-gradient(transparent, var(--col-bg) 70%) bottom / 100% 28px no-repeat local,
      radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.14), transparent) top / 100% 10px no-repeat scroll,
      radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.14), transparent) bottom / 100% 10px no-repeat scroll;
    background-color: var(--col-bg);
  }
  .kcol.drag-over .kcards {
    background-color: transparent;
    background-image: none;
  }
  .tasks-page.board-mode .kcards::-webkit-scrollbar {
    width: 8px;
  }
  .tasks-page.board-mode .kcards::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 8px;
    border: 2px solid var(--col-bg);
  }
  .tasks-page.board-mode .kcards::-webkit-scrollbar-track {
    background: transparent;
  }
  .tasks-page.board-mode .kcard {
    flex-shrink: 0;
  }
}
@media (min-width: 769px) {
  /* one row that fills the board, so every column (even an empty one) is a full-height drop target */
  .tasks-page.board-mode .kboard {
    grid-template-rows: minmax(0, 1fr);
  }
}

/* AI model picker: a normal dropdown under the model field */
#s-model-select {
  margin-top: 8px;
  height: 38px;
}

/* ==========================================================================
   Canned replies page + staged canned images in the composer
   ========================================================================== */
.cn-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.cn-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  max-height: calc(100vh - 190px);
  overflow-y: auto;
  padding: 2px;
}
.cn-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  flex-shrink: 0;
}
.cn-item:hover {
  border-color: var(--border-strong);
}
.cn-item.active {
  border-color: var(--brand-border);
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}
.cn-item-title {
  font-weight: 700;
  font-size: 13.5px;
}
.cn-item-text {
  font-size: 12.5px;
  color: var(--muted);
  white-space: pre-line;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.cn-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}
.cn-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-weight: 650;
}
.cn-pill .ic {
  width: 12px;
  height: 12px;
}
.cn-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}
.cn-empty > .ic {
  width: 26px;
  height: 26px;
  opacity: 0.6;
}

.cn-editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px;
  min-width: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}
.cn-back {
  display: none;
  align-self: flex-start;
}
.cn-ed-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.cn-ed-head .muted {
  font-size: 12px;
}
.cn-ed-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.cn-msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.cn-vars {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
}
.cn-vars button {
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.cn-vars button:hover {
  border-color: var(--brand-border);
  color: var(--brand);
}
.cn-content {
  min-height: 150px;
  resize: vertical;
  line-height: 1.5;
  font-weight: 400;
}
.cn-under {
  display: flex;
  justify-content: flex-end;
  font-weight: 400;
  font-size: 11.5px;
}
.cn-sub {
  font-weight: 400;
  font-size: 12px;
}
.tf-label .cn-sub {
  display: inline;
}
.cn-polish-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cn-polish-row .muted {
  font-size: 12.5px;
  flex: 1 1 220px;
}
#cn-polish {
  color: var(--brand);
  border-color: var(--brand-border);
}
.cn-polished {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
}
.cn-polished-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--brand);
  flex-wrap: wrap;
}
.cn-polished-head .muted {
  font-size: 12px;
}
.cn-polished-text {
  white-space: pre-wrap;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  max-height: 320px;
  overflow-y: auto;
}
.cn-polished-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cn-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px;
  margin: -4px;
  border-radius: 12px;
  border: 2px dashed transparent;
}
.cn-images.drag {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.cn-thumb {
  position: relative;
  width: 112px;
  height: 84px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
  display: block;
}
.cn-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cn-thumb-x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 0;
  background: rgba(15, 20, 23, 0.72);
  color: #fff;
  cursor: pointer;
  padding: 0;
}
.cn-thumb-x .ic {
  width: 13px;
  height: 13px;
}
.cn-thumb-x:hover {
  background: var(--red);
}
.cn-thumb-tag {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 10.5px;
  background: rgba(15, 20, 23, 0.72);
  color: #fff;
}
.cn-add-img {
  width: 112px;
  height: 84px;
  border-radius: 10px;
  border: 1.5px dashed var(--border-strong);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-shrink: 0;
}
.cn-add-img small {
  font-weight: 400;
  font-size: 11px;
}
.cn-add-img:hover {
  border-color: var(--brand);
  color: var(--brand);
}
.cn-preview {
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.cn-bubble {
  font-size: 13.5px;
  line-height: 1.5;
}
.cn-bubble b {
  font-size: 13px;
}
.cn-bubble-text {
  white-space: pre-wrap;
  margin-top: 2px;
  color: var(--text);
}
.cn-bubble-imgs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.cn-bubble-imgs img {
  max-width: 220px;
  max-height: 160px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
}
.cn-readonly {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.55;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.cn-ed-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.cn-ed-actions .muted {
  font-size: 12.5px;
}

@media (max-width: 860px) {
  .cn-layout {
    grid-template-columns: 1fr;
  }
  .cn-list {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .cn-wrap.cn-editing .cn-list,
  .cn-wrap.cn-editing .tp-head {
    display: none;
  }
  .cn-wrap:not(.cn-editing) .cn-editor {
    display: none;
  }
  .cn-back {
    display: inline-flex;
  }
  .cn-editor {
    padding: 14px;
  }
  .cn-content,
  #cn-title {
    font-size: 16px;
  }
  .cn-thumb,
  .cn-add-img {
    width: 96px;
    height: 72px;
  }
}

.staged-canned {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 20px;
  padding: 6px 11px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 13px;
  color: var(--text);
}
.staged-canned > .ic {
  color: var(--brand);
  flex-shrink: 0;
}
.staged-canned #sc-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sc-thumbs {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
}
.sc-thumbs img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.staged-canned button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
  display: grid;
  place-items: center;
}
.staged-canned button:hover {
  color: var(--red);
}
@media (max-width: 768px) {
  .staged-canned {
    margin: 0 12px;
  }
}

/* someone else is writing a reply on this ticket */
.typing-warn {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 20px;
  padding: 6px 11px;
  background: var(--amber-soft, rgba(245, 158, 11, 0.12));
  border: 1px solid var(--amber-border, rgba(245, 158, 11, 0.35));
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--amber, #b45309);
}
.typing-dots {
  display: inline-flex;
  gap: 3px;
  flex-shrink: 0;
}
.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots i:nth-child(2) {
  animation-delay: .15s;
}
.typing-dots i:nth-child(3) {
  animation-delay: .3s;
}
@keyframes typing-bounce {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .typing-dots i {
    animation: none;
  }
}
@media (max-width: 768px) {
  .typing-warn {
    margin: 0 12px;
  }
}

/* ==========================================================================
   Smart triage card, similar tickets, and the next-step / promise pop-ups
   ========================================================================== */
.triage-card {
  margin: 10px 18px 0;
  padding: 12px 14px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  font-size: 13px;
  flex-shrink: 0;
}
.tri-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--brand);
}
.tri-head .muted {
  font-size: 12.5px;
  color: var(--muted);
}
.tri-spacer {
  flex: 1;
}
.tri-head .btn-sm {
  height: 28px;
  padding: 0 9px;
}
.tri-x {
  width: 28px;
  padding: 0 !important;
  justify-content: center;
}
.tri-summary {
  margin: 0;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
}
.tri-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tri-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 7px;
  border-radius: 10px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.tri-chip input {
  margin: 0;
  accent-color: var(--brand);
}
.tri-chip span {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  font-weight: 650;
}
.tri-chip small {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.tri-chip.already {
  opacity: 0.6;
  cursor: default;
}
.tri-sim {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tri-sim-head {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.tri-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tri-actions .muted {
  font-size: 12.5px;
}

.sim-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sim-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.sim-item:hover {
  border-color: var(--brand-border);
}
.sim-top {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sim-st {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 650;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
}
.sim-st.closed,
.sim-st.deleted {
  background: var(--green-soft, rgba(34, 197, 94, 0.14));
  color: var(--green);
}
.sim-snip {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.sim-none {
  font-size: 12.5px;
}
#side-similar:empty {
  display: none;
}
#side-similar .btn-sm {
  width: 100%;
  justify-content: center;
}

.smart-pops {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 24px));
  pointer-events: none;
}
.smart-pop {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 13px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text);
  animation: pop-in .18s ease-out;
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .smart-pop {
    animation: none;
  }
}
.smart-pop p {
  margin: 0;
  line-height: 1.45;
}
.sp-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--brand);
}
.sp-head b {
  flex: 1;
  color: var(--text);
}
.sp-x {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.sp-x:hover {
  background: var(--surface-3);
  color: var(--text);
}
.sp-muted {
  color: var(--muted);
}
.sp-action {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
}
.sp-action.close {
  background: var(--green-soft, rgba(34, 197, 94, 0.14));
  color: var(--green);
}
.sp-action.wait {
  background: var(--amber-soft);
  color: var(--amber);
}
.sp-reply {
  margin: 0;
  padding: 8px 10px;
  border-left: 3px solid var(--brand-border);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
  white-space: pre-wrap;
  max-height: 160px;
  overflow-y: auto;
  font-size: 12.5px;
  line-height: 1.45;
}
.sp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sp-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sp-due {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 600;
}
.sp-due .input {
  flex: 1;
  min-width: 0;
}
@media (max-width: 768px) {
  .triage-card {
    margin: 8px 12px 0;
  }
  .smart-pops {
    right: 12px;
    bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  }
  body.viewing .smart-pops {
    bottom: calc(150px + env(safe-area-inset-bottom, 0px));
  }
  .sp-form .input {
    font-size: 16px;
  }
}
.triage-card {
  gap: 6px;
  padding: 9px 12px;
}
.tri-head {
  gap: 6px;
}
.tri-head > b {
  color: var(--brand);
  white-space: nowrap;
}
.tri-line {
  font-weight: 650;
  color: var(--text);
  min-width: 0;
}
.tri-summary {
  font-size: 12.5px;
  color: var(--text-2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.tri-reason {
  font-size: 12px;
}
.smart-pops {
  z-index: 2000;
}

/* ==========================================================================
   Reports page
   ========================================================================== */
.rp-range {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.rp-range button {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.rp-range button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow-sm);
}
#rp-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: opacity .15s;
}
#rp-body.rp-loading {
  opacity: 0.55;
}
.rp-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.rp-kpi {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.rp-kpi-label {
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}
.rp-kpi-val {
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.rp-kpi-val small {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.rp-kpi-hint {
  font-size: 11.5px;
  color: var(--muted);
}
.rp-delta {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.rp-delta.good {
  color: var(--green);
}
.rp-delta.bad {
  color: var(--red);
}
.rp-card {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  min-width: 0;
}
.rp-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.rp-card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.rp-card-head .muted {
  font-size: 12px;
}
.rp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.rp-sub-head {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 12px 0 6px;
}
.rp-card-head + .rp-sub-head {
  margin-top: 0;
}
.rp-empty {
  font-size: 13px;
  padding: 6px 0;
}
.rp-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.rp-legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  margin-left: 6px;
}
.lg-open,
.rp-chart .b-open {
  background: var(--brand);
  fill: var(--brand);
}
.lg-closed,
.rp-chart .b-closed {
  background: #94a3b8;
  fill: #94a3b8;
}
.rp-chart {
  position: relative;
  padding-left: 26px;
}
.rp-chart svg {
  width: 100%;
  height: 180px;
  display: block;
  border-bottom: 1px solid var(--border);
}
.rp-chart g:hover .b-open,
.rp-chart g:hover .b-closed {
  opacity: 0.75;
}
.rp-ymax {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 11px;
  color: var(--muted);
}
.rp-xaxis {
  position: relative;
  height: 18px;
  margin-top: 4px;
}
.rp-xaxis span {
  position: absolute;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.rp-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rp-bar {
  display: grid;
  grid-template-columns: minmax(70px, 140px) 1fr 34px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.rp-bl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}
.rp-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.rp-track span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
}
.rp-n {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}
.rp-heat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-x: auto;
}
.hm-row {
  display: grid;
  grid-template-columns: 34px repeat(24, minmax(9px, 1fr));
  gap: 3px;
  align-items: center;
}
.hm-day {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}
.hm-cell {
  height: 18px;
  border-radius: 4px;
  background: var(--surface-3);
  position: relative;
  overflow: hidden;
}
.hm-cell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--brand);
  opacity: var(--a);
}
.hm-axis span {
  font-size: 10.5px;
  color: var(--muted);
}
.rp-csat {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 6px;
  height: 150px;
  align-items: end;
}
.cs-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 3px;
  min-width: 0;
}
.cs-val {
  font-size: 11px;
  font-weight: 650;
  color: var(--text-2);
}
.cs-bar {
  width: 100%;
  max-width: 30px;
  border-radius: 5px 5px 2px 2px;
  background: var(--surface-3);
  min-height: 2px;
}
.cs-bar.good {
  background: var(--green);
}
.cs-bar.ok {
  background: var(--amber);
}
.cs-bar.bad {
  background: var(--red);
}
.cs-lbl {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
}
.rp-low {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rp-low-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 2px 8px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.rp-low-item:hover {
  border-color: var(--red-border);
}
.rp-low-item > span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rp-low-item .muted {
  grid-column: 2 / -1;
  font-size: 12px;
}
.rp-stars {
  color: var(--amber);
  letter-spacing: 1px;
}
.rp-table-wrap {
  overflow-x: auto;
}
.rp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.rp-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.rp-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.rp-table tr:last-child td {
  border-bottom: 0;
}
.rp-weekly-note {
  margin: 0 0 10px;
  font-size: 13px;
}
.rp-weekly-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.rp-weekly-form select {
  width: auto;
  min-width: 220px;
  max-width: 100%;
}
.rp-weekly-form .muted {
  font-size: 12.5px;
}
@media (max-width: 900px) {
  .rp-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 768px) {
  .rp-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .rp-kpi-val {
    font-size: 22px;
  }
  .rp-card {
    padding: 14px;
  }
  .rp-chart svg {
    height: 140px;
  }
  .hm-row {
    grid-template-columns: 30px repeat(24, minmax(7px, 1fr));
    gap: 2px;
  }
  .hm-cell {
    height: 14px;
    border-radius: 3px;
  }
  .rp-weekly-form select {
    font-size: 16px;
  }
}

.close-delete {
  font-size: 13px;
  align-items: flex-start;
  gap: 8px;
}
.close-delete .muted {
  font-size: 12px;
}

/* back to the ticket you came from (similar tickets) */
.back-chip {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--brand-border);
  background: var(--brand-soft);
  color: var(--brand);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.back-chip:hover {
  background: var(--surface);
}
.back-chip.hidden {
  display: none;
}
.rp-kpis {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.rp-delta.neutral {
  color: var(--text-2);
}

/* ==========================================================================
   Zoho Assist remote sessions
   ========================================================================== */
.remote-cards:empty {
  display: none;
}
.remote-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 18px 0;
  flex-shrink: 0;
}
.remote-card {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--brand-border);
  box-shadow: inset 3px 0 0 var(--brand);
  font-size: 13px;
}
.rc-head {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  color: var(--brand);
}
.rc-head b {
  color: var(--text);
}
.rc-head .muted {
  font-size: 12px;
}
.rc-head .btn-sm {
  height: 28px;
  padding: 0 10px;
  text-decoration: none;
}
.rc-steps {
  margin-top: 6px;
}
.rc-steps summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
}
.rc-steps ol,
.remote-steps {
  margin: 6px 0 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1.45;
  color: var(--text);
}
.rc-steps p {
  margin: 6px 0 0;
  font-size: 12.5px;
}
.remote-card-modal {
  max-width: 560px;
}
.remote-msg {
  width: 100%;
  font-size: 13.5px;
  line-height: 1.5;
  resize: vertical;
  min-height: 220px;
  box-sizing: border-box;
  margin: 8px 0 4px;
}
#remote-body .s-actions {
  align-items: center;
}
#remote-body p {
  margin: 0 0 6px;
}
#remote-body a.btn {
  text-decoration: none;
}
@media (max-width: 768px) {
  .remote-cards {
    margin: 8px 12px 0;
  }
  .remote-msg {
    font-size: 16px;
  }
}

.remote-card.ended {
  box-shadow: inset 3px 0 0 var(--green);
  border-color: var(--green-border);
}
.remote-card.ended .rc-head {
  color: var(--green);
}
.rc-live {
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
}
.rc-auto {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}
.rc-auto .ic {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}
.rc-auto a {
  color: var(--brand);
  font-weight: 650;
}

/* videos play inside the chat bubble */
.m-video {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  max-width: 360px;
}
.m-video video {
  width: 100%;
  max-height: 260px;
  border-radius: 10px;
  background: #000;
  border: 1px solid var(--border);
}
.m-video a {
  font-size: 12.5px;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.m-video-note {
  font-size: 12.5px;
}

/* remote session send window: preview of the Discord card */
.remote-note {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  font-size: 13.5px;
  line-height: 1.45;
  margin-bottom: 8px;
}
.remote-sub {
  font-weight: 400;
  font-size: 12px;
}
#remote-preview {
  margin: 4px 0 6px;
}
.dc-msg {
  padding: 12px;
  border-radius: 10px;
  background: #313338;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.dc-embed {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px 12px;
  border-radius: 4px;
  max-width: 440px;
  width: 100%;
  box-sizing: border-box;
  background: #2b2d31;
  border-left: 4px solid #0f766e;
  color: #dbdee1;
  font-size: 13.5px;
  line-height: 1.4;
}
.dc-title {
  font-weight: 700;
  color: #00a8fc;
  font-size: 15px;
}
.dc-desc {
  white-space: pre-wrap;
}
.dc-link {
  font-weight: 700;
  color: #00a8fc;
}
.dc-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dc-field b {
  color: #f2f3f5;
  font-size: 13px;
}
.dc-field span {
  color: #dbdee1;
  font-size: 13px;
}
.dc-field span b {
  font-size: inherit;
}
.dc-footer {
  font-size: 11.5px;
  color: #b5bac1;
  margin-top: 2px;
}
.dc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 4px;
  background: #4e5058;
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
}
