/* Support desk layout. */
.inbox { display: grid; grid-template-columns: 224px 340px 1fr 300px; height: 100%; min-height: 0; }
.inbox.no-side { grid-template-columns: 224px 340px 1fr; }
@media (max-width: 1280px) { .inbox { grid-template-columns: 200px 300px 1fr 280px; } }
@media (max-width: 1080px) { .inbox { grid-template-columns: 56px 300px 1fr; } .inbox .side { display: none; } .inbox .navcol .lbl, .inbox .navcol h4, .inbox .navcol .cnt { display: none; } }

/* left navigation column */
.navcol { background: var(--surface); border-inline-end: 1px solid var(--line); overflow: auto; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.navcol h4 { padding: 12px 10px 4px; display: flex; align-items: center; justify-content: space-between; }
.navcol h4 .iconbtn { width: 22px; height: 22px; }
.navcol .nitem { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; width: 100%; text-align: start; }
.navcol .nitem:hover { background: var(--surface-2); }
.navcol .nitem.active { background: var(--brand-50); color: var(--brand-600); }
.navcol .nitem .ic { color: var(--muted); }
.navcol .nitem.active .ic { color: var(--brand-600); }
.navcol .nitem .cnt { margin-inline-start: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.navcol .nitem.active .cnt { color: var(--brand-600); font-weight: 800; }
.navcol .nitem .lbl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* conversation list */
.clist { background: var(--surface); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.clist .ltop { padding: 10px 12px 8px; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 8px; }
.clist .ltop .row h2 { font-size: 15px; }
.clist .items { flex: 1; overflow: auto; }
.ci { display: flex; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--line-2); cursor: pointer; position: relative; align-items: flex-start; }
.ci:hover { background: var(--surface-2); }
.ci.active { background: var(--brand-50); }
.ci.unread .ttl { font-weight: 800; }
.ci.unread::before { content: ''; position: absolute; inset-inline-start: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--brand); }
.ci .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ci .ttl { font-size: 13px; }
.ci .prev { font-size: 12px; color: var(--muted); }
.ci .foot { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 2px; }
.ci .sel { width: 16px; height: 16px; accent-color: var(--brand); margin-top: 10px; flex-shrink: 0; }
.ci .time { font-size: 11px; color: var(--faint); white-space: nowrap; }
.ci .pri { width: 8px; height: 8px; border-radius: 50%; }
.ci .pri.urgent { background: var(--rose); } .ci .pri.high { background: var(--amber); }
.bulkbar { position: sticky; bottom: 0; background: var(--brand-900); color: #fff; padding: 8px 12px; display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; }
.bulkbar .btn { height: 30px; font-size: 12px; background: rgba(255,255,255,.14); box-shadow: none; }

/* conversation pane */
.cpane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.chead { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chead .who { display: flex; flex-direction: column; min-width: 0; }
.chead .who b { font-size: 14px; }
.chead .acts { display: flex; align-items: center; gap: 4px; margin-inline-start: auto; }
.cpane .msgs { flex: 1; overflow: auto; }
.cfoot { background: var(--surface); border-top: 1px solid var(--line); padding: 8px 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.cfoot .modes { display: flex; align-items: center; gap: 8px; }
.cfoot .modes .tabs { border: 0; }
.cfoot .modes .tabs button { padding: 4px 10px; font-size: 12px; }
.cfoot .hint { font-size: 11px; color: var(--faint); margin-inline-start: auto; }
.macro-pop { position: absolute; bottom: 100%; inset-inline-start: 0; inset-inline-end: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-3); max-height: 260px; overflow: auto; z-index: 5; margin-bottom: 6px; }
.macro-pop .item { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.macro-pop .item:hover, .macro-pop .item.active { background: var(--brand-50); }
.macro-pop .item b { font-size: 12.5px; }
.macro-pop .item span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cwrap { position: relative; }
.viewers { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); padding: 4px 16px 0; }

/* details panel */
.side { background: var(--surface); border-inline-start: 1px solid var(--line); overflow: auto; }
.side .panel-section h4 { cursor: pointer; }
.side .chips { display: flex; flex-wrap: wrap; gap: 4px; }
.side .tcard { border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; background: var(--surface-2); }
.side .tcard:hover { border-color: var(--brand-100); }
.side .qlink { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 6px 0; color: var(--brand-600); font-weight: 600; }
.attr-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; padding: 5px 0; border-bottom: 1px dashed var(--line-2); }
.attr-row:last-child { border-bottom: 0; }
.attr-row .k { color: var(--muted); }
.attr-row select, .attr-row .input { max-width: 150px; }
.attr-row select { border: 1px solid transparent; border-radius: 6px; padding: 2px 4px; background: transparent; font-weight: 600; cursor: pointer; max-width: 160px; }
.attr-row select:hover { border-color: var(--line); background: var(--surface); }

/* tickets page */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.bcol { background: var(--surface-2); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 160px; }
.bcol .bhead { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; font-weight: 800; color: var(--text-2); padding: 2px 4px; }
.bcol .bhead .cnt { background: var(--surface); border-radius: 999px; padding: 0 8px; font-size: 11px; color: var(--muted); }
/* The count must survive a long stage name, so the title is what truncates. */
.bcol .bhead > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcol .bhead > .row { flex: 0 0 auto; }
.tk { background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 5px; cursor: pointer; box-shadow: var(--sh-1); }
.tk:hover { border-color: var(--brand-100); box-shadow: var(--sh-2); }
.tk .ttl { font-size: 13px; font-weight: 700; }
.tk .sub { font-size: 11.5px; color: var(--muted); }
.tk .foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 2px; }
/* Stage names are long in Arabic; a card is narrow. The stage chip is the one
   that gives way — the priority beside it is two words and stays whole. */
.tk > .row.between, .tk > .row.between > .row { min-width: 0; }
.tk > .row.between > .row > .chip { flex: 0 0 auto; }
.tk > .row.between > .row > .chip:last-child {
  flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: block;
}
.tk.late { border-inline-start: 3px solid var(--rose); }
.tk.urgent .ttl::before { content: '!'; display: inline-flex; width: 16px; height: 16px; border-radius: 50%; background: var(--rose-bg); color: var(--rose); font-size: 11px; align-items: center; justify-content: center; margin-inline-end: 5px; }

/* customers page */
.co-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.co-head .avatar.lg { border-radius: 14px; }
.sugg { position: absolute; top: 44px; inset-inline-start: 0; inset-inline-end: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-3); z-index: 20; max-height: 320px; overflow: auto; }
.sugg .item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; cursor: pointer; font-size: 13px; }
.sugg .item:hover { background: var(--surface-2); }

/* reports */
.rpt-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.rpt-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.rpt-grid .span4 { grid-column: span 4; } .rpt-grid .span6 { grid-column: span 6; } .rpt-grid .span8 { grid-column: span 8; } .rpt-grid .span12 { grid-column: span 12; }
@media (max-width: 1100px) { .rpt-grid .span4, .rpt-grid .span6, .rpt-grid .span8 { grid-column: span 12; } }
.daterange { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.daterange input[type=date] { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: var(--surface); font-size: 12px; }

/* knowledge */
.kb-layout { display: grid; grid-template-columns: 240px 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .kb-layout { grid-template-columns: 1fr; } }
.kb-editor textarea { min-height: 260px; font-family: var(--font); }

/* automation */
.rule { display: flex; flex-direction: column; gap: 10px; }
.rule .blk { display: flex; align-items: flex-start; gap: 12px; }
.rule .blk .lbl { width: 70px; flex-shrink: 0; font-weight: 800; font-size: 12px; color: var(--muted); padding-top: 9px; text-transform: uppercase; letter-spacing: .04em; }
.rule .blk .box { flex: 1; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.rule .line { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; align-items: center; }
.rule .connector { width: 2px; height: 14px; background: var(--line); margin-inline-start: 82px; }
.rule-card { display: flex; align-items: center; gap: 12px; }
.rule-card .flow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.rule-card .flow .chip { font-size: 11px; }

/* settings */
.settings-layout { display: grid; grid-template-columns: 220px 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .settings-layout { grid-template-columns: 1fr; } }
.settings-layout .menu { display: flex; flex-direction: column; gap: 2px; }
.settings-layout .menu button { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-2); text-align: start; }
.settings-layout .menu button.active { background: var(--brand-50); color: var(--brand-600); }
.module-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------------------
   The desk on a phone. Four columns cannot share 390 pixels: the reply box was
   being squeezed to sixteen of them, which left an agent on a phone unable to
   answer at all. Below this width the list and the conversation take turns.
   --------------------------------------------------------------------------- */
.chead .backtolist { display: none; }

@media (max-width: 900px) {
  .inbox, .inbox.no-side { grid-template-columns: minmax(0, 1fr); }
  .inbox .navcol, .inbox .side { display: none; }

  /* A conversation is open when it has a composer in it. */
  .inbox:has(.composer) .clist { display: none; }
  .inbox:not(:has(.composer)) .cpane { display: none; }

  .chead .backtolist { display: inline-flex; flex: none; }
  .chead { gap: 8px; padding-inline: 10px; }
  .chead .acts { margin-inline-start: auto; }
  /* Five fixed controls and a text box do not fit across a phone, so the text
     box takes the top line to itself and the controls sit under it. */
  .cpane .composer {
    padding: 8px; flex-wrap: wrap; align-items: stretch; gap: 6px;
  }
  .cpane .composer textarea { order: -1; flex: 1 0 100%; min-width: 0; }
  .cpane .composer .btn { margin-inline-start: auto; }

  /* Headers that were laid out for a wide screen have to be allowed to wrap
     rather than push their last control off the edge. */
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .topbar h1 { font-size: 16px; }
  .chead .acts { flex-wrap: wrap; margin-inline-start: 0; width: 100%; justify-content: flex-end; }
  .chead .who { flex: 1 1 100%; order: 2; }
  .cpane .msgs { padding-inline: 10px; }
  .msg { max-width: 88%; }
}

/* a recorded call plays where it happened, inside the conversation */
.msg.sys .bubble.rec-play { display: flex; flex-direction: column; gap: 8px; align-items: stretch; max-width: 420px; }
.msg.sys .bubble.rec-play audio { width: 100%; height: 34px; }

/* Unified desk: the MT_Pro (Delphi) product. Made By Ahmed Ramadan (Klinton) */
.chip.mtpro { background: #FFF1E6; color: #A0571A; }
:root[data-theme="dark"] .chip.mtpro { background: rgba(217,130,43,.18); color: #F2B37A; }
.rd-box { display: flex; flex-direction: column; gap: 8px; }
.rd-state { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; }
.rd-state .led { width: 10px; height: 10px; border-radius: 50%; background: var(--slate); flex: none; }
.rd-state.requested .led, .rd-state.accepted .led { background: var(--amber); animation: rdpulse 1.2s infinite; }
.rd-state.ready .led { background: var(--green); }
.rd-state.rejected .led { background: var(--rose); }
.rd-id { display: flex; align-items: center; gap: 6px; direction: ltr; justify-content: flex-end; }
.rd-id .code { font-size: 18px; letter-spacing: 2px; font-weight: 800; }
@keyframes rdpulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
